Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / spc / lsu / rtl / lsu_lru8_ctl.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: lsu_lru8_ctl.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 ============================================
35module lsu_lru8_ctl (
36 l1clk,
37 scan_in,
38 spc_aclk,
39 spc_bclk,
40 scan_out,
41 request,
42 enable,
43 select);
44wire siclk;
45wire soclk;
46wire dff_lru_scanin;
47wire dff_lru_scanout;
48wire nlru0_7;
49wire nlru0_3;
50wire nlru4_7;
51wire nlru0_1;
52wire nlru2_3;
53wire nlru4_5;
54wire nlru6_7;
55wire lru0_7;
56wire lru0_3;
57wire lru4_7;
58wire lru0_1;
59wire lru2_3;
60wire lru4_5;
61wire lru6_7;
62wire pick_0123;
63wire pick_4567;
64wire pick_01;
65wire pick_23;
66wire pick_45;
67wire pick_67;
68wire pick_0;
69wire pick_1;
70wire pick_2;
71wire pick_3;
72wire pick_4;
73wire pick_5;
74wire pick_6;
75wire pick_7;
76
77
78input l1clk;
79input scan_in;
80input spc_aclk;
81input spc_bclk;
82output scan_out;
83
84input [7:0] request;
85input [7:0] enable;
86
87output [7:0] select;
88
89// scan renames
90assign siclk = spc_aclk;
91assign soclk = spc_bclk;
92// end scan
93
94////////////////////////////////////////////////////////////////////////////////
95// Pseudo-LRU picker to choose the oldest thread for issuing to pcx.
96// The picker uses a binary tree to track age.
97// lru0_1 -> 0=#0 is newer, 1=#1 is newer
98// lru2_3 -> 0=#2 is newer, 1=#3 is newer
99// lru0_3 -> 0={0,1} is newer, 1={2,3} is newer
100// lru4_7 -> 0={4,5} is newer, 1={6,7} is newer
101// lru0_7 -> 0={0,1,2,3} is newer, 1={4,5,6,7} is newer
102// The state updates every time an entry is written. The "least recently written"
103// as determined by tracing the tree has priority.
104////////////////////////////////////////////////////////////////////////////////
105
106lsu_lru8_ctl_msff_ctl_macro__width_7 dff_lru (
107 .scan_in(dff_lru_scanin),
108 .scan_out(dff_lru_scanout),
109 .din ({nlru0_7,nlru0_3,nlru4_7,nlru0_1,nlru2_3,nlru4_5,nlru6_7}),
110 .dout ({ lru0_7, lru0_3, lru4_7, lru0_1, lru2_3, lru4_5, lru6_7}),
111 .l1clk(l1clk),
112 .siclk(siclk),
113 .soclk(soclk)
114);
115
116assign pick_0123 = (|request[3:0]) & ( lru0_7 | ~(|request[7:4]));
117assign pick_4567 = (|request[7:4]) & (~lru0_7 | ~(|request[3:0]));
118assign pick_01 = (|request[1:0]) & ( lru0_3 | ~(|request[3:2]));
119assign pick_23 = (|request[3:2]) & (~lru0_3 | ~(|request[1:0]));
120assign pick_45 = (|request[5:4]) & ( lru4_7 | ~(|request[7:6]));
121assign pick_67 = (|request[7:6]) & (~lru4_7 | ~(|request[5:4]));
122assign pick_0 = request[0] & ( lru0_1 | ~request[1]);
123assign pick_1 = request[1] & (~lru0_1 | ~request[0]);
124assign pick_2 = request[2] & ( lru2_3 | ~request[3]);
125assign pick_3 = request[3] & (~lru2_3 | ~request[2]);
126assign pick_4 = request[4] & ( lru4_5 | ~request[5]);
127assign pick_5 = request[5] & (~lru4_5 | ~request[4]);
128assign pick_6 = request[6] & ( lru6_7 | ~request[7]);
129assign pick_7 = request[7] & (~lru6_7 | ~request[6]);
130
131assign select[0] = pick_0123 & pick_01 & pick_0;
132assign select[1] = pick_0123 & pick_01 & pick_1;
133assign select[2] = pick_0123 & pick_23 & pick_2;
134assign select[3] = pick_0123 & pick_23 & pick_3;
135assign select[4] = pick_4567 & pick_45 & pick_4;
136assign select[5] = pick_4567 & pick_45 & pick_5;
137assign select[6] = pick_4567 & pick_67 & pick_6;
138assign select[7] = pick_4567 & pick_67 & pick_7;
139
140assign nlru0_1 = enable[1] | (~enable[0] & lru0_1);
141assign nlru2_3 = enable[3] | (~enable[2] & lru2_3);
142assign nlru4_5 = enable[5] | (~enable[4] & lru4_5);
143assign nlru6_7 = enable[7] | (~enable[6] & lru6_7);
144assign nlru0_3 = (enable[2] | enable[3]) | (~(enable[0] | enable[1]) & lru0_3);
145assign nlru4_7 = (enable[6] | enable[7]) | (~(enable[4] | enable[5]) & lru4_7);
146assign nlru0_7 = (enable[4] | enable[5] | enable[6] | enable[7]) |
147 (~(enable[0] | enable[1] | enable[2] | enable[3]) &
148 lru0_7);
149
150
151supply0 vss;
152supply1 vdd;
153// fixscan start:
154assign dff_lru_scanin = scan_in ;
155assign scan_out = dff_lru_scanout ;
156// fixscan end:
157endmodule
158
159
160
161
162
163
164// any PARAMS parms go into naming of macro
165
166module lsu_lru8_ctl_msff_ctl_macro__width_7 (
167 din,
168 l1clk,
169 scan_in,
170 siclk,
171 soclk,
172 dout,
173 scan_out);
174wire [6:0] fdin;
175wire [5:0] so;
176
177 input [6:0] din;
178 input l1clk;
179 input scan_in;
180
181
182 input siclk;
183 input soclk;
184
185 output [6:0] dout;
186 output scan_out;
187assign fdin[6:0] = din[6:0];
188
189
190
191
192
193
194dff #(7) d0_0 (
195.l1clk(l1clk),
196.siclk(siclk),
197.soclk(soclk),
198.d(fdin[6:0]),
199.si({scan_in,so[5:0]}),
200.so({so[5:0],scan_out}),
201.q(dout[6:0])
202);
203
204
205
206
207
208
209
210
211
212
213
214
215endmodule
216
217
218
219
220
221
222
223