1 |
2 |
unicore |
---------------------------------------------------------------------
|
2 |
|
|
---- ----
|
3 |
|
|
---- DCT IP core ----
|
4 |
|
|
---- ----
|
5 |
|
|
---- Authors: Anatoliy Sergienko, Volodya Lepeha ----
|
6 |
|
|
---- Company: Unicore Systems http://unicore.co.ua ----
|
7 |
|
|
---- ----
|
8 |
|
|
---- Downloaded from: http://www.opencores.org ----
|
9 |
|
|
---- ----
|
10 |
|
|
---------------------------------------------------------------------
|
11 |
|
|
---- ----
|
12 |
|
|
---- Copyright (C) 2006-2010 Unicore Systems LTD ----
|
13 |
|
|
---- www.unicore.co.ua ----
|
14 |
|
|
---- o.uzenkov@unicore.co.ua ----
|
15 |
|
|
---- ----
|
16 |
|
|
---- This source file may be used and distributed without ----
|
17 |
|
|
---- restriction provided that this copyright statement is not ----
|
18 |
|
|
---- removed from the file and that any derivative work contains ----
|
19 |
|
|
---- the original copyright notice and the associated disclaimer.----
|
20 |
|
|
---- ----
|
21 |
|
|
---- THIS SOFTWARE IS PROVIDED "AS IS" ----
|
22 |
|
|
---- AND ANY EXPRESSED OR IMPLIED WARRANTIES, ----
|
23 |
|
|
---- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ----
|
24 |
|
|
---- WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT ----
|
25 |
|
|
---- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ----
|
26 |
|
|
---- IN NO EVENT SHALL THE UNICORE SYSTEMS OR ITS ----
|
27 |
|
|
---- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ----
|
28 |
|
|
---- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ----
|
29 |
|
|
---- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ----
|
30 |
|
|
---- OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ----
|
31 |
|
|
---- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ----
|
32 |
|
|
---- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ----
|
33 |
|
|
---- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ----
|
34 |
|
|
---- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ----
|
35 |
|
|
---- IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ----
|
36 |
|
|
---- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ----
|
37 |
|
|
---- ----
|
38 |
|
|
---------------------------------------------------------------------
|
39 |
|
|
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
40 |
|
|
--DESCRIPTION:
|
41 |
|
|
--
|
42 |
|
|
-- FUNCTION 64 data are stored to the FIFO buffer
|
43 |
|
|
-- 64 data read from FIFO taps in the transposed order.
|
44 |
|
|
-- Synthesable for Xilinx FPGAs.
|
45 |
|
|
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
library IEEE;
|
49 |
|
|
use IEEE.std_logic_1164.all;
|
50 |
|
|
use IEEE.std_logic_arith.all;
|
51 |
|
|
use IEEE.std_logic_signed.all;
|
52 |
|
|
|
53 |
|
|
entity DCT_BUF is
|
54 |
|
|
generic( wi: integer:= 10 -- input data width
|
55 |
|
|
);
|
56 |
|
|
port (
|
57 |
|
|
CLK: in STD_LOGIC;
|
58 |
|
|
RST: in STD_LOGIC;
|
59 |
|
|
START: in STD_LOGIC; -- after this impulse the 0-th datum is sampled
|
60 |
|
|
EN: in STD_LOGIC; -- operation enable to slow-down the calculations
|
61 |
|
|
DATA_IN: in STD_LOGIC_VECTOR (wi-1 downto 0);
|
62 |
|
|
RDY: out STD_LOGIC; -- delayed START impulse, after it the 0-th result is outputted
|
63 |
|
|
DATA_OUT: out STD_LOGIC_VECTOR (wi-1 downto 0) -- output data
|
64 |
|
|
);
|
65 |
|
|
end DCT_BUF;
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
architecture SRL16 of DCT_BUF is
|
69 |
|
|
|
70 |
|
|
constant rnd: STD_LOGIC:='0';
|
71 |
|
|
|
72 |
|
|
type Tarr100 is array (0 to 99) of STD_LOGIC_VECTOR (wi -1 downto 0);
|
73 |
|
|
type Tarr64i is array (0 to 63) of integer range 0 to 127 ;
|
74 |
|
|
constant Addrr:Tarr64i:=
|
75 |
|
|
(49,50-8, 51-16,52-24, 53-32,54-40,55-48,56-56,
|
76 |
|
|
56, 57-8, 58-16,59-24, 60-32,61-40,62-48,63-56,
|
77 |
|
|
63, 64-8, 65-16,66-24, 67-32,68-40,69-48,70-56,
|
78 |
|
|
70, 71-8, 72-16,73-24, 74-32,75-40,76-48,77-56,
|
79 |
|
|
|
80 |
|
|
77, 78-8, 79-16,80-24, 81-32,82-40,83-48,84-56,
|
81 |
|
|
84, 85-8, 86-16,87-24, 88-32,89-40,90-48,91-56,
|
82 |
|
|
91, 92-8, 93-16,94-24, 95-32,96-40,97-48,98-56,
|
83 |
|
|
98, 99-8,100-16,101-24,102-32,103-40,104-48,105-56);
|
84 |
|
|
|
85 |
|
|
signal sr64:TARR100:=(others=>(others=>'0')); -- масив регiстрiв SRL16
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
signal cycle,ad1: integer range 0 to 63;
|
89 |
|
|
signal ad2: integer range 0 to 99;
|
90 |
|
|
signal cycles: integer range 0 to 63;
|
91 |
|
|
|
92 |
|
|
|
93 |
|
|
begin
|
94 |
|
|
UU_COUN:process(CLK,RST)
|
95 |
|
|
begin
|
96 |
|
|
if RST = '1' then
|
97 |
|
|
ad1<= ( - 5) mod 64;
|
98 |
|
|
cycles <=63;
|
99 |
|
|
RDY<='0';
|
100 |
|
|
elsif CLK = '1' and CLK'event then
|
101 |
|
|
if en = '1' then
|
102 |
|
|
RDY<='0';
|
103 |
|
|
if START = '1' then
|
104 |
|
|
ad1<= ( - 48) mod 64;
|
105 |
|
|
cycles <=0;
|
106 |
|
|
elsif en = '1' then
|
107 |
|
|
ad1<=(ad1 +1) mod 64;
|
108 |
|
|
RDY<='0';
|
109 |
|
|
if cycles/=63 then
|
110 |
|
|
cycles<=(cycles +1) ;
|
111 |
|
|
end if;
|
112 |
|
|
if cycles=48 then
|
113 |
|
|
RDY<='1';
|
114 |
|
|
ad1 <=0;
|
115 |
|
|
end if;
|
116 |
|
|
end if;
|
117 |
|
|
end if;
|
118 |
|
|
end if;
|
119 |
|
|
end process;
|
120 |
|
|
|
121 |
|
|
SRL16_a:process(CLK) begin -- SRL16
|
122 |
|
|
if CLK'event and CLK='1' then
|
123 |
|
|
if en='1' then
|
124 |
|
|
sr64<=DATA_IN & sr64(0 to 98); -- shift SRL16
|
125 |
|
|
ad2<= Addrr(ad1) ; --FIFO address recoding
|
126 |
|
|
end if;
|
127 |
|
|
end if;
|
128 |
|
|
end process;
|
129 |
|
|
|
130 |
|
|
DATA_OUT <=sr64(ad2); -- output from SRL16
|
131 |
|
|
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
end SRL16;
|