blob: 0d7fec3ba410c437f668721f012e3186d9def558 [file] [log] [blame]
Timothy Chenff4a7702020-10-27 15:08:53 -07001// Copyright lowRISC contributors.
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4//
5// Flash Controller Module
6//
7//
8
9`include "prim_assert.sv"
10
Rupert Swarbrick21d6e5b2021-03-18 09:07:35 +000011module flash_ctrl
12 import flash_ctrl_pkg::*;
13 import flash_ctrl_reg_pkg::*;
14#(
15 parameter logic [NumAlerts-1:0] AlertAsyncOn = {NumAlerts{1'b1}},
16 parameter flash_key_t RndCnstAddrKey = RndCnstAddrKeyDefault,
17 parameter flash_key_t RndCnstDataKey = RndCnstDataKeyDefault,
18 parameter lfsr_seed_t RndCnstLfsrSeed = RndCnstLfsrSeedDefault,
19 parameter lfsr_perm_t RndCnstLfsrPerm = RndCnstLfsrPermDefault
Timothy Chenf52a4612020-12-04 20:37:49 -080020) (
Timothy Chenff4a7702020-10-27 15:08:53 -070021 input clk_i,
22 input rst_ni,
23
Timothy Chenf52a4612020-12-04 20:37:49 -080024 input clk_otp_i,
25 input rst_otp_ni,
26
Timothy Chen8ea1b412020-11-18 18:32:08 -080027 // life cycle interface
Timothy Chen99f3e3a2020-12-09 18:30:19 -080028 input lc_ctrl_pkg::lc_tx_t lc_creator_seed_sw_rw_en_i,
29 input lc_ctrl_pkg::lc_tx_t lc_owner_seed_sw_rw_en_i,
30 input lc_ctrl_pkg::lc_tx_t lc_iso_part_sw_rd_en_i,
31 input lc_ctrl_pkg::lc_tx_t lc_iso_part_sw_wr_en_i,
32 input lc_ctrl_pkg::lc_tx_t lc_seed_hw_rd_en_i,
Timothy Chen8ea1b412020-11-18 18:32:08 -080033
Timothy Chenff4a7702020-10-27 15:08:53 -070034 // Bus Interface
Timothy Chen8adb20d2021-03-25 16:49:04 -070035 input tlul_pkg::tl_h2d_t core_tl_i,
36 output tlul_pkg::tl_d2h_t core_tl_o,
37 input tlul_pkg::tl_h2d_t prim_tl_i,
38 output tlul_pkg::tl_d2h_t prim_tl_o,
Timothy Chenff4a7702020-10-27 15:08:53 -070039
40 // Flash Interface
41 input flash_rsp_t flash_i,
42 output flash_req_t flash_o,
43
44 // otp/lc/pwrmgr/keymgr Interface
Timothy Chenf52a4612020-12-04 20:37:49 -080045 output otp_ctrl_pkg::flash_otp_key_req_t otp_o,
46 input otp_ctrl_pkg::flash_otp_key_rsp_t otp_i,
Timothy Chend39402a2020-12-15 20:34:09 -080047 input lc_ctrl_pkg::lc_tx_t rma_req_i,
48 input lc_ctrl_pkg::lc_flash_rma_seed_t rma_seed_i,
49 output lc_ctrl_pkg::lc_tx_t rma_ack_o,
Timothy Chenff4a7702020-10-27 15:08:53 -070050 input pwrmgr_pkg::pwr_flash_req_t pwrmgr_i,
51 output pwrmgr_pkg::pwr_flash_rsp_t pwrmgr_o,
Timothy Chenff4a7702020-10-27 15:08:53 -070052 output keymgr_flash_t keymgr_o,
53
Timothy Chend8fded82021-02-22 11:32:55 -080054 // IOs
55 input cio_tck_i,
56 input cio_tms_i,
57 input cio_tdi_i,
58 output logic cio_tdo_en_o,
59 output logic cio_tdo_o,
60
Timothy Chenff4a7702020-10-27 15:08:53 -070061 // Interrupts
62 output logic intr_prog_empty_o, // Program fifo is empty
63 output logic intr_prog_lvl_o, // Program fifo is empty
64 output logic intr_rd_full_o, // Read fifo is full
65 output logic intr_rd_lvl_o, // Read fifo is full
66 output logic intr_op_done_o, // Requested flash operation (wr/erase) done
Timothy Chen16741102021-01-15 17:32:13 -080067
68 // Alerts
69 input prim_alert_pkg::alert_rx_t [flash_ctrl_reg_pkg::NumAlerts-1:0] alert_rx_i,
70 output prim_alert_pkg::alert_tx_t [flash_ctrl_reg_pkg::NumAlerts-1:0] alert_tx_o
71
72
Timothy Chenff4a7702020-10-27 15:08:53 -070073);
74
75 import flash_ctrl_reg_pkg::*;
76
Timothy Chen8adb20d2021-03-25 16:49:04 -070077 flash_ctrl_core_reg2hw_t reg2hw;
78 flash_ctrl_core_hw2reg_t hw2reg;
Timothy Chenff4a7702020-10-27 15:08:53 -070079
Timothy Chen8adb20d2021-03-25 16:49:04 -070080 tlul_pkg::tl_h2d_t tl_win_h2d [2];
81 tlul_pkg::tl_d2h_t tl_win_d2h [2];
Timothy Chenff4a7702020-10-27 15:08:53 -070082
Timothy Chen8adb20d2021-03-25 16:49:04 -070083 assign prim_tl_o = flash_i.tl_flash_p2c;
Timothy Chenff4a7702020-10-27 15:08:53 -070084 // Register module
Timothy Chen8adb20d2021-03-25 16:49:04 -070085 flash_ctrl_core_reg_top u_reg_core (
Timothy Chenff4a7702020-10-27 15:08:53 -070086 .clk_i,
87 .rst_ni,
88
Timothy Chen8adb20d2021-03-25 16:49:04 -070089 .tl_i(core_tl_i),
90 .tl_o(core_tl_o),
Timothy Chenff4a7702020-10-27 15:08:53 -070091
Timothy Chen6e495182020-12-28 16:16:35 -080092 .tl_win_o (tl_win_h2d),
93 .tl_win_i (tl_win_d2h),
Timothy Chenff4a7702020-10-27 15:08:53 -070094
95 .reg2hw,
96 .hw2reg,
97
Timothy Chen8ec347f2021-03-02 11:52:17 -080098 .intg_err_o (),
Timothy Chenff4a7702020-10-27 15:08:53 -070099 .devmode_i (1'b1)
100 );
101
102 // FIFO Connections
103 logic prog_fifo_wvalid;
104 logic prog_fifo_wready;
105 logic prog_fifo_rvalid;
106 logic prog_fifo_ren;
107 logic [BusWidth-1:0] prog_fifo_wdata;
108 logic [BusWidth-1:0] prog_fifo_rdata;
109 logic [FifoDepthW-1:0] prog_fifo_depth;
110 logic rd_fifo_wready;
111 logic rd_fifo_rvalid;
112 logic rd_fifo_rready;
113 logic rd_fifo_wen;
114 logic rd_fifo_ren;
115 logic [BusWidth-1:0] rd_fifo_wdata;
116 logic [BusWidth-1:0] rd_fifo_rdata;
117 logic [FifoDepthW-1:0] rd_fifo_depth;
Timothy Chen71d98f82020-12-17 17:17:25 -0800118 logic rd_fifo_full;
Timothy Chenff4a7702020-10-27 15:08:53 -0700119
120 // Program Control Connections
121 logic prog_flash_req;
122 logic prog_flash_ovfl;
123 logic [BusAddrW-1:0] prog_flash_addr;
124 logic prog_op_valid;
125
126 // Read Control Connections
127 logic rd_flash_req;
128 logic rd_flash_ovfl;
129 logic [BusAddrW-1:0] rd_flash_addr;
130
131 // Erase Control Connections
132 logic erase_flash_req;
133 logic [BusAddrW-1:0] erase_flash_addr;
134 flash_erase_e erase_flash_type;
135
136 // Done / Error signaling from ctrl modules
137 logic prog_done, rd_done, erase_done;
138 logic prog_err, rd_err, erase_err;
139
Timothy Chend5323562020-12-02 16:10:44 -0800140 // Flash Memory Properties Connections
Timothy Chenff4a7702020-10-27 15:08:53 -0700141 logic [BusAddrW-1:0] flash_addr;
142 logic flash_req;
143 logic flash_rd_done, flash_prog_done, flash_erase_done;
144 logic flash_mp_error;
145 logic [BusWidth-1:0] flash_prog_data;
146 logic flash_prog_last;
147 flash_prog_e flash_prog_type;
148 logic [BusWidth-1:0] flash_rd_data;
149 logic flash_rd_err;
150 logic flash_phy_busy;
151 logic rd_op;
152 logic prog_op;
153 logic erase_op;
154 logic [AllPagesW-1:0] err_addr;
155 flash_lcmgr_phase_e phase;
156
157 // Flash control arbitration connections to hardware interface
Timothy Chenf52a4612020-12-04 20:37:49 -0800158 flash_key_t addr_key;
159 flash_key_t data_key;
Timothy Chenff4a7702020-10-27 15:08:53 -0700160 flash_ctrl_reg2hw_control_reg_t hw_ctrl;
161 logic hw_req;
162 logic [top_pkg::TL_AW-1:0] hw_addr;
163 logic hw_done;
164 logic hw_err;
165 logic hw_rvalid;
166 logic hw_rready;
Timothy Chend39402a2020-12-15 20:34:09 -0800167 logic hw_wvalid;
168 logic [BusWidth-1:0] hw_wdata;
169 logic hw_wready;
Timothy Chenff4a7702020-10-27 15:08:53 -0700170 flash_sel_e if_sel;
171 logic sw_sel;
172 flash_lcmgr_phase_e hw_phase;
173 logic creator_seed_priv;
174 logic owner_seed_priv;
175
176 // Flash control arbitration connections to software interface
177 logic sw_ctrl_done;
178 logic sw_ctrl_err;
179
180 // Flash control muxed connections
181 flash_ctrl_reg2hw_control_reg_t muxed_ctrl;
182 logic [top_pkg::TL_AW-1:0] muxed_addr;
183 logic op_start;
184 logic [11:0] op_num_words;
185 logic [BusAddrW-1:0] op_addr;
186 flash_op_e op_type;
187 flash_part_e op_part;
188 logic [InfoTypesWidth-1:0] op_info_sel;
189 flash_erase_e op_erase_type;
190 flash_prog_e op_prog_type;
191
192 logic ctrl_init_busy;
193 logic fifo_clr;
194
195 // software tlul to flash control aribration
196 logic sw_rvalid;
197 logic adapter_rvalid;
198 logic sw_wvalid;
Timothy Chend39402a2020-12-15 20:34:09 -0800199 logic [BusWidth-1:0] sw_wdata;
Timothy Chenff4a7702020-10-27 15:08:53 -0700200 logic sw_wen;
201 logic sw_wready;
202
203 // lfsr for local entropy usage
204 logic [31:0] rand_val;
205 logic lfsr_en;
Timothy Chend39402a2020-12-15 20:34:09 -0800206 logic lfsr_seed_en;
Timothy Chenff4a7702020-10-27 15:08:53 -0700207
Timothy Chen8ea1b412020-11-18 18:32:08 -0800208 // life cycle connections
Cindy Chen39b14342021-01-29 16:25:24 -0800209 lc_ctrl_pkg::lc_tx_t [0:0] lc_creator_seed_sw_rw_en;
210 lc_ctrl_pkg::lc_tx_t [0:0] lc_owner_seed_sw_rw_en;
211 lc_ctrl_pkg::lc_tx_t [0:0] lc_iso_part_sw_rd_en;
212 lc_ctrl_pkg::lc_tx_t [0:0] lc_iso_part_sw_wr_en;
213 lc_ctrl_pkg::lc_tx_t [0:0] lc_seed_hw_rd_en;
Timothy Chen8ea1b412020-11-18 18:32:08 -0800214
Timothy Chen99f3e3a2020-12-09 18:30:19 -0800215 // synchronize enables into local domain
Timothy Chen8d923152020-12-02 18:01:28 -0800216 prim_lc_sync #(
217 .NumCopies(1)
Timothy Chen99f3e3a2020-12-09 18:30:19 -0800218 ) u_lc_creator_seed_sw_rw_en_sync (
Timothy Chen8d923152020-12-02 18:01:28 -0800219 .clk_i,
220 .rst_ni,
Timothy Chen99f3e3a2020-12-09 18:30:19 -0800221 .lc_en_i(lc_creator_seed_sw_rw_en_i),
222 .lc_en_o(lc_creator_seed_sw_rw_en)
Timothy Chen8d923152020-12-02 18:01:28 -0800223 );
224
Timothy Chen99f3e3a2020-12-09 18:30:19 -0800225 prim_lc_sync #(
226 .NumCopies(1)
227 ) u_lc_owner_seed_sw_rw_en_sync (
228 .clk_i,
229 .rst_ni,
230 .lc_en_i(lc_owner_seed_sw_rw_en_i),
231 .lc_en_o(lc_owner_seed_sw_rw_en)
232 );
233
234 prim_lc_sync #(
235 .NumCopies(1)
236 ) u_lc_iso_part_sw_rd_en_sync (
237 .clk_i,
238 .rst_ni,
239 .lc_en_i(lc_iso_part_sw_rd_en_i),
240 .lc_en_o(lc_iso_part_sw_rd_en)
241 );
242
243 prim_lc_sync #(
244 .NumCopies(1)
245 ) u_lc_iso_part_sw_wr_en_sync (
246 .clk_i,
247 .rst_ni,
248 .lc_en_i(lc_iso_part_sw_wr_en_i),
249 .lc_en_o(lc_iso_part_sw_wr_en)
250 );
251
252 prim_lc_sync #(
253 .NumCopies(1)
254 ) u_lc_seed_hw_rd_en_sync (
255 .clk_i,
256 .rst_ni,
257 .lc_en_i(lc_seed_hw_rd_en_i),
258 .lc_en_o(lc_seed_hw_rd_en)
259 );
Timothy Chen8d923152020-12-02 18:01:28 -0800260
Timothy Chenff4a7702020-10-27 15:08:53 -0700261 prim_lfsr #(
Timothy Chenaeffadc2020-12-11 15:03:07 -0800262 .EntropyDw(EdnWidth),
Timothy Chenf52a4612020-12-04 20:37:49 -0800263 .LfsrDw(LfsrWidth),
Timothy Chenaeffadc2020-12-11 15:03:07 -0800264 .StateOutDw(LfsrWidth),
265 .DefaultSeed(RndCnstLfsrSeed),
266 .StatePermEn(1),
267 .StatePerm(RndCnstLfsrPerm)
Timothy Chenff4a7702020-10-27 15:08:53 -0700268 ) u_lfsr (
269 .clk_i,
270 .rst_ni,
Timothy Chend39402a2020-12-15 20:34:09 -0800271 .seed_en_i(lfsr_seed_en),
272 .seed_i(rma_seed_i),
Timothy Chenff4a7702020-10-27 15:08:53 -0700273 .lfsr_en_i(lfsr_en),
Timothy Chenaeffadc2020-12-11 15:03:07 -0800274 .entropy_i('0),
Timothy Chenff4a7702020-10-27 15:08:53 -0700275 .state_o(rand_val)
276 );
277
278 // flash control arbitration between softawre / harware interfaces
279 flash_ctrl_arb u_ctrl_arb (
280 .clk_i,
281 .rst_ni,
282
283 // software interface to rd_ctrl / erase_ctrl
284 .sw_ctrl_i(reg2hw.control),
285 .sw_addr_i(reg2hw.addr.q),
286 .sw_ack_o(sw_ctrl_done),
287 .sw_err_o(sw_ctrl_err),
288
289 // software interface to rd_fifo
290 .sw_rvalid_o(sw_rvalid),
291 .sw_rready_i(adapter_rvalid),
292
293 // software interface to prog_fifo
294 .sw_wvalid_i(sw_wvalid & sw_wen),
Timothy Chend39402a2020-12-15 20:34:09 -0800295 .sw_wdata_i(sw_wdata),
Timothy Chenff4a7702020-10-27 15:08:53 -0700296 .sw_wready_o(sw_wready),
297
298 // hardware interface to rd_ctrl / erase_ctrl
299 .hw_req_i(hw_req),
300 .hw_ctrl_i(hw_ctrl),
301
302 // hardware interface indicating operation phase
303 .hw_phase_i(hw_phase),
304
305 // hardware works on word address, however software expects byte address
306 .hw_addr_i(hw_addr),
307 .hw_ack_o(hw_done),
308 .hw_err_o(hw_err),
309
310 // hardware interface to rd_fifo
311 .hw_rvalid_o(hw_rvalid),
312 .hw_rready_i(hw_rready),
Timothy Chend39402a2020-12-15 20:34:09 -0800313 .hw_wvalid_i(hw_wvalid),
314 .hw_wdata_i(hw_wdata),
315 .hw_wready_o(hw_wready),
Timothy Chenff4a7702020-10-27 15:08:53 -0700316
317 // hardware interface does not talk to prog_fifo
318
319 // muxed interface to rd_ctrl / erase_ctrl
320 .muxed_ctrl_o(muxed_ctrl),
321 .muxed_addr_o(muxed_addr),
322 .prog_ack_i(prog_done),
323 .prog_err_i(prog_err),
324 .rd_ack_i(rd_done),
325 .rd_err_i(rd_err),
326 .erase_ack_i(erase_done),
327 .erase_err_i(erase_err),
328
329 // muxed interface to rd_fifo
330 .rd_fifo_rvalid_i(rd_fifo_rvalid),
331 .rd_fifo_rready_o(rd_fifo_rready),
332
333 // muxed interface to prog_fifo
334 .prog_fifo_wvalid_o(prog_fifo_wvalid),
Timothy Chend39402a2020-12-15 20:34:09 -0800335 .prog_fifo_wdata_o(prog_fifo_wdata),
Timothy Chenff4a7702020-10-27 15:08:53 -0700336 .prog_fifo_wready_i(prog_fifo_wready),
337
338 // flash phy initilization ongoing
339 .flash_phy_busy_i(flash_phy_busy),
340
341 // clear fifos
342 .fifo_clr_o(fifo_clr),
343
344 // phase indication
345 .phase_o(phase),
346
347 // indication that sw has been selected
Timothy Chenaeffadc2020-12-11 15:03:07 -0800348 .sel_o(if_sel)
Timothy Chenff4a7702020-10-27 15:08:53 -0700349 );
350
351 assign op_start = muxed_ctrl.start.q;
352 assign op_num_words = muxed_ctrl.num.q;
353 assign op_erase_type = flash_erase_e'(muxed_ctrl.erase_sel.q);
354 assign op_prog_type = flash_prog_e'(muxed_ctrl.prog_sel.q);
355 assign op_addr = muxed_addr[BusByteWidth +: BusAddrW];
356 assign op_type = flash_op_e'(muxed_ctrl.op.q);
357 assign op_part = flash_part_e'(muxed_ctrl.partition_sel.q);
358 assign op_info_sel = muxed_ctrl.info_sel.q;
359 assign rd_op = op_type == FlashOpRead;
360 assign prog_op = op_type == FlashOpProgram;
361 assign erase_op = op_type == FlashOpErase;
362 assign sw_sel = if_sel == SwSel;
363
Timothy Chen99f3e3a2020-12-09 18:30:19 -0800364 // software privilege to creator seed
Cindy Chen39b14342021-01-29 16:25:24 -0800365 assign creator_seed_priv = lc_creator_seed_sw_rw_en[0] == lc_ctrl_pkg::On;
Timothy Chen99f3e3a2020-12-09 18:30:19 -0800366
367 // software privilege to owner seed
Cindy Chen39b14342021-01-29 16:25:24 -0800368 assign owner_seed_priv = lc_owner_seed_sw_rw_en[0] == lc_ctrl_pkg::On;
Timothy Chen99f3e3a2020-12-09 18:30:19 -0800369
Timothy Chenff4a7702020-10-27 15:08:53 -0700370 // hardware interface
Timothy Chenf52a4612020-12-04 20:37:49 -0800371 flash_ctrl_lcmgr #(
372 .RndCnstAddrKey(RndCnstAddrKey),
373 .RndCnstDataKey(RndCnstDataKey)
374 ) u_flash_hw_if (
Timothy Chenff4a7702020-10-27 15:08:53 -0700375 .clk_i,
376 .rst_ni,
Timothy Chenf52a4612020-12-04 20:37:49 -0800377 .clk_otp_i,
378 .rst_otp_ni,
Timothy Chenff4a7702020-10-27 15:08:53 -0700379
380 .init_i(pwrmgr_i.flash_init),
381 .init_done_o(pwrmgr_o.flash_done),
Cindy Chen39b14342021-01-29 16:25:24 -0800382 .provision_en_i(lc_seed_hw_rd_en[0] == lc_ctrl_pkg::On),
Timothy Chenff4a7702020-10-27 15:08:53 -0700383
384 // interface to ctrl arb control ports
385 .ctrl_o(hw_ctrl),
386 .req_o(hw_req),
387 .addr_o(hw_addr),
388 .done_i(hw_done),
389 .err_i(hw_err),
390
391 // interface to ctrl_arb data ports
392 .rready_o(hw_rready),
393 .rvalid_i(hw_rvalid),
Timothy Chend39402a2020-12-15 20:34:09 -0800394 .wready_i(hw_wready),
395 .wvalid_o(hw_wvalid),
396 .wdata_o(hw_wdata),
Timothy Chenff4a7702020-10-27 15:08:53 -0700397
398 // direct form rd_fifo
399 .rdata_i(rd_fifo_rdata),
400
401 // external rma request
Timothy Chend39402a2020-12-15 20:34:09 -0800402 .rma_req_i,
403 .rma_ack_o,
Timothy Chenff4a7702020-10-27 15:08:53 -0700404
Timothy Chenff4a7702020-10-27 15:08:53 -0700405 // outgoing seeds
406 .seeds_o(keymgr_o.seeds),
407 .seed_err_o(), // TBD hook-up to Err code register
408
409 // phase indication
410 .phase_o(hw_phase),
411
Timothy Chen6b241b32020-11-13 15:15:45 -0800412 // phy read buffer enable
413 .rd_buf_en_o(flash_o.rd_buf_en),
414
Timothy Chenf52a4612020-12-04 20:37:49 -0800415 // connection to otp
416 .otp_key_req_o(otp_o),
417 .otp_key_rsp_i(otp_i),
418 .addr_key_o(addr_key),
419 .data_key_o(data_key),
420
Timothy Chenaeffadc2020-12-11 15:03:07 -0800421 // entropy interface
Timothy Chend39402a2020-12-15 20:34:09 -0800422 .edn_req_o(lfsr_seed_en),
423 .edn_ack_i(1'b1),
Timothy Chenaeffadc2020-12-11 15:03:07 -0800424 .lfsr_en_o(lfsr_en),
425 .rand_i(rand_val),
426
Timothy Chenff4a7702020-10-27 15:08:53 -0700427 // init ongoing
428 .init_busy_o(ctrl_init_busy)
429 );
430
431 // Program FIFO
432 // Since the program and read FIFOs are never used at the same time, it should really be one
433 // FIFO with muxed inputs and outputs. This should be addressed once the flash integration
434 // strategy has been identified
435 assign prog_op_valid = op_start & prog_op;
436
437 tlul_adapter_sram #(
438 .SramAw(1), //address unused
439 .SramDw(BusWidth),
440 .ByteAccess(0), //flash may not support byte access
441 .ErrOnRead(1) //reads not supported
442 ) u_to_prog_fifo (
443 .clk_i,
444 .rst_ni,
Timothy Chen1a9a60f2021-02-10 18:04:39 -0800445 .tl_i (tl_win_h2d[0]),
446 .tl_o (tl_win_d2h[0]),
447 .en_ifetch_i (tlul_pkg::InstrDis),
448 .req_o (sw_wvalid),
449 .gnt_i (sw_wready),
450 .we_o (sw_wen),
451 .addr_o (),
452 .wmask_o (),
Timothy Chen12cce142021-03-02 18:11:01 -0800453 .intg_error_o(),
Timothy Chen1a9a60f2021-02-10 18:04:39 -0800454 .wdata_o (sw_wdata),
455 .rdata_i (BusWidth'(0)),
456 .rvalid_i (1'b0),
457 .rerror_i (2'b0)
Timothy Chenff4a7702020-10-27 15:08:53 -0700458 );
459
460 prim_fifo_sync #(
461 .Width(BusWidth),
462 .Depth(FifoDepth)
463 ) u_prog_fifo (
464 .clk_i,
465 .rst_ni,
466 .clr_i (reg2hw.fifo_rst.q | fifo_clr),
467 .wvalid_i(prog_fifo_wvalid & prog_op_valid),
468 .wready_o(prog_fifo_wready),
469 .wdata_i (prog_fifo_wdata),
470 .depth_o (prog_fifo_depth),
Philipp Wagner7858f3d2021-02-01 16:38:13 +0000471 .full_o (),
Timothy Chenff4a7702020-10-27 15:08:53 -0700472 .rvalid_o(prog_fifo_rvalid),
473 .rready_i(prog_fifo_ren),
474 .rdata_o (prog_fifo_rdata)
475 );
476
477 // Program handler is consumer of prog_fifo
Timothy Chenf52a4612020-12-04 20:37:49 -0800478 logic [1:0] prog_type_en;
479 assign prog_type_en[FlashProgNormal] = flash_i.prog_type_avail[FlashProgNormal] &
480 reg2hw.prog_type_en.normal.q;
481 assign prog_type_en[FlashProgRepair] = flash_i.prog_type_avail[FlashProgRepair] &
482 reg2hw.prog_type_en.repair.q;
Timothy Chenff4a7702020-10-27 15:08:53 -0700483 flash_ctrl_prog u_flash_ctrl_prog (
484 .clk_i,
485 .rst_ni,
486
487 // Control interface
488 .op_start_i (prog_op_valid),
489 .op_num_words_i (op_num_words),
490 .op_done_o (prog_done),
491 .op_err_o (prog_err),
492 .op_addr_i (op_addr),
493 .op_type_i (op_prog_type),
Timothy Chenf52a4612020-12-04 20:37:49 -0800494 .type_avail_i (prog_type_en),
Timothy Chenff4a7702020-10-27 15:08:53 -0700495
496 // FIFO Interface
497 .data_i (prog_fifo_rdata),
498 .data_rdy_i (prog_fifo_rvalid),
499 .data_rd_o (prog_fifo_ren),
500
501 // Flash Macro Interface
502 .flash_req_o (prog_flash_req),
503 .flash_addr_o (prog_flash_addr),
504 .flash_ovfl_o (prog_flash_ovfl),
505 .flash_data_o (flash_prog_data),
506 .flash_last_o (flash_prog_last),
507 .flash_type_o (flash_prog_type),
508 .flash_done_i (flash_prog_done),
509 .flash_error_i (flash_mp_error)
510 );
511
512 always_ff @(posedge clk_i or negedge rst_ni) begin
513 if (!rst_ni) begin
514 adapter_rvalid <= 1'b0;
515 end else begin
516 adapter_rvalid <= rd_fifo_ren && sw_rvalid;
517 end
518 end
519
520 // tlul adapter represents software's access interface to flash
521 tlul_adapter_sram #(
522 .SramAw(1), //address unused
523 .SramDw(BusWidth),
524 .ByteAccess(0), //flash may not support byte access
525 .ErrOnWrite(1) //writes not supported
526 ) u_to_rd_fifo (
527 .clk_i,
528 .rst_ni,
Timothy Chen1a9a60f2021-02-10 18:04:39 -0800529 .tl_i (tl_win_h2d[1]),
530 .tl_o (tl_win_d2h[1]),
531 .en_ifetch_i (tlul_pkg::InstrDis),
532 .req_o (rd_fifo_ren),
533 .gnt_i (rd_fifo_rvalid),
534 .we_o (),
535 .addr_o (),
536 .wmask_o (),
537 .wdata_o (),
Timothy Chen12cce142021-03-02 18:11:01 -0800538 .intg_error_o(),
Timothy Chen1a9a60f2021-02-10 18:04:39 -0800539 .rdata_i (rd_fifo_rdata),
540 .rvalid_i (adapter_rvalid),
541 .rerror_i (2'b0)
Timothy Chenff4a7702020-10-27 15:08:53 -0700542 );
543
544 prim_fifo_sync #(
545 .Width(BusWidth),
546 .Depth(FifoDepth)
547 ) u_rd_fifo (
548 .clk_i,
549 .rst_ni,
550 .clr_i (reg2hw.fifo_rst.q | fifo_clr),
551 .wvalid_i(rd_fifo_wen),
552 .wready_o(rd_fifo_wready),
553 .wdata_i (rd_fifo_wdata),
Timothy Chen71d98f82020-12-17 17:17:25 -0800554 .full_o (rd_fifo_full),
Timothy Chenff4a7702020-10-27 15:08:53 -0700555 .depth_o (rd_fifo_depth),
556 .rvalid_o(rd_fifo_rvalid),
557 .rready_i(rd_fifo_rready),
558 .rdata_o (rd_fifo_rdata)
559 );
560
561 // Read handler is consumer of rd_fifo
562 flash_ctrl_rd u_flash_ctrl_rd (
563 .clk_i,
564 .rst_ni,
565
566 // To arbiter Interface
567 .op_start_i (op_start & rd_op),
568 .op_num_words_i (op_num_words),
569 .op_done_o (rd_done),
570 .op_err_o (rd_err),
571 .op_addr_i (op_addr),
572
573 // FIFO Interface
574 .data_rdy_i (rd_fifo_wready),
575 .data_o (rd_fifo_wdata),
576 .data_wr_o (rd_fifo_wen),
577
578 // Flash Macro Interface
579 .flash_req_o (rd_flash_req),
580 .flash_addr_o (rd_flash_addr),
581 .flash_ovfl_o (rd_flash_ovfl),
582 .flash_data_i (flash_rd_data),
583 .flash_done_i (flash_rd_done),
584 .flash_error_i (flash_mp_error | flash_rd_err)
585 );
586
587 // Erase handler does not consume fifo
588 flash_ctrl_erase u_flash_ctrl_erase (
589 // Software Interface
590 .op_start_i (op_start & erase_op),
591 .op_type_i (op_erase_type),
592 .op_done_o (erase_done),
593 .op_err_o (erase_err),
594 .op_addr_i (op_addr),
595
596 // Flash Macro Interface
597 .flash_req_o (erase_flash_req),
598 .flash_addr_o (erase_flash_addr),
599 .flash_op_o (erase_flash_type),
600 .flash_done_i (flash_erase_done),
601 .flash_error_i (flash_mp_error)
602 );
603
604 // Final muxing to flash macro module
605 always_comb begin
606 unique case (op_type)
607 FlashOpRead: begin
608 flash_req = rd_flash_req;
609 flash_addr = rd_flash_addr;
610 end
611 FlashOpProgram: begin
612 flash_req = prog_flash_req;
613 flash_addr = prog_flash_addr;
614 end
615 FlashOpErase: begin
616 flash_req = erase_flash_req;
617 flash_addr = erase_flash_addr;
618 end
619 default: begin
620 flash_req = 1'b0;
621 flash_addr = '0;
622 end
623 endcase // unique case (op_type)
624 end
625
626 //////////////////////////////////////
Timothy Chend5323562020-12-02 16:10:44 -0800627 // Data partition properties configuration
Timothy Chenff4a7702020-10-27 15:08:53 -0700628 //////////////////////////////////////
629 // extra region is the default region
630 mp_region_cfg_t [MpRegions:0] region_cfgs;
631 assign region_cfgs[MpRegions-1:0] = reg2hw.mp_region_cfg[MpRegions-1:0];
632
633 //default region
634 assign region_cfgs[MpRegions].base.q = '0;
635 assign region_cfgs[MpRegions].size.q = NumBanks * PagesPerBank;
636 assign region_cfgs[MpRegions].en.q = 1'b1;
637 assign region_cfgs[MpRegions].rd_en.q = reg2hw.default_region.rd_en.q;
638 assign region_cfgs[MpRegions].prog_en.q = reg2hw.default_region.prog_en.q;
639 assign region_cfgs[MpRegions].erase_en.q = reg2hw.default_region.erase_en.q;
640 assign region_cfgs[MpRegions].scramble_en.q = reg2hw.default_region.scramble_en.q;
Timothy Chena2db9332020-11-13 18:47:54 -0800641 assign region_cfgs[MpRegions].ecc_en.q = reg2hw.default_region.ecc_en.q;
Timothy Chend5323562020-12-02 16:10:44 -0800642 assign region_cfgs[MpRegions].he_en.q = reg2hw.default_region.he_en.q;
Timothy Chenff4a7702020-10-27 15:08:53 -0700643
644 //////////////////////////////////////
Timothy Chend5323562020-12-02 16:10:44 -0800645 // Info partition properties configuration
Timothy Chenff4a7702020-10-27 15:08:53 -0700646 //////////////////////////////////////
647 info_page_cfg_t [NumBanks-1:0][InfoTypes-1:0][InfosPerBank-1:0] reg2hw_info_page_cfgs;
648 info_page_cfg_t [NumBanks-1:0][InfoTypes-1:0][InfosPerBank-1:0] info_page_cfgs;
Timothy Chene97e0b82020-12-11 17:18:43 -0800649 localparam int InfoBits = $bits(info_page_cfg_t) * InfosPerBank;
Timothy Chenff4a7702020-10-27 15:08:53 -0700650
651 // transform from reg output to structure
Timothy Chene97e0b82020-12-11 17:18:43 -0800652 // Not all types have the maximum number of banks, so those are packed to 0
Timothy Chenff4a7702020-10-27 15:08:53 -0700653 % for bank in range(cfg['banks']):
654 % for idx in range(cfg['info_types']):
Timothy Chene97e0b82020-12-11 17:18:43 -0800655 assign reg2hw_info_page_cfgs[${bank}][${idx}] = InfoBits'(reg2hw.bank${bank}_info${idx}_page_cfg);
Timothy Chenff4a7702020-10-27 15:08:53 -0700656 % endfor
657 % endfor
658
659 // qualify reg2hw settings with creator / owner privileges
660 for(genvar i = 0; i < NumBanks; i++) begin : gen_info_priv_bank
661 for (genvar j = 0; j < InfoTypes; j++) begin : gen_info_priv_type
662 flash_ctrl_info_cfg # (
663 .Bank(i),
664 .InfoSel(j)
665 ) u_info_cfg (
666 .cfgs_i(reg2hw_info_page_cfgs[i][j]),
667 .creator_seed_priv_i(creator_seed_priv),
668 .owner_seed_priv_i(owner_seed_priv),
Cindy Chen39b14342021-01-29 16:25:24 -0800669 .iso_flash_wr_en_i(lc_iso_part_sw_wr_en[0] == lc_ctrl_pkg::On),
670 .iso_flash_rd_en_i(lc_iso_part_sw_rd_en[0] == lc_ctrl_pkg::On),
Timothy Chenff4a7702020-10-27 15:08:53 -0700671 .cfgs_o(info_page_cfgs[i][j])
672 );
673 end
674 end
675
676 //////////////////////////////////////
Timothy Chend5323562020-12-02 16:10:44 -0800677 // flash memory properties
Timothy Chenff4a7702020-10-27 15:08:53 -0700678 //////////////////////////////////////
679 // direct assignment since prog/rd/erase_ctrl do not make use of op_part
680 flash_part_e flash_part_sel;
681 logic [InfoTypesWidth-1:0] flash_info_sel;
682 assign flash_part_sel = op_part;
683 assign flash_info_sel = op_info_sel;
684
Timothy Chen7d051eb2020-12-11 14:06:43 -0800685 // tie off hardware clear path
686 assign hw2reg.erase_suspend.d = 1'b0;
687
Timothy Chend5323562020-12-02 16:10:44 -0800688 // Flash memory Properties
689 // Memory property is page based and thus should use phy addressing
Timothy Chenff4a7702020-10-27 15:08:53 -0700690 // This should move to flash_phy long term
691 flash_mp u_flash_mp (
692 .clk_i,
693 .rst_ni,
694
695 // arbiter interface selection
696 .if_sel_i(if_sel),
697
698 // sw configuration for data partition
699 .region_cfgs_i(region_cfgs),
700 .bank_cfgs_i(reg2hw.mp_bank_cfg),
701
702 // sw configuration for info partition
703 .info_page_cfgs_i(info_page_cfgs),
704
705 // read / prog / erase controls
706 .req_i(flash_req),
707 .phase_i(phase),
708 .req_addr_i(flash_addr[BusAddrW-1 -: AllPagesW]),
709 .req_part_i(flash_part_sel),
710 .info_sel_i(flash_info_sel),
711 .addr_ovfl_i(rd_flash_ovfl | prog_flash_ovfl),
712 .rd_i(rd_op),
713 .prog_i(prog_op),
714 .pg_erase_i(erase_op & (erase_flash_type == FlashErasePage)),
715 .bk_erase_i(erase_op & (erase_flash_type == FlashEraseBank)),
Timothy Chen7d051eb2020-12-11 14:06:43 -0800716 .erase_suspend_i(reg2hw.erase_suspend),
717 .erase_suspend_done_o(hw2reg.erase_suspend.de),
Timothy Chenff4a7702020-10-27 15:08:53 -0700718 .rd_done_o(flash_rd_done),
719 .prog_done_o(flash_prog_done),
720 .erase_done_o(flash_erase_done),
721 .error_o(flash_mp_error),
722 .err_addr_o(err_addr),
723
724 // flash phy interface
725 .req_o(flash_o.req),
726 .scramble_en_o(flash_o.scramble_en),
Timothy Chena2db9332020-11-13 18:47:54 -0800727 .ecc_en_o(flash_o.ecc_en),
Timothy Chend5323562020-12-02 16:10:44 -0800728 .he_en_o(flash_o.he_en),
Timothy Chenff4a7702020-10-27 15:08:53 -0700729 .rd_o(flash_o.rd),
730 .prog_o(flash_o.prog),
731 .pg_erase_o(flash_o.pg_erase),
732 .bk_erase_o(flash_o.bk_erase),
Timothy Chen7d051eb2020-12-11 14:06:43 -0800733 .erase_suspend_o(flash_o.erase_suspend),
Timothy Chenff4a7702020-10-27 15:08:53 -0700734 .rd_done_i(flash_i.rd_done),
735 .prog_done_i(flash_i.prog_done),
736 .erase_done_i(flash_i.erase_done)
737 );
738
739
740 // software interface feedback
741 // most values (other than flash_phy_busy) should only update when software operations
742 // are actually selected
743 assign hw2reg.op_status.done.d = 1'b1;
744 assign hw2reg.op_status.done.de = sw_ctrl_done;
745 assign hw2reg.op_status.err.d = 1'b1;
746 assign hw2reg.op_status.err.de = sw_ctrl_err;
Timothy Chen71d98f82020-12-17 17:17:25 -0800747 assign hw2reg.status.rd_full.d = rd_fifo_full;
Timothy Chenff4a7702020-10-27 15:08:53 -0700748 assign hw2reg.status.rd_full.de = sw_sel;
749 assign hw2reg.status.rd_empty.d = ~rd_fifo_rvalid;
750 assign hw2reg.status.rd_empty.de = sw_sel;
751 assign hw2reg.status.prog_full.d = ~prog_fifo_wready;
752 assign hw2reg.status.prog_full.de = sw_sel;
753 assign hw2reg.status.prog_empty.d = ~prog_fifo_rvalid;
754 assign hw2reg.status.prog_empty.de = sw_sel;
755 assign hw2reg.status.init_wip.d = flash_phy_busy | ctrl_init_busy;
756 assign hw2reg.status.init_wip.de = 1'b1;
Timothy Chenff4a7702020-10-27 15:08:53 -0700757 assign hw2reg.control.start.d = 1'b0;
758 assign hw2reg.control.start.de = sw_ctrl_done;
759 // if software operation selected, based on transaction start
760 // if software operation not selected, software is free to change contents
761 assign hw2reg.ctrl_regwen.d = sw_sel ? !op_start : 1'b1;
762
763 // phy status
764 assign hw2reg.phy_status.init_wip.d = flash_phy_busy;
765 assign hw2reg.phy_status.init_wip.de = 1'b1;
766 assign hw2reg.phy_status.prog_normal_avail.d = flash_i.prog_type_avail[FlashProgNormal];
767 assign hw2reg.phy_status.prog_normal_avail.de = 1'b1;
768 assign hw2reg.phy_status.prog_repair_avail.d = flash_i.prog_type_avail[FlashProgRepair];
769 assign hw2reg.phy_status.prog_repair_avail.de = 1'b1;
770
771 // Flash Interface
772 assign flash_o.addr = flash_addr;
773 assign flash_o.part = flash_part_sel;
Timothy Chena0a550a2020-12-03 13:11:03 -0800774 assign flash_o.info_sel = flash_info_sel;
Timothy Chenff4a7702020-10-27 15:08:53 -0700775 assign flash_o.prog_type = flash_prog_type;
776 assign flash_o.prog_data = flash_prog_data;
777 assign flash_o.prog_last = flash_prog_last;
778 assign flash_o.region_cfgs = region_cfgs;
Timothy Chenf52a4612020-12-04 20:37:49 -0800779 assign flash_o.addr_key = addr_key;
780 assign flash_o.data_key = data_key;
Timothy Chen8adb20d2021-03-25 16:49:04 -0700781 assign flash_o.tl_flash_c2p = prim_tl_i;
Timothy Chen16741102021-01-15 17:32:13 -0800782 assign flash_o.alert_trig = reg2hw.phy_alert_cfg.alert_trig.q;
783 assign flash_o.alert_ack = reg2hw.phy_alert_cfg.alert_ack.q;
Timothy Chend8fded82021-02-22 11:32:55 -0800784 assign flash_o.jtag_req.tck = cio_tck_i;
785 assign flash_o.jtag_req.tms = cio_tms_i;
786 assign flash_o.jtag_req.tdi = cio_tdi_i;
787 assign flash_o.jtag_req.trst_n = '0;
788 assign cio_tdo_o = flash_i.jtag_rsp.tdo;
789 assign cio_tdo_en_o = flash_i.jtag_rsp.tdo_oe;
Timothy Chenff4a7702020-10-27 15:08:53 -0700790 assign flash_rd_err = flash_i.rd_err;
791 assign flash_rd_data = flash_i.rd_data;
792 assign flash_phy_busy = flash_i.init_busy;
793
Timothy Chend8fded82021-02-22 11:32:55 -0800794
Timothy Chenff4a7702020-10-27 15:08:53 -0700795 // Interface to pwrmgr
796 // flash is not idle as long as there is a stateful operation ongoing
797 logic flash_idle_d;
798 assign flash_idle_d = ~(flash_o.req &
799 (flash_o.prog | flash_o.pg_erase | flash_o.bk_erase));
800
801 prim_flop #(
802 .Width(1),
803 .ResetValue(1'b1)
804 ) u_reg_idle (
805 .clk_i,
806 .rst_ni,
807 .d_i(flash_idle_d),
808 .q_o(pwrmgr_o.flash_idle)
809 );
810
Timothy Chen16741102021-01-15 17:32:13 -0800811 //////////////////////////////////////
812 // Alert senders
813 //////////////////////////////////////
Timothy Chenff4a7702020-10-27 15:08:53 -0700814
Timothy Chen16741102021-01-15 17:32:13 -0800815 logic [NumAlerts-1:0] alert_srcs;
816 logic [NumAlerts-1:0] alert_tests;
817
Timothy Chen5302fff2021-01-22 14:36:54 -0800818 logic recov_err;
819 assign recov_err = flash_i.flash_alert_p | ~flash_i.flash_alert_n;
Timothy Chen16741102021-01-15 17:32:13 -0800820
821 logic recov_mp_err;
822 assign recov_mp_err = flash_mp_error;
823
824 logic recov_ecc_err;
825 assign recov_ecc_err = |flash_i.ecc_single_err | |flash_i.ecc_multi_err;
826
827 assign alert_srcs = { recov_ecc_err,
828 recov_mp_err,
Timothy Chen5302fff2021-01-22 14:36:54 -0800829 recov_err
Timothy Chen16741102021-01-15 17:32:13 -0800830 };
831
832 assign alert_tests = { reg2hw.alert_test.recov_ecc_err.q & reg2hw.alert_test.recov_ecc_err.qe,
833 reg2hw.alert_test.recov_mp_err.q & reg2hw.alert_test.recov_mp_err.qe,
Timothy Chen5302fff2021-01-22 14:36:54 -0800834 reg2hw.alert_test.recov_err.q & reg2hw.alert_test.recov_err.qe
Timothy Chen16741102021-01-15 17:32:13 -0800835 };
836
837 for (genvar i = 0; i < NumAlerts; i++) begin : gen_alert_senders
838 prim_alert_sender #(
Rupert Swarbrick21d6e5b2021-03-18 09:07:35 +0000839 .AsyncOn(AlertAsyncOn[i])
Timothy Chen16741102021-01-15 17:32:13 -0800840 ) u_alert_sender (
841 .clk_i,
842 .rst_ni,
Timothy Chen06f78312021-01-20 18:43:27 -0800843 .alert_req_i(alert_srcs[i]),
844 .alert_test_i(alert_tests[i]),
Timothy Chen16741102021-01-15 17:32:13 -0800845 .alert_ack_o(),
Timothy Chen06f78312021-01-20 18:43:27 -0800846 .alert_state_o(),
Timothy Chen16741102021-01-15 17:32:13 -0800847 .alert_rx_i(alert_rx_i[i]),
848 .alert_tx_o(alert_tx_o[i])
849 );
850 end
851
852
853 //////////////////////////////////////
854 // Errors and Interrupts
855 //////////////////////////////////////
856
857 assign hw2reg.err_code.mp_err.d = 1'b1;
858 assign hw2reg.err_code.ecc_single_err.d = 1'b1;
859 assign hw2reg.err_code.ecc_multi_err.d = 1'b1;
860 assign hw2reg.err_code.flash_err.d = 1'b1;
861 assign hw2reg.err_code.flash_alert.d = 1'b1;
862 assign hw2reg.err_code.mp_err.de = flash_mp_error;
863 assign hw2reg.err_code.ecc_single_err.de = |flash_i.ecc_single_err;
864 assign hw2reg.err_code.ecc_multi_err.de = |flash_i.ecc_multi_err;
865 assign hw2reg.err_code.flash_err.de = flash_i.flash_err;
866 assign hw2reg.err_code.flash_alert.de = flash_i.flash_alert_p | ~flash_i.flash_alert_n;
867 assign hw2reg.err_addr.d = err_addr;
868 assign hw2reg.err_addr.de = flash_mp_error;
869
870 for (genvar bank = 0; bank < NumBanks; bank++) begin : gen_err_cons
871 assign hw2reg.ecc_err_addr[bank].d = {flash_i.ecc_addr[bank], {BusByteWidth{1'b0}}};
872 assign hw2reg.ecc_err_addr[bank].de = flash_i.ecc_single_err[bank] |
873 flash_i.ecc_multi_err[bank];
874 end
875
Timothy Chenff4a7702020-10-27 15:08:53 -0700876 // Generate edge triggered signals for sources that are level
877 logic [3:0] intr_src;
878 logic [3:0] intr_src_q;
879 logic [3:0] intr_assert;
880
881 assign intr_src = { ~prog_fifo_rvalid,
882 reg2hw.fifo_lvl.prog.q == prog_fifo_depth,
Timothy Chen71d98f82020-12-17 17:17:25 -0800883 rd_fifo_full,
Timothy Chenff4a7702020-10-27 15:08:53 -0700884 reg2hw.fifo_lvl.rd.q == rd_fifo_depth
885 };
886
887 always_ff @(posedge clk_i or negedge rst_ni) begin
888 if (!rst_ni) begin
889 intr_src_q <= 4'h8; //prog_fifo is empty by default
890 end else if (sw_sel) begin
891 intr_src_q <= intr_src;
892 end
893 end
894
895 assign intr_assert = ~intr_src_q & intr_src;
896
897
898 assign intr_prog_empty_o = reg2hw.intr_enable.prog_empty.q & reg2hw.intr_state.prog_empty.q;
899 assign intr_prog_lvl_o = reg2hw.intr_enable.prog_lvl.q & reg2hw.intr_state.prog_lvl.q;
900 assign intr_rd_full_o = reg2hw.intr_enable.rd_full.q & reg2hw.intr_state.rd_full.q;
901 assign intr_rd_lvl_o = reg2hw.intr_enable.rd_lvl.q & reg2hw.intr_state.rd_lvl.q;
902 assign intr_op_done_o = reg2hw.intr_enable.op_done.q & reg2hw.intr_state.op_done.q;
Timothy Chenff4a7702020-10-27 15:08:53 -0700903
904 assign hw2reg.intr_state.prog_empty.d = 1'b1;
905 assign hw2reg.intr_state.prog_empty.de = intr_assert[3] |
906 (reg2hw.intr_test.prog_empty.qe &
907 reg2hw.intr_test.prog_empty.q);
908
909 assign hw2reg.intr_state.prog_lvl.d = 1'b1;
910 assign hw2reg.intr_state.prog_lvl.de = intr_assert[2] |
911 (reg2hw.intr_test.prog_lvl.qe &
912 reg2hw.intr_test.prog_lvl.q);
913
914 assign hw2reg.intr_state.rd_full.d = 1'b1;
915 assign hw2reg.intr_state.rd_full.de = intr_assert[1] |
916 (reg2hw.intr_test.rd_full.qe &
917 reg2hw.intr_test.rd_full.q);
918
919 assign hw2reg.intr_state.rd_lvl.d = 1'b1;
920 assign hw2reg.intr_state.rd_lvl.de = intr_assert[0] |
921 (reg2hw.intr_test.rd_lvl.qe &
922 reg2hw.intr_test.rd_lvl.q);
923
924
925 assign hw2reg.intr_state.op_done.d = 1'b1;
926 assign hw2reg.intr_state.op_done.de = sw_ctrl_done |
927 (reg2hw.intr_test.op_done.qe &
928 reg2hw.intr_test.op_done.q);
929
Timothy Chenff4a7702020-10-27 15:08:53 -0700930
931 // Unused bits
932 logic [BusByteWidth-1:0] unused_byte_sel;
933 logic [top_pkg::TL_AW-1-BusAddrW:0] unused_higher_addr_bits;
934 logic [top_pkg::TL_AW-1:0] unused_scratch;
935
Timothy Chenff4a7702020-10-27 15:08:53 -0700936 // Unused signals
937 assign unused_byte_sel = muxed_addr[BusByteWidth-1:0];
938 assign unused_higher_addr_bits = muxed_addr[top_pkg::TL_AW-1:BusAddrW];
939 assign unused_scratch = reg2hw.scratch;
940
941
942 // Assertions
Timothy Chen8adb20d2021-03-25 16:49:04 -0700943 `ASSERT_KNOWN(TlDValidKnownO_A, core_tl_o.d_valid )
944 `ASSERT_KNOWN(TlAReadyKnownO_A, core_tl_o.a_ready )
945 `ASSERT_KNOWN(PrimTlDValidKnownO_A, prim_tl_o.d_valid )
946 `ASSERT_KNOWN(PrimTlAReadyKnownO_A, prim_tl_o.a_ready )
Timothy Chenff4a7702020-10-27 15:08:53 -0700947 `ASSERT_KNOWN(FlashKnownO_A, {flash_o.req, flash_o.rd, flash_o.prog, flash_o.pg_erase,
948 flash_o.bk_erase})
949 `ASSERT_KNOWN_IF(FlashAddrKnown_A, flash_o.addr, flash_o.req)
950 `ASSERT_KNOWN_IF(FlashProgKnown_A, flash_o.prog_data, flash_o.prog & flash_o.req)
951 `ASSERT_KNOWN(IntrProgEmptyKnownO_A, intr_prog_empty_o)
952 `ASSERT_KNOWN(IntrProgLvlKnownO_A, intr_prog_lvl_o )
953 `ASSERT_KNOWN(IntrProgRdFullKnownO_A, intr_rd_full_o )
954 `ASSERT_KNOWN(IntrRdLvlKnownO_A, intr_rd_lvl_o )
955 `ASSERT_KNOWN(IntrOpDoneKnownO_A, intr_op_done_o )
Timothy Chenff4a7702020-10-27 15:08:53 -0700956
957endmodule