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

Subversion Repositories xmatchpro

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

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 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       = DECODING_BUFFER_CU              --
19
--  version      = 1.0                             --
20
--  last update  = 16/6/00                         --
21
--  author       = Jose Nunez                      --
22
-----------------------------------------------------
23
 
24
 
25
-- FUNCTION
26
-- Control unit that controls the decoding buffer
27
 
28
 
29
--  PIN LIST
30
--  START : enable writting to the buffer
31
--  FINISHED : the block has been process in the decompression engine stop requesting data.
32
--  UNDERFLOW : 64 bit of compressed data are needed.
33
--  THRESHOLD : more data is available in the buffer to be decompressed than the threshold limit.
34
--  CODING_READ_ADDRESS : buffer location that it is being read
35
--  CODING_WRITE_ADDRESS : buffer location that it is being written
36
--  CLK : clock
37
--  CLEAR : clear
38
--  BUS_REQUEST : more compressed data is required if after getting data the bus is denied and data is in the internal buffer stop requesting.
39
--  CODING_OVERFLOW : the CU detects a coding overflow stop inputting compressed data 
40
--  CODING_UNDERFLOW : the CU detects a coding underflow stop outputting compressed data
41
--  ENABLE_WRITE : enable writting to the buffer
42
--  FINISH : the buffer process
43
--  ENABLE_READ : enable reading from the buffer
44
 
45
library ieee;
46
use ieee.std_logic_1164.all;
47
library dzx;
48
use dzx.bit_arith.all;
49
use dzx.bit_utils.all;
50
 
51
 
52
entity DECODING_BUFFER_CU_2 is
53
port
54
(
55
    FORCE_STOP : in bit;
56
          START_D : in bit;  --  enter decompression mode
57
          START_C : in bit;  --  enter test mode since compression is active
58
          FINISHED_D : in bit; --  finish decompression mode
59
          FINISHED_C : in bit; -- finish test mode
60
          UNDERFLOW : in bit; -- the engine requests data
61
          BUS_ACKNOWLEDGE : in bit;
62
                WAITN : in bit; -- wait states being introduced
63
          C_DATA_VALID : in bit; -- compressed data available in test mode
64
          THRESHOLD_LEVEL : in bit_vector(9 downto 0);
65
          DECODING_READ_ADDRESS : in bit_vector(9 downto 0);
66
          DECODING_WRITE_ADDRESS : in bit_vector(9 downto 0);
67
          CLK : in bit;
68
          CLEAR : in bit;
69
          BUS_REQUEST : out bit;
70
          DECODING_UNDERFLOW : out bit;
71
          ENABLE_WRITE : out bit;
72
          FINISH : out bit; -- the buffer process
73
          CLEAR_COUNTERS : out bit;
74
    OVERFLOW_CONTROL : out bit;
75
          ENABLE_READ : out bit
76
);
77
end DECODING_BUFFER_CU_2;
78
 
79
architecture STRUCTURAL of DECODING_BUFFER_CU_2 is
80
 
81
signal CURRENT_STATE : bit_vector(3 downto 0);
82
signal NEXT_STATE : bit_vector(3 downto 0);
83
signal DECODING_OVERFLOW_AUX : bit;
84
signal DECODING_UNDERFLOW_AUX : bit;
85
signal ENABLE_READ_INT : bit;
86
signal DECODING_UNDERFLOW_INT : bit; -- to hold underflow until threshold is overpassed
87
signal ENABLE_WRITE_INT : bit;
88
signal BUS_ACKNOWLEDGE_INT : bit;
89
signal BUS_REQUEST_INT : bit;
90
signal OVERFLOW_CONTROL_AUX : bit;
91
--signal DECODING_UNDERFLOW_DELAY : bit;
92
 
93
begin
94
 
95
STATES : process (WAITN, START_C, START_D, THRESHOLD_LEVEL, CURRENT_STATE, FINISHED_C, FINISHED_D, C_DATA_VALID, DECODING_UNDERFLOW_AUX, DECODING_OVERFLOW_AUX, DECODING_READ_ADDRESS, DECODING_WRITE_ADDRESS, BUS_ACKNOWLEDGE)
96
begin
97
case CURRENT_STATE is
98
        when "0000" =>  -- state 0 buffer inactive. Two modes: test mode and decompression mode
99
                if (START_D = '0') then
100
                        NEXT_STATE <= "0001";
101
                elsif (START_C = '0') then
102
                        NEXT_STATE <= "1001";
103
                else
104
                        NEXT_STATE <= CURRENT_STATE;
105
                end if;
106
            BUS_ACKNOWLEDGE_INT <= '0';
