Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / dmu / rtl / dmu_mmu_ptb.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: dmu_mmu_ptb.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 dmu_mmu_ptb
36 (
37 l2clk, // clock for rams
38 clk, // clock
39 rst_l, // reset
40 scan_in,
41 tcu_array_bypass,
42 tcu_se_scancollar_in,
43 tcu_scan_en,
44 tcu_array_wr_inhibit,
45 tcu_pce_ov,
46 tcu_aclk,
47 tcu_bclk,
48 scan_out,
49
50 csr2ptb_inv, // rcb snoop address
51 csr2ptb_ra, // rcb snoop valid
52 csr2ptb_wa, // tlb physical tag address
53 csr2ptb_wd, // csr tag invalidate
54 csr2ptb_we, // csr read address
55 rcb2ptb_addr, // csr write address
56 rcb2ptb_vld, // csr write data
57 tcb2ptb_sel, // csr write enable
58 tcb2ptb_vld, // tcb select
59 tcb2ptb_wa, // tcb valid
60 tcb2ptb_we, // tcb write address
61 tlb2ptb_addr, // tcb write enable
62 ptb2csr_rd, // csr read data
63 ptb2tcb_hit, // tcb physical tag hit
64 ptb2vtb_inv, // vtb tag invalidate
65
66 dmu_cb0_run,
67 dmu_cb0_addr,
68 dmu_cb0_wdata_key,
69 dmu_cb0_mmu_ptb_wr_en,
70 dmu_cb0_mmu_ptb_rd_en,
71 dmu_cb0_mmu_ptb_lkup_en,
72 mmu_ptb_hit
73 );
74
75// ----------------------------------------------------------------------------
76// Ports
77// ----------------------------------------------------------------------------
78 input l2clk;
79 input clk;
80 input rst_l;
81 input scan_in;
82 input tcu_array_bypass;
83 input tcu_se_scancollar_in;
84 input tcu_scan_en;
85 input tcu_array_wr_inhibit;
86 input tcu_pce_ov;
87 input tcu_aclk;
88 input tcu_bclk;
89 output scan_out;
90
91 input [`FIRE_DLC_MMU_PTD_TAG_BITS] rcb2ptb_addr;
92 input rcb2ptb_vld;
93 input [`FIRE_DLC_MMU_PTD_TAG_BITS] tlb2ptb_addr;
94 input csr2ptb_inv;
95 input [`FIRE_DLC_MMU_TAG_PTR_BITS] csr2ptb_ra;
96 input [`FIRE_DLC_MMU_TAG_PTR_BITS] csr2ptb_wa;
97 input [`FIRE_CSR_DATA_BITS] csr2ptb_wd;
98 input csr2ptb_we;
99 input tcb2ptb_sel;
100 input tcb2ptb_vld;
101 input [`FIRE_DLC_MMU_TAG_PTR_BITS] tcb2ptb_wa;
102 input tcb2ptb_we;
103
104 input dmu_cb0_run;
105 input [5:0] dmu_cb0_addr;
106 input [32:0] dmu_cb0_wdata_key;
107 input dmu_cb0_mmu_ptb_wr_en;
108 input dmu_cb0_mmu_ptb_rd_en;
109 input dmu_cb0_mmu_ptb_lkup_en;
110 output [63:0] mmu_ptb_hit;
111
112 output [`FIRE_CSR_DATA_BITS] ptb2csr_rd;
113 output ptb2tcb_hit;
114 output [`FIRE_DLC_MMU_TAG_BITS] ptb2vtb_inv;
115
116// ----------------------------------------------------------------------------
117// Variables
118// ----------------------------------------------------------------------------
119 wire [`FIRE_CSR_DATA_BITS] ptb2csr_rd;
120 wire [`FIRE_DLC_MMU_TAG_BITS] ptb2vtb_inv, tag_inv, nxt_inv;
121 wire [`FIRE_DLC_MMU_TAG_BITS] hit_vld, nxt_vld, clr_vld;
122 wire [`FIRE_DLC_MMU_PTD_TAG_BITS] new_tag;
123 wire [`FIRE_DLC_MMU_TAG_PTR_BITS] new_wa;
124
125// reg [`FIRE_DLC_MMU_PTD_TAG_BITS] tag [`FIRE_DLC_MMU_TAG_MEM_BITS];
126 reg [`FIRE_DLC_MMU_TAG_BITS] vld, set_vld, clr_vct;
127// reg [`FIRE_DLC_MMU_TAG_BITS] tag_ld, csr_inv;
128 reg [`FIRE_DLC_MMU_TAG_BITS] csr_inv;
129 wire [`FIRE_DLC_MMU_TAG_BITS] hit_inv;
130 wire [`FIRE_DLC_MMU_TAG_BITS] hit_out;
131// integer i;
132
133// ----------------------------------------------------------------------------
134// Zero In Checkers
135// ----------------------------------------------------------------------------
136
137 // 0in bits_on -var {csr2ptb_we, tcb2ptb_we} -max 1
138 // 0in bits_on -var hit_inv -max 1
139 // 0in decoder -in new_wa -out set_vld -active set_bit
140 // 0in decoder -in new_wa -out clr_vct -active clr_bit
141//** // 0in decoder -in new_wa -out tag_ld -active new_we
142
143// ----------------------------------------------------------------------------
144// Combinational
145// ----------------------------------------------------------------------------
146
147// csr read data
148 assign ptb2csr_rd[`FIRE_DLC_MMU_PTD_RZ1_BITS] = 0;
149 assign ptb2csr_rd[`FIRE_DLC_MMU_PTD_RZ0_BITS] = 0;
150// assign ptb2csr_rd[`FIRE_DLC_MMU_PTD_TAG_BITS] = tag[csr2ptb_ra];
151// assign ptb2csr_rd[42:39] = 4'b0;
152 assign ptb2csr_rd[`FIRE_DLC_MMU_PTD_VLD_BITS] = vld[csr2ptb_ra];
153
154// invalidate vector
155 assign tag_inv = hit_inv | csr_inv;
156
157// tcb hit is the physical address tlb tag hit
158 wire tlb_hit = rcb2ptb_vld & (rcb2ptb_addr == tlb2ptb_addr);
159
160 wire ptb2tcb_hit = csr2ptb_inv | tlb_hit;
161
162// vtb cache tag invalidate
163 assign ptb2vtb_inv = tag_inv;
164
165// new tag address, write address, and write enable
166 assign new_tag = tcb2ptb_sel ? tlb2ptb_addr : csr2ptb_wd[`FIRE_DLC_MMU_PTD_TAG_BITS];
167 assign new_wa = tcb2ptb_sel ? tcb2ptb_wa : csr2ptb_wa;
168
169 wire new_we = tcb2ptb_we | csr2ptb_we;
170
171// csr valid set and clear
172 wire csr_set = csr2ptb_we & csr2ptb_wd[0];
173 wire csr_clr = csr2ptb_we & ~csr2ptb_wd[0];
174
175// tcb valid set and clear
176 wire tcb_set = tcb2ptb_we & tcb2ptb_vld;
177 wire tcb_clr = tcb2ptb_we & ~tcb2ptb_vld;
178
179// valid bit set and clear
180 wire set_bit = tcb_set | csr_set;
181 wire clr_bit = tcb_clr | csr_clr;
182
183// valid bit set for the valid bit vector
184 always @ (new_wa or set_bit) begin
185 set_vld = 0;
186 set_vld[new_wa] = set_bit;
187 end
188
189// valid bit clear for the valid bit vector
190 always @ (new_wa or clr_bit) begin
191 clr_vct = 0;
192 clr_vct[new_wa] = clr_bit;
193 end
194
195 assign clr_vld = clr_vct | tag_inv;
196
197// next valid bit vector
198 assign nxt_vld = (vld & ~clr_vld) | set_vld;
199
200// tag load
201// always @ (new_we or new_wa or rst_l) begin
202// tag_ld = { `FIRE_DLC_MMU_TAG_SIZE { ~rst_l } };
203// tag_ld[new_wa] = new_we | ~rst_l;
204// end
205
206// tag request vector
207 assign hit_vld = rcb2ptb_vld ? vld & ~tag_inv : 0;
208
209// csr invalidate
210 assign nxt_inv = csr2ptb_inv ? csr2ptb_wd[`FIRE_DLC_MMU_TAG_BITS] : 0;
211
212// ----------------------------------------------------------------------------
213// Sequential
214// ----------------------------------------------------------------------------
215 always @ (posedge clk) begin
216 if (!rst_l) begin
217 vld <= 0;
218 csr_inv <= 0;
219 end
220 else begin
221 vld <= nxt_vld;
222 csr_inv <= nxt_inv;
223 end
224 end
225/*
226// always @ (posedge clk) begin
227// for (i = 0; i < `FIRE_DLC_MMU_TAG_SIZE; i = i + 1) begin
228// hit_inv[i] <= hit_vld[i] & (rcb2ptb_addr == tag[i]);
229// if (tag_ld[i]) tag[i] <= new_tag;
230// end
231// end
232*/
233//BP 9-23-04 add scan bypass mux
234// note new_tag comes from flops in
235wire [32:0] ptb_out;
236assign ptb2csr_rd[38:6] = tcu_array_bypass ? tlb2ptb_addr[`FIRE_DLC_MMU_PTD_TAG_BITS] : ptb_out[32:0];
237
238//SV 02/24/05 added BIST logic
239 wire [32:0] din_cam, key_cam ;
240 wire [5:0] rd_addr_cam, wr_addr_cam ;
241 wire wr_en_cam, rd_en_cam, lkup_en_cam ;
242
243 assign mmu_ptb_hit = hit_out ;
244 assign din_cam = dmu_cb0_run ? dmu_cb0_wdata_key : new_tag[38:6] ;
245 assign rd_addr_cam = dmu_cb0_run ? dmu_cb0_addr : csr2ptb_ra ;
246 assign wr_addr_cam = dmu_cb0_run ? dmu_cb0_addr : new_wa ;
247 assign wr_en_cam = dmu_cb0_run ? dmu_cb0_mmu_ptb_wr_en : new_we ;
248 assign rd_en_cam = dmu_cb0_run ? dmu_cb0_mmu_ptb_rd_en : 1'b1 ;
249 assign key_cam = dmu_cb0_run ? dmu_cb0_wdata_key : rcb2ptb_addr[38:6] ;
250 assign lkup_en_cam = dmu_cb0_run ? dmu_cb0_mmu_ptb_lkup_en : 1'b1 ;
251
252
253/* 0in memory_access -read_addr rd_addr_cam -read (rd_en_cam & ~wr_en_cam)
254 -write_addr wr_addr_cam -write wr_en_cam
255 -latency 1
256 -write_data din_cam -read_data ptb_out[32:0]
257 -group mbist_mode
258*/
259
260 n2_mmu_cm_64x34s_cust ptb_cam
261 (
262 // address ports
263 .rd_addr (rd_addr_cam),
264 .wr_addr (wr_addr_cam),
265
266 // clock ports
267 .clk (l2clk),
268
269 // data input ports
270 .din (din_cam),
271
272 // data output ports
273// .dout (ptb2csr_rd[38:6]),
274 .dout (ptb_out[32:0]),
275
276 // port enables
277 .wr_en (wr_en_cam),
278 .rd_en (rd_en_cam),
279
280 // key--address to CAM against
281 .key (key_cam),
282
283 // key--address to CAM against
284 .lkup_en (lkup_en_cam),
285
286 // hold key
287 .hld (1'b0),
288
289 // 64 hit values after CAM'ing
290 .hit (hit_out),
291
292
293 // scan ports
294 .scan_in (scan_in),
295 .tcu_se_scancollar_in (tcu_se_scancollar_in),
296 .tcu_scan_en (tcu_scan_en),
297 .tcu_array_wr_inhibit (tcu_array_wr_inhibit),
298 .tcu_pce_ov (tcu_pce_ov),
299 .pce (1'b1),
300 .tcu_aclk (tcu_aclk),
301 .tcu_bclk (tcu_bclk),
302 .scan_out (scan_out)
303 );
304
305reg [63:0] hit_vld_d;
306 always @ (posedge clk)
307 if(~rst_l) begin
308 hit_vld_d <= {64{1'b0}};
309 end
310 else begin
311 hit_vld_d <= hit_vld;
312 end
313
314assign hit_inv = hit_vld_d & hit_out;
315
316endmodule // dmu_mmu_ptb