OpenCores
URL https://opencores.org/ocsvn/funbase_ip_library/funbase_ip_library/trunk

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [ip.hwp.accelerator/] [dctqidct/] [1.0/] [hdl/] [dct/] [DCT_core.vhd] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
------------------------------------------------------------------------------
2
-- Author        : Timo Alho
3
-- e-mail        : timo.a.alho@tut.fi
4
-- Date          : 11.08.2004 13:28:12
5
-- File          : DCT_core.vhd
6
-- Design        : VHDL Entity for dct.DCT_core.symbol
7
-- Generated by Mentor Graphics' HDL Designer 2003.1 (Build 399)
8
------------------------------------------------------------------------------
9
LIBRARY ieee;
10
USE ieee.std_logic_1164.all;
11
USE ieee.std_logic_arith.all;
12
LIBRARY dct;
13
USE dct.DCT_pkg.all;
14
LIBRARY common_da;
15
 
16
ENTITY DCT_core IS
17
   PORT(
18
      clk              : IN     std_logic;
19
      -- input data bus
20
      data_in          : IN     std_logic_vector (DCT_inputw_co-1 DOWNTO 0);
21
      -- output status. (set to '1' if output block is capable of receiving column/row)
22
      next_block_ready : IN     std_logic;
23
      rst_n            : IN     std_logic;
24
      -- write signal for input data
25
      wr_new_data      : IN     std_logic;
26
      -- DC coefficient ('1' when DC coefficient is in output bus)
27
      DC               : OUT    std_logic;
28
      -- output data bus
29
      data_out         : OUT    std_logic_vector (DCT_resultw_co-1 DOWNTO 0);
30
      -- input data status. ('1' if block is capable of receiving column/row)
31
      ready_for_rx     : OUT    std_logic;
32
      -- write signal for output data
33
      wr_out           : OUT    std_logic
34
   );
35
 
36
-- Declarations
37
 
38
END DCT_core ;
39
 
40
------------------------------------------------------------------------------
41
-- Author        : Timo Alho
42
-- e-mail        : timo.a.alho@tut.fi
43
-- Date          : 11.08.2004 13:28:13
44
-- File          : DCT_core.vhd
45
-- Design        : VHDL Architecture for dct.DCT_core.symbol
46
-- Generated by Mentor Graphics' HDL Designer 2003.1 (Build 399)
47
------------------------------------------------------------------------------
48
LIBRARY ieee;
49
USE ieee.std_logic_1164.all;
50
USE ieee.std_logic_arith.all;
51
LIBRARY dct;
52
USE dct.DCT_pkg.all;
53
LIBRARY common_da;
54
 
55
 
56
ARCHITECTURE struct OF DCT_core IS
57
 
58
   -- Architecture declarations
59
 
60
   -- Internal signal declarations
61
   SIGNAL data_dct_to_shifter : std_logic_vector(8*DCT_dataw_co-1 DOWNTO 0);
62
   SIGNAL data_out_int        : std_logic_vector(DCT_resultw_co-1 DOWNTO 0);
63
   SIGNAL data_to_dct         : std_logic_vector(8*DCT_dataw_co-1 DOWNTO 0);
64
   SIGNAL dct_output_int      : std_logic_vector(DCT_dataw_co-1 DOWNTO 0);
65
   SIGNAL dct_ram_out         : std_logic_vector(DCT_dataw_co-1 DOWNTO 0);
66
   SIGNAL load_dct_input      : std_logic;
67
   SIGNAL load_dct_output     : std_logic;
68
   SIGNAL out_clk_en          : std_logic;
69
   SIGNAL rdaddr              : std_logic_vector(5 DOWNTO 0);
70
   SIGNAL scaled_input        : std_logic_vector(DCT_dataw_co-1 DOWNTO 0);
71
   SIGNAL sel_input           : std_logic;
72
   SIGNAL ser_input_to_dct    : std_logic_vector(DCT_dataw_co-1 DOWNTO 0);
73
   SIGNAL start_dct           : std_logic;
74
   SIGNAL stop_dct            : std_logic;
75
   SIGNAL we                  : std_logic;
76
   SIGNAL wraddr              : std_logic_vector(5 DOWNTO 0);
77
 
78
 
79
   -- Component Declarations
80
   COMPONENT Column_to_elements
81
   GENERIC (
82
      dataw_g : integer := 18
83
   );
