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

Subversion Repositories xmatchpro

[/] [xmatchpro/] [trunk/] [xmw4-comdec/] [xmatch_sim7/] [src/] [input_buffer_cu.vhd] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 eejlny
--This library is free software; you can redistribute it and/or
2
--modify it under the terms of the GNU Lesser General Public
3
--License as published by the Free Software Foundation; either
4
--version 2.1 of the License, or (at your option) any later version.
5
 
6
--This library is distributed in the hope that it will be useful,
7
--but WITHOUT ANY WARRANTY; without even the implied warranty of
8
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
9
--Lesser General Public License for more details.
10
 
11
--You should have received a copy of the GNU Lesser General Public
12
--License along with this library; if not, write to the Free Software
13
--Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
14
 
15
-- e_mail : j.l.nunez-yanez@byacom.co.uk
16
 
17
-----------------------------------------------------
18
--  ENTITY       = INPUT_BUFFER_CU                --
19
--  version      = 1.0                             --
20
--  last update  = 31/5/01                        --
21
--  author       = Jose Nunez                      --
22
-----------------------------------------------------
23
 
24
 
25
-- FUNCTION
26
-- Control unit that controls the input buffer
27
 
28
--  PIN LIST
29
--  START : enable the buffer
30
--  STOP : The whole file has access the internal buffers
31
--  FINISHED : the block has been processed in the compressor engine 
32
--  BUS_ACKNOWLEDGE : the uncompressed bus in is granted
33
--  CODING_READ_ADDRESS : input buffer location that it is being read
34
--  CODING_WRITE_ADDRESS : input buffer location that it is being written
35
--  CLK : clock
36
--  CLEAR : clear
37
--  BUS_REQUEST : the input buffer is being requested
38
--  READY : buffer ready with data to be processed in the compression engine
39
--  FULL : Data cannot be written to the buffer
40
--  CLEAR_COUNTERS : counters are reset. Counters generate the addresses to the buffers
41
--  ENABLE_WRITE : enable writting to the buffer
42
--  ENABLE_READ : enable reading from the buffer
43
 
44
library ieee;
45
use ieee.std_logic_1164.all;
46
library dzx;
47
use dzx.bit_arith.all;
48
use dzx.bit_utils.all;
49
 
50
 
51
entity INPUT_BUFFER_CU is
52
port
53
(
54
                OVERFLOW_CONTROL : in bit; -- to control possible overflows in the decoding input buffer
55
    FORCE_STOP : in bit;
56
          START : in bit;
57
          STOP  : in bit;
58
          WAITN : in bit;
59
          BUS_ACKNOWLEDGE : in bit;
60
          CODING_READ_ADDRESS : in bit_vector(7 downto 0);
61
          CODING_WRITE_ADDRESS : in bit_vector(7 downto 0);
62
          CLK : in bit;
63
          CLEAR : in bit;
64
          BUS_REQUEST : out bit;
65
    CLEAR_COUNTERS : out bit;
66
          RESET_TOTAL_COUNTER : out bit;
67
          ENABLE_PARSER : out bit;
68
          ENABLE_READ : out bit;
69
          ENABLE_WRITE : out bit
70
);
71
end INPUT_BUFFER_CU;
72
 
73
architecture STRUCTURAL of INPUT_BUFFER_CU is
74
 
75
signal CURRENT_STATE : bit_vector(3 downto 0);
76
signal NEXT_STATE : bit_vector(3 downto 0);
77
signal FINISHED_AUX : bit;
78
signal ENABLE_READ_INT : bit;
79
signal ENABLE_WRITE_INT : bit;
80
 
81
 
82
 
83
begin
84
 
85
STATES : process (START, STOP, CURRENT_STATE, FINISHED_AUX, CODING_READ_ADDRESS, CODING_WRITE_ADDRESS, BUS_ACKNOWLEDGE, WAITN, OVERFLOW_CONTROL)
86
begin
87
case CURRENT_STATE is
88
        when "0000" =>  -- state 0 buffer inactive
89
                if (START = '0') then
90
                        NEXT_STATE <= "0001";
91
                else
92
                        NEXT_STATE <= CURRENT_STATE;
93
                end if;
94
                ENABLE_READ_INT <= '0';
95
                ENABLE_WRITE_INT <= '0';
96
                BUS_REQUEST <= '1';
97
            CLEAR_COUNTERS <= '1';
98
                RESET_TOTAL_COUNTER <='1';
99
 
100
         when "0001" =>  -- state 1 request the bus
101
                if (BUS_ACKNOWLEDGE = '0') then -- bus ready with data
102
                        NEXT_STATE <= "0010";
103
                else
104
                        NEXT_STATE <= CURRENT_STATE;
105
                end if;
106
                ENABLE_READ_INT <= '0';
107
                ENABLE_WRITE_INT <= '0';
108
                BUS_REQUEST <= '0';
109
        CLEAR_COUNTERS <= '1';
110
            RESET_TOTAL_COUNTER <= '0';
111
 
112
 
113
 
114
         when "0010" =>    -- start writting data to the input buffer. only writting
