Skip to content

Commit

Permalink
Merge branch 'user-mode-support-ant'
Browse files Browse the repository at this point in the history
  • Loading branch information
tmichalak committed Jun 12, 2024
2 parents 97bf102 + 414f696 commit 8e99e82
Show file tree
Hide file tree
Showing 82 changed files with 5,900 additions and 787 deletions.
8 changes: 6 additions & 2 deletions .github/scripts/run_regression_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ run_regression_test(){
echo -e "${COLOR_WHITE} NAME = ${NAME}${COLOR_CLEAR}"
echo -e "${COLOR_WHITE} COVERAGE = ${COVERAGE}${COLOR_CLEAR}"

COMMON_PARAMS="-set=user_mode=1 -set=smepmp=1"

if [[ "${BUS}" == "axi" ]]; then
PARAMS="-set build_axi4"
PARAMS="-set build_axi4 ${COMMON_PARAMS}"
elif [[ "${BUS}" == "ahb" ]]; then
PARAMS="-set build_ahb_lite"
PARAMS="-set build_ahb_lite ${COMMON_PARAMS}"
else
echo -e "${COLOR_RED}Unknown system bus type '${BUS}'${COLOR_CLEAR}"
exit 1
fi

echo -e "${COLOR_WHITE} CONF PARAMS = ${PARAMS}${COLOR_CLEAR}"

mkdir -p ${RESULTS_DIR}
LOG="${RESULTS_DIR}/test_${NAME}_${COVERAGE}.log"
touch ${LOG}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test-regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ jobs:
strategy:
matrix:
bus: ["axi", "ahb"]
test: ["hello_world", "hello_world_dccm", "hello_world_iccm", "cmark", "cmark_dccm", "cmark_iccm", "dhry", "pmp"]
test: ["hello_world", "hello_world_dccm", "hello_world_iccm", "cmark", "cmark_dccm", "cmark_iccm", "dhry",
"csr_misa", "csr_access", "csr_mstatus", "csr_mseccfg", "modesw", "insns", "irq", "perf_counters", "pmp"]
coverage: ["branch", "toggle"] #TODO: add functional coverage
env:
DEBIAN_FRONTEND: "noninteractive"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-riscof.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ jobs:
export RV_ROOT=`pwd`
pushd riscof
$RV_ROOT/configs/veer.config
make -f $RV_ROOT/tools/Makefile verilator-build COVERAGE=${{ matrix.coverage }}
make -f $RV_ROOT/tools/Makefile verilator-build CONF_PARAMS="-set build_axi4 -set=user_mode=1 -set=smepmp=1" COVERAGE=${{ matrix.coverage }}
popd
- name: Run tests, collect coverage
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-riscv-dv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ jobs:
include: ${{ fromJSON(needs.generate-config.outputs.test-include-generate) }}
env:
GHA_EXTERNAL_DISK: additional-tools
CACHE_HASH: ${{ needs.generate-config.outputs.hash }}
CACHE_HASH: 96d836528b2e032c9145830619eeaabdd49e94fed4e405865df15e6211b0c27c
steps:
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -219,7 +219,7 @@ jobs:
CCACHE_DIR: "/opt/riscv-dv/.cache/"
VERILATOR_VERSION: v5.010
SPIKE_VERSION: d70ea67d
CACHE_HASH: ${{ needs.generate-config.outputs.hash }}
CACHE_HASH: 96d836528b2e032c9145830619eeaabdd49e94fed4e405865df15e6211b0c27c

steps:
- name: Install utils
Expand Down
34 changes: 30 additions & 4 deletions configs/veer.config
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ my @dvars = qw(retstack btb bht core dccm iccm icache pic protection memmap bus)
# Prefix all macros with
my $prefix = "RV_";
# No prefix if keyword has
my $no_prefix = 'RV|TOP|tec_rv_icg|regwidth|clock_period|^datawidth|verilator|SDVT_AHB|tech_specific_.*|user_.*';
my $no_prefix = 'RV|TOP|tec_rv_icg|regwidth|clock_period|^datawidth|verilator|SDVT_AHB|tech_specific_.*|user_ec_rv_icg';

my $vlog_use__wh = 1;

Expand Down Expand Up @@ -93,6 +93,8 @@ User options:
Parameters that can be set by the end user:
-set=user_mode = {0,1}
enable, disable user mode support in the core
-set=ret_stack_size = {2, 3, 4, ... 8}
size of return stack
-set=btb_enable = {0,1}
Expand Down Expand Up @@ -201,6 +203,8 @@ Parameters that can be set by the end user:
Don't add ICCM preload code in generated link.ld
-set=pmp_entries = {0, 16, 64 }
number of PMP entries
-set=smepmp = {0, 1}
Enable Smepmp PMP extension
Additionally the following may be set for bus masters and slaves using the -set=var=value option:
Expand All @@ -210,6 +214,7 @@ Additionally the following may be set for bus masters and slaves using the -set=
{inst|data}_access_mask[0-7] : default 0xffffffff
";

my $user_mode;

my $ret_stack_size;
my $btb_size;
Expand Down Expand Up @@ -269,7 +274,9 @@ my $text_in_iccm = 0;
my $lsu2dma = 0;

my $pmp_entries=16;
my $smepmp=0;

$user_mode=0;
$ret_stack_size=8;
$btb_enable=1;
$btb_fullya=0;
Expand Down Expand Up @@ -886,6 +893,7 @@ our %config = (#{{{
},

"core" => {
"user_mode" => "$user_mode",
"div_bit" => "$div_bit", # Design Parm, Overridable
"div_new" => "$div_new", # Design Parm, Overridable
"lsu_stbuf_depth" => "$lsu_stbuf_depth", # Design Parm, Overridable
Expand Down Expand Up @@ -1040,6 +1048,7 @@ our %config = (#{{{
},
"protection" => { # Design parms, Overridable - static MPU
"pmp_entries" => "$pmp_entries",
"smepmp" => "$smepmp",
"inst_access_enable0" => "0x0",
"inst_access_addr0" => "0x00000000",
"inst_access_mask0" => "0xffffffff",
Expand Down Expand Up @@ -1127,6 +1136,8 @@ our %config = (#{{{
# need to have this be width in binary
# for now autosize to the data
our %verilog_parms = (
"user_mode" => '1',

"lsu2dma" => '1',
"timer_legal_en" => '1',
"bitmanip_zbb" => '1',
Expand All @@ -1140,6 +1151,7 @@ our %verilog_parms = (
"fast_interrupt_redirect" => '1',

"pmp_entries" => '7',
"smepmp" => '1',
"inst_access_enable0" => '1',
"inst_access_addr0" => '32',
"inst_access_mask0" => '32',
Expand Down Expand Up @@ -1306,7 +1318,9 @@ our %verilog_parms = (
# to make sure parameter math works properly add 4 to each key of %verilog_parms - was an issue in btb calculations
my $key;
foreach $key (sort keys %verilog_parms) {
$verilog_parms{$key} += 4;
if ( $key ne "user_mode" && $key ne "smepmp" ) {
$verilog_parms{$key} += 4;
}
}


Expand Down Expand Up @@ -1840,6 +1854,14 @@ dump_define("","", \%config,[]);
#print Dumper(\%unsets);

# Sanity checks

# Do not allow Smepmp to be enabled when user mode is disabled
# TODO: Allowing this combination would require adding additional CSR decoder
# variants.
if(( $config{core}{user_mode} eq 0 ) && ( $config{protection}{smepmp} eq 1 )) {
die "$self: ERROR! Currently Smepmp feature cannot be enabled when user mode support is disabled\n";
}

check_addr_align("dccm", hex($config{dccm}{dccm_sadr}), $config{dccm}{dccm_size}*1024);
check_addr_align("iccm", hex($config{iccm}{iccm_sadr}), $config{iccm}{iccm_size}*1024);
check_addr_align("pic", hex($config{pic}{pic_base_addr}), $config{pic}{pic_size}*1024);
Expand Down Expand Up @@ -1930,6 +1952,7 @@ if (($iccm_enable==0) && !grep(/iccm_enable/, @sets)) { delete $conf


# new code to handle the -set=parm=0 value correctly for common_defines.vh
$c=$config{core}{user_mode}; if ($c==0 && !grep(/user_mode=1/, @sets)) { delete $config{"core"}{"user_mode"}; }
$c=$config{core}{load_to_use_plus1}; if ($c==0 && !grep(/load_to_use_plus1=1/, @sets)) { delete $config{"core"}{"load_to_use_plus1"}; }
$c=$config{core}{opensource}; if ($c==0 && !grep(/opensource=1/, @sets)) { delete $config{"core"}{"opensource"}; }
$c=$config{core}{verilator}; if ($c==0 && !grep(/verilator=1/, @sets)) { delete $config{"core"}{"verilator"}; }
Expand All @@ -1946,6 +1969,7 @@ $c=$config{icache}{icache_2banks}; if ($c==0 && !grep(/icache_2banks=1/, @sets
$c=$config{pic}{pic_2cycle}; if ($c==0 && !grep(/pic_2cycle=1/, @sets)) { delete $config{"pic"}{"pic_2cycle"}; }

$c=$config{btb}{btb_fullya}; if ($c==0 && !grep(/btb_fullya=1/, @sets)) { delete $config{"btb"}{"btb_fullya"}; }
$c=$config{protection}{smepmp}; if ($c==0 && !grep(/smepmp=1/, @sets)) { delete $config{"protection"}{"smepmp"}; }



Expand Down Expand Up @@ -2580,8 +2604,10 @@ sub dump_parms {#{{{
$pcnt++;
if ($pcnt==$parmcnt) { undef $delim; }
if ($hash->{$key} eq "0") { $hash->{$key}="0000"; }
$msb=substr($hash->{$key},0,4); # require upper 4b to be 0
if ($msb ne "0000") { die("parameter $upper upper 4b must be 0"); }
if (length($hash->{$key}) != 1) {
$msb=substr($hash->{$key},0,4); # require upper 4b to be 0
if ($msb ne "0000") { die("parameter $upper upper 4b must be 0"); }
}
printf(FILE2 "\t%-22s : %d\'h%-10s $delim\n",$upper,length($hash->{$key}),b2h($hash->{$key}));
}
printf(FILE2 "}\n");
Expand Down
File renamed without changes.
Loading

0 comments on commit 8e99e82

Please sign in to comment.