Srikrishna Iyer | b29ebe8 | 2020-05-20 11:29:25 -0700 | [diff] [blame] | 1 | // 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 | module tb; |
| 6 | // dep packages |
| 7 | import uvm_pkg::*; |
Srikrishna Iyer | 61fc513 | 2020-07-10 23:13:50 -0700 | [diff] [blame] | 8 | import top_pkg::*; |
Srikrishna Iyer | b29ebe8 | 2020-05-20 11:29:25 -0700 | [diff] [blame] | 9 | import dv_utils_pkg::*; |
Srikrishna Iyer | 61fc513 | 2020-07-10 23:13:50 -0700 | [diff] [blame] | 10 | import flash_ctrl_pkg::*; |
Srikrishna Iyer | b29ebe8 | 2020-05-20 11:29:25 -0700 | [diff] [blame] | 11 | import flash_ctrl_env_pkg::*; |
| 12 | import flash_ctrl_test_pkg::*; |
Srikrishna Iyer | 59b74f6 | 2021-06-05 00:35:43 -0700 | [diff] [blame] | 13 | import mem_bkdr_util_pkg::mem_bkdr_util; |
Srikrishna Iyer | b29ebe8 | 2020-05-20 11:29:25 -0700 | [diff] [blame] | 14 | |
| 15 | // macro includes |
| 16 | `include "uvm_macros.svh" |
| 17 | `include "dv_macros.svh" |
| 18 | |
Eitan Shapira | 040c4f7 | 2022-01-31 17:14:16 +0200 | [diff] [blame] | 19 | // TB base test ENV_T & CFG_T specification |
| 20 | // |
| 21 | // Specify the parameters for the flash_ctrl_base_test |
| 22 | // This will invoke the UVM registry and link this test type to |
| 23 | // the name 'flash_ctrl_base_test' as a test name passed by UVM_TESTNAME |
| 24 | // |
| 25 | // This is done explicitly only for the prim_pkg::ImplGeneric implementation |
| 26 | // since partner base tests inherit from flash_ctrl_base_test#(CFG_T, ENV_T) and |
| 27 | // specify directly (CFG_T, ENV_T) via the class extension and use a different |
| 28 | // UVM_TESTNAME |
| 29 | if (`PRIM_DEFAULT_IMPL==prim_pkg::ImplGeneric) begin : gen_spec_base_test_params |
| 30 | typedef flash_ctrl_base_test #(.CFG_T(flash_ctrl_env_cfg), |
| 31 | .ENV_T(flash_ctrl_env)) flash_ctrl_base_test_t; |
| 32 | end |
| 33 | |
Cindy Chen | 1c5b13c | 2021-11-12 16:39:57 -0800 | [diff] [blame] | 34 | wire clk, rst_n, rst_shadowed_n; |
Srikrishna Iyer | b29ebe8 | 2020-05-20 11:29:25 -0700 | [diff] [blame] | 35 | wire devmode; |
| 36 | wire intr_prog_empty; |
| 37 | wire intr_prog_lvl; |
| 38 | wire intr_rd_full; |
| 39 | wire intr_rd_lvl; |
| 40 | wire intr_op_done; |
Srikrishna Iyer | 5311829 | 2021-06-17 00:50:00 -0700 | [diff] [blame] | 41 | wire intr_err; |
Srikrishna Iyer | b29ebe8 | 2020-05-20 11:29:25 -0700 | [diff] [blame] | 42 | wire [NUM_MAX_INTERRUPTS-1:0] interrupts; |
| 43 | |
| 44 | // interfaces |
Nikola Miladinovic | ae005eb | 2021-12-09 15:34:02 +0000 | [diff] [blame] | 45 | clk_rst_if clk_rst_if ( |
| 46 | .clk (clk), |
| 47 | .rst_n(rst_n) |
| 48 | ); |
| 49 | rst_shadowed_if rst_shadowed_if ( |
| 50 | .rst_n(rst_n), |
| 51 | .rst_shadowed_n(rst_shadowed_n) |
| 52 | ); |
| 53 | pins_if #(NUM_MAX_INTERRUPTS) intr_if (interrupts); |
| 54 | pins_if #(1) devmode_if (devmode); |
| 55 | tl_if tl_if ( |
| 56 | .clk (clk), |
| 57 | .rst_n(rst_n) |
| 58 | ); |
| 59 | tl_if eflash_tl_if ( |
| 60 | .clk (clk), |
| 61 | .rst_n(rst_n) |
| 62 | ); |
Jaedon Kim | 4410d45 | 2022-08-03 23:30:30 +0000 | [diff] [blame] | 63 | tl_if prim_tl_if ( |
| 64 | .clk (clk), |
| 65 | .rst_n(rst_n) |
| 66 | ); |
Nikola Miladinovic | ae005eb | 2021-12-09 15:34:02 +0000 | [diff] [blame] | 67 | flash_ctrl_if flash_ctrl_if (); |
Jaedon Kim | ee48b8f | 2022-06-17 17:26:30 +0000 | [diff] [blame] | 68 | flash_phy_prim_if fpp_if ( |
| 69 | .clk (clk), |
| 70 | .rst_n(rst_n) |
| 71 | ); |
| 72 | |
| 73 | `define FLASH_DEVICE_HIER tb.dut.u_eflash.u_flash |
| 74 | assign fpp_if.req = `FLASH_DEVICE_HIER.flash_req_i; |
| 75 | assign fpp_if.rsp = `FLASH_DEVICE_HIER.flash_rsp_o; |
Jaedon Kim | 36188dd | 2022-08-20 07:55:46 +0000 | [diff] [blame] | 76 | for (genvar i = 0; i < flash_ctrl_pkg::NumBanks; i++) begin : gen_bank_loop |
| 77 | assign fpp_if.rreq[i] = tb.dut.u_eflash.gen_flash_cores[i].u_core.u_rd.req_i; |
| 78 | assign fpp_if.rdy[i] = tb.dut.u_eflash.gen_flash_cores[i].u_core.u_rd.rdy_o; |
| 79 | |
| 80 | assign flash_ctrl_if.hazard[i] = |
| 81 | tb.dut.u_eflash.gen_flash_cores[i].u_core.u_rd.data_hazard[3:0]; |
| 82 | assign flash_ctrl_if.evict_prog[i] = |
| 83 | tb.dut.u_eflash.gen_flash_cores[i].u_core.u_rd.prog_i; |
| 84 | assign flash_ctrl_if.evict_erase[i] = |
| 85 | tb.dut.u_eflash.gen_flash_cores[i].u_core.u_rd.pg_erase_i; |
| 86 | for (genvar j = 0; j < flash_phy_pkg::NumBuf; j++) begin : gen_per_buffer |
| 87 | assign flash_ctrl_if.rd_buf[i][j] = |
| 88 | tb.dut.u_eflash.gen_flash_cores[i].u_core.u_rd.read_buf[j]; |
| 89 | end |
| 90 | end |
| 91 | assign flash_ctrl_if.fatal_err = tb.dut.fatal_err; |
Jaedon Kim | ee48b8f | 2022-06-17 17:26:30 +0000 | [diff] [blame] | 92 | `undef FLASH_DEVICE_HIER |
Srikrishna Iyer | b29ebe8 | 2020-05-20 11:29:25 -0700 | [diff] [blame] | 93 | |
Timothy Chen | 06f7831 | 2021-01-20 18:43:27 -0800 | [diff] [blame] | 94 | `DV_ALERT_IF_CONNECT |
| 95 | |
TIM EWINS | 8ae9bce | 2022-02-02 15:32:36 +0000 | [diff] [blame] | 96 | // SIMPLE OTP KEY INTERFACE (Access via VIF) |
| 97 | |
Timothy Chen | fb8a784 | 2021-08-20 00:23:47 -0700 | [diff] [blame] | 98 | otp_ctrl_pkg::flash_otp_key_req_t otp_req; |
| 99 | otp_ctrl_pkg::flash_otp_key_rsp_t otp_rsp; |
| 100 | |
TIM EWINS | 8ae9bce | 2022-02-02 15:32:36 +0000 | [diff] [blame] | 101 | assign flash_ctrl_if.otp_req.addr_req = otp_req.addr_req; |
| 102 | assign flash_ctrl_if.otp_req.data_req = otp_req.data_req; |
| 103 | |
TIM EWINS | f6dbc05 | 2022-04-28 16:10:48 +0100 | [diff] [blame] | 104 | assign otp_rsp.addr_ack = flash_ctrl_if.otp_rsp.addr_ack; |
| 105 | assign otp_rsp.data_ack = flash_ctrl_if.otp_rsp.data_ack; |
| 106 | assign otp_rsp.key = flash_ctrl_if.otp_rsp.key; |
| 107 | assign otp_rsp.rand_key = flash_ctrl_if.otp_rsp.rand_key; |
| 108 | assign otp_rsp.seed_valid = flash_ctrl_if.otp_rsp.seed_valid; |
Timothy Chen | fb8a784 | 2021-08-20 00:23:47 -0700 | [diff] [blame] | 109 | |
Jaedon Kim | 5fbaea1 | 2022-09-07 15:47:05 +0000 | [diff] [blame^] | 110 | assign flash_ctrl_if.rd_buf_en = tb.dut.u_flash_hw_if.rd_buf_en_o; |
| 111 | assign flash_ctrl_if.rma_state = tb.dut.u_flash_hw_if.rma_state_q; |
| 112 | assign flash_ctrl_if.prog_state0 = |
Jaedon Kim | 514f199 | 2022-08-24 21:01:17 +0000 | [diff] [blame] | 113 | tb.dut.u_eflash.gen_flash_cores[0].u_core.gen_prog_data.u_prog.state_q; |
Jaedon Kim | 5fbaea1 | 2022-09-07 15:47:05 +0000 | [diff] [blame^] | 114 | assign flash_ctrl_if.prog_state1 = |
Jaedon Kim | 514f199 | 2022-08-24 21:01:17 +0000 | [diff] [blame] | 115 | tb.dut.u_eflash.gen_flash_cores[1].u_core.gen_prog_data.u_prog.state_q; |
Jaedon Kim | 5fbaea1 | 2022-09-07 15:47:05 +0000 | [diff] [blame^] | 116 | assign flash_ctrl_if.lcmgr_state = tb.dut.u_flash_hw_if.state_q; |
| 117 | assign flash_ctrl_if.init = tb.dut.u_flash_hw_if.init_i; |
Jaedon Kim | 514f199 | 2022-08-24 21:01:17 +0000 | [diff] [blame] | 118 | |
Nikola Miladinovic | 537937a | 2021-11-22 15:42:23 +0000 | [diff] [blame] | 119 | wire flash_test_v; |
Nikola Miladinovic | ae005eb | 2021-12-09 15:34:02 +0000 | [diff] [blame] | 120 | assign (pull1, pull0) flash_test_v = 1'b1; |
Nikola Miladinovic | 537937a | 2021-11-22 15:42:23 +0000 | [diff] [blame] | 121 | wire [1:0] flash_test_mode_a; |
Nikola Miladinovic | ae005eb | 2021-12-09 15:34:02 +0000 | [diff] [blame] | 122 | assign (pull1, pull0) flash_test_mode_a = 2'h3; |
Nikola Miladinovic | 537937a | 2021-11-22 15:42:23 +0000 | [diff] [blame] | 123 | |
Srikrishna Iyer | b29ebe8 | 2020-05-20 11:29:25 -0700 | [diff] [blame] | 124 | // dut |
Timothy Chen | 6dd70f7 | 2022-04-07 10:59:10 -0700 | [diff] [blame] | 125 | flash_ctrl #( |
| 126 | .ProgFifoDepth(ProgFifoDepth), |
| 127 | .RdFifoDepth(ReadFifoDepth) |
| 128 | ) dut ( |
Nikola Miladinovic | ae005eb | 2021-12-09 15:34:02 +0000 | [diff] [blame] | 129 | .clk_i (clk), |
| 130 | .rst_ni (rst_n), |
| 131 | .rst_shadowed_ni(rst_shadowed_n), |
| 132 | .clk_otp_i (clk), |
| 133 | .rst_otp_ni (rst_n), |
Srikrishna Iyer | b29ebe8 | 2020-05-20 11:29:25 -0700 | [diff] [blame] | 134 | |
Timothy Chen | fb8a784 | 2021-08-20 00:23:47 -0700 | [diff] [blame] | 135 | // various tlul interfaces |
Nikola Miladinovic | ae005eb | 2021-12-09 15:34:02 +0000 | [diff] [blame] | 136 | .core_tl_i(tl_if.h2d), |
| 137 | .core_tl_o(tl_if.d2h), |
Jaedon Kim | 4410d45 | 2022-08-03 23:30:30 +0000 | [diff] [blame] | 138 | .prim_tl_i(prim_tl_if.h2d), |
| 139 | .prim_tl_o(prim_tl_if.d2h), |
Nikola Miladinovic | ae005eb | 2021-12-09 15:34:02 +0000 | [diff] [blame] | 140 | .mem_tl_i (eflash_tl_if.h2d), |
| 141 | .mem_tl_o (eflash_tl_if.d2h), |
Srikrishna Iyer | b29ebe8 | 2020-05-20 11:29:25 -0700 | [diff] [blame] | 142 | |
Timothy Chen | fb8a784 | 2021-08-20 00:23:47 -0700 | [diff] [blame] | 143 | // otp interface |
Nikola Miladinovic | ae005eb | 2021-12-09 15:34:02 +0000 | [diff] [blame] | 144 | .otp_i(otp_rsp), |
| 145 | .otp_o(otp_req), |
Timothy Chen | d2c9ff4 | 2020-11-19 16:03:54 -0800 | [diff] [blame] | 146 | |
Timothy Chen | fb8a784 | 2021-08-20 00:23:47 -0700 | [diff] [blame] | 147 | // various life cycle decode signals |
Nikola Miladinovic | ae005eb | 2021-12-09 15:34:02 +0000 | [diff] [blame] | 148 | .lc_creator_seed_sw_rw_en_i(flash_ctrl_if.lc_creator_seed_sw_rw_en), |
| 149 | .lc_owner_seed_sw_rw_en_i (flash_ctrl_if.lc_owner_seed_sw_rw_en), |
| 150 | .lc_iso_part_sw_rd_en_i (flash_ctrl_if.lc_iso_part_sw_rd_en), |
| 151 | .lc_iso_part_sw_wr_en_i (flash_ctrl_if.lc_iso_part_sw_wr_en), |
| 152 | .lc_seed_hw_rd_en_i (flash_ctrl_if.lc_seed_hw_rd_en), |
| 153 | .lc_nvm_debug_en_i (flash_ctrl_if.lc_nvm_debug_en), |
| 154 | .lc_escalate_en_i (flash_ctrl_if.lc_escalate_en), |
Srikrishna Iyer | aebf7c1 | 2020-07-24 11:02:23 -0700 | [diff] [blame] | 155 | |
Timothy Chen | fb8a784 | 2021-08-20 00:23:47 -0700 | [diff] [blame] | 156 | // life cycle rma handling |
Nikola Miladinovic | ae005eb | 2021-12-09 15:34:02 +0000 | [diff] [blame] | 157 | .rma_req_i (flash_ctrl_if.rma_req), |
| 158 | .rma_seed_i(flash_ctrl_if.rma_seed), |
| 159 | .rma_ack_o (flash_ctrl_if.rma_ack), |
Timothy Chen | fb8a784 | 2021-08-20 00:23:47 -0700 | [diff] [blame] | 160 | |
| 161 | // power manager indication |
Nikola Miladinovic | ae005eb | 2021-12-09 15:34:02 +0000 | [diff] [blame] | 162 | .pwrmgr_o(flash_ctrl_if.pwrmgr), |
| 163 | .keymgr_o(flash_ctrl_if.keymgr), |
Timothy Chen | fb8a784 | 2021-08-20 00:23:47 -0700 | [diff] [blame] | 164 | |
| 165 | // flash prim signals |
Nikola Miladinovic | 1ea6e94 | 2022-06-01 17:21:17 +0100 | [diff] [blame] | 166 | .flash_power_ready_h_i (flash_ctrl_if.power_ready_h), |
Nikola Miladinovic | ae005eb | 2021-12-09 15:34:02 +0000 | [diff] [blame] | 167 | .flash_power_down_h_i (flash_power_down_h), |
Timothy Chen | f4d5e9a | 2021-11-09 13:41:04 -0800 | [diff] [blame] | 168 | .flash_bist_enable_i (prim_mubi_pkg::MuBi4False), |
Nikola Miladinovic | ae005eb | 2021-12-09 15:34:02 +0000 | [diff] [blame] | 169 | .flash_test_mode_a_io (flash_test_mode_a), |
| 170 | .flash_test_voltage_h_io(flash_test_v), |
Timothy Chen | fb8a784 | 2021-08-20 00:23:47 -0700 | [diff] [blame] | 171 | |
| 172 | // test |
Nikola Miladinovic | ae005eb | 2021-12-09 15:34:02 +0000 | [diff] [blame] | 173 | .scanmode_i (prim_mubi_pkg::MuBi4False), |
| 174 | .scan_rst_ni('0), |
| 175 | .scan_en_i ('0), |
Timothy Chen | fb8a784 | 2021-08-20 00:23:47 -0700 | [diff] [blame] | 176 | |
Nikola Miladinovic | 537937a | 2021-11-22 15:42:23 +0000 | [diff] [blame] | 177 | // JTAG |
Nikola Miladinovic | ae005eb | 2021-12-09 15:34:02 +0000 | [diff] [blame] | 178 | .cio_tck_i (flash_ctrl_if.cio_tck), |
| 179 | .cio_tms_i (flash_ctrl_if.cio_tms), |
| 180 | .cio_tdi_i (flash_ctrl_if.cio_tdi), |
| 181 | .cio_tdo_en_o(flash_ctrl_if.cio_tdo_en), |
| 182 | .cio_tdo_o (flash_ctrl_if.cio_tdo), |
Nikola Miladinovic | 537937a | 2021-11-22 15:42:23 +0000 | [diff] [blame] | 183 | |
Timothy Chen | fb8a784 | 2021-08-20 00:23:47 -0700 | [diff] [blame] | 184 | // alerts and interrupts |
Nikola Miladinovic | ae005eb | 2021-12-09 15:34:02 +0000 | [diff] [blame] | 185 | .intr_prog_empty_o(intr_prog_empty), |
| 186 | .intr_prog_lvl_o (intr_prog_lvl), |
| 187 | .intr_rd_full_o (intr_rd_full), |
| 188 | .intr_rd_lvl_o (intr_rd_lvl), |
| 189 | .intr_op_done_o (intr_op_done), |
| 190 | .intr_corr_err_o (intr_err), |
| 191 | .alert_rx_i (alert_rx), |
Michael Schaffner | 88829b6 | 2022-08-25 11:29:53 -0700 | [diff] [blame] | 192 | .alert_tx_o (alert_tx) |
Srikrishna Iyer | b29ebe8 | 2020-05-20 11:29:25 -0700 | [diff] [blame] | 193 | ); |
| 194 | |
Eitan Shapira | 11b04a9 | 2021-04-22 10:00:46 +0300 | [diff] [blame] | 195 | // Create edge in flash_power_down_h_i, whenever reset is asserted |
Eitan Shapira | 0e0a74b | 2021-03-01 17:17:48 +0200 | [diff] [blame] | 196 | logic init; |
| 197 | assign flash_power_down_h = (init ? 1'b1 : 1'b0); |
| 198 | initial begin |
Eitan Shapira | 11b04a9 | 2021-04-22 10:00:46 +0300 | [diff] [blame] | 199 | forever begin |
| 200 | fork |
| 201 | begin : isolation_fork |
| 202 | if (rst_n === 1'b1) begin |
| 203 | // Fork off a thread to deassert init after 5 clocks. |
| 204 | fork |
| 205 | begin : deassert_init |
| 206 | clk_rst_if.wait_clks(5); |
| 207 | init = 1'b0; |
| 208 | end : deassert_init |
| 209 | join_none |
| 210 | end else begin |
Eitan Shapira | 0e847a6 | 2022-01-27 15:48:32 +0200 | [diff] [blame] | 211 | init = 1'b1; |
Eitan Shapira | 11b04a9 | 2021-04-22 10:00:46 +0300 | [diff] [blame] | 212 | end |
| 213 | |
| 214 | // Wait for the rst_n to change. |
| 215 | @(rst_n); |
| 216 | disable fork; |
| 217 | end : isolation_fork |
| 218 | join |
| 219 | end |
Eitan Shapira | 0e0a74b | 2021-03-01 17:17:48 +0200 | [diff] [blame] | 220 | end |
| 221 | |
Srikrishna Iyer | 59b74f6 | 2021-06-05 00:35:43 -0700 | [diff] [blame] | 222 | // Instantitate the memory backdoor util instances. |
Eitan Shapira | 0e0a74b | 2021-03-01 17:17:48 +0200 | [diff] [blame] | 223 | // |
Srikrishna Iyer | 59b74f6 | 2021-06-05 00:35:43 -0700 | [diff] [blame] | 224 | // This only applies to the generic eflash. A unique memory backdoor util instance is created for |
| 225 | // each type of flash partition in each bank. |
| 226 | // |
| 227 | // For eflash of a specific vendor implementation, set the hierarchy to the memory element |
| 228 | // correctly when creating these instances in the extended testbench. |
Srikrishna Iyer | fe8a53a | 2022-08-30 11:32:56 -0700 | [diff] [blame] | 229 | `define FLASH_BANK_HIER(i) \ |
Timothy Chen | fb8a784 | 2021-08-20 00:23:47 -0700 | [diff] [blame] | 230 | tb.dut.u_eflash.u_flash.gen_generic.u_impl_generic.gen_prim_flash_banks[i]. \ |
Srikrishna Iyer | fe8a53a | 2022-08-30 11:32:56 -0700 | [diff] [blame] | 231 | u_prim_flash_bank |
| 232 | |
| 233 | `define FLASH_DATA_MEM_HIER(i) \ |
| 234 | `FLASH_BANK_HIER(i).u_mem.gen_generic.u_impl_generic.mem |
Eitan Shapira | 0e0a74b | 2021-03-01 17:17:48 +0200 | [diff] [blame] | 235 | |
Srikrishna Iyer | 59b74f6 | 2021-06-05 00:35:43 -0700 | [diff] [blame] | 236 | `define FLASH_DATA_MEM_HIER_STR(i) \ |
Timothy Chen | fb8a784 | 2021-08-20 00:23:47 -0700 | [diff] [blame] | 237 | $sformatf({"tb.dut.u_eflash.u_flash.gen_generic.u_impl_generic.", \ |
Srikrishna Iyer | 59b74f6 | 2021-06-05 00:35:43 -0700 | [diff] [blame] | 238 | "gen_prim_flash_banks[%0d].u_prim_flash_bank.u_mem.gen_generic.", \ |
| 239 | "u_impl_generic.mem"}, i) |
Srikrishna Iyer | b29ebe8 | 2020-05-20 11:29:25 -0700 | [diff] [blame] | 240 | |
Srikrishna Iyer | 59b74f6 | 2021-06-05 00:35:43 -0700 | [diff] [blame] | 241 | `define FLASH_INFO_MEM_HIER(i, j) \ |
Timothy Chen | fb8a784 | 2021-08-20 00:23:47 -0700 | [diff] [blame] | 242 | tb.dut.u_eflash.u_flash.gen_generic.u_impl_generic.gen_prim_flash_banks[i]. \ |
Srikrishna Iyer | 59b74f6 | 2021-06-05 00:35:43 -0700 | [diff] [blame] | 243 | u_prim_flash_bank.gen_info_types[j].u_info_mem.gen_generic.u_impl_generic.mem |
Srikrishna Iyer | 6ff88ed | 2020-07-10 16:29:26 -0700 | [diff] [blame] | 244 | |
Srikrishna Iyer | 59b74f6 | 2021-06-05 00:35:43 -0700 | [diff] [blame] | 245 | `define FLASH_INFO_MEM_HIER_STR(i, j) \ |
Timothy Chen | fb8a784 | 2021-08-20 00:23:47 -0700 | [diff] [blame] | 246 | $sformatf({"tb.dut.u_eflash.u_flash.gen_generic.u_impl_generic.", \ |
Srikrishna Iyer | 59b74f6 | 2021-06-05 00:35:43 -0700 | [diff] [blame] | 247 | "gen_prim_flash_banks[%0d].u_prim_flash_bank.gen_info_types[%0d].", \ |
| 248 | "u_info_mem.gen_generic.u_impl_generic.mem"}, i, j) |
Srikrishna Iyer | 6ff88ed | 2020-07-10 16:29:26 -0700 | [diff] [blame] | 249 | |
Srikrishna Iyer | 59b74f6 | 2021-06-05 00:35:43 -0700 | [diff] [blame] | 250 | if (`PRIM_DEFAULT_IMPL == prim_pkg::ImplGeneric) begin : gen_generic |
| 251 | for (genvar i = 0; i < flash_ctrl_pkg::NumBanks; i++) begin : gen_each_bank |
Eitan Shapira | 0e0a74b | 2021-03-01 17:17:48 +0200 | [diff] [blame] | 252 | flash_dv_part_e part = part.first(); |
| 253 | |
Eitan Shapira | 0e0a74b | 2021-03-01 17:17:48 +0200 | [diff] [blame] | 254 | initial begin |
Srikrishna Iyer | 20c3149 | 2022-01-31 12:17:57 -0800 | [diff] [blame] | 255 | flash_mem_bkdr_util m_mem_bkdr_util; |
Nikola Miladinovic | ae005eb | 2021-12-09 15:34:02 +0000 | [diff] [blame] | 256 | m_mem_bkdr_util = new( |
| 257 | .name($sformatf("mem_bkdr_util[%0s][%0d]", part.name(), i)), |
| 258 | .path(`FLASH_DATA_MEM_HIER_STR(i)), |
| 259 | .depth($size(`FLASH_DATA_MEM_HIER(i))), |
| 260 | .n_bits($bits(`FLASH_DATA_MEM_HIER(i))), |
| 261 | .err_detection_scheme(mem_bkdr_util_pkg::EccHamming_76_68) |
| 262 | ); |
Srikrishna Iyer | 59b74f6 | 2021-06-05 00:35:43 -0700 | [diff] [blame] | 263 | uvm_config_db#(mem_bkdr_util)::set(null, "*.env", m_mem_bkdr_util.get_name(), |
| 264 | m_mem_bkdr_util); |
Eitan Shapira | 0e0a74b | 2021-03-01 17:17:48 +0200 | [diff] [blame] | 265 | part = part.next(); |
Eitan Shapira | 0e0a74b | 2021-03-01 17:17:48 +0200 | [diff] [blame] | 266 | end |
| 267 | |
Srikrishna Iyer | 59b74f6 | 2021-06-05 00:35:43 -0700 | [diff] [blame] | 268 | for (genvar j = 0; j < flash_ctrl_pkg::InfoTypes; j++) begin : gen_each_info_type |
| 269 | initial begin |
Srikrishna Iyer | 20c3149 | 2022-01-31 12:17:57 -0800 | [diff] [blame] | 270 | flash_mem_bkdr_util m_mem_bkdr_util; |
Nikola Miladinovic | ae005eb | 2021-12-09 15:34:02 +0000 | [diff] [blame] | 271 | m_mem_bkdr_util = new( |
| 272 | .name($sformatf("mem_bkdr_util[%0s][%0d]", part.name(), i)), |
| 273 | .path(`FLASH_INFO_MEM_HIER_STR(i, j)), |
| 274 | .depth($size(`FLASH_INFO_MEM_HIER(i, j))), |
| 275 | .n_bits($bits(`FLASH_INFO_MEM_HIER(i, j))), |
| 276 | .err_detection_scheme(mem_bkdr_util_pkg::EccHamming_76_68) |
| 277 | ); |
Srikrishna Iyer | 59b74f6 | 2021-06-05 00:35:43 -0700 | [diff] [blame] | 278 | uvm_config_db#(mem_bkdr_util)::set(null, "*.env", m_mem_bkdr_util.get_name(), |
| 279 | m_mem_bkdr_util); |
| 280 | part = part.next(); |
| 281 | end |
| 282 | end : gen_each_info_type |
Eitan Shapira | 0e0a74b | 2021-03-01 17:17:48 +0200 | [diff] [blame] | 283 | |
Srikrishna Iyer | fe8a53a | 2022-08-30 11:32:56 -0700 | [diff] [blame] | 284 | bind `FLASH_BANK_HIER(i) flash_ctrl_mem_if flash_ctrl_mem_if ( |
| 285 | .clk_i, |
| 286 | .rst_ni, |
| 287 | .data_mem_req, |
| 288 | .mem_wr, |
| 289 | .mem_addr, |
| 290 | .mem_wdata, |
| 291 | .mem_part, |
| 292 | .mem_info_sel, |
| 293 | .info0_mem_req (gen_info_types[0].info_mem_req), |
| 294 | .info1_mem_req (gen_info_types[1].info_mem_req), |
| 295 | .info2_mem_req (gen_info_types[2].info_mem_req) |
| 296 | ); |
| 297 | initial begin |
| 298 | uvm_config_db#(virtual flash_ctrl_mem_if)::set(null, "*.env", |
| 299 | $sformatf("flash_ctrl_mem_vif[%0d]", i), `FLASH_BANK_HIER(i).flash_ctrl_mem_if); |
| 300 | end |
| 301 | |
Srikrishna Iyer | 59b74f6 | 2021-06-05 00:35:43 -0700 | [diff] [blame] | 302 | end : gen_each_bank |
| 303 | end : gen_generic |
Eitan Shapira | 0e0a74b | 2021-03-01 17:17:48 +0200 | [diff] [blame] | 304 | |
Srikrishna Iyer | fe8a53a | 2022-08-30 11:32:56 -0700 | [diff] [blame] | 305 | `undef FLASH_BANK_HIER |
Srikrishna Iyer | 6ff88ed | 2020-07-10 16:29:26 -0700 | [diff] [blame] | 306 | `undef FLASH_DATA_MEM_HIER |
| 307 | `undef FLASH_INFO_MEM_HIER |
Srikrishna Iyer | b29ebe8 | 2020-05-20 11:29:25 -0700 | [diff] [blame] | 308 | |
| 309 | // Connect the interrupts |
| 310 | assign interrupts[FlashCtrlIntrProgEmpty] = intr_prog_empty; |
| 311 | assign interrupts[FlashCtrlIntrProgLvl] = intr_prog_lvl; |
| 312 | assign interrupts[FlashCtrlIntrRdFull] = intr_rd_full; |
| 313 | assign interrupts[FlashCtrlIntrRdLvl] = intr_rd_lvl; |
| 314 | assign interrupts[FlashCtrlIntrOpDone] = intr_op_done; |
Srikrishna Iyer | 5311829 | 2021-06-17 00:50:00 -0700 | [diff] [blame] | 315 | assign interrupts[FlashCtrlIntrErr] = intr_err; |
Srikrishna Iyer | b29ebe8 | 2020-05-20 11:29:25 -0700 | [diff] [blame] | 316 | |
| 317 | initial begin |
| 318 | // drive clk and rst_n from clk_if |
| 319 | clk_rst_if.set_active(); |
| 320 | uvm_config_db#(virtual clk_rst_if)::set(null, "*.env", "clk_rst_vif", clk_rst_if); |
Nikola Miladinovic | ae005eb | 2021-12-09 15:34:02 +0000 | [diff] [blame] | 321 | uvm_config_db#(virtual clk_rst_if)::set(null, "*.env", |
| 322 | "clk_rst_vif_flash_ctrl_eflash_reg_block", clk_rst_if); |
Jaedon Kim | 4410d45 | 2022-08-03 23:30:30 +0000 | [diff] [blame] | 323 | uvm_config_db#(virtual clk_rst_if)::set(null, "*.env", |
| 324 | "clk_rst_vif_flash_ctrl_prim_reg_block", clk_rst_if); |
| 325 | |
Cindy Chen | 1c5b13c | 2021-11-12 16:39:57 -0800 | [diff] [blame] | 326 | uvm_config_db#(virtual rst_shadowed_if)::set(null, "*.env", "rst_shadowed_vif", |
| 327 | rst_shadowed_if); |
Srikrishna Iyer | b29ebe8 | 2020-05-20 11:29:25 -0700 | [diff] [blame] | 328 | uvm_config_db#(intr_vif)::set(null, "*.env", "intr_vif", intr_if); |
| 329 | uvm_config_db#(devmode_vif)::set(null, "*.env", "devmode_vif", devmode_if); |
Weicai Yang | a1a444c | 2021-04-09 17:55:57 -0700 | [diff] [blame] | 330 | uvm_config_db#(virtual tl_if)::set(null, "*.env.m_tl_agent_flash_ctrl_core_reg_block*", "vif", |
| 331 | tl_if); |
Nikola Miladinovic | ae005eb | 2021-12-09 15:34:02 +0000 | [diff] [blame] | 332 | uvm_config_db#(virtual tl_if)::set(null, "*.env.m_tl_agent_flash_ctrl_eflash_reg_block*", "vif", |
| 333 | eflash_tl_if); |
Jaedon Kim | 4410d45 | 2022-08-03 23:30:30 +0000 | [diff] [blame] | 334 | uvm_config_db#(virtual tl_if)::set(null, "*.env.m_tl_agent_flash_ctrl_prim_reg_block*", "vif", |
| 335 | prim_tl_if); |
Nikola Miladinovic | 537937a | 2021-11-22 15:42:23 +0000 | [diff] [blame] | 336 | uvm_config_db#(virtual flash_ctrl_if)::set(null, "*.env", "flash_ctrl_vif", flash_ctrl_if); |
Jaedon Kim | ee48b8f | 2022-06-17 17:26:30 +0000 | [diff] [blame] | 337 | uvm_config_db#(virtual flash_phy_prim_if)::set(null, "*.env.m_fpp_agent*", "vif", fpp_if); |
| 338 | $timeformat(-9, 1, " ns", 9); |
Srikrishna Iyer | b29ebe8 | 2020-05-20 11:29:25 -0700 | [diff] [blame] | 339 | run_test(); |
| 340 | end |
| 341 | |
| 342 | endmodule |