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

powered by: WebSVN 2.1.0

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