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/] [dctQidct/] [IDCT_fifo.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                 : 30.06.2004 15:43:52
5
-- File                 : idct_fifo.vhd
6
-- Design               : VHDL Entity DCT_RC_DA.idct_fifo.rtl
7
------------------------------------------------------------------------------
8
-- Description  : Non-generic FIFO -buffer between Inverse quantizer and IDCT
9
------------------------------------------------------------------------------
10
LIBRARY ieee;
11
USE ieee.std_logic_1164.ALL;
12
USE ieee.std_logic_arith.ALL;
13
LIBRARY idct;
14
USE idct.IDCT_pkg.all;
15
 
16
ENTITY IDCT_fifo IS
17
   GENERIC(
18
      dataw_g      : integer := 0;
19
      fifo_depth_g : integer := 0
20
   );
21
   PORT(
22
      clk              : IN     std_logic;
23
      rst_n            : IN     std_logic;
24
      -- input data bus
25
      data_in          : IN     std_logic_vector (dataw_g-1 DOWNTO 0);
26
      -- input status ('1' if block is capable of receiving 8 datawords)
27
      ready8           : OUT    std_logic;
28
      -- write signal for input data
29
      wr_in            : IN     std_logic;
30
      -- output data bus
31
      data_out         : OUT    std_logic_vector (dataw_g-1 DOWNTO 0);
32
      -- output status (set to '1', if next block is capable of receiving 8 datawords)
33
      next_block_ready : IN     std_logic;
34
      -- write signal for output data
35
      wr_out           : OUT    std_logic
36
   );
37
 
38
-- Declarations
39
 
40
END IDCT_fifo ;
41
 
42
--
43
ARCHITECTURE rtl OF IDCT_fifo IS
44
  CONSTANT max_data : integer := (2**fifo_depth_g)-1;
45
 
46
  --maximum datacount where ready8 is still active
47
  CONSTANT safe_fill : integer := max_data-8;
48
 
49
  TYPE FIFOram_type IS ARRAY (((2**fifo_depth_g) -1) DOWNTO 0)
50
    OF std_logic_vector(dataw_g-1 DOWNTO 0);
51
  SIGNAL FIFOram_table : FIFOram_type;  -- := (OTHERS => (OTHERS => '0'));
52
 
53
  SIGNAL wraddr_r : unsigned(fifo_depth_g-1 DOWNTO 0);
54
  SIGNAL rdaddr_r : unsigned(fifo_depth_g-1 DOWNTO 0);
55
 
56
  SIGNAL data_counter_r : unsigned(fifo_depth_g-1 DOWNTO 0);
57
 
58
  SIGNAL output_counter_r : unsigned(2 DOWNTO 0);
59
  SIGNAL wr_out_r         : std_logic;
60
  SIGNAL out_active_r     : std_logic;
61
 
62
BEGIN
63
  -- purpose: main process
64
  -- type   : sequential
65
  -- inputs : clk, rst_n
66
  -- outputs: 
67
  clocked : PROCESS (clk, rst_n)
68
  BEGIN  -- PROCESS clocked
69
    IF rst_n = '0' THEN                 -- asynchronous reset (active low)
70
      data_counter_r <= (OTHERS => '0');
71
      rdaddr_r       <= (OTHERS => '0');
72
      wraddr_r       <= (OTHERS => '0');
73
      wr_out_r       <= '0';
74
 
75
    ELSIF clk'event AND clk = '1' THEN  -- rising clock edge
76
 
77
      IF (out_active_r = '1' AND wr_in = '1') THEN
78
        wr_out_r       <= '1';
79
        data_counter_r <= data_counter_r;
80
        wraddr_r       <= wraddr_r + 1;
81
        rdaddr_r       <= rdaddr_r + 1;
82
      ELSIF (out_active_r = '1') THEN
83
        wr_out_r       <= '1';
84
        data_counter_r <= data_counter_r - 1;
85
        rdaddr_r       <= rdaddr_r + 1;
86
      ELSIF (wr_in = '1') THEN
87
        wr_out_r       <= '0';
88
        data_counter_r <= data_counter_r + 1;
89
        wraddr_r       <= wraddr_r + 1;
90
      ELSE
91
        wr_out_r       <= '0';
92
        data_counter_r <= data_counter_r;
93
      END IF;
94
 
95
    END IF;
96
  END PROCESS clocked;
97
 
98
  -- purpose: sends data to fifo output
99
  -- type   : sequential
100
  -- inputs : clk, rst_n
101
  -- outputs: 
102
  output_ctrl : PROCESS (clk, rst_n)
103
  BEGIN  -- PROCESS output_ctrl
104
    IF rst_n = '0' THEN                 -- asynchronous reset (active low)
105
      out_active_r   <= '0';
106
      output_counter_r   <= (OTHERS => '0');
107
    ELSIF clk'event AND clk = '1' THEN  -- rising clock edge
108
      IF (output_counter_r /= 0 AND data_counter_r /= 0) THEN
109
        --send data
110
        out_active_r     <= '1';
111
        output_counter_r <= output_counter_r - 1;
112
      ELSIF (next_block_ready = '1' AND data_counter_r /= 0) THEN
113
        --begin sending if there is enough data and next block is ready
114
        out_active_r     <= '1';
115
        output_counter_r <= conv_unsigned(7, 3);
116
      ELSE
117
        out_active_r     <= '0';
118
        output_counter_r <= output_counter_r;
119
      END IF;
120
    END IF;
121
  END PROCESS output_ctrl;
122
 
123
  wr_out <= wr_out_r;
124
 
125
-- purpose: activates ready to receive signal
126
-- type : combinational
127
-- inputs : data_counter_r
128
-- outputs: ready8
129
  input_active : PROCESS (data_counter_r)
130
  BEGIN  -- PROCESS input
131
    IF (data_counter_r < safe_fill) THEN
132
      ready8 <= '1';
133
    ELSE
134
      ready8 <= '0';
135
    END IF;
136
  END PROCESS input_active;
137
 
138
-- purpose: reads data from fifo
139
-- type : sequential
140
-- inputs : clk, rst_n
141
-- outputs:
142
  data_to_output : PROCESS (clk)
143
  BEGIN  -- PROCESS data_to_output
144
    IF clk'event AND clk = '1' THEN     -- rising clock edge
145
      data_out <= FIFOram_table(CONV_INTEGER(unsigned(rdaddr_r)));
146
    END IF;
147
  END PROCESS data_to_output;
148
 
149
-- purpose: writes data to fifo
150
-- type : sequential
151
-- inputs : clk
152
-- outputs:
153
  data_to_input : PROCESS (clk)
154
  BEGIN  -- PROCESS data_to_input
155
    IF clk'event AND clk = '1' THEN     -- rising clock edge
156
      IF (wr_in = '1') THEN
157
        FIFOram_table(CONV_INTEGER(unsigned(wraddr_r))) <= data_in;
158
      END IF;
159
    END IF;
160
  END PROCESS data_to_input;
161
 
162
END rtl;
163
 
164
 
165
 
166
 
167
 
168
 

powered by: WebSVN 2.1.0

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