84
   PORT (
85
      clk       : IN     std_logic ;
86
      --enable shifting:
87
      --if '1' one value is shifted to output
88
      clk_en    : IN     std_logic ;
89
      --parallel input (8 * (dataw_g-1 downto 0))
90
      column_in : IN     std_logic_vector (8*dataw_g-1 DOWNTO 0);
91
      --if '1' parallel input is loaded into shiftregister
92
      load      : IN     std_logic ;
93
      rst_n     : IN     std_logic ;
94
      --serial output
95
      d_out     : OUT    std_logic_vector (dataw_g-1 DOWNTO 0)
96
   );
97
   END COMPONENT;
98
   COMPONENT DPRAM
99
   GENERIC (
100
      dataw_g : integer := 18;
101
      addrw_g : integer := 5
102
   );
103
   PORT (
104
      clk     : IN     std_logic ;
105
      d_in    : IN     std_logic_vector (dataw_g-1 DOWNTO 0); --input data
106
      rdaddr  : IN     std_logic_vector (addrw_g-1 DOWNTO 0); --read address
107
      we      : IN     std_logic ;                            -- write enable
108
      wraddr  : IN     std_logic_vector (addrw_g-1 DOWNTO 0); --write address
109
      ram_out : OUT    std_logic_vector (dataw_g-1 DOWNTO 0)  --output data
110
   );
111
   END COMPONENT;
112
   COMPONENT Elements_to_column
113
   GENERIC (
114
      dataw_g : integer := 18
115
   );
116
   PORT (
117
      clk        : IN     std_logic ;
118
      --serial input
119
      d_in       : IN     std_logic_vector (dataw_g-1 DOWNTO 0);
120
      --'1' serial input is loaded into shiftregister
121
      load       : IN     std_logic ;
122
      rst_n      : IN     std_logic ;
123
      --parallel output
124
      column_out : OUT    std_logic_vector (8*dataw_g-1 DOWNTO 0)
125
   );
126
   END COMPONENT;
127
   COMPONENT FlipFlop
128
   GENERIC (
129
      dataw_g : INTEGER := 16
130
   );
131
   PORT (
132
      clk   : IN     std_logic ;
133
      d_in  : IN     std_logic_vector (dataw_g-1 DOWNTO 0);
134
      rst_n : IN     std_logic ;
135
      d_out : OUT    std_logic_vector (dataw_g-1 DOWNTO 0)
136
   );
137
   END COMPONENT;
138
   COMPONENT Mux2to1
139
   GENERIC (
140
      dataw_g : integer := 16
141
   );
142
   PORT (
143
      in0     : IN     std_logic_vector (dataw_g-1 DOWNTO 0);
144
      in1     : IN     std_logic_vector (dataw_g-1 DOWNTO 0);
145
      sel     : IN     std_logic ;
146
      mux_out : OUT    std_logic_vector (dataw_g-1 DOWNTO 0)
147
   );
148
   END COMPONENT;
149
   COMPONENT DCT1D_DA
150
   PORT (
151
      clk            : IN     std_logic ;
152
      dct_input_data : IN     std_logic_vector (8*DCT_dataw_co-1 DOWNTO 0);
153
      last_bit       : IN     std_logic ;
154
      rst_n          : IN     std_logic ;
155
      start          : IN     std_logic ;
156
      dct1d_out      : OUT    std_logic_vector (8*DCT_dataw_co-1 DOWNTO 0)
157
   );
158
   END COMPONENT;
159
   COMPONENT DCT_control
160
   PORT (
161
      clk              : IN     std_logic ;
162
      next_block_ready : IN     std_logic ;
163
      rst_n            : IN     std_logic ;
164
      wr_new_data      : IN     std_logic ;
165
      DC               : OUT    std_logic ;
166
      load_dct_input   : OUT    std_logic ;
167
      load_dct_output  : OUT    std_logic ;
168
      out_clk_en       : OUT    std_logic ;
169
      rdaddr           : OUT    std_logic_vector (5 DOWNTO 0);
170
      ready_for_rx     : OUT    std_logic ;
171
      sel_input        : OUT    std_logic ;
172
      start_dct        : OUT    std_logic ;
173
      stop_dct         : OUT    std_logic ;
174
      we               : OUT    std_logic ;
175
      wr_out           : OUT    std_logic ;
176
      wraddr           : OUT    std_logic_vector (5 DOWNTO 0)
177
   );