107
                DECODING_UNDERFLOW_INT <= '0';
108
                ENABLE_READ_INT <= '0';
109
                ENABLE_WRITE_INT <= '0';
110
                BUS_REQUEST_INT <= '1';
111
                FINISH <= '1';
112
                CLEAR_COUNTERS <= '1'; -- read and write counters are at 0
113
 
114
         when "0001" =>  -- request data ( request the bus )
115
     if (FINISHED_D = '0' and BUS_ACKNOWLEDGE = '0' and WAITN = '1') then --simultanenously
116
                         NEXT_STATE <= "0101"; -- wait for a bus acknowledge before you finish
117
     elsif (FINISHED_D = '0') then -- if finish when requesting the bus
118
                         NEXT_STATE <= "0111"; -- wait for a bus acknowledge before you finish
119
                elsif (BUS_ACKNOWLEDGE = '0') then
120
                        NEXT_STATE <= "0010"; -- start writting data to the buffer
121
                else
122
                        NEXT_STATE <= CURRENT_STATE;
123
                end if;
124
                DECODING_UNDERFLOW_INT <= '0';
125
                BUS_ACKNOWLEDGE_INT <= '1';
126
                ENABLE_READ_INT <= '0';
127
                ENABLE_WRITE_INT <= '0';
128
                BUS_REQUEST_INT <= '0';
129
                FINISH <= '1';
130
          CLEAR_COUNTERS <= '1';
131
 
132
 
133
         when "0010" =>    -- state 2 writing to the buffer
134
                if (FINISHED_D = '0' and BUS_ACKNOWLEDGE = '0' and WAITN = '1') then --the decompression engine finishes
135
                        NEXT_STATE <= "0101"; -- end
136
                elsif (FINISHED_D = '0') then --the decompression engine finishes. so automatically ends no more data needed all lbock reconstructed
137
                        NEXT_STATE <= "0111"; -- wait for acknowledge
138
        --      elsif(BUS_ACKNOWLEDGE = '1' and WAITN = '1') then -- no more data available to write to the buffer block is inside. This is only valid if bus_acknowledge negated means finish
139
        --              NEXT_STATE <= "0100"; -- start only reading
140
                elsif (DECODING_WRITE_ADDRESS - DECODING_READ_ADDRESS > THRESHOLD_LEVEL) then --start reading from the buffer
141
                        NEXT_STATE <= "0011"; -- start reading data from the buffer
142
                else
143
                        NEXT_STATE <= CURRENT_STATE;
144
                end if;
145
                DECODING_UNDERFLOW_INT <= '1';
146
                BUS_ACKNOWLEDGE_INT <= '1';
147
                ENABLE_READ_INT <= '0';
148
                ENABLE_WRITE_INT <= '1';
149
                BUS_REQUEST_INT <= '0';
150
                FINISH <= '1';
151
            CLEAR_COUNTERS <= '0';
152
 
153
         when "0011" =>    -- state 3 reading from the buffer and writting to it
154
     if (FINISHED_D = '0' and BUS_ACKNOWLEDGE = '0' and WAITN ='1') then --simultanenously
155
                         NEXT_STATE <= "0101"; -- wait for a bus acknowledge before you finish
156
                elsif (FINISHED_D = '0') then --the decompression engine finishes. so automatically ends no more data needed all lbock reconstructed
157
                        NEXT_STATE <= "0111"; -- wait for acknowledge
158
        --      elsif (BUS_ACKNOWLEDGE='1' and WAITN = '1')  then --stop writting to the buffer process terminates. This is only valid if bus_acknowledge negated means finish
159
        --              NEXT_STATE <= "0100"; -- only reading data from the buffer
160
        --      elsif ( DECODING_OVERFLOW_AUX = '0' or DECODING_WRITE_ADDRESS(8 downto 1) = "00111111") then
161
     elsif (DECODING_OVERFLOW_AUX = '0') then
162
                        NEXT_STATE <= "0110"; -- wait 
163
                elsif (DECODING_UNDERFLOW_AUX = '1') then -- only writting to the buffer. underflow can happen with wait states
164
                        NEXT_STATE <= "0010";
165
                else
166
                        NEXT_STATE <= CURRENT_STATE;
167
                end if;
168
                DECODING_UNDERFLOW_INT <= '0';
169
                BUS_ACKNOWLEDGE_INT <= '1';
170
                ENABLE_READ_INT <= '1';
171
                ENABLE_WRITE_INT <= '1';
172
                BUS_REQUEST_INT <= '0';
173
                FINISH <= '1';
174
        CLEAR_COUNTERS <= '0';
175
 