115
                if (WAITN = '1') then
116
                        NEXT_STATE <= "0011";  -- only start reading when wait is inactive
117
                else
118
                        NEXT_STATE <= CURRENT_STATE;
119
                end if;
120
                 ENABLE_READ_INT <= '0';
121
                 ENABLE_WRITE_INT <= '1';
122
                 BUS_REQUEST <= '0';
123
         CLEAR_COUNTERS <= '0';
124
             RESET_TOTAL_COUNTER <= '0';
125
 
126
 
127
 
128
 
129
         when "0011" => -- now writting and reading
130
                 if (STOP = '1' and BUS_ACKNOWLEDGE = '0' and WAITN = '1') then -- the whole file has accessed the internal buffer
131
                        NEXT_STATE <= "0101";
132
                 elsif (FINISHED_AUX = '1') then -- this can happen under wait states
133
                        NEXT_STATE <= "0010"; -- to write only
134
          -- elsif (CODING_WRITE_ADDRESS + "00000001" = CODING_READ_ADDRESS) then -- we have fill the buffer wait. About to overflow do not write more data
135
                 elsif ((CODING_WRITE_ADDRESS >= "10000000" or OVERFLOW_CONTROL = '1') and BUS_ACKNOWLEDGE = '0' and WAITN = '1') then -- we have fill the buffer wait. About to overflow do not write more data
136
                                NEXT_STATE <= "0100";
137
                 else
138
                        NEXT_STATE <= CURRENT_STATE;
139
                 end if;
140
 
141
      ENABLE_WRITE_INT <= '1';
142
                 ENABLE_READ_INT  <= '1';
143
                 BUS_REQUEST <= '0';
144
     CLEAR_COUNTERS <= '0';
145
           RESET_TOTAL_COUNTER <= '0';
146
 
147
 
148
 
149
         when "0100" => -- waiting for engine to finish the block
150
      if(STOP = '1') then
151
                                NEXT_STATE <= "0101";
152
                 elsif (FINISHED_AUX = '1' and OVERFLOW_CONTROL = '0') then
153
                          NEXT_STATE <= "0001"; --write new data to the bus 
154
                 else
155
                      NEXT_STATE <= CURRENT_STATE;
156
                 end if;
157
 
158
         ENABLE_WRITE_INT <= '0';
159
                 ENABLE_READ_INT  <= '1';
160
                 BUS_REQUEST <= '1';
161
      CLEAR_COUNTERS <= '0';
162
            RESET_TOTAL_COUNTER <= '0';
163
 
164
 
165
         when "0101" => -- the whole file has acessed the buffers
166
                 if (FINISHED_AUX = '1') then  -- when the last block finishes it is over
167
                        NEXT_STATE <= "0000"; --go to first state 
168
                 else
169
                        NEXT_STATE <= CURRENT_STATE;
170
                 end if;
171
                 ENABLE_WRITE_INT <= '0';
172
                 ENABLE_READ_INT  <= '1';
173
                 BUS_REQUEST <= '1';
174
         CLEAR_COUNTERS <= '0';
175
                 RESET_TOTAL_COUNTER <= '0';
176
 
177
         when others =>
178
        NEXT_STATE <= "0000";
179
                ENABLE_READ_INT <= '0';
180
                ENABLE_WRITE_INT <= '0';
181
                BUS_REQUEST <= '1';
182
        CLEAR_COUNTERS <= '0';
183
            RESET_TOTAL_COUNTER <= '0';
184
 
185
 
186
end  case;
187
end process STATES;
188
 
189
 
190
FINISHED_AUX <= '1' when (CODING_WRITE_ADDRESS = CODING_READ_ADDRESS) else '0'; -- detect when all data has accessed the engine
191
 
192
ENABLE_READ <= ENABLE_READ_INT and not(FINISHED_AUX);
193
ENABLE_WRITE <= ENABLE_WRITE_INT and not(STOP);
194
 
195
PARSER_FF: process(CLK,CLEAR)
196
begin
197
if (CLEAR = '0') then
198
        ENABLE_PARSER <= '0'; --state 0
199
elsif ((CLK'event) and (CLK='1')) then
200
         if (FINISHED_AUX = '1') then
201
                ENABLE_PARSER <= '0';
202
         else
203
                ENABLE_PARSER <= ENABLE_READ_INT; -- parser follows the memory read enable
204
         end if;
205
end if;
206
end process PARSER_FF;
207
 
208
FLIP_FLOPS : process(CLK, CLEAR)
209
begin
210
 
211
if (CLEAR = '0') then
212
        CURRENT_STATE <= "0000"; --state 0
213
elsif ((CLK'event) and (CLK='1')) then
214
     if ( FORCE_STOP = '0') then
215
                        CURRENT_STATE <= "0000"; --state 0
216
     else
217
                        CURRENT_STATE <= NEXT_STATE;
218
     end if;
219
end if;
220
 
221
end process FLIP_FLOPS;
222
 
223
 
224
 
225
 
226
end STRUCTURAL;
227
 

powered by: WebSVN 2.1.0

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