178
   END COMPONENT;
179
 
180
 
181
BEGIN
182
   -- Architecture concurrent statements
183
   -- HDL Embedded Text Block 1 scale_input
184
   -- scale_input 1
185
   scaled_input <= conv_std_logic_vector(signed(data_in), DCT_dataw_co);
186
 
187
   -- HDL Embedded Text Block 2 round_and_scale_output
188
   -- scale_output 2                                        
189
   scale_output : PROCESS(dct_output_int)
190
     CONSTANT scale_co : integer := DCT_dataw_co - DCT_resultw_co - 1;
191
     VARIABLE temp : signed(DCT_dataw_co-1 downto 0);
192
     VARIABLE temp2 : signed(DCT_resultw_co DOWNTO 0);
193
 
194
   BEGIN
195
     temp := signed(dct_output_int);
196
     --scale!
197
     temp := SHR(temp, conv_unsigned(scale_co, 4));
198
     temp2 := temp(DCT_resultw_co DOWNTO 0);
199
     --round!
200
     temp2 := temp2 + conv_signed(1, DCT_resultw_co+1);
201
 
202
     --result is scaled down, rounded and multiplied by 2
203
     data_out_int <= conv_std_logic_vector(temp2(DCT_resultw_co DOWNTO 1), DCT_resultw_co);
204
   END process scale_output;
205
 
206
 
207
   -- Instance port mappings.
208
   c2e : Column_to_elements
209
      GENERIC MAP (
210
         dataw_g => DCT_dataw_co
211
      )
212
      PORT MAP (
213
         clk       => clk,
214
         clk_en    => out_clk_en,
215
         column_in => data_dct_to_shifter,
216
         load      => load_dct_output,
217
         rst_n     => rst_n,
218
         d_out     => dct_output_int
219
      );
220
   tr_ram : DPRAM
221
      GENERIC MAP (
222
         dataw_g => DCT_dataw_co,
223
         addrw_g => 6
224
      )
225
      PORT MAP (
226
         clk     => clk,
227
         d_in    => dct_output_int,
228
         rdaddr  => rdaddr,
229
         we      => we,
230
         wraddr  => wraddr,
231
         ram_out => dct_ram_out
232
      );
233
   e2c : Elements_to_column
234
      GENERIC MAP (
235
         dataw_g => DCT_dataw_co
236
      )
237
      PORT MAP (
238
         clk        => clk,
239
         d_in       => ser_input_to_dct,
240
         load       => load_dct_input,
241
         rst_n      => rst_n,
242
         column_out => data_to_dct
243
      );
244
   outputreg : FlipFlop
245
      GENERIC MAP (
246
         dataw_g => DCT_resultw_co
247
      )
248
      PORT MAP (
249
         clk   => clk,
250
         d_in  => data_out_int,
251
         rst_n => rst_n,
252
         d_out => data_out
253
      );
254
   inputmux : Mux2to1
255
      GENERIC MAP (
256
         dataw_g => DCT_dataw_co
257
      )
258
      PORT MAP (
259
         in0     => dct_ram_out,
260
         in1     => scaled_input,
261
         sel     => sel_input,
262
         mux_out => ser_input_to_dct
263
      );
264
   dct_8point : DCT1D_DA
265
      PORT MAP (
266
         clk            => clk,
267
         dct_input_data => data_to_dct,
268
         last_bit       => stop_dct,
269
         rst_n          => rst_n,
270
         start          => start_dct,
271
         dct1d_out      => data_dct_to_shifter
272
      );
273
   control : DCT_control
274
      PORT MAP (
275
         clk              => clk,
276
         next_block_ready => next_block_ready,
277
         rst_n            => rst_n,
278
         wr_new_data      => wr_new_data,
279
         DC               => DC,
280
         load_dct_input   => load_dct_input,
281
         load_dct_output  => load_dct_output,
282
         out_clk_en       => out_clk_en,
283
         rdaddr           => rdaddr,
284
         ready_for_rx     => ready_for_rx,
285
         sel_input        => sel_input,
286
         start_dct        => start_dct,
287
         stop_dct         => stop_dct,
288
         we               => we,
289
         wr_out           => wr_out,
290
         wraddr           => wraddr
291
      );
292
 
293
END struct;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.