diff --git a/bin/clonetb b/bin/clonetb index d467751a87..63157fc7ea 100755 --- a/bin/clonetb +++ b/bin/clonetb @@ -81,8 +81,7 @@ clone() { clone_cv32e40x() { CV_CORE=cv32e40x VERIF_ENV_REPO=https://github.com/openhwgroup/cv32e40x-dv.git - VERIF_ENV_REF=443f11c - + VERIF_ENV_REF=be17b8902002f91803abde4bfb8caa91088575e1 clone ignore_cloned_directory diff --git a/bin/gen_csr_access_test.py b/bin/gen_csr_access_test.py old mode 100644 new mode 100755 index 3601544ae0..889a0b0fe4 --- a/bin/gen_csr_access_test.py +++ b/bin/gen_csr_access_test.py @@ -1,3 +1,34 @@ +#!/usr/bin/env python3 + + +# Copyright 2023 Silicon Labs, Inc. +# +# SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 +# +# Licensed under the Solderpad Hardware License v 2.1 (the "License"); you may +# not use this file except in compliance with the License, or, at your option, +# the Apache License version 2.0. +# +# You may obtain a copy of the License at +# https://solderpad.org/licenses/SHL-2.1/ +# +# Unless required by applicable law or agreed to in writing, any work +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# +# See the License for the specific language governing permissions and +# limitations under the License. + + +# Description: +# This script is for generating the CSR access test: +# `cv32e40(s|x)/tests/programs/custom/cv32e40x_csr_access_test/`. +# +# It calls a generation script within `riscv-dv`. +# A Yaml config as per `--input_yaml_path` is used as its input. +# See the README in the path mention above for additional usage info. + + import sys import os import argparse @@ -5,6 +36,7 @@ import yaml import shlex + if (sys.version_info < (3,5,0)): print ('Requires python 3.5') exit(1) @@ -108,47 +140,28 @@ def run_riscv_dv_gen_csr_script(output_yaml_path): print("error: exception in 'run_riscv_dv_gen_csr_script'") print(e) -def preprocess_yaml(): - input_script_path = yaml_file_path - w_enable = True - w_enable_n = w_enable - str_args = "" - enabled_features = { - "clic": False, - "clint": False, - "debug": False, - "e_base": False, - "i_base": False, - "m_ext": False, - "m_none": False, - "readonly": False, - "umode": False, - "a_ext": False, - "f_ext": False, - "p_ext": False, - "v_ext": False, - "x_ext": False, - "xsecure": False, - "zc": False, - "zicntr": False, - "marchid": 0, - "num_mhpmcounters": 0, - "pmp_num_regions": 0, - "dbg_num_triggers": 0, - } +def set_enabled_features(enabled_features_previous, str_args_previous, args): + enabled_features = enabled_features_previous + str_args = str_args_previous + + # "VERIF_HEADER" (Design-workaround for CSR field alternatives.) + enabled_features["verif_header"] = True # CLIC if (args.clic_enable): str_args = str_args + "_clic" enabled_features["clic"] = True + # CLINT if (args.clint_enable or not args.clic_enable): str_args = str_args + "_clint" enabled_features["clint"] = True if not enabled_features["clic"] else False + # DEBUG if (args.debug_enable): str_args = str_args + "_debug" enabled_features["debug"] = True + # I/E if (args.i_base_enable or args.i_ext_enable): str_args = str_args + "_i" @@ -161,6 +174,7 @@ def preprocess_yaml(): exit(1) if (args.i_ext_enable or args.e_ext_enable): print("warning: i and e are 'base' modules, not extensions", file=sys.stderr) + # M if (args.m_ext_enable): str_args = str_args + "_m" @@ -171,59 +185,105 @@ def preprocess_yaml(): else: print("error: need '--m_ext_enable' or '--m_none_enable'", file=sys.stderr) exit(1) + # A_EXT if (args.a_ext_enable): str_args = str_args + "_a" enabled_features["a_ext"] = True + # F_EXT if (args.f_ext_enable): str_args = str_args + "_f" enabled_features["f_ext"] = True + # P_EXT if (args.p_ext_enable): str_args = str_args + "_p" enabled_features["p_ext"] = True + # V_EXT if (args.v_ext_enable): str_args = str_args + "_v" enabled_features["v_ext"] = True + # X_EXT if (args.x_ext_enable): str_args = str_args + "_x" enabled_features["x_ext"] = True + # XSECURE if (args.xsecure_enable): str_args = str_args + "_xsecure" enabled_features["xsecure"] = True + # UMODE if (args.umode_enable): str_args = str_args + "_umode" enabled_features["umode"] = True + # ZC if (args.zc_enable): str_args = str_args + "_zc" enabled_features["zc"] = True + # ZICNTR if (args.zicntr_enable): str_args = str_args + "_zicntr" enabled_features["zicntr"] = True + # MARCHID if (int(args.marchid) > 0): str_args = str_args + "_marchid" + args.marchid enabled_features["marchid"] = int(args.marchid) + # MHPMCOUNTERS if (int(args.mhpmcounter_num) > 0): str_args = str_args + "_mhpmctr" + args.mhpmcounter_num enabled_features["num_mhpmcounters"] = int(args.mhpmcounter_num) + # PMP if (int(args.pmp_num_regions) > 0): str_args = str_args + "_pmp" + args.pmp_num_regions enabled_features["pmp_num_regions"] = int(args.pmp_num_regions) + # TRIGGERS if (int(args.num_triggers) > 0): str_args = str_args + "_triggers" + args.num_triggers enabled_features["dbg_num_triggers"] = int(args.num_triggers) - # TODO:silabs-robin Any other "enabled_features"? + + return (enabled_features, str_args) + +def preprocess_yaml(): + input_script_path = yaml_file_path + w_enable = True + w_enable_n = w_enable + str_args = "" + enabled_features = { + "clic": False, + "clint": False, + "debug": False, + "e_base": False, + "i_base": False, + "m_ext": False, + "m_none": False, + "readonly": False, + "umode": False, + "a_ext": False, + "f_ext": False, + "p_ext": False, + "v_ext": False, + "x_ext": False, + "xsecure": False, + "zc": False, + "zicntr": False, + "marchid": 0, + "num_mhpmcounters": 0, + "pmp_num_regions": 0, + "dbg_num_triggers": 0, + } + + (enabled_features, str_args) = \ + set_enabled_features(enabled_features, str_args, args) print("enabled_features: {}".format(enabled_features)) @@ -320,7 +380,7 @@ def preprocess_yaml_m4(enabled_features, input_script_path, output_script_handle # Run the preprocessing args = args_pre + args_mid + args_post - print('running m4 as: ' + str(args)) # TODO:silabs-robin "if '--verbose'" + print('running m4 as: ' + str(args)) proc_results = subprocess.run(args, stdout=output_script_handle) if proc_results.returncode != 0: diff --git a/cv32e40s/tb/uvmt/uvmt_cv32e40s_umode_assert.sv b/cv32e40s/tb/assertions/uvmt_cv32e40s_umode_assert.sv similarity index 98% rename from cv32e40s/tb/uvmt/uvmt_cv32e40s_umode_assert.sv rename to cv32e40s/tb/assertions/uvmt_cv32e40s_umode_assert.sv index fa86e34698..67dd3cff70 100644 --- a/cv32e40s/tb/uvmt/uvmt_cv32e40s_umode_assert.sv +++ b/cv32e40s/tb/assertions/uvmt_cv32e40s_umode_assert.sv @@ -932,21 +932,21 @@ module uvmt_cv32e40s_umode_assert // vplan:InstrProt - a_instr_prot: assert property ( + a_rvfi_instr_prot: assert property ( rvfi_valid |-> - (rvfi_if.instr_prot[2:1] == rvfi_if.rvfi_mode) || + (rvfi_if.rvfi_instr_prot[2:1] == rvfi_if.rvfi_mode) || (rvfi_if.rvfi_trap.exception_cause == cv32e40s_pkg::EXC_CAUSE_INSTR_FAULT) || (rvfi_trap.debug_cause == DBG_CAUSE_TRIGGER) //Note: Triggers can overshadow access faults ) else `uvm_error(info_tag, "the prot on fetch must match the mode on retirement"); - a_instr_prot_legal: assert property ( + a_rvfi_instr_prot_legal: assert property ( rvfi_valid && (rvfi_if.rvfi_trap.exception_cause != cv32e40s_pkg::EXC_CAUSE_INSTR_FAULT) |-> - (rvfi_if.instr_prot[2:0] inside {3'b 000, 3'b 110}) - ) else `uvm_error(info_tag, "instr_prot illegal value"); + (rvfi_if.rvfi_instr_prot[2:0] inside {3'b 000, 3'b 110}) + ) else `uvm_error(info_tag, "rvfi_instr_prot illegal value"); a_prot_iside_legal: assert property ( obi_iside_prot inside {3'b 000, 3'b 110} @@ -959,14 +959,14 @@ module uvmt_cv32e40s_umode_assert rvfi_valid && (rvfi_if.rvfi_mem_rmask || rvfi_if.rvfi_mem_wmask) |-> - (rvfi_if.mem_prot[2:1] == effective_rvfi_privmode) + (rvfi_if.rvfi_mem_prot[2:1] == effective_rvfi_privmode) ) else `uvm_error(info_tag, "the prot on load/store must match the effective mode on retirement"); a_data_prot_legal: assert property ( rvfi_valid && (rvfi_if.rvfi_trap.exception_cause != cv32e40s_pkg::EXC_CAUSE_INSTR_FAULT) |-> - (rvfi_if.mem_prot[2:0] inside {3'b 001, 3'b 111}) + (rvfi_if.rvfi_mem_prot[2:0] inside {3'b 001, 3'b 111}) ) else `uvm_error(info_tag, "data_prot illegal value"); a_prot_dside_legal: assert property ( @@ -977,7 +977,7 @@ module uvmt_cv32e40s_umode_assert logic [NMEM-1:0] mem_act; for (genvar i = 0; i < NMEM; i++) begin: gen_data_prot_equals always_comb begin - data_prot_equals[i] = (rvfi_if.mem_prot[i*3+:3] == rvfi_if.mem_prot[2:0]); + data_prot_equals[i] = (rvfi_if.rvfi_mem_prot[i*3+:3] == rvfi_if.rvfi_mem_prot[2:0]); mem_act[i] = |rvfi_if.check_mem_act(i); end end @@ -1008,7 +1008,7 @@ module uvmt_cv32e40s_umode_assert rvfi_if.rvfi_valid && rvfi_if.rvfi_dbg_mode |-> - (rvfi_if.instr_prot[2:1] == MODE_M) || + (rvfi_if.rvfi_instr_prot[2:1] == MODE_M) || (rvfi_if.rvfi_trap.exception_cause == cv32e40s_pkg::EXC_CAUSE_INSTR_FAULT) ) else `uvm_error(info_tag, "dmode should fetch as mmode"); @@ -1017,7 +1017,7 @@ module uvmt_cv32e40s_umode_assert rvfi_valid && (|rvfi_if.rvfi_mem_rmask || |rvfi_if.rvfi_mem_wmask) |-> - (rvfi_if.mem_prot[2:1] == effective_rvfi_privmode) + (rvfi_if.rvfi_mem_prot[2:1] == effective_rvfi_privmode) ) else `uvm_error(info_tag, "dmode should fetch as effective mode"); diff --git a/cv32e40s/tb/uvmt/uvmt_cv32e40s_umode_cov.sv b/cv32e40s/tb/assertions/uvmt_cv32e40s_umode_cov.sv similarity index 100% rename from cv32e40s/tb/uvmt/uvmt_cv32e40s_umode_cov.sv rename to cv32e40s/tb/assertions/uvmt_cv32e40s_umode_cov.sv diff --git a/cv32e40s/tb/uvmt/uvmt_cv32e40s_tb.sv b/cv32e40s/tb/uvmt/uvmt_cv32e40s_tb.sv index 9be0477378..6cf84133ea 100644 --- a/cv32e40s/tb/uvmt/uvmt_cv32e40s_tb.sv +++ b/cv32e40s/tb/uvmt/uvmt_cv32e40s_tb.sv @@ -164,45 +164,55 @@ module uvmt_cv32e40s_tb; // "rvfi_instr_if" bind cv32e40s_wrapper - uvma_rvfi_instr_if_t#(uvmt_cv32e40s_base_test_pkg::ILEN, - uvmt_cv32e40s_base_test_pkg::XLEN) rvfi_instr_if(.clk(clk_i), - .reset_n(rst_ni), - - .rvfi_valid(rvfi_i.rvfi_valid[0]), - .rvfi_order(rvfi_i.rvfi_order[uvma_rvfi_pkg::ORDER_WL*0+:uvma_rvfi_pkg::ORDER_WL]), - .rvfi_insn(rvfi_i.rvfi_insn[uvmt_cv32e40s_base_test_pkg::ILEN*0+:uvmt_cv32e40s_base_test_pkg::ILEN]), - .rvfi_trap(rvfi_i.rvfi_trap), - .rvfi_halt(rvfi_i.rvfi_halt[0]), - .rvfi_intr(rvfi_i.rvfi_intr), - .rvfi_dbg(rvfi_i.rvfi_dbg), - .rvfi_dbg_mode(rvfi_i.rvfi_dbg_mode), - .rvfi_nmip(rvfi_i.rvfi_nmip), - .rvfi_mode(rvfi_i.rvfi_mode[uvma_rvfi_pkg::MODE_WL*0+:uvma_rvfi_pkg::MODE_WL]), - .rvfi_ixl(rvfi_i.rvfi_ixl[uvma_rvfi_pkg::IXL_WL*0+:uvma_rvfi_pkg::IXL_WL]), - .rvfi_pc_rdata(rvfi_i.rvfi_pc_rdata[uvmt_cv32e40s_base_test_pkg::XLEN*0+:uvmt_cv32e40s_base_test_pkg::XLEN]), - .rvfi_pc_wdata(rvfi_i.rvfi_pc_wdata[uvmt_cv32e40s_base_test_pkg::XLEN*0+:uvmt_cv32e40s_base_test_pkg::XLEN]), - .rvfi_rs1_addr(rvfi_i.rvfi_rs1_addr[uvma_rvfi_pkg::GPR_ADDR_WL*0+:uvma_rvfi_pkg::GPR_ADDR_WL]), - .rvfi_rs1_rdata(rvfi_i.rvfi_rs1_rdata[uvmt_cv32e40s_base_test_pkg::XLEN*0+:uvmt_cv32e40s_base_test_pkg::XLEN]), - .rvfi_rs2_addr(rvfi_i.rvfi_rs2_addr[uvma_rvfi_pkg::GPR_ADDR_WL*0+:uvma_rvfi_pkg::GPR_ADDR_WL]), - .rvfi_rs2_rdata(rvfi_i.rvfi_rs2_rdata[uvmt_cv32e40s_base_test_pkg::XLEN*0+:uvmt_cv32e40s_base_test_pkg::XLEN]), - .rvfi_rs3_addr('0), - .rvfi_rs3_rdata('0), - .rvfi_rd1_addr(rvfi_i.rvfi_rd_addr[uvma_rvfi_pkg::GPR_ADDR_WL*0+:uvma_rvfi_pkg::GPR_ADDR_WL]), - .rvfi_rd1_wdata(rvfi_i.rvfi_rd_wdata[uvmt_cv32e40s_base_test_pkg::XLEN*0+:uvmt_cv32e40s_base_test_pkg::XLEN]), - .rvfi_rd2_addr('0), - .rvfi_rd2_wdata('0), - .rvfi_gpr_rdata(rvfi_i.rvfi_gpr_rdata[32*uvmt_cv32e40s_base_test_pkg::XLEN*0 +:32*uvmt_cv32e40s_base_test_pkg::XLEN]), - .rvfi_gpr_rmask(rvfi_i.rvfi_gpr_rmask[32*0 +:32]), - .rvfi_gpr_wdata(rvfi_i.rvfi_gpr_wdata[32*uvmt_cv32e40s_base_test_pkg::XLEN*0 +:32*uvmt_cv32e40s_base_test_pkg::XLEN]), - .rvfi_gpr_wmask(rvfi_i.rvfi_gpr_wmask[32*0 +:32]), - .rvfi_mem_addr(rvfi_i.rvfi_mem_addr[ uvma_rvfi_pkg::NMEM*uvmt_cv32e40s_base_test_pkg::XLEN*0 +:uvma_rvfi_pkg::NMEM*uvmt_cv32e40s_base_test_pkg::XLEN]), - .rvfi_mem_rdata(rvfi_i.rvfi_mem_rdata[uvma_rvfi_pkg::NMEM*uvmt_cv32e40s_base_test_pkg::XLEN*0 +:uvma_rvfi_pkg::NMEM*uvmt_cv32e40s_base_test_pkg::XLEN]), - .rvfi_mem_rmask(rvfi_i.rvfi_mem_rmask[uvma_rvfi_pkg::NMEM*uvmt_cv32e40s_base_test_pkg::XLEN/8*0 +:uvma_rvfi_pkg::NMEM*uvmt_cv32e40s_base_test_pkg::XLEN/8]), - .rvfi_mem_wdata(rvfi_i.rvfi_mem_wdata[uvma_rvfi_pkg::NMEM*uvmt_cv32e40s_base_test_pkg::XLEN*0 +:uvma_rvfi_pkg::NMEM*uvmt_cv32e40s_base_test_pkg::XLEN]), - .rvfi_mem_wmask(rvfi_i.rvfi_mem_wmask[uvma_rvfi_pkg::NMEM*uvmt_cv32e40s_base_test_pkg::XLEN/8*0 +:uvma_rvfi_pkg::NMEM*uvmt_cv32e40s_base_test_pkg::XLEN/8]), - .instr_prot(rvfi_i.rvfi_instr_prot), - .mem_prot(rvfi_i.rvfi_mem_prot) - ); + uvma_rvfi_instr_if_t#( + uvmt_cv32e40s_base_test_pkg::ILEN, + uvmt_cv32e40s_base_test_pkg::XLEN + ) rvfi_instr_if( + .clk (clk_i), + .reset_n (rst_ni), + + .rvfi_valid (rvfi_i.rvfi_valid[0]), + .rvfi_order (rvfi_i.rvfi_order[uvma_rvfi_pkg::ORDER_WL*0+:uvma_rvfi_pkg::ORDER_WL]), + .rvfi_insn (rvfi_i.rvfi_insn[uvmt_cv32e40s_base_test_pkg::ILEN*0+:uvmt_cv32e40s_base_test_pkg::ILEN]), + .rvfi_trap (rvfi_i.rvfi_trap), + .rvfi_halt (rvfi_i.rvfi_halt[0]), + .rvfi_intr (rvfi_i.rvfi_intr), + .rvfi_dbg (rvfi_i.rvfi_dbg), + .rvfi_dbg_mode (rvfi_i.rvfi_dbg_mode), + .rvfi_nmip (rvfi_i.rvfi_nmip), + .rvfi_mode (rvfi_i.rvfi_mode[uvma_rvfi_pkg::MODE_WL*0+:uvma_rvfi_pkg::MODE_WL]), + .rvfi_ixl (rvfi_i.rvfi_ixl[uvma_rvfi_pkg::IXL_WL*0+:uvma_rvfi_pkg::IXL_WL]), + .rvfi_pc_rdata (rvfi_i.rvfi_pc_rdata[uvmt_cv32e40s_base_test_pkg::XLEN*0+:uvmt_cv32e40s_base_test_pkg::XLEN]), + .rvfi_pc_wdata (rvfi_i.rvfi_pc_wdata[uvmt_cv32e40s_base_test_pkg::XLEN*0+:uvmt_cv32e40s_base_test_pkg::XLEN]), + .rvfi_rs1_addr (rvfi_i.rvfi_rs1_addr[uvma_rvfi_pkg::GPR_ADDR_WL*0+:uvma_rvfi_pkg::GPR_ADDR_WL]), + .rvfi_rs1_rdata (rvfi_i.rvfi_rs1_rdata[uvmt_cv32e40s_base_test_pkg::XLEN*0+:uvmt_cv32e40s_base_test_pkg::XLEN]), + .rvfi_rs2_addr (rvfi_i.rvfi_rs2_addr[uvma_rvfi_pkg::GPR_ADDR_WL*0+:uvma_rvfi_pkg::GPR_ADDR_WL]), + .rvfi_rs2_rdata (rvfi_i.rvfi_rs2_rdata[uvmt_cv32e40s_base_test_pkg::XLEN*0+:uvmt_cv32e40s_base_test_pkg::XLEN]), + .rvfi_rs3_addr ('0), + .rvfi_rs3_rdata ('0), + .rvfi_rd1_addr (rvfi_i.rvfi_rd_addr[uvma_rvfi_pkg::GPR_ADDR_WL*0+:uvma_rvfi_pkg::GPR_ADDR_WL]), + .rvfi_rd1_wdata (rvfi_i.rvfi_rd_wdata[uvmt_cv32e40s_base_test_pkg::XLEN*0+:uvmt_cv32e40s_base_test_pkg::XLEN]), + .rvfi_rd2_addr ('0), + .rvfi_rd2_wdata ('0), + .rvfi_gpr_rdata (rvfi_i.rvfi_gpr_rdata[32*uvmt_cv32e40s_base_test_pkg::XLEN*0 +:32*uvmt_cv32e40s_base_test_pkg::XLEN]), + .rvfi_gpr_rmask (rvfi_i.rvfi_gpr_rmask[32*0 +:32]), + .rvfi_gpr_wdata (rvfi_i.rvfi_gpr_wdata[32*uvmt_cv32e40s_base_test_pkg::XLEN*0 +:32*uvmt_cv32e40s_base_test_pkg::XLEN]), + .rvfi_gpr_wmask (rvfi_i.rvfi_gpr_wmask[32*0 +:32]), + .rvfi_mem_addr (rvfi_i.rvfi_mem_addr[ uvma_rvfi_pkg::NMEM*uvmt_cv32e40s_base_test_pkg::XLEN*0 +:uvma_rvfi_pkg::NMEM*uvmt_cv32e40s_base_test_pkg::XLEN]), + .rvfi_mem_rdata (rvfi_i.rvfi_mem_rdata[uvma_rvfi_pkg::NMEM*uvmt_cv32e40s_base_test_pkg::XLEN*0 +:uvma_rvfi_pkg::NMEM*uvmt_cv32e40s_base_test_pkg::XLEN]), + .rvfi_mem_rmask (rvfi_i.rvfi_mem_rmask[uvma_rvfi_pkg::NMEM*uvmt_cv32e40s_base_test_pkg::XLEN/8*0 +:uvma_rvfi_pkg::NMEM*uvmt_cv32e40s_base_test_pkg::XLEN/8]), + .rvfi_mem_wdata (rvfi_i.rvfi_mem_wdata[uvma_rvfi_pkg::NMEM*uvmt_cv32e40s_base_test_pkg::XLEN*0 +:uvma_rvfi_pkg::NMEM*uvmt_cv32e40s_base_test_pkg::XLEN]), + .rvfi_mem_wmask (rvfi_i.rvfi_mem_wmask[uvma_rvfi_pkg::NMEM*uvmt_cv32e40s_base_test_pkg::XLEN/8*0 +:uvma_rvfi_pkg::NMEM*uvmt_cv32e40s_base_test_pkg::XLEN/8]), + .rvfi_instr_prot (rvfi_i.rvfi_instr_prot), + .rvfi_instr_memtype (rvfi_i.rvfi_instr_memtype), + .rvfi_instr_dbg (rvfi_i.rvfi_instr_dbg), + .rvfi_mem_prot (rvfi_i.rvfi_mem_prot), + .rvfi_mem_exokay (rvfi_i.rvfi_mem_exokay), + .rvfi_mem_err (rvfi_i.rvfi_mem_err), + .rvfi_mem_atop (rvfi_i.rvfi_mem_atop), + .rvfi_mem_memtype (rvfi_i.rvfi_mem_memtype), + .rvfi_mem_dbg (rvfi_i.rvfi_mem_dbg) + ); // RVFI CSR binds `RVFI_CSR_BIND(cpuctrl) diff --git a/cv32e40s/tb/uvmt/uvmt_cv32e40s_tb_files.flist b/cv32e40s/tb/uvmt/uvmt_cv32e40s_tb_files.flist index 341738c0b9..a092c6618f 100644 --- a/cv32e40s/tb/uvmt/uvmt_cv32e40s_tb_files.flist +++ b/cv32e40s/tb/uvmt/uvmt_cv32e40s_tb_files.flist @@ -22,13 +22,13 @@ ${DV_UVMT_PATH}/../assertions/uvmt_cv32e40s_fencei_assert.sv ${DV_UVMT_PATH}/../assertions/uvmt_cv32e40s_pmp_assert.sv ${DV_UVMT_PATH}/../assertions/uvmt_cv32e40s_pmprvfi_assert.sv ${DV_UVMT_PATH}/../assertions/uvmt_cv32e40s_rvfi_assert.sv +${DV_UVMT_PATH}/../assertions/uvmt_cv32e40s_umode_assert.sv ${DV_UVMT_PATH}/uvmt_cv32e40s_clic_interrupt_assert.sv ${DV_UVMT_PATH}/uvmt_cv32e40s_debug_assert.sv ${DV_UVMT_PATH}/uvmt_cv32e40s_integration_assert.sv ${DV_UVMT_PATH}/uvmt_cv32e40s_interrupt_assert.sv ${DV_UVMT_PATH}/uvmt_cv32e40s_pma_assert.sv ${DV_UVMT_PATH}/uvmt_cv32e40s_triggers_assert_cov.sv -${DV_UVMT_PATH}/uvmt_cv32e40s_umode_assert.sv ${DV_UVMT_PATH}/uvmt_cv32e40s_xsecure_assert/uvmt_cv32e40s_xsecure_bus_protocol_hardening_assert.sv ${DV_UVMT_PATH}/uvmt_cv32e40s_xsecure_assert/uvmt_cv32e40s_xsecure_data_independent_timing_assert.sv ${DV_UVMT_PATH}/uvmt_cv32e40s_xsecure_assert/uvmt_cv32e40s_xsecure_dummy_and_hint_assert.sv @@ -46,11 +46,11 @@ ${DV_UVMT_PATH}/uvmt_cv32e40s_zc_assert.sv ${DV_UVMT_PATH}/../assertions/uvmt_cv32e40s_pma_model.sv ${DV_UVMT_PATH}/../assertions/uvmt_cv32e40s_pmp_model.sv ${DV_UVMT_PATH}/../assertions/uvmt_cv32e40s_rvfi_cov.sv -${DV_UVMT_PATH}/support_logic/uvmt_cv32e40s_sl_obi_phases_monitor.sv +${DV_UVMT_PATH}/../assertions/uvmt_cv32e40s_umode_cov.sv +${DV_UVMT_PATH}/support_logic/uvmt_cv32e40s_rchk_shim.sv ${DV_UVMT_PATH}/support_logic/uvmt_cv32e40s_sl_fifo.sv -${DV_UVMT_PATH}/support_logic/uvmt_cv32e40s_sl_trigger_match_mem.sv +${DV_UVMT_PATH}/support_logic/uvmt_cv32e40s_sl_obi_phases_monitor.sv ${DV_UVMT_PATH}/support_logic/uvmt_cv32e40s_sl_trigger_match.sv +${DV_UVMT_PATH}/support_logic/uvmt_cv32e40s_sl_trigger_match_mem.sv ${DV_UVMT_PATH}/support_logic/uvmt_cv32e40s_support_logic.sv -${DV_UVMT_PATH}/support_logic/uvmt_cv32e40s_rchk_shim.sv ${DV_UVMT_PATH}/uvmt_cv32e40s_pma_cov.sv -${DV_UVMT_PATH}/uvmt_cv32e40s_umode_cov.sv diff --git a/lib/uvm_agents/uvma_obi_memory/src/obj/uvma_obi_memory_cfg.sv b/lib/uvm_agents/uvma_obi_memory/src/obj/uvma_obi_memory_cfg.sv index e9f5adde70..f0681078b4 100644 --- a/lib/uvm_agents/uvma_obi_memory/src/obj/uvma_obi_memory_cfg.sv +++ b/lib/uvm_agents/uvma_obi_memory/src/obj/uvma_obi_memory_cfg.sv @@ -93,6 +93,11 @@ class uvma_obi_memory_cfg_c extends uvm_object; bit [31:0] directed_slv_exokay_addr_max; bit directed_slv_exokay_valid; + bit [31:0] directed_slv_reservation_addr_min; + bit [31:0] directed_slv_reservation_addr_max; + bit directed_slv_reservation_valid; + bit [31:0] directed_slv_nr_reserved_words = 32'b1; + `uvm_object_utils_begin(uvma_obi_memory_cfg_c) `uvm_field_int ( enabled , UVM_DEFAULT) @@ -145,6 +150,11 @@ class uvma_obi_memory_cfg_c extends uvm_object; `uvm_field_int ( directed_slv_exokay_addr_min , UVM_DEFAULT) `uvm_field_int ( directed_slv_exokay_addr_max , UVM_DEFAULT) `uvm_field_int ( directed_slv_exokay_valid , UVM_DEFAULT) + + `uvm_field_int ( directed_slv_reservation_addr_min , UVM_DEFAULT) + `uvm_field_int ( directed_slv_reservation_addr_max , UVM_DEFAULT) + `uvm_field_int ( directed_slv_reservation_valid , UVM_DEFAULT) + `uvm_field_int ( directed_slv_nr_reserved_words , UVM_DEFAULT) `uvm_object_utils_end constraint defaults_cons { @@ -245,7 +255,17 @@ class uvma_obi_memory_cfg_c extends uvm_object; /** * Calculate a random atomic exokay response from random knobs */ - extern function bit calc_random_exokay(bit[31:0] addr); + extern function bit calc_random_exokay(bit[31:0] addr, bit is_SCW); + + /** + * Invalidate RL.W reservation set + */ + extern function void invalidate_reservation(); + + /** + * Set RL.W reservation set + */ + extern function void set_reservation(bit[31:0] addr); /** * Returns 1 if this OBI agent supports version 1.2 or higher @@ -272,6 +292,8 @@ function uvma_obi_memory_cfg_c::new(string name="uvma_obi_memory_cfg"); rvalid_singles_stall = 1; end + directed_slv_exokay_valid = 0; + endfunction : new @@ -353,14 +375,15 @@ function bit uvma_obi_memory_cfg_c::calc_random_err(bit[31:0] addr); endfunction : calc_random_err -function bit uvma_obi_memory_cfg_c::calc_random_exokay(bit[31:0] addr); +function bit uvma_obi_memory_cfg_c::calc_random_exokay(bit[31:0] addr, bit is_SCW); bit exokay; // Check for a directed error reponse first - if (directed_slv_exokay_valid && - (addr <= directed_slv_exokay_addr_min) && - (addr <= directed_slv_exokay_addr_min)) begin + if (is_SCW && + (!directed_slv_reservation_valid || + ((addr < directed_slv_reservation_addr_min) || + (addr > directed_slv_reservation_addr_max)))) begin return 0; end @@ -378,6 +401,22 @@ function bit uvma_obi_memory_cfg_c::calc_random_exokay(bit[31:0] addr); endfunction : calc_random_exokay +function void uvma_obi_memory_cfg_c::invalidate_reservation(); + + directed_slv_reservation_valid = 0; + +endfunction : invalidate_reservation + +function void uvma_obi_memory_cfg_c::set_reservation(bit[31:0] addr); + + if (addr[1:0] == 2'b0) begin + directed_slv_reservation_valid = 1; + directed_slv_reservation_addr_min = addr; + directed_slv_reservation_addr_max = addr + 4*(directed_slv_nr_reserved_words-1); + end + +endfunction : set_reservation + function bit uvma_obi_memory_cfg_c::is_1p2_or_higher(); return (version >= UVMA_OBI_MEMORY_VERSION_1P2) ? 1 : 0; diff --git a/lib/uvm_agents/uvma_obi_memory/src/seq/uvma_obi_memory_slv_base_seq.sv b/lib/uvm_agents/uvma_obi_memory/src/seq/uvma_obi_memory_slv_base_seq.sv index b68591b4d6..ebf46798c0 100644 --- a/lib/uvm_agents/uvma_obi_memory/src/seq/uvma_obi_memory_slv_base_seq.sv +++ b/lib/uvm_agents/uvma_obi_memory/src/seq/uvma_obi_memory_slv_base_seq.sv @@ -165,13 +165,19 @@ endfunction : add_err function void uvma_obi_memory_slv_base_seq_c::add_exokay(uvma_obi_memory_mon_trn_c mon_req, uvma_obi_memory_slv_seq_item_c slv_rsp); - // Only respond exokay == 1 to SC or LR as signaled by atop if (mon_req.atop[5] != 1'b1 || !(mon_req.atop[4:0] inside {5'h2, 5'h3})) begin slv_rsp.exokay = 0; - return; + end else begin + slv_rsp.exokay = cfg.calc_random_exokay(slv_rsp.orig_trn.address, (mon_req.atop == 6'h23)); end - slv_rsp.exokay = cfg.calc_random_exokay(slv_rsp.orig_trn.address); + if (slv_rsp.exokay && mon_req.atop == 6'h22) begin //LR.W + cfg.set_reservation(slv_rsp.orig_trn.address); + end + + if (mon_req.atop == 6'h23) begin //SC.W + cfg.invalidate_reservation(); + end endfunction : add_exokay diff --git a/lib/uvm_agents/uvma_pma/src/comps/uvma_pma_sb.sv b/lib/uvm_agents/uvma_pma/src/comps/uvma_pma_sb.sv index 35ff18d6c4..64f957fd53 100644 --- a/lib/uvm_agents/uvma_pma/src/comps/uvma_pma_sb.sv +++ b/lib/uvm_agents/uvma_pma/src/comps/uvma_pma_sb.sv @@ -290,14 +290,6 @@ function void uvma_pma_sb_c::check_obi_i_default_region(uvma_obi_memory_mon_trn_ obi.access_type.name(), obi.address, override_region, obi.memtype[UVMA_OBI_MEMORY_MEMTYPE_CACHEABLE_BIT], cfg.region_overrides[override_region].cacheable)); end - - // TODO: this needs to be modified when atomics are introduced for X to preserve code compatibility - // Check: atomic attributes should be 0 - if (obi.atop) begin - `uvm_error("PMAOBII", $sformatf("OBI I %s address: 0x%08x, region: %0d atop is not zero, OBI: 0x%0x", - obi.access_type.name(), obi.address, override_region, - obi.atop)); - end end else begin // Check: Bufferable bit must be 0 in OBI for instruction fetches if (obi.memtype[UVMA_OBI_MEMORY_MEMTYPE_BUFFERABLE_BIT]) begin @@ -310,13 +302,13 @@ function void uvma_pma_sb_c::check_obi_i_default_region(uvma_obi_memory_mon_trn_ `uvm_error("PMAOBII", $sformatf("OBI I %s address: 0x%08x cacheable bit set for PMA default region", obi.access_type.name(), obi.address)); end + end - // Check: atomic attributes should be 0 - if (obi.atop) begin - `uvm_error("PMAOBII", $sformatf("OBI I %s address: 0x%08x atop is not zero, OBI: 0x%0x", - obi.access_type.name(), obi.address, - obi.atop)); - end + // Check: atomic attributes should be 0 for all instruction fetches + if (obi.atop) begin + `uvm_error("PMAOBII", $sformatf("OBI I %s address: 0x%08x, region: %0d atop is not zero, OBI: 0x%0x", + obi.access_type.name(), obi.address, override_region, + obi.atop)); end endfunction : check_obi_i_default_region @@ -342,14 +334,6 @@ function void uvma_pma_sb_c::check_obi_i_mapped_region(uvma_obi_memory_mon_trn_c obi.access_type.name(), obi.address, override_region, obi.memtype[UVMA_OBI_MEMORY_MEMTYPE_CACHEABLE_BIT], cfg.region_overrides[override_region].cacheable)); end - - // TODO: this needs to be modified when atomics are introduced for X to preserve code compatibility - // Check: atomic attributes should be 0 - if (obi.atop) begin - `uvm_error("PMAOBII", $sformatf("OBI I %s address: 0x%08x, override region: %0d atop is not zero, OBI: 0x%0x", - obi.access_type.name(), obi.address, override_region, - obi.atop)); - end end else begin // Check: Must be main memory if (!cfg.regions[index].main) begin @@ -369,13 +353,13 @@ function void uvma_pma_sb_c::check_obi_i_mapped_region(uvma_obi_memory_mon_trn_c obi.access_type.name(), obi.address, index, obi.memtype[UVMA_OBI_MEMORY_MEMTYPE_CACHEABLE_BIT], cfg.regions[index].cacheable)); end + end - // Check: atomic attributes should be 0 - if (obi.atop) begin - `uvm_error("PMAOBII", $sformatf("OBI I %s address: 0x%08x, region: %0d atop is not zero, OBI: 0x%0x", - obi.access_type.name(), obi.address, index, - obi.atop)); - end + // Check: atomic attributes should be 0 for all instruction fetches + if (obi.atop) begin + `uvm_error("PMAOBII", $sformatf("OBI I %s address: 0x%08x, override region: %0d atop is not zero, OBI: 0x%0x", + obi.access_type.name(), obi.address, override_region, + obi.atop)); end endfunction : check_obi_i_mapped_region @@ -413,8 +397,7 @@ function void uvma_pma_sb_c::check_obi_d_default_region(uvma_obi_memory_mon_trn_ obi.memtype[UVMA_OBI_MEMORY_MEMTYPE_CACHEABLE_BIT], cfg.region_overrides[override_region].cacheable)); end - // TODO: this needs to be modified when atomics are introduced for X to preserve code compatibility - // Check: atomic attributes should be 0 + // Check: atomic attributes should be 0 for debug mode if (obi.atop) begin `uvm_error("PMAOBII", $sformatf("OBI I %s address: 0x%08x, override region: %0d atop is not zero, OBI: 0x%0x", obi.access_type.name(), obi.address, override_region, @@ -438,6 +421,7 @@ function void uvma_pma_sb_c::check_obi_d_default_region(uvma_obi_memory_mon_trn_ `uvm_error("PMAOBID", $sformatf("OBI D %s address: 0x%08x atop is not zero for PMA default region, OBI: 0x%0x", obi.access_type.name(), obi.address, obi.atop)); + end end @@ -461,8 +445,7 @@ function void uvma_pma_sb_c::check_obi_d_mapped_region(uvma_obi_memory_mon_trn_c obi.memtype[UVMA_OBI_MEMORY_MEMTYPE_CACHEABLE_BIT], cfg.region_overrides[override_region].cacheable)); end - // TODO: this needs to be modified when atomics are introduced for X to preserve code compatibility - // Check: atomic attributes should be 0 + // Check: atomic attributes should be 0 for debug mode if (obi.atop) begin `uvm_error("PMAOBII", $sformatf("OBI I %s address: 0x%08x, override region: %0d atop is not zero, OBI: 0x%0x", obi.access_type.name(), obi.address, override_region, @@ -491,13 +474,6 @@ function void uvma_pma_sb_c::check_obi_d_mapped_region(uvma_obi_memory_mon_trn_c obi.access_type.name(), obi.address, index, obi.memtype[UVMA_OBI_MEMORY_MEMTYPE_CACHEABLE_BIT], cfg.regions[index].cacheable)); end - - // Check: atomic attributes should be 0 - if (obi.atop) begin - `uvm_error("PMAOBID", $sformatf("OBI D %s address: 0x%08x, region: %0d atop is not zero, OBI: 0x%0x", - obi.access_type.name(), obi.address, index, - obi.atop)); - end end endfunction : check_obi_d_mapped_region diff --git a/lib/uvm_agents/uvma_rvfi/uvma_rvfi_instr_if.sv b/lib/uvm_agents/uvma_rvfi/uvma_rvfi_instr_if.sv index 722106c713..1a9f80f564 100644 --- a/lib/uvm_agents/uvma_rvfi/uvma_rvfi_instr_if.sv +++ b/lib/uvm_agents/uvma_rvfi/uvma_rvfi_instr_if.sv @@ -73,8 +73,15 @@ interface uvma_rvfi_instr_if_t input logic [(NMEM*XLEN)-1:0] rvfi_mem_wdata, input logic [(NMEM*XLEN/8)-1:0] rvfi_mem_wmask, - input logic [2:0] instr_prot, - input logic [NMEM*3-1:0] mem_prot + input logic [2:0] rvfi_instr_prot, + input logic [1:0] rvfi_instr_memtype, + input logic rvfi_instr_dbg, + input logic [ NMEM*3-1:0] rvfi_mem_prot, + input logic [ 1*NMEM-1:0] rvfi_mem_exokay, + input logic [ 1*NMEM-1:0] rvfi_mem_err, + input logic [ 6*NMEM-1:0] rvfi_mem_atop, + input logic [ 2*NMEM-1:0] rvfi_mem_memtype, + input logic [ NMEM-1 :0] rvfi_mem_dbg ); typedef logic[4*NMEM-1:0] mem_mask_t;