176
   -- this state is currently not reachable 
177
         when "0100" =>    -- state 4 reading from the buffer. In only reading never request more data
178
     if (FINISHED_D = '0' and BUS_ACKNOWLEDGE = '0' and WAITN = '1') then --simultanenously
179
                         NEXT_STATE <= "0101"; -- wait for a bus acknowledge before you finish
180
                elsif (FINISHED_D = '0') then --the decompression engine finishes. so automatically ends no more data needed all lbock reconstructed
181
                        NEXT_STATE <= "0111"; -- wait for acknowledge   
182
--              elsif (DECODING_UNDERFLOW_AUX = '1') then -- only writting to the buffer
183
--                      NEXT_STATE <= "0010";
184
                else
185
                        NEXT_STATE <= CURRENT_STATE;
186
                end if;
187
                DECODING_UNDERFLOW_INT <= '0';
188
        BUS_ACKNOWLEDGE_INT <= '0';
189
                ENABLE_READ_INT <= '1';
190
                ENABLE_WRITE_INT <= '0';
191
                BUS_REQUEST_INT <= '1';
192
                FINISH <= '1';
193
            CLEAR_COUNTERS <= '0';
194
         when "0101" =>    -- signal finish
195
                DECODING_UNDERFLOW_INT <= '0';
196
                BUS_ACKNOWLEDGE_INT <= '0';
197
                NEXT_STATE <= "0000"; -- end
198
                ENABLE_READ_INT <= '0';
199
                ENABLE_WRITE_INT <= '0';
200
                BUS_REQUEST_INT <= '1';
201
                FINISH <= '0';
202
                CLEAR_COUNTERS <= '0';
203
        when "0110" =>    -- state 6 reading from the buffer. overflow more data needed
204
    if (FINISHED_D = '0') then --simultanenously
205
                         NEXT_STATE <= "0101"; -- wait for a bus acknowledge before you finish
206
                elsif (DECODING_UNDERFLOW_AUX = '1') then -- we have exahusted the compressed data request more
207
                        NEXT_STATE <= "0001"; -- request bus
208
                else
209
                        NEXT_STATE <= CURRENT_STATE;
210
                end if;
211
                DECODING_UNDERFLOW_INT <= '0';
212
                BUS_ACKNOWLEDGE_INT <= '1';
213
                ENABLE_READ_INT <= '1';
214
                ENABLE_WRITE_INT <= '0';
215
                BUS_REQUEST_INT <= '1';
216
                FINISH <= '1';
217
            CLEAR_COUNTERS <= '0';
218
 
219
 
220
         when "0111" =>  -- request data ( request the bus ) waiting for the acknowlecge before finishing directly
221
                if (BUS_ACKNOWLEDGE = '0' and WAITN = '1') then
222
                        NEXT_STATE <= "0101"; -- finish directly
223
                else
224
                        NEXT_STATE <= CURRENT_STATE;
225
                end if;
226
                DECODING_UNDERFLOW_INT <= '0';
227
                BUS_ACKNOWLEDGE_INT <= '1';
228
                ENABLE_READ_INT <= '0';
229
                ENABLE_WRITE_INT <= '0';
230
                BUS_REQUEST_INT <= '0';
231
                FINISH <= '1';
232
          CLEAR_COUNTERS <= '1';
233
 
234
         when "1001" =>  -- waiting for data in test mode 
235
                if (C_DATA_VALID = '0') then
236
                        NEXT_STATE <= "1010"; -- start writting data to the buffer
237
                else
238
                        NEXT_STATE <= CURRENT_STATE;
239
                end if;
240
                DECODING_UNDERFLOW_INT <= '0';
241
                BUS_ACKNOWLEDGE_INT <= '1';
242
                ENABLE_READ_INT <= '0';
243
                ENABLE_WRITE_INT <= '0';
244
                BUS_REQUEST_INT <= '1';
245
                FINISH <= '1';
246
            CLEAR_COUNTERS <= '1';
247
 
248
        when "1010" =>    -- state 2 writing to the buffer
249
                if (FINISHED_C = '0') then -- no more data available to write to the buffer the whole block is inside finish
250
                        NEXT_STATE <= "1100"; -- start only reading
251
                elsif (C_DATA_VALID = '1') then
252
                        NEXT_STATE <= "1110"; -- wait 
253
                elsif (DECODING_WRITE_ADDRESS - DECODING_READ_ADDRESS > "0000000010") then --start reading from the buffer
254
                        NEXT_STATE <= "1011"; -- start reading data from the buffer
255
                else
256
                        NEXT_STATE <= CURRENT_STATE;
257
                end if;
