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

Subversion Repositories xmatchpro

[/] [xmatchpro/] [trunk/] [xmw4-comdec/] [xmatch_sim7/] [src/] [decomp_decode_4.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       = DECOMP_DECODE  --
19
--  version      = 1.0            --
20
--  last update  = 9/09/99       --
21
--  author       = Jose Nunez     --
22
------------------------------------
23
 
24
-- FUNCTION
25
-- decodes the match location (phased binary code) and match type (Huffman code)
26
 
27
-- PIN LIST
28
-- D_IN         = input data containing the match location and type codes
29
-- DECOMP       = indicates that we are in decompression mode (active low)
30
-- ENABLE       = indicates that block should be enabled [DECOMP must also be low] (active low)
31
-- FULL_MLENGTH = full match length (location + type + literal characters)
32
-- FULL_HIT     = indicates that a full hit (match type 0) has occurred (active low)
33
-- MATCH_TYPE   = decoded match type
34
-- MATCH_LOC    = decoded match location in the table
35
-- RL_DETECTED  = detection of code MAX_TABLE_ENTRIES-1
36
-- PART_MLENGTH = partial match length (location + type)
37
 
38
-- new function decodes de match type since no coding of the location is included
39
 
40
library ieee,dzx;
41
use ieee.std_logic_1164.all;
42
use dzx.bit_arith.all;
43
use dzx.attributes.all;
44
use dzx.bit_utils.all;
45
 
46
 
47
entity DECOMP_DECODE_4 is
48
port
49
(
50
      D_IN : in bit_vector(15 downto 0) ; -- 1 + 4 + 3 + 8 bits 
51
      DECOMP : in bit ;
52
      OVERFLOW_CONTROL  : in bit;
53
      ENABLE : in bit ;
54
      DECODING_UNDERFLOW : in bit; -- buffer is empty. invalid data in the 64 bit bus
55
      UNDERFLOW : in bit; -- produce in decomp assem 5
56
          INC : in bit;
57
     SET_LENGTH_TO_ZERO : in bit;
58
          TABLE_FULL : in bit;
59
          NFL_MINUS_ONE : in bit_vector(3 downto 0);
60
          CLK : in bit;
61
          CLEAR : in bit;
62
          RESET : in bit;
63
          FULL_MLENGTH : out bit_vector(5 downto 0);
64
          FULL_HIT : out bit ;
65
      MATCH_TYPE : out bit_vector(3 downto 0) ;
66
      MATCH_LOC : out bit_vector(3 downto 0) ;
67
          RL_COUNT : out bit_vector(7 downto 0);
68
          WAIT_DATA : out bit; -- next decoding cycle is not valid
69
          RL_DETECTED : out bit;
70
          MASK : out bit_vector(4 downto 0);
71
      PART_MLENGTH : out bit_vector(3 downto 0)
72
);
73
end DECOMP_DECODE_4;
74
 
75
 
76
architecture NODECOMP2 of DECOMP_DECODE_4 is
77
 
78
component LENGTH_SELECTION_2
79
 
80
port (MATCH_LOC_K : in bit_vector(3 downto 0);
81
          MATCH_LOC_K_1 : in bit_vector(3 downto 0);
82
          SUB : in bit_vector(4 downto 0);
83
          MAX_MATCH_LENGTH : in bit_vector(2 downto 0);
84
          MATCH_LENGTH : out bit_vector(2 downto 0);
85
          SEL_MATCH_LOC : out bit_vector(3 downto 0);
86
          K_BITS: out bit
87
         );
88
end component;
89
 
90
component MAX_PBC_LENGTH_2
91
 
92
port (OR_VECTOR: in bit_vector(2 downto 0);
93
          CODE : in bit_vector(14 downto 0); -- 4 ml and 6 mt and rl
94
          POS_RL_K_1 : out bit_vector(7 downto 0);
95
          POS_RL_K : out bit_vector(7 downto 0);
96
          POS_ML_K_1 : out bit_vector(3 downto 0);
97
          POS_ML_K : out bit_vector(3 downto 0);
98
          POS_MT_K_1 : out bit_vector(5 downto 0);
99
          POS_MT_K : out bit_vector(5 downto 0)
100
          );
101
 
102
end component;
103
 
104
component DECODE_MISS_2
105
port
106
(
107
        CODE : in bit_vector(3 downto 0);
108
        M_LIT_LENGTH : out bit_vector(5 downto 0);
109
        MASK : out bit_vector(4 downto 0)
110
);
111
end component;
112
 
113
component DECODE_MT_2
114
port
115
(
116
        CODE : in bit_vector(5 downto 0);
117
        M_LIT_LENGTH : out bit_vector(4 downto 0);
118
        RL_DETECTED : out bit;
119
        M_TYPE : out bit_vector(3 downto 0)
120
);
121
end component;
122
 
123
 
124
signal FULL_HIT_INT: bit;
125
signal MISS_LENGTH : bit_vector (5 downto 0);
126
signal MASK_AUX : bit_vector( 4 downto 0);
127
signal MASK_INT : bit_vector(4 downto 0);
128
signal ML_LIT_K : bit_vector(4 downto 0);
129
signal PM_L : bit_vector(2 downto 0);
130
signal MTL_LIT_K : bit_vector(4 downto 0);
131
signal MTL_LIT_AUX_K : bit_vector(4 downto 0);
132
signal MTL_LIT_AUX_K_1 : bit_vector(4 downto 0);
133
signal MTL_RUN : bit_vector(4 downto 0);
134
signal ML_K : bit_vector(2 downto 0);
135
signal TYPE_K : bit_vector(3 downto 0);
136
signal TYPE_AUX_K : bit_vector(3 downto 0);
137
signal TYPE_AUX_K_1 : bit_vector(3 downto 0);
138
signal FULL_SUM_K : bit_vector(4 downto 0);
139
signal P_SUM_K : bit_vector(3 downto 0);
140
signal TEMP_MTYPE : bit_vector(3 downto 0);
141
signal MATCH_LOC_AUX : bit_vector(3 downto 0);
142
signal MATCH_LOC_INT : bit_vector(3 downto 0);
143
signal RL_DETECTED_INT : bit;
144
signal RL_DETECTED_AUX : bit;
145
signal RL_DETECTED_AUX_K : bit;
146
signal RL_DETECTED_AUX_K_1 : bit;
147
signal MOVE_8 : bit;
148
-- signal ACTIVE : bit;
149
signal WAIT_DATA_INT : bit; -- under underflow the current decoding cycle does not take place although there is data ready for it.
150
signal POS_MT_K : bit_vector(5 downto 0);
151
signal POS_MT_K_1 : bit_vector(5 downto 0);
152
signal K_BITS : bit;
153
signal MAX_MATCH_LENGTH : bit_vector(2 downto 0);
154
signal MATCH_LENGTH : bit_vector(2 downto 0);
155
signal OR_VECTOR: bit_vector(2 downto 0);
156
signal OR_VECTOR_A: bit_vector(2 downto 0);
157
signal OR_VECTOR_B: bit_vector(2 downto 0);
158
signal MAX_MATCH_LENGTH_A : bit_vector(2 downto 0);
159
signal MAX_MATCH_LENGTH_B : bit_vector(2 downto 0);
160
signal SUB : bit_vector(4 downto 0);
161
signal SUB_A : bit_vector(4 downto 0);
162
signal SUB_B : bit_vector(4 downto 0);
163
signal OR_VECTOR_INT: bit_vector(2 downto 0);
164
signal SUB_INT : bit_vector(4 downto 0);
165
signal MAX_MATCH_LENGTH_INT : bit_vector(2 downto 0);
166
signal POS_ML_K_1 : bit_vector(3 downto 0);
167
signal POS_ML_K : bit_vector(3 downto 0);
168
signal POS_RL_K_1 : bit_vector(7 downto 0);
169
signal POS_RL_K : bit_vector(7 downto 0);
170
signal RL_COUNT_INT : bit_vector(7 downto 0);
171
 
172
begin
173
 
174
-- ACTIVE <= DECOMP or ENABLE;  -- block is active only when DECOMP and ENABLE are both low
175
 
176
-- ACTIVE <= DECOMP;
177
 
178
 
179
MAX_PBC_LENGTH_1 : MAX_PBC_LENGTH_2
180
port map(OR_VECTOR => OR_VECTOR,
181
                 CODE => D_IN(14 downto 0), -- max match loc and match type and rl
182
                 POS_RL_K_1 => POS_RL_K_1,
183
                 POS_RL_K => POS_RL_K,
184
                 POS_ML_K_1 => POS_ML_K_1,
185
                 POS_ML_K => POS_ML_K,
186
             POS_MT_K_1 => POS_MT_K_1,
187
                 POS_MT_K => POS_MT_K
188
                 );
189
 
190
DECODE_MATCH_TYPE_K_1 : DECODE_MT_2 port map ( CODE => POS_MT_K_1,
191
                                M_LIT_LENGTH => MTL_LIT_AUX_K_1,
192
                                                                RL_DETECTED => RL_DETECTED_AUX_K_1,
193
                                                                M_TYPE => TYPE_AUX_K_1);
194
 
195
DECODE_MATCH_TYPE_K : DECODE_MT_2 port map ( CODE => POS_MT_K,
196
                                M_LIT_LENGTH => MTL_LIT_AUX_K,
197
                                                                RL_DETECTED => RL_DETECTED_AUX_K,
198
                                                                M_TYPE => TYPE_AUX_K);
199
 
200
 
201
LENGTH_SELECTION_1 : LENGTH_SELECTION_2
202
                                         port map(MATCH_LOC_K => POS_ML_K,
203
                                                          MATCH_LOC_K_1 => POS_ML_K_1,
204
                                                          SUB => SUB,
205
                                                          MAX_MATCH_LENGTH => MAX_MATCH_LENGTH,
206
                                                          MATCH_LENGTH => MATCH_LENGTH,
207
                                                          SEL_MATCH_LOC => MATCH_LOC_INT,
208
                                                          K_BITS => K_BITS
209
                                                           );
210
 
211
 
212
MUX_SEL : process( K_BITS, POS_RL_K, POS_RL_K_1, MTL_LIT_AUX_K, MTL_LIT_AUX_K_1,
213
                                RL_DETECTED_AUX_K_1, RL_DETECTED_AUX_K,
214
                                TYPE_AUX_K_1, TYPE_AUX_K)
215
begin
216
 
217
if (K_BITS = '1') then -- use k bits
218
        MTL_LIT_K <= MTL_LIT_AUX_K;
219
        RL_DETECTED_AUX <= RL_DETECTED_AUX_K;
220
        RL_COUNT_INT <= POS_RL_K;
221
        TYPE_K <= TYPE_AUX_K;
222
else
223
        MTL_LIT_K <= MTL_LIT_AUX_K_1;   -- use k-1 bits
224
        RL_DETECTED_AUX <= RL_DETECTED_AUX_K_1;
225
        RL_COUNT_INT <= POS_RL_K_1;
226
        TYPE_K <= TYPE_AUX_K_1;
227
end if;
228
 
229
end process MUX_SEL;
230
 
231
 
232
OR_VECTOR_BP : process(NFL_MINUS_ONE)
233
 
234
variable NFL_MINUS_ONE_TEMP : bit_vector(3 downto 0);
235
variable OR_VECTOR_BL : bit_vector(2 downto 0);
236
variable LENGTH_POWER_B : bit_vector(4 downto 0);
237
 
238
 
239
begin
240
 
241
NFL_MINUS_ONE_TEMP := NFL_MINUS_ONE + "0001";
242
 
243
OR_VECTOR_BL(0) := NFL_MINUS_ONE_TEMP(3) or NFL_MINUS_ONE_TEMP(2) or NFL_MINUS_ONE_TEMP(1);
244
OR_VECTOR_BL(1) := NFL_MINUS_ONE_TEMP(3) or NFL_MINUS_ONE_TEMP(2);
245
OR_VECTOR_BL(2) := NFL_MINUS_ONE_TEMP(3);
246
 
247
case OR_VECTOR_BL is
248
 
249
when "000" =>
250
MAX_MATCH_LENGTH_B <= "001";
251
LENGTH_POWER_B := "00001"; -- sub 1 to get NFL_MINUS_ONE + 1 = VALID
252
when "001" =>
253
MAX_MATCH_LENGTH_B <= "010";
254
LENGTH_POWER_B := "00011"; -- sub 1 to get NFL_MINUS_ONE + 1 = VALID
255
when "011" =>
256
MAX_MATCH_LENGTH_B <= "011";
257
LENGTH_POWER_B := "00111"; -- sub 1 to get NFL_MINUS_ONE + 1 = VALID
258
when "111" =>
259
MAX_MATCH_LENGTH_B <= "100";
260
LENGTH_POWER_B := "01111"; -- sub 1 to get NFL_MINUS_ONE + 1 = VALID
261
when  others =>
262
MAX_MATCH_LENGTH_B <= "000";
263
LENGTH_POWER_B := "00000";
264
end case;
265
 
266
SUB_B <= LENGTH_POWER_B - ('0' & NFL_MINUS_ONE_TEMP);
267
OR_VECTOR_B <= OR_VECTOR_BL;
268
 
269
end process OR_VECTOR_BP;
270
 
271
 
272
 
273
OR_VECTOR_AP : process(NFL_MINUS_ONE)
274
 
275
variable OR_VECTOR_AL : bit_vector(2 downto 0);
276
variable LENGTH_POWER_A : bit_vector(4 downto 0);
277
 
278
begin
279
 
280
OR_VECTOR_AL(0) := NFL_MINUS_ONE(3) or NFL_MINUS_ONE(2) or NFL_MINUS_ONE(1);
281
OR_VECTOR_AL(1) := NFL_MINUS_ONE(3) or NFL_MINUS_ONE(2);
282
OR_VECTOR_AL(2) := NFL_MINUS_ONE(3);
283
 
284
case OR_VECTOR_AL is
285
 
286
when "000" =>
287
MAX_MATCH_LENGTH_A <= "001";
288
LENGTH_POWER_A := "00001"; -- sub 1 to get NFL_MINUS_ONE + 1 = VALID
289
when "001" =>
290
MAX_MATCH_LENGTH_A <= "010";
291
LENGTH_POWER_A := "00011"; -- sub 1 to get NFL_MINUS_ONE + 1 = VALID
292
when "011" =>
293
MAX_MATCH_LENGTH_A <= "011";
294
LENGTH_POWER_A := "00111"; -- sub 1 to get NFL_MINUS_ONE + 1 = VALID
295
when "111" =>
296
MAX_MATCH_LENGTH_A <= "100";
297
LENGTH_POWER_A := "01111"; -- sub 1 to get NFL_MINUS_ONE + 1 = VALID
298
when  others =>
299
MAX_MATCH_LENGTH_A <= "000";
300
LENGTH_POWER_A := "00000";
301
end case;
302
 
303
SUB_A <= LENGTH_POWER_A - ('0' & NFL_MINUS_ONE);
304
OR_VECTOR_A <= OR_VECTOR_AL;
305
 
306
end process OR_VECTOR_AP;
307
 
308
 
309
 
310
SEL_K : process(INC, TABLE_FULL, OR_VECTOR_A, OR_VECTOR_B, MAX_MATCH_LENGTH_A, MAX_MATCH_LENGTH_B, SUB_A, SUB_B)
311
 
312
begin
313
 
314
if (INC = '0' or TABLE_FULL = '0') then -- TABLE_FULL active at zero
315
        OR_VECTOR_INT <= OR_VECTOR_A;
316
        SUB_INT <= SUB_A;
317
        MAX_MATCH_LENGTH_INT <= MAX_MATCH_LENGTH_A;
318
else
319
        OR_VECTOR_INT <= OR_VECTOR_B;
320
        SUB_INT <= SUB_B;
321
        MAX_MATCH_LENGTH_INT <= MAX_MATCH_LENGTH_B;
322
end if;
323
 
324
end process SEL_K;
325
 
326
 
327
OR_VECTOR_REG : process(CLEAR, CLK)
328
 
329
begin
330
 
331
if (CLEAR = '0') then
332
    OR_VECTOR <= "000";
333
        SUB <= "00000";
334
        MAX_MATCH_LENGTH <= "000";
335
elsif ((CLK'event) and (CLK = '1')) then
336
        if (RESET = '0') then
337
                 OR_VECTOR <= "000"; -- initial next free location minus one is 1
338
                 SUB <= "00000";
339
                 MAX_MATCH_LENGTH <= "001";
340
        elsif(ENABLE = '1') then
341
                 OR_VECTOR <= "000";
342
                 SUB <= "00000";
343
                 MAX_MATCH_LENGTH <= "001";
344
        elsif (WAIT_DATA_INT = '0') then
345
         OR_VECTOR <= OR_VECTOR_INT;
346
                 SUB <= SUB_INT;
347
                 MAX_MATCH_LENGTH <= MAX_MATCH_LENGTH_INT;
348
        else
349
         OR_VECTOR <= OR_VECTOR;
350
                 SUB <= SUB;
351
                 MAX_MATCH_LENGTH <= MAX_MATCH_LENGTH;
352
        end if;
353
end if;
354
end process OR_VECTOR_REG;
355
 
356
 
357
DECODE_MISS_TYPE_1 : DECODE_MISS_2 port map ( CODE => D_IN(14 downto 11),
358
                                                                                  M_LIT_LENGTH => MISS_LENGTH,
359
                                                                                  MASK => MASK_AUX);
360
 
361
 
362
 
363
WAIT_DATA_INT <= (DECODING_UNDERFLOW and not(UNDERFLOW) and not(SET_LENGTH_TO_ZERO)) or (OVERFLOW_CONTROL and not(SET_LENGTH_TO_ZERO)); -- data not available from the decoding buffer
364
-- 1 bit is the match bit (13 total)
365
 
366
WAIT_DATA <= WAIT_DATA_INT or ENABLE;
367
 
368
-- ML_LIT_K <= MTL_RUN when RL_DETECTED_INT = '1' else MTL_LIT_K; 
369
 
370
-- careful I change this line
371
 
372
ML_LIT_K <= MTL_RUN when RL_DETECTED_AUX = '1' else MTL_LIT_K;
373
 
374
-- 8 bits run on zero 2 bits the rest
375
 
376
MTL_RUN <= ("01000" + MTL_LIT_K) when  MATCH_LOC_INT = "0000" else ("00010" + MTL_LIT_K);
377
 
378
-- to code 5 repeticions with only 2 bits extend the not of the MSB
379
 
380
RL_COUNT <= RL_COUNT_INT when MATCH_LOC_INT = "0000" else "00000"& not(RL_COUNT_INT(7)) & RL_COUNT_INT(7 downto 6);
381
 
382
MUX : process (D_IN(15), ENABLE, DECOMP, FULL_SUM_K , P_SUM_K ,  TYPE_K,
383
                                PM_L, RL_DETECTED_AUX, MISS_LENGTH, MASK_AUX, WAIT_DATA_INT, MATCH_LOC_INT)
384
begin
385
 
386
if (DECOMP = '0' and WAIT_DATA_INT = '0') then
387
    if (ENABLE='1') then
388
                FULL_MLENGTH <= "100011";
389
                PART_MLENGTH <= "0001";
390
                TEMP_MTYPE <= "0000";
391
                MASK_INT <= "11111";
392
                MATCH_LOC_AUX <= "0000";
393
                RL_DETECTED_INT <= '0';
394
    else
395
                   if (D_IN(15) = '0') then -- match
396
                      FULL_MLENGTH <= '0' & FULL_SUM_K;
397
                      PART_MLENGTH <= P_SUM_K;
398
                      TEMP_MTYPE <= TYPE_K;
399
                              MASK_INT <= "11111";
400
                  MATCH_LOC_AUX <= MATCH_LOC_INT;
401
                                  RL_DETECTED_INT <= RL_DETECTED_AUX;
402
                else
403
                              FULL_MLENGTH <= MISS_LENGTH; -- miss
404
                      PART_MLENGTH <= '0' & PM_L;
405
                      TEMP_MTYPE <= "1111";
406
                              MASK_INT <= MASK_AUX;
407
                  MATCH_LOC_AUX <= "0000";
408
                                  RL_DETECTED_INT <= '0';
409
           end if;
410
   end if;
411
else
412
    FULL_MLENGTH <= "000000"; -- no move
413
    PART_MLENGTH <= "0000";
414
    MASK_INT <= "11111";
415
    TEMP_MTYPE <= "1111";
416
    MATCH_LOC_AUX <= "0000";
417
    RL_DETECTED_INT <= '0';
418
end if;
419
end process MUX;
420
 
421
RL_DETECTED <= RL_DETECTED_INT;
422
 
423
 
424
 
425
ML_K <= ML_LIT_K(2 downto 0);
426
 
427
PM_L <= MISS_LENGTH(2 downto 0);
428
 
429
 
430
 
431
FULL_SUM_K <= "00" & MATCH_LENGTH + ML_LIT_K;
432
 
433
P_SUM_K <= '0'& MATCH_LENGTH + ('0' & ML_K);
434
 
435
 
436
MATCH_TYPE <= TEMP_MTYPE;
437
FULL_HIT_INT <= (TEMP_MTYPE(3) or TEMP_MTYPE(2)) or (TEMP_MTYPE(1) or TEMP_MTYPE(0));
438
MATCH_LOC <= MATCH_LOC_AUX;
439
 
440
FULL_HIT <= FULL_HIT_INT when MASK_INT(3) = '1' else '0';  -- if only space NFL does not increment full hit must be active
441
 
442
MASK <= MASK_INT;
443
 
444
end NODECOMP2;  -- end of architecture
445
 
446
 
447
 
448
 

powered by: WebSVN 2.1.0

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