Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / design / sys / iop / dmu / rtl / dmu_mmu_csr_cim.v
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: dmu_mmu_csr_cim.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_csr_cim
36 (
37 clk, // clock
38 rst_l, // reset
39 cr2mm_dbg_sel_a, // cru debug select a
40 cr2mm_dbg_sel_b, // cru debug select b
41 crb2csr_dbg_a, // crb debug data a
42 crb2csr_dbg_b, // crb debug data b
43 crb2csr_rd, // crb read data
44 ptb2csr_rd, // ptb read data
45 qcb2csr_dbg_a, // qcb debug bus a
46 qcb2csr_dbg_b, // qcb debug bus b
47 qcb2csr_paq, // csr physical address queue not empty
48 qcb2csr_vaq, // csr virtual address queue not empty
49 tcb2csr_dbg_a, // tcb debug bus a
50 tcb2csr_dbg_b, // tcb debug bus b
51 tcb2csr_err, // tcb error
52 tcb2csr_prf, // tcb performance events
53 tcb2csr_tcm, // csr tablewalk cache mode
54 tcb2csr_tip, // csr tablewalk in progress
55 tcb2csr_tpl, // csr translation pipeline not empty
56 tdb2csr_rd, // tdb read data
57 tlb2csr_addr, // tlb address
58 tlb2csr_dbra, // tlb data buffer read address
59 tlb2csr_rqid, // tlb requester ID
60 tlb2csr_type, // tlb type
61 vtb2csr_prf, // vtb performance event
62 vtb2csr_rd, // vtb read data
63 csrbus_acc_vio, // access violation
64 ext_addr, // external address
65 ext_wr, // external write
66 ext_wr_data, // external write data
67 ctl_sparec_hw_read, // spare controls
68 ctl_pd_hw_read, // process disable
69 ctl_se_hw_read, // snoop enable
70 ctl_cm_hw_read, // cache mode
71 ctl_be_hw_read, // bypass enable
72 ctl_te_hw_read, // translation enable
73 tsb_tb_hw_read, // tsb base address
74 tsb_ps_hw_read, // tsb page size
75 tsb_ts_hw_read, // tsb size
76 int_en_hw_read, // event interrupt enable
77 log_en_hw_read, // event log enable
78 err_hw_read, // events
79 prfc_sel1_hw_read, // performance select 1
80 prfc_sel0_hw_read, // performance select 0
81 prf0_cnt_hw_read, // performance count 0
82 prf1_cnt_hw_read, // performance count 1
83 inv_ext_select, // invalidate
84 vtb_ext_select, // vtb select
85 ptb_ext_select, // ptb select
86 tdb_ext_select, // tdb select
87 mm2cr_dbg_a, // cru debug bus a
88 mm2cr_dbg_b, // cru debug bus b
89 mm2im_int, // imu interrupt
90 csr2crb_ds_a, // crb debug select a
91 csr2crb_ds_b, // crb debug select b
92 csr2crb_ra, // crb read address
93 csr2crb_wa, // crb write address
94 csr2crb_wd, // crb write data
95 csr2crb_we, // crb write enable
96 csr2pab_ps, // pab page size
97 csr2ptb_inv, // crb tag invalidate
98 csr2ptb_ra, // ptb read address
99 csr2ptb_wa, // ptb write address
100 csr2ptb_wd, // ptb write data
101 csr2ptb_we, // ptb write enable
102 csr2qcb_ds_a, // qcb debug select a
103 csr2qcb_ds_b, // qcb debug select b
104 csr2rcb_se, // rcb snoop enable
105// csr2rcb_tb, // rcb tsb base address
106// csr2rcb_ts, // rcb tsb size
107 csr2tcb_av, // tcb access violation
108 csr2tcb_be, // tcb bypass enable
109 csr2tcb_cm, // tcb cache mode
110 csr2tcb_ds_a, // tcb debug select a
111 csr2tcb_ds_b, // tcb debug select b
112 csr2tcb_pd, // tcb processing disable
113 csr2tcb_te, // tcb translation enable
114 csr2tdb_ra, // tdb read address
115 csr2tdb_wa, // tdb write address
116 csr2tdb_wd, // tdb write data
117 csr2tdb_we, // tdb write enable
118 csr2tlb_ps, // tlb page size
119 csr2tlb_tb, // tlb table base address
120 csr2tlb_ts, // tlb table size
121 csr2vab_ps, // vab page size
122 csr2vab_ts, // vab table size
123 csr2vtb_ra, // vtb read address
124 csr2vtb_wa, // vtb write address
125 csr2vtb_wd, // vtb write data
126 csr2vtb_we, // vtb write enable
127 ctl_spares_hw_write, // spare status
128 ctl_paq_hw_write, // physical address queue not empty
129 ctl_vaq_hw_write, // virtual address queue not empty
130 ctl_tpl_hw_write, // translation pipeline not empty
131 ctl_tip_hw_write, // tablewalk in progress
132 ctl_tcm_hw_write, // tablewalk cache mode
133 en_err_err_s_ext_read_data, // enabled secondary events
134 en_err_err_p_ext_read_data, // enabled primary events
135 err_hw_set, // error set
136 flta_va_hw_ld, // virtual address load
137 flta_va_hw_write, // virtual address
138 flts_entry_hw_ld, // entry load
139 flts_entry_hw_write, // entry
140 flts_type_hw_ld, // type load
141 flts_type_hw_write, // type
142 flts_id_hw_ld, // requester id load
143 flts_id_hw_write, // requester id
144 prf0_cnt_hw_write, // performance count 0
145 prf1_cnt_hw_write, // performance count 1
146 vtb_hw_acc_jtag_rd, // vtb read access violation
147 vtb_hw_acc_jtag_wr, // vtb write access violation
148 vtb_hw_acc_pio_slow_rd, // vtb read access violation
149 vtb_hw_acc_pio_slow_wr, // vtb write access violation
150 vtb_hw_acc_pio_med_rd, // vtb read access violation
151 vtb_hw_acc_pio_med_wr, // vtb write access violation
152 vtb_hw_acc_pio_fast_rd, // vtb read access violation
153 vtb_hw_acc_pio_fast_wr, // vtb write access violation
154 vtb_ext_read_data, // vtb read data
155 ptb_hw_acc_jtag_rd, // ptb read access violation
156 ptb_hw_acc_jtag_wr, // ptb write access violation
157 ptb_hw_acc_pio_slow_rd, // ptb read access violation
158 ptb_hw_acc_pio_slow_wr, // ptb write access violation
159 ptb_hw_acc_pio_med_rd, // ptb read access violation
160 ptb_hw_acc_pio_med_wr, // ptb write access violation
161 ptb_hw_acc_pio_fast_rd, // ptb read access violation
162 ptb_hw_acc_pio_fast_wr, // ptb write access violation
163 ptb_ext_read_data, // ptb read data
164 tdb_hw_acc_jtag_rd, // tdb read access violation
165 tdb_hw_acc_jtag_wr, // tdb write access violation
166 tdb_hw_acc_pio_slow_rd, // tdb read access violation
167 tdb_hw_acc_pio_slow_wr, // tdb write access violation
168 tdb_hw_acc_pio_med_rd, // tdb read access violation
169 tdb_hw_acc_pio_med_wr, // tdb write access violation
170 tdb_hw_acc_pio_fast_rd, // tdb read access violation
171 tdb_hw_acc_pio_fast_wr, // tdb write access violation
172 tdb_ext_read_data, // tdb read data
173 dev2iotsb_hw_acc_jtag_rd,
174 dev2iotsb_hw_acc_jtag_wr,
175 dev2iotsb_hw_acc_pio_slow_rd,
176 dev2iotsb_hw_acc_pio_slow_wr,
177 dev2iotsb_hw_acc_pio_med_rd,
178 dev2iotsb_hw_acc_pio_med_wr,
179 dev2iotsb_hw_acc_pio_fast_rd,
180 dev2iotsb_hw_acc_pio_fast_wr,
181 dev2iotsb_ext_select,
182 dev_iotsb_ext_read_data,
183 dev_iotsb2csr_rd,
184 csr2dev_iotsb_rwa,
185 csr2dev_iotsb_wd,
186 csr2dev2iotsb_we,
187 csr2dev2iotsb_re,
188 IotsbDesc_hw_acc_jtag_rd,
189 IotsbDesc_hw_acc_jtag_wr,
190 IotsbDesc_hw_acc_pio_slow_rd,
191 IotsbDesc_hw_acc_pio_slow_wr,
192 IotsbDesc_hw_acc_pio_med_rd,
193 IotsbDesc_hw_acc_pio_med_wr,
194 IotsbDesc_hw_acc_pio_fast_rd,
195 IotsbDesc_hw_acc_pio_fast_wr,
196 IotsbDesc_ext_select,
197 csr2IotsbDesc_we,
198 csr2IotsbDesc_re
199
200 );
201
202// ----------------------------------------------------------------------------
203// Ports
204// ----------------------------------------------------------------------------
205 input clk;
206 input rst_l;
207
208 input [`FIRE_DLC_DBG_SEL_BITS] cr2mm_dbg_sel_a;
209 input [`FIRE_DLC_DBG_SEL_BITS] cr2mm_dbg_sel_b;
210 input [`FIRE_DBG_DATA_BITS] crb2csr_dbg_a;
211 input [`FIRE_DBG_DATA_BITS] crb2csr_dbg_b;
212 input [`FIRE_DLC_MMU_VTC_BITS] crb2csr_rd;
213 input [`FIRE_CSR_DATA_BITS] ptb2csr_rd;
214 input [`FIRE_DBG_DATA_BITS] qcb2csr_dbg_a;
215 input [`FIRE_DBG_DATA_BITS] qcb2csr_dbg_b;
216 input qcb2csr_paq;
217 input qcb2csr_vaq;
218 input [`FIRE_DBG_DATA_BITS] tcb2csr_dbg_a;
219 input [`FIRE_DBG_DATA_BITS] tcb2csr_dbg_b;
220 input [`FIRE_DLC_MMU_CSR_ERR_BITS] tcb2csr_err;
221 input [`FIRE_DLC_MMU_TCB_PRF_BITS] tcb2csr_prf;
222 input [`FIRE_DLC_MMU_CSR_CM_BITS] tcb2csr_tcm;
223 input tcb2csr_tip;
224 input tcb2csr_tpl;
225 input [`FIRE_DLC_MMU_TDR_BITS] tdb2csr_rd;
226 input [`FIRE_DLC_MMU_VA_ADDR_BITS] tlb2csr_addr;
227 input [`FIRE_DLC_MMU_TDB_PTR_BITS] tlb2csr_dbra;
228 input [`FIRE_DLC_MMU_VA_RQID_BITS] tlb2csr_rqid;
229 input [`FIRE_DLC_MMU_VA_TYPE_BITS] tlb2csr_type;
230 input vtb2csr_prf;
231 input [`FIRE_DLC_MMU_VTR_BITS] vtb2csr_rd;
232 input csrbus_acc_vio;
233 input [`FIRE_DLC_MMU_TDB_PTR_BITS] ext_addr;
234 input ext_wr;
235 input [`FIRE_CSR_DATA_BITS] ext_wr_data;
236 input [3:0] ctl_sparec_hw_read;
237 input ctl_pd_hw_read;
238 input ctl_se_hw_read;
239 input [`FIRE_DLC_MMU_CSR_CM_BITS] ctl_cm_hw_read;
240 input ctl_be_hw_read;
241 input ctl_te_hw_read;
242 input [`FIRE_DLC_MMU_CSR_TB_BITS] tsb_tb_hw_read;
243 input tsb_ps_hw_read;
244 input [`FIRE_DLC_MMU_CSR_TS_BITS] tsb_ts_hw_read;
245 input [`FIRE_CSR_DATA_BITS] int_en_hw_read;
246 input [`FIRE_DLC_MMU_CSR_ERR_BITS] log_en_hw_read;
247 input [`FIRE_CSR_DATA_BITS] err_hw_read;
248 input [`FIRE_PRF_ADDR_BITS] prfc_sel1_hw_read;
249 input [`FIRE_PRF_ADDR_BITS] prfc_sel0_hw_read;
250 input [`FIRE_PRF_DATA_BITS] prf0_cnt_hw_read;
251 input [`FIRE_PRF_DATA_BITS] prf1_cnt_hw_read;
252 input inv_ext_select;
253 input vtb_ext_select;
254 input ptb_ext_select;
255 input tdb_ext_select;
256
257 output [`FIRE_DBG_DATA_BITS] mm2cr_dbg_a;
258 output [`FIRE_DBG_DATA_BITS] mm2cr_dbg_b;
259 output mm2im_int;
260 output [`FIRE_DLC_MMU_CSR_DS_BITS] csr2crb_ds_a;
261 output [`FIRE_DLC_MMU_CSR_DS_BITS] csr2crb_ds_b;
262 output [`FIRE_DLC_MMU_TAG_PTR_BITS] csr2crb_ra;
263 output [`FIRE_DLC_MMU_TAG_PTR_BITS] csr2crb_wa;
264 output [`FIRE_DLC_MMU_VTC_BITS] csr2crb_wd;
265 output csr2crb_we;
266 output csr2pab_ps;
267 output csr2ptb_inv;
268 output [`FIRE_DLC_MMU_TAG_PTR_BITS] csr2ptb_ra;
269 output [`FIRE_DLC_MMU_TAG_PTR_BITS] csr2ptb_wa;
270 output [`FIRE_CSR_DATA_BITS] csr2ptb_wd;
271 output csr2ptb_we;
272 output [`FIRE_DLC_MMU_CSR_DS_BITS] csr2qcb_ds_a;
273 output [`FIRE_DLC_MMU_CSR_DS_BITS] csr2qcb_ds_b;
274 output csr2rcb_se;
275// output [`FIRE_DLC_MMU_CSR_TB_BITS] csr2rcb_tb;
276// output [`FIRE_DLC_MMU_CSR_TS_BITS] csr2rcb_ts;
277 output csr2tcb_av;
278 output csr2tcb_be;
279 output [`FIRE_DLC_MMU_CSR_CM_BITS] csr2tcb_cm;
280 output [`FIRE_DLC_MMU_CSR_DS_BITS] csr2tcb_ds_a;
281 output [`FIRE_DLC_MMU_CSR_DS_BITS] csr2tcb_ds_b;
282 output csr2tcb_pd;
283 output csr2tcb_te;
284 output [`FIRE_DLC_MMU_TDB_PTR_BITS] csr2tdb_ra;
285 output [`FIRE_DLC_MMU_TDB_PTR_BITS] csr2tdb_wa;
286 output [`FIRE_DLC_MMU_TDR_BITS] csr2tdb_wd;
287 output csr2tdb_we;
288 output csr2tlb_ps;
289 output [`FIRE_DLC_MMU_CSR_TB_BITS] csr2tlb_tb;
290 output [`FIRE_DLC_MMU_CSR_TS_BITS] csr2tlb_ts;
291 output csr2vab_ps;
292 output [`FIRE_DLC_MMU_CSR_TS_BITS] csr2vab_ts;
293 output [`FIRE_DLC_MMU_TAG_PTR_BITS] csr2vtb_ra;
294 output [`FIRE_DLC_MMU_TAG_PTR_BITS] csr2vtb_wa;
295 output [`FIRE_DLC_MMU_VTR_BITS] csr2vtb_wd;
296 output csr2vtb_we;
297 output [3:0] ctl_spares_hw_write;
298 output ctl_paq_hw_write;
299 output ctl_vaq_hw_write;
300 output ctl_tpl_hw_write;
301 output ctl_tip_hw_write;
302 output [`FIRE_DLC_MMU_CSR_CM_BITS] ctl_tcm_hw_write;
303 output [`FIRE_DLC_MMU_CSR_ERR_BITS] en_err_err_s_ext_read_data;
304 output [`FIRE_DLC_MMU_CSR_ERR_BITS] en_err_err_p_ext_read_data;
305 output [`FIRE_CSR_DATA_BITS] err_hw_set;
306 output flta_va_hw_ld;
307 output [`FIRE_DLC_MMU_VA_ADDR_BITS] flta_va_hw_write;
308 output flts_entry_hw_ld;
309 output [`FIRE_DLC_MMU_TDB_PTR_BITS] flts_entry_hw_write;
310 output flts_type_hw_ld;
311 output [`FIRE_DLC_MMU_VA_TYPE_BITS] flts_type_hw_write;
312 output flts_id_hw_ld;
313 output [`FIRE_DLC_MMU_VA_RQID_BITS] flts_id_hw_write;
314 output [`FIRE_PRF_DATA_BITS] prf0_cnt_hw_write;
315 output [`FIRE_PRF_DATA_BITS] prf1_cnt_hw_write;
316 output vtb_hw_acc_jtag_rd;
317 output vtb_hw_acc_jtag_wr;
318 output vtb_hw_acc_pio_slow_rd;
319 output vtb_hw_acc_pio_slow_wr;
320 output vtb_hw_acc_pio_med_rd;
321 output vtb_hw_acc_pio_med_wr;
322 output vtb_hw_acc_pio_fast_rd;
323 output vtb_hw_acc_pio_fast_wr;
324 output [`FIRE_CSR_DATA_BITS] vtb_ext_read_data;
325 output ptb_hw_acc_jtag_rd;
326 output ptb_hw_acc_jtag_wr;
327 output ptb_hw_acc_pio_slow_rd;
328 output ptb_hw_acc_pio_slow_wr;
329 output ptb_hw_acc_pio_med_rd;
330 output ptb_hw_acc_pio_med_wr;
331 output ptb_hw_acc_pio_fast_rd;
332 output ptb_hw_acc_pio_fast_wr;
333 output [`FIRE_CSR_DATA_BITS] ptb_ext_read_data;
334 output tdb_hw_acc_jtag_rd;
335 output tdb_hw_acc_jtag_wr;
336 output tdb_hw_acc_pio_slow_rd;
337 output tdb_hw_acc_pio_slow_wr;
338 output tdb_hw_acc_pio_med_rd;
339 output tdb_hw_acc_pio_med_wr;
340 output tdb_hw_acc_pio_fast_rd;
341 output tdb_hw_acc_pio_fast_wr;
342 output [`FIRE_CSR_DATA_BITS] tdb_ext_read_data;
343 output dev2iotsb_hw_acc_jtag_rd;
344 output dev2iotsb_hw_acc_jtag_wr;
345 output dev2iotsb_hw_acc_pio_slow_rd;
346 output dev2iotsb_hw_acc_pio_slow_wr;
347 output dev2iotsb_hw_acc_pio_med_rd;
348 output dev2iotsb_hw_acc_pio_med_wr;
349 output dev2iotsb_hw_acc_pio_fast_rd;
350 output dev2iotsb_hw_acc_pio_fast_wr;
351 input dev2iotsb_ext_select;
352 output [`FIRE_CSR_DATA_BITS] dev_iotsb_ext_read_data;
353 input [`FIRE_CSR_DATA_BITS] dev_iotsb2csr_rd;
354 output [4:0] csr2dev_iotsb_rwa;
355 output [`FIRE_CSR_DATA_BITS] csr2dev_iotsb_wd;
356 output csr2dev2iotsb_we;
357 output csr2dev2iotsb_re;
358 output IotsbDesc_hw_acc_jtag_rd;
359 output IotsbDesc_hw_acc_jtag_wr;
360 output IotsbDesc_hw_acc_pio_slow_rd;
361 output IotsbDesc_hw_acc_pio_slow_wr;
362 output IotsbDesc_hw_acc_pio_med_rd;
363 output IotsbDesc_hw_acc_pio_med_wr;
364 output IotsbDesc_hw_acc_pio_fast_rd;
365 output IotsbDesc_hw_acc_pio_fast_wr;
366 input IotsbDesc_ext_select;
367 output csr2IotsbDesc_we;
368 output csr2IotsbDesc_re;
369
370// ----------------------------------------------------------------------------
371// Variables
372// ----------------------------------------------------------------------------
373 wire [`FIRE_DLC_MMU_CSR_DS_BITS] csr2crb_ds_a, csr2crb_ds_b;
374 wire [`FIRE_DLC_MMU_TAG_PTR_BITS] csr2crb_ra, csr2crb_wa;
375 wire [`FIRE_DLC_MMU_VTC_BITS] csr2crb_wd;
376 wire [`FIRE_DLC_MMU_TAG_PTR_BITS] csr2ptb_ra, csr2ptb_wa;
377 wire [`FIRE_CSR_DATA_BITS] csr2ptb_wd;
378 wire [`FIRE_DLC_MMU_CSR_DS_BITS] csr2qcb_ds_a, csr2qcb_ds_b;
379// wire [`FIRE_DLC_MMU_CSR_TB_BITS] csr2rcb_tb, csr2tlb_tb;
380 wire [`FIRE_DLC_MMU_CSR_TB_BITS] csr2tlb_tb;
381// wire [`FIRE_DLC_MMU_CSR_TS_BITS] csr2rcb_ts, csr2tlb_ts, csr2vab_ts;
382 wire [`FIRE_DLC_MMU_CSR_TS_BITS] csr2tlb_ts, csr2vab_ts;
383 wire [`FIRE_DLC_MMU_CSR_CM_BITS] csr2tcb_cm;
384 wire [`FIRE_DLC_MMU_CSR_DS_BITS] csr2tcb_ds_a, csr2tcb_ds_b;
385 wire [`FIRE_DLC_MMU_TDB_PTR_BITS] csr2tdb_ra, csr2tdb_wa;
386 wire [`FIRE_DLC_MMU_TDR_BITS] csr2tdb_wd;
387 wire [`FIRE_DLC_MMU_TAG_PTR_BITS] csr2vtb_ra, csr2vtb_wa;
388 wire [`FIRE_DLC_MMU_VTR_BITS] csr2vtb_wd;
389 wire [3:0] ctl_spares_hw_write;
390 wire [`FIRE_DLC_MMU_CSR_CM_BITS] ctl_tcm_hw_write;
391 wire [`FIRE_DLC_MMU_CSR_ERR_BITS] en_err_err_s_ext_read_data;
392 wire [`FIRE_DLC_MMU_CSR_ERR_BITS] en_err_err_p_ext_read_data;
393 wire [`FIRE_CSR_DATA_BITS] err_hw_set, en_err;
394 wire [`FIRE_DLC_MMU_VA_ADDR_BITS] flta_va_hw_write;
395 wire [`FIRE_DLC_MMU_TDB_PTR_BITS] flts_entry_hw_write;
396 wire [`FIRE_DLC_MMU_VA_TYPE_BITS] flts_type_hw_write;
397 wire [`FIRE_DLC_MMU_VA_RQID_BITS] flts_id_hw_write;
398 wire [`FIRE_PRF_DATA_BITS] prf0_cnt_hw_write, prf1_cnt_hw_write;
399 wire [`FIRE_CSR_DATA_BITS] ptb_ext_read_data;
400 wire [`FIRE_CSR_DATA_BITS] tdb_ext_read_data;
401 wire [`FIRE_CSR_DATA_BITS] vtb_ext_read_data;
402 wire [`FIRE_DLC_MMU_CSR_ERR_BITS] err, err_p, err_s;
403 wire [`FIRE_PRF_DATA_BITS] inc_cnt0, inc_cnt1;
404 wire [`FIRE_DBG_DATA_BITS] mm2cr_dbg_a, mm2cr_dbg_b;
405 wire [`FIRE_CSR_DATA_BITS] dev_iotsb_ext_read_data;
406
407 reg [`FIRE_CSR_DATA_BITS] dev_iotsb_rd;
408 reg mm2im_int;
409 reg [`FIRE_DLC_MMU_TDB_PTR_BITS] ext_wa;
410 reg [`FIRE_CSR_DATA_BITS] ext_wd;
411 reg crb_we, ptb_we, tdb_we, vtb_we;
412 reg ptb_inv;
413 reg [`FIRE_DLC_MMU_VTC_BITS] crb_rd;
414 reg [`FIRE_CSR_DATA_BITS] ptb_rd;
415 reg [`FIRE_DLC_MMU_TDR_BITS] tdb_rd;
416 reg [`FIRE_DLC_MMU_VTR_BITS] vtb_rd;
417 reg [3:0] spares;
418
419 reg [`FIRE_PRF_ADDR_BITS] prf_sel [0:1];
420 reg [1:0] prf_inc;
421
422 reg [`FIRE_DBG_DATA_BITS] dbg [0:1];
423 reg [`FIRE_DBG_DATA_BITS] nxt_dbg [0:1];
424 reg dev2iotsb_we;
425 reg dev2iotsb_re;
426 reg IotsbDesc_we;
427 reg IotsbDesc_re;
428
429 integer i;
430
431// ----------------------------------------------------------------------------
432// Combinational
433// ----------------------------------------------------------------------------
434// crb read address, write address, write data, and write enable
435 assign csr2crb_ra = ext_addr[`FIRE_DLC_MMU_TAG_PTR_BITS];
436 assign csr2crb_wa = ext_wa[`FIRE_DLC_MMU_TAG_PTR_BITS];
437 assign csr2crb_wd = ext_wd[`FIRE_DLC_MMU_VTD_CNT_BITS];
438 wire csr2crb_we = crb_we;
439
440// pab page size
441 wire csr2pab_ps = tsb_ps_hw_read;
442
443// dev & iotsb read/write address, write data and write enables
444 assign csr2dev_iotsb_rwa = ext_addr[4:0];
445 assign csr2dev_iotsb_wd = ext_wd;
446 wire csr2dev2iotsb_we = dev2iotsb_we;
447 wire csr2IotsbDesc_we = IotsbDesc_we;
448 wire csr2dev2iotsb_re = dev2iotsb_re;
449 wire csr2IotsbDesc_re = IotsbDesc_re;
450// ptb invalidate
451 wire csr2ptb_inv = ptb_inv;
452
453// ptb read address, write address, write data, and write enable
454 assign csr2ptb_ra = ext_addr[`FIRE_DLC_MMU_TAG_PTR_BITS];
455 assign csr2ptb_wa = ext_wa[`FIRE_DLC_MMU_TAG_PTR_BITS];
456 assign csr2ptb_wd = ext_wd;
457 wire csr2ptb_we = ptb_we;
458
459// rcb snoop enable, tsb base address, and tsb size
460 wire csr2rcb_se = ctl_se_hw_read;
461// assign csr2rcb_tb = tsb_tb_hw_read;
462// assign csr2rcb_ts = tsb_ts_hw_read;
463
464// tcb bypass enable, cache mode, process disable, and translation enable
465 wire csr2tcb_be = ctl_be_hw_read;
466 assign csr2tcb_cm = ctl_cm_hw_read;
467 wire csr2tcb_pd = ctl_pd_hw_read;
468 wire csr2tcb_te = ctl_te_hw_read;
469
470// tcb access violation
471 wire csr2tcb_av = csrbus_acc_vio;
472
473// tdb read address, write address, write data, and write enable
474 assign csr2tdb_ra = ext_addr;
475 assign csr2tdb_wa = ext_wa;
476 wire csr2tdb_we = tdb_we;
477
478 assign csr2tdb_wd[`FIRE_DLC_MMU_TDR_PAR_BITS] = ext_wd[`FIRE_DLC_MMU_TDD_PAR_BITS];
479 assign csr2tdb_wd[`FIRE_DLC_MMU_TDR_PPN_BITS] = ext_wd[`FIRE_DLC_MMU_TDD_PPN_BITS];
480 assign csr2tdb_wd[`FIRE_DLC_MMU_TDR_WRT_BITS] = ext_wd[`FIRE_DLC_MMU_TDD_WRT_BITS];
481 assign csr2tdb_wd[`FIRE_DLC_MMU_TDR_VLD_BITS] = ext_wd[`FIRE_DLC_MMU_TDD_VLD_BITS];
482 assign csr2tdb_wd[`FIRE_DLC_MMU_TDR_KEYVLD_BITS] = ext_wd[`FIRE_DLC_MMU_TDD_KEYVLD_BITS];
483 assign csr2tdb_wd[`FIRE_DLC_MMU_TDR_FNM_BITS] = ext_wd[`FIRE_DLC_MMU_TDD_FNM_BITS];
484 assign csr2tdb_wd[`FIRE_DLC_MMU_TDR_KEY_BITS] = ext_wd[`FIRE_DLC_MMU_TDD_KEY_BITS];
485
486// tlb page size, tsb base address, and tsb size
487 wire csr2tlb_ps = tsb_ps_hw_read;
488 assign csr2tlb_tb = tsb_tb_hw_read;
489 assign csr2tlb_ts = tsb_ts_hw_read;
490
491// vab page size and tsb size
492 wire csr2vab_ps = tsb_ps_hw_read;
493 assign csr2vab_ts = tsb_ts_hw_read;
494
495// vtb read address, write address, write data, and write enable
496 assign csr2vtb_ra = ext_addr[`FIRE_DLC_MMU_TAG_PTR_BITS];
497 assign csr2vtb_wa = ext_wa[`FIRE_DLC_MMU_TAG_PTR_BITS];
498 wire csr2vtb_we = vtb_we;
499
500 assign csr2vtb_wd[`FIRE_DLC_MMU_VTR_VPN_BITS] = ext_wd[`FIRE_DLC_MMU_VTD_VPN_BITS];
501 assign csr2vtb_wd[`FIRE_DLC_MMU_VTR_VLD_BITS] = ext_wd[`FIRE_DLC_MMU_VTD_VLD_BITS];
502 assign csr2vtb_wd[`FIRE_DLC_MMU_VTR_IOTSBNO_BITS] = ext_wd[`FIRE_DLC_MMU_VTD_IOTSBNO_BITS];
503
504// spare status
505 assign ctl_spares_hw_write = spares;
506
507// status
508 wire ctl_paq_hw_write = qcb2csr_paq;
509 wire ctl_vaq_hw_write = qcb2csr_vaq;
510 wire ctl_tpl_hw_write = tcb2csr_tpl;
511 wire ctl_tip_hw_write = tcb2csr_tip;
512 assign ctl_tcm_hw_write = tcb2csr_tcm;
513
514// external read data
515 assign ptb_ext_read_data = ptb_rd;
516 assign dev_iotsb_ext_read_data = dev_iotsb_rd;
517
518 assign tdb_ext_read_data[`FIRE_DLC_MMU_TDD_PAR_BITS] = tdb_rd[`FIRE_DLC_MMU_TDR_PAR_BITS];
519 assign tdb_ext_read_data[`FIRE_DLC_MMU_TDD_PPN_BITS] = tdb_rd[`FIRE_DLC_MMU_TDR_PPN_BITS];
520 assign tdb_ext_read_data[`FIRE_DLC_MMU_TDD_WRT_BITS] = tdb_rd[`FIRE_DLC_MMU_TDR_WRT_BITS];
521 assign tdb_ext_read_data[`FIRE_DLC_MMU_TDD_VLD_BITS] = tdb_rd[`FIRE_DLC_MMU_TDR_VLD_BITS];
522 assign tdb_ext_read_data[`FIRE_DLC_MMU_TDD_KEY_BITS] = tdb_rd[`FIRE_DLC_MMU_TDR_KEY_BITS];
523 assign tdb_ext_read_data[`FIRE_DLC_MMU_TDD_FNM_BITS] = tdb_rd[`FIRE_DLC_MMU_TDR_FNM_BITS];
524 assign tdb_ext_read_data[`FIRE_DLC_MMU_TDD_KEYVLD_BITS] = tdb_rd[`FIRE_DLC_MMU_TDR_KEYVLD_BITS];
525 assign tdb_ext_read_data[`FIRE_DLC_MMU_TDD_RZ1_BITS] = 0;
526 assign tdb_ext_read_data[`FIRE_DLC_MMU_TDD_RZ0_BITS] = 0;
527
528 assign vtb_ext_read_data[`FIRE_DLC_MMU_VTD_CNT_BITS] = crb_rd;
529 assign vtb_ext_read_data[`FIRE_DLC_MMU_VTD_VPN_BITS] = vtb_rd[`FIRE_DLC_MMU_VTR_VPN_BITS];
530 assign vtb_ext_read_data[`FIRE_DLC_MMU_VTD_VLD_BITS] = vtb_rd[`FIRE_DLC_MMU_VTR_VLD_BITS];
531 assign vtb_ext_read_data[`FIRE_DLC_MMU_VTD_IOTSBNO_BITS] = vtb_rd[`FIRE_DLC_MMU_VTR_IOTSBNO_BITS];
532 assign vtb_ext_read_data[`FIRE_DLC_MMU_VTD_RZ1_BITS] = 0;
533 assign vtb_ext_read_data[`FIRE_DLC_MMU_VTD_RZ0_BITS] = 0;
534
535// ----------------------------------------------------------------------------
536// Access
537// ----------------------------------------------------------------------------
538 wire hw_acc = ~|ctl_cm_hw_read;
539
540 wire vtb_hw_acc_jtag_rd = hw_acc;
541 wire vtb_hw_acc_jtag_wr = hw_acc;
542 wire vtb_hw_acc_pio_slow_rd = hw_acc;
543 wire vtb_hw_acc_pio_slow_wr = hw_acc;
544 wire vtb_hw_acc_pio_med_rd = hw_acc;
545 wire vtb_hw_acc_pio_med_wr = hw_acc;
546 wire vtb_hw_acc_pio_fast_rd = hw_acc;
547 wire vtb_hw_acc_pio_fast_wr = hw_acc;
548 wire ptb_hw_acc_jtag_rd = hw_acc;
549 wire ptb_hw_acc_jtag_wr = hw_acc;
550 wire ptb_hw_acc_pio_slow_rd = hw_acc;
551 wire ptb_hw_acc_pio_slow_wr = hw_acc;
552 wire ptb_hw_acc_pio_med_rd = hw_acc;
553 wire ptb_hw_acc_pio_med_wr = hw_acc;
554 wire ptb_hw_acc_pio_fast_rd = hw_acc;
555 wire ptb_hw_acc_pio_fast_wr = hw_acc;
556 wire tdb_hw_acc_jtag_rd = hw_acc;
557 wire tdb_hw_acc_jtag_wr = hw_acc;
558 wire tdb_hw_acc_pio_slow_rd = hw_acc;
559 wire tdb_hw_acc_pio_slow_wr = hw_acc;
560 wire tdb_hw_acc_pio_med_rd = hw_acc;
561 wire tdb_hw_acc_pio_med_wr = hw_acc;
562 wire tdb_hw_acc_pio_fast_rd = hw_acc;
563 wire tdb_hw_acc_pio_fast_wr = hw_acc;
564 wire dev2iotsb_hw_acc_jtag_rd = 1'b1;
565 wire dev2iotsb_hw_acc_jtag_wr = 1'b1;
566 wire dev2iotsb_hw_acc_pio_slow_rd = 1'b1;
567 wire dev2iotsb_hw_acc_pio_slow_wr = 1'b1;
568 wire dev2iotsb_hw_acc_pio_med_rd = 1'b1;
569 wire dev2iotsb_hw_acc_pio_med_wr = 1'b1;
570 wire dev2iotsb_hw_acc_pio_fast_rd = 1'b1;
571 wire dev2iotsb_hw_acc_pio_fast_wr = 1'b1;
572 wire IotsbDesc_hw_acc_jtag_rd = 1'b1;
573 wire IotsbDesc_hw_acc_jtag_wr = 1'b1;
574 wire IotsbDesc_hw_acc_pio_slow_rd = 1'b1;
575 wire IotsbDesc_hw_acc_pio_slow_wr = 1'b1;
576 wire IotsbDesc_hw_acc_pio_med_rd = 1'b1;
577 wire IotsbDesc_hw_acc_pio_med_wr = 1'b1;
578 wire IotsbDesc_hw_acc_pio_fast_rd = 1'b1;
579 wire IotsbDesc_hw_acc_pio_fast_wr = 1'b1;
580
581
582// ----------------------------------------------------------------------------
583// Errors
584// ----------------------------------------------------------------------------
585 wire flt_ld = ~|err_hw_read[`FIRE_DLC_MMU_CSR_ERR_BITS];
586
587 wire flta_va_hw_ld = flt_ld;
588 wire flts_entry_hw_ld = flt_ld;
589 wire flts_type_hw_ld = flt_ld;
590 wire flts_id_hw_ld = flt_ld;
591
592 assign flta_va_hw_write = tlb2csr_addr;
593 assign flts_entry_hw_write = tlb2csr_dbra;
594 assign flts_type_hw_write = tlb2csr_type;
595 assign flts_id_hw_write = tlb2csr_rqid;
596
597 assign err = tcb2csr_err & log_en_hw_read;
598
599 assign err_p = flt_ld ? err : 0;
600 assign err_s = flt_ld ? 0 : err;
601
602 assign err_hw_set[`FIRE_DLC_MMU_SCN_RSV_BITS] = 0;
603 assign err_hw_set[`FIRE_DLC_MMU_SCN_ERR_BITS] = err_s;
604 assign err_hw_set[`FIRE_DLC_MMU_PRM_RSV_BITS] = 0;
605 assign err_hw_set[`FIRE_DLC_MMU_PRM_ERR_BITS] = err_p;
606
607 assign en_err = err_hw_read & int_en_hw_read;
608
609 assign en_err_err_s_ext_read_data = en_err[`FIRE_DLC_MMU_SCN_ERR_BITS];
610 assign en_err_err_p_ext_read_data = en_err[`FIRE_DLC_MMU_PRM_ERR_BITS];
611
612 wire nxt_int = |en_err;
613
614// ----------------------------------------------------------------------------
615// Performance Counters
616// ----------------------------------------------------------------------------
617 assign inc_cnt0 = prf0_cnt_hw_read + 1;
618 assign inc_cnt1 = prf1_cnt_hw_read + 1;
619
620 always @ (prfc_sel0_hw_read or prfc_sel1_hw_read) begin
621 prf_sel[0] = prfc_sel0_hw_read;
622 prf_sel[1] = prfc_sel1_hw_read;
623 end
624
625 always @ (prf_sel[0] or prf_sel[1] or tcb2csr_prf or vtb2csr_prf) begin
626 for (i = 0; i < 2; i = i + 1) begin
627 case (prf_sel[i]) // synopsys infer_mux
628 8'h00 : prf_inc[i] = 1'b0;
629 8'h01 : prf_inc[i] = 1'b1;
630 8'h02 : prf_inc[i] = tcb2csr_prf[0];
631 8'h03 : prf_inc[i] = tcb2csr_prf[1];
632 8'h04 : prf_inc[i] = tcb2csr_prf[2];
633 8'h05 : prf_inc[i] = tcb2csr_prf[3];
634 8'h06 : prf_inc[i] = tcb2csr_prf[4];
635 8'h07 : prf_inc[i] = tcb2csr_prf[5];
636 8'h08 : prf_inc[i] = tcb2csr_prf[6];
637 8'h09 : prf_inc[i] = vtb2csr_prf;
638 default : prf_inc[i] = 1'b0;
639 endcase
640 end
641 end
642
643 assign prf0_cnt_hw_write = prf_inc[0] ? inc_cnt0 : prf0_cnt_hw_read;
644 assign prf1_cnt_hw_write = prf_inc[1] ? inc_cnt1 : prf1_cnt_hw_read;
645
646// ----------------------------------------------------------------------------
647// Debug Ports
648// ----------------------------------------------------------------------------
649 assign csr2crb_ds_a = cr2mm_dbg_sel_a[`FIRE_DLC_MMU_CSR_DS_BITS];
650 assign csr2crb_ds_b = cr2mm_dbg_sel_b[`FIRE_DLC_MMU_CSR_DS_BITS];
651 assign csr2qcb_ds_a = cr2mm_dbg_sel_a[`FIRE_DLC_MMU_CSR_DS_BITS];
652 assign csr2qcb_ds_b = cr2mm_dbg_sel_b[`FIRE_DLC_MMU_CSR_DS_BITS];
653 assign csr2tcb_ds_a = cr2mm_dbg_sel_a[`FIRE_DLC_MMU_CSR_DS_BITS];
654 assign csr2tcb_ds_b = cr2mm_dbg_sel_b[`FIRE_DLC_MMU_CSR_DS_BITS];
655
656 always @ (cr2mm_dbg_sel_a or
657 crb2csr_dbg_a or qcb2csr_dbg_a or tcb2csr_dbg_a ) begin
658 case (cr2mm_dbg_sel_a[5:3]) // synopsys infer_mux
659 3'b000: nxt_dbg[0] = qcb2csr_dbg_a;
660 3'b001: nxt_dbg[0] = tcb2csr_dbg_a;
661 3'b010: nxt_dbg[0] = crb2csr_dbg_a;
662 3'b011: nxt_dbg[0] = 8'h00;
663 3'b100: nxt_dbg[0] = 8'h00;
664 3'b101: nxt_dbg[0] = 8'h00;
665 3'b110: nxt_dbg[0] = 8'h00;
666 3'b111: nxt_dbg[0] = 8'h00;
667 endcase
668 end
669
670 always @ (cr2mm_dbg_sel_b or
671 crb2csr_dbg_b or qcb2csr_dbg_b or tcb2csr_dbg_b ) begin
672 case (cr2mm_dbg_sel_b[5:3]) // synopsys infer_mux
673 3'b000: nxt_dbg[1] = qcb2csr_dbg_b;
674 3'b001: nxt_dbg[1] = tcb2csr_dbg_b;
675 3'b010: nxt_dbg[1] = crb2csr_dbg_b;
676 3'b011: nxt_dbg[1] = 8'h00;
677 3'b100: nxt_dbg[1] = 8'h00;
678 3'b101: nxt_dbg[1] = 8'h00;
679 3'b110: nxt_dbg[1] = 8'h00;
680 3'b111: nxt_dbg[1] = 8'h00;
681 endcase
682 end
683
684 assign mm2cr_dbg_a = dbg[0];
685 assign mm2cr_dbg_b = dbg[1];
686
687// ----------------------------------------------------------------------------
688// Sequential
689// ----------------------------------------------------------------------------
690 always @ (posedge clk) begin
691 if (!rst_l) begin
692 ext_wa <= {`FIRE_DLC_MMU_TDB_PTR_SIZE{1'b0}};
693 ext_wd <= 64'b0;
694 crb_we <= 1'b0;
695 ptb_we <= 1'b0;
696 tdb_we <= 1'b0;
697 vtb_we <= 1'b0;
698 ptb_inv <= 1'b0;
699 dev2iotsb_we <= 1'b0;
700 IotsbDesc_we <= 1'b0;
701 dev2iotsb_re <= 1'b0;
702 IotsbDesc_re <= 1'b0;
703 end
704 else begin
705 ext_wa <= ext_addr;
706 ext_wd <= ext_wr_data;
707 crb_we <= ext_wr & vtb_ext_select;
708 ptb_we <= ext_wr & ptb_ext_select;
709 tdb_we <= ext_wr & tdb_ext_select;
710 vtb_we <= ext_wr & vtb_ext_select;
711 ptb_inv <= ext_wr & inv_ext_select;
712 dev2iotsb_we <= ext_wr & dev2iotsb_ext_select;
713 IotsbDesc_we <= ext_wr & IotsbDesc_ext_select;
714 dev2iotsb_re <= ~ext_wr & dev2iotsb_ext_select;
715 IotsbDesc_re <= ~ext_wr & IotsbDesc_ext_select;
716 end
717end
718
719 always @ (posedge clk) begin
720 if (!rst_l) begin
721 crb_rd <= {`FIRE_DLC_MMU_VTC_WDTH{1'b0}};
722 ptb_rd <= 64'b0;
723 tdb_rd <= {`FIRE_DLC_MMU_TDR_WDTH{1'b0}};
724 vtb_rd <= {`FIRE_DLC_MMU_VTR_WDTH{1'b0}};
725 spares <= 4'b0;
726 dev_iotsb_rd <= 64'b0;
727 end
728 else begin
729 crb_rd <= crb2csr_rd;
730 ptb_rd <= ptb2csr_rd;
731 tdb_rd <= tdb2csr_rd;
732 vtb_rd <= vtb2csr_rd;
733 spares <= ctl_sparec_hw_read;
734 dev_iotsb_rd <= dev_iotsb2csr_rd;
735 end
736end
737
738 always @ (posedge clk) begin
739 if (!rst_l) begin
740 mm2im_int <= 0;
741 end
742 else begin
743 mm2im_int <= nxt_int;
744 end
745 end
746
747 always @ (posedge clk) begin
748 if (!rst_l) begin
749 for (i = 0; i < 2; i = i + 1) begin
750 dbg[i] <= 8'b0;
751 end
752 end
753 else begin
754 for (i = 0; i < 2; i = i + 1) begin
755 dbg[i] <= nxt_dbg[i];
756 end
757 end
758 end
759
760endmodule // dmu_mmu_csr_cim