258
                DECODING_UNDERFLOW_INT <= '1';
259
                BUS_ACKNOWLEDGE_INT <= '1';
260
                ENABLE_READ_INT <= '0';
261
                ENABLE_WRITE_INT <= '1';
262
                BUS_REQUEST_INT <= '1';
263
                FINISH <= '1';
264
        CLEAR_COUNTERS <= '0';
265
   when "1011" =>    -- state 3 reading from the buffer and writting to it
266
                if (FINISHED_C ='0')  then --stop writting to the buffer process terminates
267
                        NEXT_STATE <= "1100"; -- only reading data from the buffer
268
                elsif (C_DATA_VALID = '1') then
269
                        NEXT_STATE <= "1110"; -- wait 
270
                elsif (DECODING_UNDERFLOW_AUX = '1') then -- only writting to the buffer
271
                        NEXT_STATE <= "1010";
272
                else
273
                        NEXT_STATE <= CURRENT_STATE;
274
                end if;
275
                DECODING_UNDERFLOW_INT <= '0';
276
                BUS_ACKNOWLEDGE_INT <= '1';
277
                ENABLE_READ_INT <= '1';
278
                ENABLE_WRITE_INT <= '1';
279
                BUS_REQUEST_INT <= '1';
280
                FINISH <= '1';
281
        CLEAR_COUNTERS <= '0';
282
   when "1110" =>    -- wait state. state reading from the buffer but waiting to write more data
283
                if (FINISHED_C ='0')  then --stop writting to the buffer process terminates
284
                        NEXT_STATE <= "1100"; -- only reading data from the buffer      
285
        elsif(C_DATA_VALID = '0' and DECODING_UNDERFLOW_AUX = '1') then -- data available write but do not read with underflow
286
                        NEXT_STATE <= "1010"; --  write
287
                elsif (DECODING_UNDERFLOW_AUX = '1') then -- total wait do not read or write
288
                        NEXT_STATE <= "1111"; -- total wait do not read or write
289
                elsif(C_DATA_VALID = '0') then -- do not read or write
290
                        NEXT_STATE <= "1011"; -- read and write
291
                else
292
                        NEXT_STATE <= CURRENT_STATE;
293
                end if;
294
                DECODING_UNDERFLOW_INT <= '0';
295
                BUS_ACKNOWLEDGE_INT <= '1';
296
                ENABLE_READ_INT <= '1';
297
                ENABLE_WRITE_INT <= '0';
298
                BUS_REQUEST_INT <= '1';
299
                FINISH <= '1';
300
        CLEAR_COUNTERS <= '0';
301
   when "1100" =>    -- state 4 reading from the buffer. In only reading never request more data
302
                if (FINISHED_D = '0') then --the decompression engine finishes
303
                        NEXT_STATE <= "1101"; -- end  
304
                else
305
                        NEXT_STATE <= CURRENT_STATE;
306
                end if;
307
                DECODING_UNDERFLOW_INT <= '0';
308
        BUS_ACKNOWLEDGE_INT <= '0';
309
                ENABLE_READ_INT <= '1';
310
                ENABLE_WRITE_INT <= '0';
311
                BUS_REQUEST_INT <= '1';
312
                FINISH <= '1';
313
        CLEAR_COUNTERS <= '0';
314
    when "1101" =>    -- signal finish
315
                DECODING_UNDERFLOW_INT <= '0';
316
                BUS_ACKNOWLEDGE_INT <= '0';
317
                NEXT_STATE <= "0000"; -- end
318
                ENABLE_READ_INT <= '0';
319
                ENABLE_WRITE_INT <= '0';
320
                BUS_REQUEST_INT <= '1';
321
                FINISH <= '0';
322
                CLEAR_COUNTERS <= '0';
323
        when "1111" =>    -- wait state. state reading from the buffer but waiting to write more data
324
                if (FINISHED_C ='0')  then --stop writting to the buffer process terminates
325
                        NEXT_STATE <= "1100"; -- only reading data from the buffer      
326
                elsif(C_DATA_VALID = '0') then -- do not read or write
327
                        NEXT_STATE <= "1010"; -- write to the buffer
328
                else
329
                        NEXT_STATE <= CURRENT_STATE;
330
                end if;
331
                DECODING_UNDERFLOW_INT <= '1';
332
                BUS_ACKNOWLEDGE_INT <= '1';
333
                ENABLE_READ_INT <= '0';
334
                ENABLE_WRITE_INT <= '0';
335
                BUS_REQUEST_INT <= '1';
336
                FINISH <= '1';
337
        CLEAR_COUNTERS <= '0';
338
         when others =>
