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

Subversion Repositories xmatchpro

[/] [xmatchpro/] [trunk/] [xmw4-comdec/] [xmatch_sim7/] [src/] [mld_logic_3_2_2.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       = MLD_LOGIC_3_2_2   --
19
--  version      = 1.0             --
20
--  last update  = 2/04/01          --
21
--  author       = Jose Nunez      --
22
-------------------------------------
23
 
24
 
25
-- FUNCTION
26
-- Match location decision logic.
27
-- This reads in the match types from each location in the CAM array
28
-- and decides which location provides the best hit in terms of the
29
-- minimum number of code bits output.
30
-- This is part 2 and solves the best match
31
 
32
 
33
--  PIN LIST
34
--  DOWN_PRIORITY_6/5/4/3/2/1 = these are the priorities that have been propagated
35
--  SAME_LENGTH = same length in data word and search word
36
--  MATCH_TYPE_A,B,C,D = It seems necessary to also pipeline the match_type
37
--  COLUMN_OR = the result of the or of each column
38
--  MATCH_LOC    = location of the best match.
39
--  MATCH_TYPE   = match type of the location with the best match.
40
 
41
 
42
library ieee,dzx;
43
use ieee.std_logic_1164.all;
44
use dzx.bit_utils.all;
45
 
46
 
47
entity MLD_LOGIC_3_2_2 is
48
port
49
(
50
                 MASK : in bit_vector(4 downto 0);
51
      DOWN_PRIORITY_6 : in bit_vector(15 downto 0) ;
52
        DOWN_PRIORITY_5 : in bit_vector(15 downto 0) ;
53
      DOWN_PRIORITY_4 : in bit_vector(15 downto 0) ;
54
      DOWN_PRIORITY_3 : in bit_vector(15 downto 0) ;
55
      DOWN_PRIORITY_2 : in bit_vector(15 downto 0) ;
56
      DOWN_PRIORITY_1 : in bit_vector(15 downto 0) ;
57
        SAME_LENGTH_2 : in bit_vector(15 downto 0);
58
        SAME_LENGTH_3 : in bit_vector(15 downto 0);
59
        SAME_LENGTH_4 : in bit_vector(15 downto 0);
60
        MATCH_TYPE_A : in bit_vector(15 downto 0);
61
        MATCH_TYPE_B : in bit_vector(15 downto 0);
62
        MATCH_TYPE_C : in bit_vector(15 downto 0);
63
        MATCH_TYPE_D : in bit_vector(15 downto 0);
64
      COLUMN_OR : in bit_vector(6 downto 1);
65
      MATCH_LOC : out bit_vector(15 downto 0) ;
66
      MATCH_TYPE : out bit_vector(3 downto 0)
67
);
68
 
69
end MLD_LOGIC_3_2_2;
70
 
71
 
72
architecture DECIDE_3 of MLD_LOGIC_3_2_2 is
73
 
74
-- a single drop down unit
75
 
76
component MLD_DPROP
77
port
78
        (
79
        DIN : in bit_vector(0 to 15);
80
        DOUT : out bit_vector(0 to 15);
81
        FULL_OR : out bit
82
        );
83
end component;
84
 
85
type MTYPE_ARRAY is array(0 to 15) of bit_vector(3 downto 0);
86
type PRI_ARRAY is array(0 to 15) of bit_vector(6 downto 1);
87
type PRI_TRANS_ARRAY is array(6 downto 1) of bit_vector(0 to 15);
88
 
89
 
90
signal SECOND_TRANS_PRI : PRI_TRANS_ARRAY;
91
signal THIRD_TRANS_PRI : PRI_TRANS_ARRAY;
92
signal LOCATION : bit_vector(15 downto 0);
93
signal LOCATION_INT : bit_vector(15 downto 0);
94
signal LOCATION_INT_AUX : bit_vector(15 downto 0);
95
signal SECOND_COLUMN_OR : bit_vector(6 downto 1);
96
signal MATCH_TYPE_AUX : bit_vector(3 downto 0);
97
signal MATCH_TYPE_INT : bit_vector(3 downto 0);
98
signal FULL_MATCH_AUX_2 : bit;
99
signal FULL_MATCH_AUX_3 : bit;
100
signal FULL_MATCH_AUX_4 : bit;
101
signal FULL_MATCH_INT : bit;
102
signal FULL_TUPLE : bit_vector(15 downto 0);
103
 
104
begin
105
 
106
 
107
FULL_TUPLE <= x"FFFF" when MASK(1) = '1' else x"0000";
108
 
109
-- MASK[1] tuple complete consider partial match
110
 
111
SECOND_TRANS_PRI(6) <= DOWN_PRIORITY_6 and (FULL_TUPLE or SAME_LENGTH_4); -- the length must be the same to consider the match. Partial words can only generate full matches
112
SECOND_TRANS_PRI(5) <= DOWN_PRIORITY_5 and (FULL_TUPLE or SAME_LENGTH_3);
113
SECOND_TRANS_PRI(4) <= DOWN_PRIORITY_4;
114
SECOND_TRANS_PRI(3) <= DOWN_PRIORITY_3;
115
SECOND_TRANS_PRI(2) <= DOWN_PRIORITY_2 and (FULL_TUPLE or SAME_LENGTH_2);
116
SECOND_TRANS_PRI(1) <= DOWN_PRIORITY_1;
117
 
118
-- or generation logic
119
SECOND_COLUMN_OR(6) <= COLUMN_OR(6);
120
SECOND_COLUMN_OR(5) <= not(COLUMN_OR(6)) and COLUMN_OR(5);
121
SECOND_COLUMN_OR(4) <= Nor_Bits(COLUMN_OR(6 downto 5))and COLUMN_OR(4);
122
SECOND_COLUMN_OR(3) <= Nor_Bits(COLUMN_OR(6 downto 4)) and COLUMN_OR(3);
123
SECOND_COLUMN_OR(2) <= Nor_Bits(COLUMN_OR(6 downto 3)) and COLUMN_OR(2);
124
SECOND_COLUMN_OR(1) <= Nor_Bits(COLUMN_OR(6 downto 2)) and COLUMN_OR(1);
125
 
126
 
127
ACROSS_PROP : process (SECOND_COLUMN_OR , SECOND_TRANS_PRI)
128
begin
129
for I in 5 downto 1 loop
130
        for J in 0 to 15 loop
131
                THIRD_TRANS_PRI(I)(J) <= SECOND_TRANS_PRI(I)(J) and SECOND_COLUMN_OR(I);
132
        end loop;
133
end loop;
134
THIRD_TRANS_PRI(6) <= SECOND_TRANS_PRI(6);
135
end process ACROSS_PROP;
136
 
137
 
138
LOCATION_DECIDE : process (THIRD_TRANS_PRI)
139
begin
140
for I in 0 to 15 loop
141
        LOCATION(15-I) <= (THIRD_TRANS_PRI(6)(I) or THIRD_TRANS_PRI(5)(I) or THIRD_TRANS_PRI(4)(I)) or (THIRD_TRANS_PRI(3)(I) or THIRD_TRANS_PRI(2)(I) or THIRD_TRANS_PRI(1)(I));
142
end loop;
143
end process LOCATION_DECIDE;
144
 
145
 
146
DROP_DOWN : MLD_DPROP port map (        DIN => LOCATION,
147
                                                                        DOUT => LOCATION_INT,
148
                                                                        FULL_OR => open );
149
 
150
 
151
 
152
TRANSPOSE : process(LOCATION_INT)
153
begin
154
        for I in 0 to 15 loop
155
                LOCATION_INT_AUX(15-I) <= LOCATION_INT(I);
156
        end loop;
157
end process;
158
 
159
MUX : process (LOCATION_INT_AUX , MATCH_TYPE_A, MATCH_TYPE_B, MATCH_TYPE_C, MATCH_TYPE_D)
160
variable MATCH_TYPE_A_TEMP : bit_vector(15 downto 0);
161
variable MATCH_TYPE_B_TEMP : bit_vector(15 downto 0);
162
variable MATCH_TYPE_C_TEMP : bit_vector(15 downto 0);
163
variable MATCH_TYPE_D_TEMP : bit_vector(15 downto 0);
164
 
165
 
166
begin
167
for I in 0 to 15 loop
168
        MATCH_TYPE_A_TEMP(I) := MATCH_TYPE_A(I) or LOCATION_INT_AUX(I);
169
        MATCH_TYPE_B_TEMP(I) := MATCH_TYPE_B(I) or LOCATION_INT_AUX(I);
170
        MATCH_TYPE_C_TEMP(I) := MATCH_TYPE_C(I) or LOCATION_INT_AUX(I);
171
        MATCH_TYPE_D_TEMP(I) := MATCH_TYPE_D(I) or LOCATION_INT_AUX(I);
172
 
173
end loop;
174
 
175
MATCH_TYPE_AUX(3) <= And_Bits(MATCH_TYPE_A_TEMP);
176
MATCH_TYPE_AUX(2) <= And_Bits(MATCH_TYPE_B_TEMP);
177
MATCH_TYPE_AUX(1) <= And_Bits(MATCH_TYPE_C_TEMP);
178
MATCH_TYPE_AUX(0) <= And_Bits(MATCH_TYPE_D_TEMP);
179
 
180
 
181
end process MUX;
182
 
183
 
184
 
185
-- active high same length
186
 
187
FULL_MATCH_AUX_2 <= or_bits(SAME_LENGTH_2 and DOWN_PRIORITY_2);
188
FULL_MATCH_AUX_3 <= or_bits(SAME_LENGTH_3 and DOWN_PRIORITY_5);
189
FULL_MATCH_AUX_4 <= or_bits(SAME_LENGTH_4 and DOWN_PRIORITY_6);
190
 
191
 
192
-- promote match type to total (15) when lengths are equal and inverted match type is 15,14 or 12;
193
MATCH_TYPE_PROMOTION: process(MATCH_TYPE_AUX, FULL_MATCH_AUX_2,FULL_MATCH_AUX_3,FULL_MATCH_AUX_4)
194
begin
195
case MATCH_TYPE_AUX is
196
        when "0000" =>
197
                if FULL_MATCH_AUX_4 = '1' then
198
                        MATCH_TYPE_INT <=  "0000";
199
                else
200
                        MATCH_TYPE_INT <= MATCH_TYPE_AUX;
201
              end if;
202
        when "0001" =>
203
                if FULL_MATCH_AUX_3 = '1' then
204
                        MATCH_TYPE_INT <=  "0000";
205
                else
206
                        MATCH_TYPE_INT <= MATCH_TYPE_AUX;
207
              end if;
208
        when "0011" =>
209
                if FULL_MATCH_AUX_2 = '1' then
210
                        MATCH_TYPE_INT <=  "0000";
211
                else
212
                        MATCH_TYPE_INT <= MATCH_TYPE_AUX;
213
              end if;
214
        when others =>
215
                MATCH_TYPE_INT <= MATCH_TYPE_AUX;
216
end case;
217
end process MATCH_TYPE_PROMOTION;
218
 
219
FULL_MATCH_INT <= '0' when MATCH_TYPE_INT = "0000" else  '1';
220
 
221
MATCH_TYPE <= MATCH_TYPE_INT;
222
MATCH_LOC <= LOCATION_INT_AUX;
223
 
224
 
225
end DECIDE_3;
226
 
227
 
228
 
229
 
230
 
231
 

powered by: WebSVN 2.1.0

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