lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [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 | package cip_base_pkg; |
| 6 | // dep packages |
| 7 | import uvm_pkg::*; |
Srikrishna Iyer | 191408b | 2020-07-23 10:52:32 -0700 | [diff] [blame] | 8 | import bus_params_pkg::*; |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 9 | import dv_utils_pkg::*; |
| 10 | import csr_utils_pkg::*; |
| 11 | import dv_lib_pkg::*; |
Weicai Yang | 0408a4e | 2020-06-04 15:03:50 -0700 | [diff] [blame] | 12 | import dv_base_reg_pkg::*; |
Weicai Yang | 9e325a6 | 2021-03-19 11:56:15 -0700 | [diff] [blame] | 13 | import tlul_pkg::*; |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 14 | import tl_agent_pkg::*; |
Cindy Chen | 12f2f88 | 2020-01-17 16:13:52 -0800 | [diff] [blame] | 15 | import alert_esc_agent_pkg::*; |
Cindy Chen | 49c187f | 2020-12-09 12:25:40 -0800 | [diff] [blame] | 16 | import push_pull_agent_pkg::*; |
Weicai Yang | 6cd8410 | 2020-06-10 19:03:24 -0700 | [diff] [blame] | 17 | import mem_model_pkg::*; |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 18 | |
| 19 | // macro includes |
| 20 | `include "uvm_macros.svh" |
| 21 | `include "dv_macros.svh" |
Weicai Yang | db58f64 | 2021-01-27 14:05:45 -0800 | [diff] [blame] | 22 | `include "cip_macros.svh" |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 23 | |
| 24 | // package variables |
| 25 | string msg_id = "cip_base_pkg"; |
Cindy Chen | 78a7a13 | 2020-12-23 15:16:16 -0800 | [diff] [blame] | 26 | parameter uint EDN_BUS_WIDTH = 32; |
| 27 | parameter uint EDN_DATA_WIDTH = EDN_BUS_WIDTH + 1; // 32 bits bus data, 1 bit fips |
Weicai Yang | 31b925a | 2021-06-08 17:43:18 -0700 | [diff] [blame] | 28 | parameter uint MAX_TL_ECC_ERRORS = 3; |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 29 | |
Cindy Chen | a72a636 | 2020-09-02 10:11:28 -0700 | [diff] [blame] | 30 | typedef enum { |
| 31 | err_update, |
| 32 | err_storage |
| 33 | } shadow_reg_alert_e; |
| 34 | |
Weicai Yang | 0e8de61 | 2021-06-06 23:14:30 -0700 | [diff] [blame] | 35 | typedef enum bit [1:0] { |
| 36 | TlIntgErrNone, |
| 37 | TlIntgErrCmd, |
| 38 | TlIntgErrData, |
Weicai Yang | 31b925a | 2021-06-08 17:43:18 -0700 | [diff] [blame] | 39 | TlIntgErrBoth // Inject errors in both command and data. |
Weicai Yang | 0e8de61 | 2021-06-06 23:14:30 -0700 | [diff] [blame] | 40 | } tl_intg_err_e; |
| 41 | |
Weicai Yang | 9e325a6 | 2021-03-19 11:56:15 -0700 | [diff] [blame] | 42 | typedef class cip_tl_seq_item; |
| 43 | |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 44 | // functions |
Weicai Yang | 7c33aa4 | 2021-06-21 18:09:56 -0700 | [diff] [blame] | 45 | function automatic tl_intg_err_e get_tl_intg_err_type(bit is_cmd_ok, bit is_data_ok); |
| 46 | case ({is_cmd_ok, is_data_ok}) |
| 47 | 2'b11: return TlIntgErrNone; |
| 48 | 2'b01: return TlIntgErrCmd; |
| 49 | 2'b10: return TlIntgErrData; |
| 50 | 2'b00: return TlIntgErrBoth; |
| 51 | default: ; |
| 52 | endcase |
| 53 | endfunction |
| 54 | |
| 55 | // get mem attributes to know what error cases can be triggered |
| 56 | function automatic void get_all_mem_attrs(input dv_base_reg_block reg_block, |
Weicai Yang | 931f120 | 2021-06-30 10:09:11 -0700 | [diff] [blame^] | 57 | output bit has_mem_byte_access_err, |
Weicai Yang | 7c33aa4 | 2021-06-21 18:09:56 -0700 | [diff] [blame] | 58 | output bit has_wo_mem, |
| 59 | output bit has_ro_mem); |
| 60 | uvm_mem mems[$]; |
| 61 | reg_block.get_memories(mems); |
| 62 | |
| 63 | foreach (mems[i]) begin |
| 64 | dv_base_mem dv_mem; |
| 65 | `downcast(dv_mem, mems[i], , , msg_id) |
Weicai Yang | 931f120 | 2021-06-30 10:09:11 -0700 | [diff] [blame^] | 66 | if (!dv_mem.get_mem_partial_write_support()) has_mem_byte_access_err = 1; |
Weicai Yang | 7c33aa4 | 2021-06-21 18:09:56 -0700 | [diff] [blame] | 67 | if (dv_mem.get_access() == "WO") has_wo_mem = 1; |
| 68 | if (dv_mem.get_access() == "RO") has_ro_mem = 1; |
| 69 | end |
| 70 | endfunction |
| 71 | |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 72 | // package sources |
| 73 | // base env |
| 74 | `include "cip_base_env_cfg.sv" |
| 75 | `include "cip_base_env_cov.sv" |
| 76 | `include "cip_base_virtual_sequencer.sv" |
| 77 | `include "cip_base_scoreboard.sv" |
| 78 | `include "cip_base_env.sv" |
| 79 | |
| 80 | // sequences |
Weicai Yang | 9e325a6 | 2021-03-19 11:56:15 -0700 | [diff] [blame] | 81 | `include "cip_seq_list.sv" |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 82 | |
| 83 | // tests |
| 84 | `include "cip_base_test.sv" |
| 85 | |
| 86 | endpackage |