339
                NEXT_STATE <= "0000";
340
                BUS_ACKNOWLEDGE_INT <= '0';
341
                DECODING_UNDERFLOW_INT <= '0';
342
                ENABLE_READ_INT <= '0';
343
                ENABLE_WRITE_INT <= '0';
344
                BUS_REQUEST_INT <= '1';
345
                FINISH <= '1';
346
                CLEAR_COUNTERS <= '1';
347
 
348
end  case;
349
end process STATES;
350
 
351
--DECODING_OVERFLOW_AUX <= '0' when ((DECODING_READ_ADDRESS(8 downto 1) = DECODING_WRITE_ADDRESS(8 downto 1) + "00000001") and (BUS_ACKNOWLEDGE_INT = '1')) else '1'; -- decoding overflow goes out of the chip is active with zero if bus_akcnowledge 1 then all the data is inside never generate overflow
352
DECODING_OVERFLOW_AUX <= '0' when (CURRENT_STATE(3) = '0' and (DECODING_WRITE_ADDRESS(9 downto 1) = "001000000") and (BUS_ACKNOWLEDGE_INT = '1')) else '1'; -- decoding overflow goes out of the chip is active with zero if bus_akcnowledge 1 then all the data is inside never generate overflow
353
DECODING_UNDERFLOW_AUX <= '1' when ((DECODING_WRITE_ADDRESS(9 downto 1) = DECODING_READ_ADDRESS(9 downto 1)) and (BUS_ACKNOWLEDGE_INT = '1') and (UNDERFLOW = '0')) else '0'; --the engine must requests data. In this case engine could request data beucase it is detected one cycle earlier
354
ENABLE_READ <= ENABLE_READ_INT and not(DECODING_UNDERFLOW_AUX); -- if decoding underflow disable the read counter 
355
ENABLE_WRITE <= ENABLE_WRITE_INT and DECODING_OVERFLOW_AUX; -- if overflow disable writting inmediatly
356
BUS_REQUEST <= BUS_REQUEST_INT or not(DECODING_OVERFLOW_AUX);
357
 
358
FLIP_FLOPS2 : process(CLK, CLEAR)
359
begin
360
 
361
if (CLEAR = '0') then
362
        OVERFLOW_CONTROL_AUX <= '0'; --state 0
363
elsif ((CLK'event) and (CLK='1')) then
364
     if (FORCE_STOP = '0') then
365
                                OVERFLOW_CONTROL_AUX <= '0'; --state 0
366
     elsif (CURRENT_STATE(3) = '1' and (DECODING_READ_ADDRESS = DECODING_WRITE_ADDRESS + "110000000")) then
367
                                OVERFLOW_CONTROL_AUX <= '1';
368
          elsif (DECODING_WRITE_ADDRESS = DECODING_READ_ADDRESS + "000000010" and WAITN = '1') then-- buffer empty    
369
                          OVERFLOW_CONTROL_AUX <= '0';
370
    else
371
                  OVERFLOW_CONTROL_AUX <= OVERFLOW_CONTROL_AUX;
372
                end if;
373
end if;
374
 
375
end process FLIP_FLOPS2;
376
 
377
OVERFLOW_CONTROL <= OVERFLOW_CONTROL_AUX;
378
 
379
FLIP_FLOPS : process(CLK, CLEAR)
380
begin
381
 
382
if (CLEAR = '0') then
383
        CURRENT_STATE <= "0000"; --state 0
384
elsif ((CLK'event) and (CLK='1')) then
385
  if (FORCE_STOP = '0') then
386
                CURRENT_STATE <= "0000";
387
  else
388
                CURRENT_STATE <= NEXT_STATE;
389
  end if;
390
end if;
391
 
392
end process FLIP_FLOPS;
393
 
394
--DELAY_UNDERFLOW : process(CLK, CLEAR, DECODING_UNDERFLOW_DELAY)
395
--begin 
396
 
397
--if (CLEAR = '0') then
398
--      DECODING_UNDERFLOW <= '0';
399
--elsif ((CLK'event) and (CLK='1')) then
400
--      DECODING_UNDERFLOW <= DECODING_UNDERFLOW_DELAY;
401
--end if;
402
--end process DELAY_UNDERFLOW;
403
 
404
 
405
 
406
DECODING_UNDERFLOW <= DECODING_UNDERFLOW_AUX or DECODING_UNDERFLOW_INT; -- never signal underflow if bus_acknowledge has gone to 1 it means that all the compressed data has been fed to the buffer. It has to terminate
407
 
408
end STRUCTURAL;
409
 

powered by: WebSVN 2.1.0

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