Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: niu_scam_enc.v | |
4 | // Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved | |
5 | // 4150 Network Circle, Santa Clara, California 95054, U.S.A. | |
6 | // | |
7 | // * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
8 | // | |
9 | // This program is free software; you can redistribute it and/or modify | |
10 | // it under the terms of the GNU General Public License as published by | |
11 | // the Free Software Foundation; version 2 of the License. | |
12 | // | |
13 | // This program is distributed in the hope that it will be useful, | |
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | // GNU General Public License for more details. | |
17 | // | |
18 | // You should have received a copy of the GNU General Public License | |
19 | // along with this program; if not, write to the Free Software | |
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | // | |
22 | // For the avoidance of doubt, and except that if any non-GPL license | |
23 | // choice is available it will apply instead, Sun elects to use only | |
24 | // the General Public License version 2 (GPLv2) at this time for any | |
25 | // software where a choice of GPL license versions is made | |
26 | // available with the language indicating that GPLv2 or any later version | |
27 | // may be used, or where a choice of which version of the GPL is applied is | |
28 | // otherwise unspecified. | |
29 | // | |
30 | // Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
31 | // CA 95054 USA or visit www.sun.com if you need additional information or | |
32 | // have any questions. | |
33 | // | |
34 | // ========== Copyright Header End ============================================ | |
35 | ||
36 | /********************************************************** | |
37 | *********************************************************** | |
38 | ||
39 | Project : Niu | |
40 | ||
41 | File name : niu_scam_enc.v | |
42 | ||
43 | Module(s) name : niu_scam_enc | |
44 | ||
45 | Parent modules : niu_scam.v | |
46 | ||
47 | Child modules : niu_scam_hit | |
48 | ||
49 | Author's name : George Chu | |
50 | ||
51 | Date : Jan. 2004 | |
52 | ||
53 | Description : | |
54 | ||
55 | Synthesis Notes: | |
56 | ||
57 | Modification History: | |
58 | Date Description | |
59 | ---- ----------- | |
60 | ||
61 | ************************************************************ | |
62 | ***********************************************************/ | |
63 | ||
64 | `timescale 1ns/10ps | |
65 | ||
66 | module niu_scam_enc ( | |
67 | match_array, | |
68 | cmp_enc, | |
69 | reset, | |
70 | cam_clk, | |
71 | cam_hit, | |
72 | cam_haddr); | |
73 | ||
74 | input [127:0] match_array; // matched entries | |
75 | input cmp_enc; // do priority encode | |
76 | input reset; | |
77 | input cam_clk; // tcam internal clock | |
78 | output cam_hit; // cam has a match/hit | |
79 | output [6:0] cam_haddr; // cam's match/hit address | |
80 | ||
81 | reg cam_hit; | |
82 | reg [6:0] cam_haddr; | |
83 | ||
84 | reg [127:0] match_array_d; | |
85 | ||
86 | wire hit; | |
87 | reg [6:0] haddr; | |
88 | ||
89 | assign hit = |(match_array[127:0]); | |
90 | ||
91 | // ------------------ priority encode the hit address --------- | |
92 | always @(match_array_d) | |
93 | casez (match_array_d) // synopsys parallel_case | |
94 | // 1 1 1 1 1 1 1 | |
95 | // 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 | |
96 | ({124'h????_????_????_????_????_????_????_???,4'b???1} ): haddr=7'h00; | |
97 | ({124'h????_????_????_????_????_????_????_???,4'b??10} ): haddr=7'h01; | |
98 | ({124'h????_????_????_????_????_????_????_???,4'b?100} ): haddr=7'h02; | |
99 | ({124'h????_????_????_????_????_????_????_???,4'b1000} ): haddr=7'h03; | |
100 | ({120'h????_????_????_????_????_????_????_??, 4'b???1, 4'b0}): haddr=7'h04; | |
101 | ({120'h????_????_????_????_????_????_????_??, 4'b??10, 4'b0}): haddr=7'h05; | |
102 | ({120'h????_????_????_????_????_????_????_??, 4'b?100, 4'b0}): haddr=7'h06; | |
103 | ({120'h????_????_????_????_????_????_????_??, 4'b1000, 4'b0}): haddr=7'h07; | |
104 | ({116'h????_????_????_????_????_????_????_?, 4'b???1, 8'b0}): haddr=7'h08; | |
105 | ({116'h????_????_????_????_????_????_????_?, 4'b??10, 8'b0}): haddr=7'h09; | |
106 | ({116'h????_????_????_????_????_????_????_?, 4'b?100, 8'b0}): haddr=7'h0a; | |
107 | ({116'h????_????_????_????_????_????_????_?, 4'b1000, 8'b0}): haddr=7'h0b; | |
108 | ({112'h????_????_????_????_????_????_????, 4'b???1, 12'b0}): haddr=7'h0c; | |
109 | ({112'h????_????_????_????_????_????_????, 4'b??10, 12'b0}): haddr=7'h0d; | |
110 | ({112'h????_????_????_????_????_????_????, 4'b?100, 12'b0}): haddr=7'h0e; | |
111 | ({112'h????_????_????_????_????_????_????, 4'b1000, 12'b0}): haddr=7'h0f; | |
112 | ||
113 | // 1 1 1 1 1 1 1 | |
114 | // 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 | |
115 | ({108'h????_????_????_????_????_????_???, 4'b???1, 16'b0}): haddr=7'h10; | |
116 | ({108'h????_????_????_????_????_????_???, 4'b??10, 16'b0}): haddr=7'h11; | |
117 | ({108'h????_????_????_????_????_????_???, 4'b?100, 16'b0}): haddr=7'h12; | |
118 | ({108'h????_????_????_????_????_????_???, 4'b1000, 16'b0}): haddr=7'h13; | |
119 | ({104'h????_????_????_????_????_????_??, 4'b???1, 20'b0}): haddr=7'h14; | |
120 | ({104'h????_????_????_????_????_????_??, 4'b??10, 20'b0}): haddr=7'h15; | |
121 | ({104'h????_????_????_????_????_????_??, 4'b?100, 20'b0}): haddr=7'h16; | |
122 | ({104'h????_????_????_????_????_????_??, 4'b1000, 20'b0}): haddr=7'h17; | |
123 | ({100'h????_????_????_????_????_????_?, 4'b???1, 24'b0}): haddr=7'h18; | |
124 | ({100'h????_????_????_????_????_????_?, 4'b??10, 24'b0}): haddr=7'h19; | |
125 | ({100'h????_????_????_????_????_????_?, 4'b?100, 24'b0}): haddr=7'h1a; | |
126 | ({100'h????_????_????_????_????_????_?, 4'b1000, 24'b0}): haddr=7'h1b; | |
127 | ({096'h????_????_????_????_????_????, 4'b???1, 28'b0}): haddr=7'h1c; | |
128 | ({096'h????_????_????_????_????_????, 4'b??10, 28'b0}): haddr=7'h1d; | |
129 | ({096'h????_????_????_????_????_????, 4'b?100, 28'b0}): haddr=7'h1e; | |
130 | ({096'h????_????_????_????_????_????, 4'b1000, 28'b0}): haddr=7'h1f; | |
131 | ||
132 | // 1 1 1 1 1 1 1 | |
133 | // 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 | |
134 | ({092'h????_????_????_????_????_???, 4'b???1, 32'b0}): haddr=7'h20; | |
135 | ({092'h????_????_????_????_????_???, 4'b??10, 32'b0}): haddr=7'h21; | |
136 | ({092'h????_????_????_????_????_???, 4'b?100, 32'b0}): haddr=7'h22; | |
137 | ({092'h????_????_????_????_????_???, 4'b1000, 32'b0}): haddr=7'h23; | |
138 | ({088'h????_????_????_????_????_??, 4'b???1, 36'b0}): haddr=7'h24; | |
139 | ({088'h????_????_????_????_????_??, 4'b??10, 36'b0}): haddr=7'h25; | |
140 | ({088'h????_????_????_????_????_??, 4'b?100, 36'b0}): haddr=7'h26; | |
141 | ({088'h????_????_????_????_????_??, 4'b1000, 36'b0}): haddr=7'h27; | |
142 | ({084'h????_????_????_????_????_?, 4'b???1, 40'b0}): haddr=7'h28; | |
143 | ({084'h????_????_????_????_????_?, 4'b??10, 40'b0}): haddr=7'h29; | |
144 | ({084'h????_????_????_????_????_?, 4'b?100, 40'b0}): haddr=7'h2a; | |
145 | ({084'h????_????_????_????_????_?, 4'b1000, 40'b0}): haddr=7'h2b; | |
146 | ({080'h????_????_????_????_????, 4'b???1, 44'b0}): haddr=7'h2c; | |
147 | ({080'h????_????_????_????_????, 4'b??10, 44'b0}): haddr=7'h2d; | |
148 | ({080'h????_????_????_????_????, 4'b?100, 44'b0}): haddr=7'h2e; | |
149 | ({080'h????_????_????_????_????, 4'b1000, 44'b0}): haddr=7'h2f; | |
150 | ||
151 | // 1 1 1 1 1 1 1 | |
152 | // 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 | |
153 | ({076'h????_????_????_????_???, 4'b???1, 48'b0}): haddr=7'h30; | |
154 | ({076'h????_????_????_????_???, 4'b??10, 48'b0}): haddr=7'h31; | |
155 | ({076'h????_????_????_????_???, 4'b?100, 48'b0}): haddr=7'h32; | |
156 | ({076'h????_????_????_????_???, 4'b1000, 48'b0}): haddr=7'h33; | |
157 | ({072'h????_????_????_????_??, 4'b???1, 52'b0}): haddr=7'h34; | |
158 | ({072'h????_????_????_????_??, 4'b??10, 52'b0}): haddr=7'h35; | |
159 | ({072'h????_????_????_????_??, 4'b?100, 52'b0}): haddr=7'h36; | |
160 | ({072'h????_????_????_????_??, 4'b1000, 52'b0}): haddr=7'h37; | |
161 | ({068'h????_????_????_????_?, 4'b???1, 56'b0}): haddr=7'h38; | |
162 | ({068'h????_????_????_????_?, 4'b??10, 56'b0}): haddr=7'h39; | |
163 | ({068'h????_????_????_????_?, 4'b?100, 56'b0}): haddr=7'h3a; | |
164 | ({068'h????_????_????_????_?, 4'b1000, 56'b0}): haddr=7'h3b; | |
165 | ({064'h????_????_????_????, 4'b???1, 60'b0}): haddr=7'h3c; | |
166 | ({064'h????_????_????_????, 4'b??10, 60'b0}): haddr=7'h3d; | |
167 | ({064'h????_????_????_????, 4'b?100, 60'b0}): haddr=7'h3e; | |
168 | ({064'h????_????_????_????, 4'b1000, 60'b0}): haddr=7'h3f; | |
169 | ||
170 | // 1 1 1 1 1 1 1 | |
171 | // 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 | |
172 | ({060'h????_????_????_???, 4'b???1, 64'b0}): haddr=7'h40; | |
173 | ({060'h????_????_????_???, 4'b??10, 64'b0}): haddr=7'h41; | |
174 | ({060'h????_????_????_???, 4'b?100, 64'b0}): haddr=7'h42; | |
175 | ({060'h????_????_????_???, 4'b1000, 64'b0}): haddr=7'h43; | |
176 | ({056'h????_????_????_??, 4'b???1, 68'b0}): haddr=7'h44; | |
177 | ({056'h????_????_????_??, 4'b??10, 68'b0}): haddr=7'h45; | |
178 | ({056'h????_????_????_??, 4'b?100, 68'b0}): haddr=7'h46; | |
179 | ({056'h????_????_????_??, 4'b1000, 68'b0}): haddr=7'h47; | |
180 | ({052'h????_????_????_?, 4'b???1, 72'b0}): haddr=7'h48; | |
181 | ({052'h????_????_????_?, 4'b??10, 72'b0}): haddr=7'h49; | |
182 | ({052'h????_????_????_?, 4'b?100, 72'b0}): haddr=7'h4a; | |
183 | ({052'h????_????_????_?, 4'b1000, 72'b0}): haddr=7'h4b; | |
184 | ({048'h????_????_????, 4'b???1, 76'b0}): haddr=7'h4c; | |
185 | ({048'h????_????_????, 4'b??10, 76'b0}): haddr=7'h4d; | |
186 | ({048'h????_????_????, 4'b?100, 76'b0}): haddr=7'h4e; | |
187 | ({048'h????_????_????, 4'b1000, 76'b0}): haddr=7'h4f; | |
188 | ||
189 | // 1 1 1 1 1 1 1 | |
190 | // 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 | |
191 | ({044'h????_????_???, 4'b???1, 80'b0}): haddr=7'h50; | |
192 | ({044'h????_????_???, 4'b??10, 80'b0}): haddr=7'h51; | |
193 | ({044'h????_????_???, 4'b?100, 80'b0}): haddr=7'h52; | |
194 | ({044'h????_????_???, 4'b1000, 80'b0}): haddr=7'h53; | |
195 | ({040'h????_????_??, 4'b???1, 84'b0}): haddr=7'h54; | |
196 | ({040'h????_????_??, 4'b??10, 84'b0}): haddr=7'h55; | |
197 | ({040'h????_????_??, 4'b?100, 84'b0}): haddr=7'h56; | |
198 | ({040'h????_????_??, 4'b1000, 84'b0}): haddr=7'h57; | |
199 | ({036'h????_????_?, 4'b???1, 88'b0}): haddr=7'h58; | |
200 | ({036'h????_????_?, 4'b??10, 88'b0}): haddr=7'h59; | |
201 | ({036'h????_????_?, 4'b?100, 88'b0}): haddr=7'h5a; | |
202 | ({036'h????_????_?, 4'b1000, 88'b0}): haddr=7'h5b; | |
203 | ({032'h????_????, 4'b???1, 92'b0}): haddr=7'h5c; | |
204 | ({032'h????_????, 4'b??10, 92'b0}): haddr=7'h5d; | |
205 | ({032'h????_????, 4'b?100, 92'b0}): haddr=7'h5e; | |
206 | ({032'h????_????, 4'b1000, 92'b0}): haddr=7'h5f; | |
207 | ||
208 | // 1 1 1 1 1 1 1 | |
209 | // 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 | |
210 | ({028'h????_???, 4'b???1, 96'b0}): haddr=7'h60; | |
211 | ({028'h????_???, 4'b??10, 96'b0}): haddr=7'h61; | |
212 | ({028'h????_???, 4'b?100, 96'b0}): haddr=7'h62; | |
213 | ({028'h????_???, 4'b1000, 96'b0}): haddr=7'h63; | |
214 | ({024'h????_??, 4'b???1,100'b0}): haddr=7'h64; | |
215 | ({024'h????_??, 4'b??10,100'b0}): haddr=7'h65; | |
216 | ({024'h????_??, 4'b?100,100'b0}): haddr=7'h66; | |
217 | ({024'h????_??, 4'b1000,100'b0}): haddr=7'h67; | |
218 | ({020'h????_?, 4'b???1,104'b0}): haddr=7'h68; | |
219 | ({020'h????_?, 4'b??10,104'b0}): haddr=7'h69; | |
220 | ({020'h????_?, 4'b?100,104'b0}): haddr=7'h6a; | |
221 | ({020'h????_?, 4'b1000,104'b0}): haddr=7'h6b; | |
222 | ({016'h????, 4'b???1,108'b0}): haddr=7'h6c; | |
223 | ({016'h????, 4'b??10,108'b0}): haddr=7'h6d; | |
224 | ({016'h????, 4'b?100,108'b0}): haddr=7'h6e; | |
225 | ({016'h????, 4'b1000,108'b0}): haddr=7'h6f; | |
226 | ||
227 | // 1 1 1 1 1 1 1 | |
228 | // 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 | |
229 | ({012'h???, 4'b???1,112'b0}): haddr=7'h70; | |
230 | ({012'h???, 4'b??10,112'b0}): haddr=7'h71; | |
231 | ({012'h???, 4'b?100,112'b0}): haddr=7'h72; | |
232 | ({012'h???, 4'b1000,112'b0}): haddr=7'h73; | |
233 | ({008'h??, 4'b???1,116'b0}): haddr=7'h74; | |
234 | ({008'h??, 4'b??10,116'b0}): haddr=7'h75; | |
235 | ({008'h??, 4'b?100,116'b0}): haddr=7'h76; | |
236 | ({008'h??, 4'b1000,116'b0}): haddr=7'h77; | |
237 | ({004'h?, 4'b???1,120'b0}): haddr=7'h78; | |
238 | ({004'h?, 4'b??10,120'b0}): haddr=7'h79; | |
239 | ({004'h?, 4'b?100,120'b0}): haddr=7'h7a; | |
240 | ({004'h?, 4'b1000,120'b0}): haddr=7'h7b; | |
241 | ({ 4'b???1,124'b0}): haddr=7'h7c; | |
242 | ({ 4'b??10,124'b0}): haddr=7'h7d; | |
243 | ({ 4'b?100,124'b0}): haddr=7'h7e; | |
244 | ({ 4'b1000,124'b0}): haddr=7'h7f; | |
245 | ||
246 | default: haddr=7'd0; | |
247 | endcase | |
248 | ||
249 | // ------------------ registers ------------------------------- | |
250 | always @(posedge cam_clk) begin | |
251 | if (reset) begin | |
252 | match_array_d <= 128'h0; | |
253 | cam_hit <= 1'h0; | |
254 | cam_haddr <= 7'h0; | |
255 | end | |
256 | else begin | |
257 | match_array_d <= match_array[127:0]; | |
258 | cam_hit <= cmp_enc && hit; | |
259 | cam_haddr <= {7{cmp_enc}} & haddr[6:0]; | |
260 | end | |
261 | end | |
262 | ||
263 | endmodule |