blob: df771e88645757fd37101a9953a11c1aa3e97451 [file] [log] [blame]
lowRISC Contributors802543a2019-08-31 12:12:56 +01001// Copyright lowRISC contributors.
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4
5package cip_base_pkg;
6 // dep packages
7 import uvm_pkg::*;
Srikrishna Iyer191408b2020-07-23 10:52:32 -07008 import bus_params_pkg::*;
lowRISC Contributors802543a2019-08-31 12:12:56 +01009 import dv_utils_pkg::*;
10 import csr_utils_pkg::*;
11 import dv_lib_pkg::*;
Weicai Yang0408a4e2020-06-04 15:03:50 -070012 import dv_base_reg_pkg::*;
Weicai Yang9e325a62021-03-19 11:56:15 -070013 import tlul_pkg::*;
lowRISC Contributors802543a2019-08-31 12:12:56 +010014 import tl_agent_pkg::*;
Cindy Chen12f2f882020-01-17 16:13:52 -080015 import alert_esc_agent_pkg::*;
Cindy Chen49c187f2020-12-09 12:25:40 -080016 import push_pull_agent_pkg::*;
Weicai Yang6cd84102020-06-10 19:03:24 -070017 import mem_model_pkg::*;
lowRISC Contributors802543a2019-08-31 12:12:56 +010018
19 // macro includes
20 `include "uvm_macros.svh"
21 `include "dv_macros.svh"
Weicai Yangdb58f642021-01-27 14:05:45 -080022 `include "cip_macros.svh"
lowRISC Contributors802543a2019-08-31 12:12:56 +010023
24 // package variables
25 string msg_id = "cip_base_pkg";
Cindy Chen78a7a132020-12-23 15:16:16 -080026 parameter uint EDN_BUS_WIDTH = 32;
27 parameter uint EDN_DATA_WIDTH = EDN_BUS_WIDTH + 1; // 32 bits bus data, 1 bit fips
Weicai Yang31b925a2021-06-08 17:43:18 -070028 parameter uint MAX_TL_ECC_ERRORS = 3;
lowRISC Contributors802543a2019-08-31 12:12:56 +010029
Cindy Chena72a6362020-09-02 10:11:28 -070030 typedef enum {
31 err_update,
32 err_storage
33 } shadow_reg_alert_e;
34
Weicai Yang0e8de612021-06-06 23:14:30 -070035 typedef enum bit [1:0] {
36 TlIntgErrNone,
37 TlIntgErrCmd,
38 TlIntgErrData,
Weicai Yang31b925a2021-06-08 17:43:18 -070039 TlIntgErrBoth // Inject errors in both command and data.
Weicai Yang0e8de612021-06-06 23:14:30 -070040 } tl_intg_err_e;
41
Weicai Yang9e325a62021-03-19 11:56:15 -070042 typedef class cip_tl_seq_item;
43
lowRISC Contributors802543a2019-08-31 12:12:56 +010044 // functions
Weicai Yang7c33aa42021-06-21 18:09:56 -070045 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 Yang931f1202021-06-30 10:09:11 -070057 output bit has_mem_byte_access_err,
Weicai Yang7c33aa42021-06-21 18:09:56 -070058 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 Yang931f1202021-06-30 10:09:11 -070066 if (!dv_mem.get_mem_partial_write_support()) has_mem_byte_access_err = 1;
Weicai Yang7c33aa42021-06-21 18:09:56 -070067 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 Contributors802543a2019-08-31 12:12:56 +010072 // 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 Yang9e325a62021-03-19 11:56:15 -070081 `include "cip_seq_list.sv"
lowRISC Contributors802543a2019-08-31 12:12:56 +010082
83 // tests
84 `include "cip_base_test.sv"
85
86endpackage