Skip to content

Commit

Permalink
Merge pull request #2367 from openhwgroup/cv32e40s/dev-1
Browse files Browse the repository at this point in the history
Merge cv32e40s/release <-- cv32e40s/dev
  • Loading branch information
MikeOpenHWGroup authored Feb 16, 2024
2 parents 22a40ee + 0c4dc9c commit 9d15b81
Show file tree
Hide file tree
Showing 19 changed files with 685 additions and 50 deletions.
157 changes: 131 additions & 26 deletions bin/merge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,15 @@
# limitations under the License.


#TODO:
#List up the PRs these changes are from (so it is easy to see what to include in the cv32e40s/dev to cv32e40x/dev merge)

#Variables:
date_time=$(date +%Y.%m.%d-%H.%M)
your_cvv_branch=$(git rev-parse --abbrev-ref HEAD)


usage() {

echo "usage: $0 --[s_into_x-dv|x-dv_into_s|sdev_into_xdev|xdev_into_sdev]"
echo "usage: $0 --[s_into_x-dv|sdev_into_xdev|xdev_into_sdev|rejection-diff]"
echo "--s_into_x-dv Do a merge of core-v-verif cv32e40s/dev cv32e40s directory into cv32e40x-dv main (make sure the clonetb script has run)"
echo "--x-dv_into_s Do a merge of cv32e40x-dv main into core-v-verif cv32e40s/dev cv32e40s (not yet developed)"
echo "--sdev_into_xdev Do a merge of core-v-verif cv32e40s/dev into core-v-verif cv32e40x/dev"
echo "--xdev_into_sdev Do a merge of core-v-verif cv32e40x/dev into core-v-verif cv32e40s/dev"
echo "--rejection-diff Merge s/dev to x-dv, using 'theirs'"
Expand Down Expand Up @@ -63,11 +60,13 @@ merge_cv32e40s_into_cv32e40x-dv () {
git checkout -b cvv_$date_time ohw_cvv/cv32e40s/dev
git subtree split --prefix cv32e40s -b cv32e40s_$date_time


echo "=== Make a branch based on the latest cv32e40x-dv content ==="
git remote add ohw_x-dv [email protected]:openhwgroup/cv32e40x-dv.git
git fetch ohw_x-dv
git checkout -b merge_cv32e40s_$date_time ohw_x-dv/main


echo "=== Merge ==="
git merge -X find-renames --no-ff --no-commit cv32e40s_$date_time

Expand All @@ -76,22 +75,45 @@ merge_cv32e40s_into_cv32e40x-dv () {

move_files_40s_into_40x () {

echo "=== Replace 40s/S with 40x/X in file names ==="
echo "======= Replace 40s/S with 40x/X in file names? (recommended) ======="
read -p "y/n? [default: y] " yn

find . -type d | egrep -iv '\/\.|40sx|40xs' | grep -i 40s | xargs -n1 dirname | awk '{gsub(/40s/, "40x"); gsub(/40S/, "40X"); print}' | xargs -n2 mkdir -p
find . -type d | egrep -iv '\/\.|40sx|40xs' | grep -i 40s | awk '{printf $1; printf " "; gsub(/40s/, "40x"); gsub(/40S/, "40X"); print}' | xargs -n2 git mv -f
find . -type f | egrep -iv '\/\.|40sx|40xs' | grep -i 40s | xargs -n1 dirname | awk '{gsub(/40s/, "40x"); gsub(/40S/, "40X"); print}' | xargs -n2 mkdir -p
find . -type f | egrep -iv '\/\.|40sx|40xs' | grep -i 40s | awk '{printf $1; printf " "; gsub(/40s/, "40x"); gsub(/40S/, "40X"); print}' | xargs -n2 git mv -f
case $yn in
[Nn])
echo "=== Skip file renaming ===";
return
;;

*)
echo "=== Rename files ==="
find . -type d | egrep -iv '\/\.|40sx|40xs' | grep -i 40s | xargs -n1 dirname | awk '{gsub(/40s/, "40x"); gsub(/40S/, "40X"); print}' | xargs -n2 mkdir -p
find . -type d | egrep -iv '\/\.|40sx|40xs' | grep -i 40s | awk '{printf $1; printf " "; gsub(/40s/, "40x"); gsub(/40S/, "40X"); print}' | xargs -n2 git mv -f
find . -type f | egrep -iv '\/\.|40sx|40xs' | grep -i 40s | xargs -n1 dirname | awk '{gsub(/40s/, "40x"); gsub(/40S/, "40X"); print}' | xargs -n2 mkdir -p
find . -type f | egrep -iv '\/\.|40sx|40xs' | grep -i 40s | awk '{printf $1; printf " "; gsub(/40s/, "40x"); gsub(/40S/, "40X"); print}' | xargs -n2 git mv -f

;;
esac
}


substitute_file_content_40s_into_40x () {

echo "=== Exchange 40x/X with 40s/S in file content ==="
echo "======= Exchange 40x/X with 40s/S in file content? (not recommended) ======="
read -p "y/n? [default: n] " yn
case $yn in
[Yy])
echo "=== Content substitution ===";

find . -type f -exec grep -Il . {} + | egrep -iv '\/\.|40sx|40xs' | xargs -n1 sed -i 's/40s/40x/g'
find . -type f -exec grep -Il . {} + | egrep -iv '\/\.|40sx|40xs' | xargs -n1 sed -i 's/40S/40X/g'

find . -type f -exec grep -Il . {} + | egrep -iv '\/\.|40sx|40xs' | xargs -n1 sed -i 's/40s/40x/g'
find . -type f -exec grep -Il . {} + | egrep -iv '\/\.|40sx|40xs' | xargs -n1 sed -i 's/40S/40X/g'
return
;;

*)
echo "=== Skip content substitution ===";
;;
esac

}

Expand All @@ -107,12 +129,15 @@ merge_sdev_into_xdev () {
echo "=== Make a core-v-verif/cv32e40s/dev branch ==="
git checkout -b cvv_sdev_$date_time ohw_cvv/cv32e40s/dev


echo "=== Make a core-v-verif/cv32e40x/dev branch ==="
git checkout -b cvv_xdev_$date_time ohw_cvv/cv32e40x/dev
git checkout -b merge_sdev_into_xdev_$date_time ohw_cvv/cv32e40x/dev


echo "=== Merge ==="
git merge --no-commit --no-ff cvv_sdev_$date_time


}


Expand All @@ -127,27 +152,28 @@ merge_xdev_into_sdev () {
echo "=== Make a core-v-verif/cv32e40s/dev branch ==="
git checkout -b cvv_xdev_$date_time ohw_cvv/cv32e40x/dev


echo "=== Make a core-v-verif/cv32e40s/dev branch ==="
git checkout -b cvv_sdev_$date_time ohw_cvv/cv32e40s/dev
git checkout -b merge_xdev_into_sdev_$date_time ohw_cvv/cv32e40s/dev


echo "=== Merge ==="
git merge --no-commit --no-ff cvv_xdev_$date_time


}


clone_x_dv() {

echo "=== Cloning x-dv ==="
echo "======= Cloning x-dv ======="

read -p "This overwrites 'cv32e40x/'. Continue? y/n " yn
case $yn in
[Yy]* ) ;;
* ) echo "aborting"; exit;;
esac
read -p "This overwrites 'cv32e40x/'. Continue? y/n [default: y] " yn
continue_check $yn

./bin/clonetb --x-main


}


Expand All @@ -160,7 +186,7 @@ check_merge_status() {

rejection_diff() {

echo "=== Merging s/dev to x-dv, using 'theirs' ==="
echo "======= Merging s/dev to x-dv, using 'theirs' ======="
echo "WARNING, this function is crude and makes assumptions."

cd cv32e40x
Expand All @@ -177,19 +203,98 @@ rejection_diff() {

}

need_40s_40x-dv_merge(){
echo -e "\n======= Check if there are new commits i cv32e40s to merge to cv32e40x-dv ======="

main() {
new_40s_commits=()
num_40s_commits_to_check=100
num_40x_commits_to_check=100

# Get the updated commit messages from cv32e40s
echo -e "\n== Checkout an updated cv32e40s/dev branch =="
git remote add ohw_cvv [email protected]:openhwgroup/core-v-verif.git
git fetch ohw_cvv
git checkout ohw_cvv/cv32e40s/dev
commit_messages_40s=$(git log --format=%s -$num_40s_commits_to_check -- cv32e40s)

for commit_message in $commit_messages_40s; do

# Check if the commit message exist in cv32e40x (checks only the <num_40x_commits_to_check> last commits of 40x)
cd cv32e40x
is_commit_message_in_40x=$(git log -$num_40x_commits_to_check --grep="$commit_message" --format=oneline)
cd ..

if [[ -z $is_commit_message_in_40x ]]; then
# Add new 40s commit to list. Display the new item with sha and commit message
new_40s_commit_wit_both_sha_and_message=$(git log -$num_40s_commits_to_check --grep="$commit_message" --format=oneline)
new_40s_commits+=("$new_40s_commit_wit_both_sha_and_message")
fi

done

echo -e "\n== Restore your cvv branch =="
git checkout $your_cvv_branch

# Print commits needed to be merged,
if [[ -n $new_40s_commits ]]; then
echo -e "\n== New commits in cv32e40s that need to be merged: =="
for ((i=0; i <= ${#new_40s_commits[@]} ; i++)); do
echo ${new_40s_commits[$i]}
done

else
echo -e "\n== No new commits in cv32e40s that need to be merged =="
fi

# List warnings and ask to continue merge
echo "== WARNING 1: =="
echo "The script use commit message to identify merged commits"
echo "If a new commit in cv32e40s has the same commit message as a commit in cv32e40x-dv or no -m at all,"
echo -e "the commit is not in the list of commits that need to be merged.\n"

echo "== WARNING 2: =="
echo "The script compares only the 100 latest commits in cv32e40s and cv32e40x-dv"
echo -e "If there has been a lot of activity in the reposetories, the result of the above check can be faulty.\n"

read -p "Merge the commits into cv32e40x-dv? y/n [default: y] " yn
continue_check $yn

}

continue_check() {
case $1 in
[Nn])
echo "Exit merge!"
exit 1
;;
*)
echo "Continue merge process!"
return
;;
esac
}

recommended_way_forward() {
echo "======= Recommended way forward ======="

echo "1) Evaluate all git conflict"
echo "2) Run git diff HEAD on all files (red and green files) to see all merge changes"
echo "3) If some files are not renamed from 40s to 40x, the file content is too different to be recognized as the same file."
echo " Compare the 40s and 40x version of the same file and know there are new changes in the 40s version"
echo " that must manualy be merged to the 40x version. Delete the 40s version of the file after the manual merge is finished."

}

main() {
case $1 in
"--s_into_x-dv")
clone_x_dv
need_40s_40x-dv_merge
merge_cv32e40s_into_cv32e40x-dv
move_files_40s_into_40x
substitute_file_content_40s_into_40x
check_merge_status
;;
"--x-dv_into_s")
echo "This merge method is not yet developed"
recommended_way_forward
;;
"--sdev_into_xdev")
merge_sdev_into_xdev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ CLIC 8675ec,Interrupt CSR,mtvt,"Function ptr reads treated as instruction fetch,

Note, instruction fetch is treated as an implicit read, thus do not require PMP read permissions, but execute permission is required.

Both the pointer fetch and the fetch of the actual instruction located at the pointer address should be covered by the above restrictions. ",Assertion Check,"ENV capability, not specific test",Functional Coverage,clic::invalid_mtvt_ptr_exec_mret
Both the pointer fetch and the fetch of the actual instruction located at the pointer address should be covered by the above restrictions. ",Assertion Check,"ENV capability, not specific test",Functional Coverage,"clic::invalid_mtvt_ptr_exec_mret, minhv_pma_block.c"
UM v0.3.0 Common,Interrupt CSR,mtvt,"Always aligned to 2^(max(6, 2+SMCLIC_ID_WIDTH)","Assert that mtvt [max(6, 2+SMCLIC_ID_WIDTH)-1:0] = 0",Assertion Check,"ENV capability, not specific test",Functional Coverage,a_mtvt_alignment_correct
CLIC 8675ec,Interrupt CSR,mtvt,"Determine alignment by software access,
Write ones to lower order bits and read back",Test that correct alignment can be inferred by writing to these fields and read back.,Self Checking Test,Directed Self-Checking,Testcase,clic :: w_mtvt_rd_alignment
Expand Down Expand Up @@ -305,6 +305,8 @@ Added assertion for formal coverage",Assertion Check,"ENV capability, not specif
[clic_assert].a_mret_mie_mpie"
CLIC 0.9-draft 4/11/2023,Return from handler,mret,"""If the hart is currently running at some privilege mode x, an MRET or SRET instruction that changes the privilege mode to a mode less privileged than x also sets xintthresh = 0.""","Use ""mret"" to enter U-mode.
Check that ""mintthresh"" is written to zero upon executing the mret.",Assertion Check,"ENV capability, not specific test",Assertion Coverage,A: uvmt_cv32e40s_tb.dut_wrap.cv32e40s_wrapper_i.core_i.clic_assert_i.gen_clic_assertions.a_mret_umode_clear_mintthresh
CLIC 0.9-draft 12/19/2023,Return from handler,mret minhv=1,"""If the xinhv bit is set, the hart resumes the trap handler memory access to retrieve the function pointer for vectoring with permissions corresponding to the previous privilege mode. The trap handler function address is obtained from the current privilege mode’s xepc with the low bits of the address cleared to force the access to be naturally aligned to an XLEN/8-byte table entry.""","Run mret when minhv is set. Check that the next instruction to be executed is the address pointed to by the mepc, and check that mepc gets naturally aligned to XLEN/8 byte.",Self Checking Test,Directed Self-Checking,Testcase,"DTC: clic :: mret_with_minhv
clic ::mret_with_minhv_and_unaligned_mepc"
CLIC 0.9-draft 4/11/2023,Return from debug mode,dret,"""Likewise, if the RISC-V debug specification is implemented and the hart is currently running at some privilege mode x, a DRET instruction that changes the privilege mode to a mode less privileged than x also sets xintthresh = 0.""","Use ""dret"" to enter U-mode.
Check that ""mintthresh"" is written to zero upon executing the dret.",Assertion Check,"ENV capability, not specific test",Assertion Coverage,Requirement removed
CLIC 8675ec,WFI,Wakeup conditions,"A pending-and-enabled interrupt i causes the hart to resume execution if interrupt i
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@
"Pass/Fail Criteria": "Assertion Check",
"Test Type": "ENV capability, not specific test",
"Coverage Method": "Functional Coverage",
"Link to Coverage": "clic::invalid_mtvt_ptr_exec_mret"
"Link to Coverage": "clic::invalid_mtvt_ptr_exec_mret, minhv_pma_block.c"
},
{
"Requirement Location": "UM v0.3.0 Common",
Expand Down Expand Up @@ -791,6 +791,17 @@
"Coverage Method": "Assertion Coverage",
"Link to Coverage": "A: uvmt_cv32e40s_tb.dut_wrap.cv32e40s_wrapper_i.core_i.clic_assert_i.gen_clic_assertions.a_mret_umode_clear_mintthresh"
},
{
"Requirement Location": "CLIC 0.9-draft 12/19/2023",
"Feature": "Return from handler",
"Sub Feature": "mret minhv=1",
"Feature Description": "\"If the xinhv bit is set, the hart resumes the trap handler memory access to retrieve the function pointer for vectoring with permissions corresponding to the previous privilege mode. The trap handler function address is obtained from the current privilege mode\u2019s xepc with the low bits of the address cleared to force the access to be naturally aligned to an XLEN/8-byte table entry.\"",
"Verification Goal": "Run mret when minhv is set. Check that the next instruction to be executed is the address pointed to by the mepc, and check that mepc gets naturally aligned to XLEN/8 byte.",
"Pass/Fail Criteria": "Self Checking Test",
"Test Type": "Directed Self-Checking",
"Coverage Method": "Testcase",
"Link to Coverage": "DTC: clic :: mret_with_minhv\nclic ::mret_with_minhv_and_unaligned_mepc"
},
{
"Requirement Location": "CLIC 0.9-draft 4/11/2023",
"Feature": "Return from debug mode",
Expand Down
Binary file modified cv32e40s/docs/VerifPlans/Simulation/interrupts/CV32E40SX_CLIC.xlsx
Binary file not shown.
3 changes: 0 additions & 3 deletions cv32e40s/env/uvme/uvme_cv32e40s_cfg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,6 @@ endfunction : is_csr_check_disabled

function void uvme_cv32e40s_cfg_c::configure_disable_csr_checks();

// TODO: remove when fixed in ISS
disable_csr_check("misa");

// Need to check
disable_csr_check("mcountinhibit");

Expand Down
11 changes: 11 additions & 0 deletions cv32e40s/regress/cv32e40s_full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ builds:
cfg: pma_test_cfg_2
dir: cv32e40s/sim/uvmt

uvmt_cv32e40s_pma_2_clic:
cmd: make comp_corev-dv comp
cfg: pma_test_cfg_2_clic
dir: cv32e40s/sim/uvmt

uvmt_cv32e40s_pma_3:
cmd: make comp_corev-dv comp
cfg: pma_test_cfg_3
Expand Down Expand Up @@ -583,3 +588,9 @@ tests:
dir: cv32e40s/sim/uvmt
cmd: make test TEST=mhpmcounter_write_test

minhv_pma_block:
description: test minhv=1 and pma block of mepc address
builds: [ uvmt_cv32e40s_pma_2_clic ]
dir: cv32e40s/sim/uvmt
cmd: make test TEST=minhv_pma_block

Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ module uvmt_cv32e40s_sl_trigger_match
(rvfi.is_umode && in_support_if.tdata1_array[t][TDATA1_ET_U_MODE]));


// Trigger match instruction:
// Trigger match instruction:
assign trigger_match_execute[t] = csr_conditions_m2_m6[t]
&& in_support_if.tdata1_array[t][TDATA1_EXECUTE]
&& system_conditions
&& !rvfi.rvfi_trap.clicptr //TODO: KD: burde finne ut hvorfor clicptr er et unntak.
&& !rvfi.rvfi_trap.clicptr
&& (((rvfi.rvfi_pc_rdata == in_support_if.tdata2_array[t]) && in_support_if.tdata1_array[t][TDATA1_MSB_MATCH:TDATA1_LSB_MATCH] == TDATA1_MATCH_WHEN_EQUAL)
|| ((rvfi.rvfi_pc_rdata >= in_support_if.tdata2_array[t]) && in_support_if.tdata1_array[t][TDATA1_MSB_MATCH:TDATA1_LSB_MATCH] == TDATA1_MATCH_WHEN_GREATER_OR_EQUAL)
|| ((rvfi.rvfi_pc_rdata < in_support_if.tdata2_array[t]) && in_support_if.tdata1_array[t][TDATA1_MSB_MATCH:TDATA1_LSB_MATCH] == TDATA1_MATCH_WHEN_LESSER));
Expand Down
28 changes: 23 additions & 5 deletions cv32e40s/tb/uvmt/uvmt_cv32e40s_pma_assert.sv
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,20 @@ module uvmt_cv32e40s_pma_assert

// After PMA-deny, subsequent accesses are also suppressed (vplan:"Multi-memory operation instructions")

a_failure_denies_subsequents: assert property (
rvfi_instr_if.is_pma_instr_fault
a_failure_denies_subsequents_loads: assert property (
rvfi_instr_if.is_pma_data_fault
|->
(rvfi_instr_if.rvfi_mem_wmask == '0)
//TODO:ERROR:silabs-robin Zcmp should be able to break this. RVFI bug.
//TODO:ERROR:silabs-robin Also reads
(rvfi_instr_if.rvfi_mem_rmask != rvfi_instr_if.rvfi_mem_rmask_intended)
||
(rvfi_instr_if.rvfi_mem_rmask == 'd 0)
) else `uvm_error(info_tag, "accesses aftmr pma fault should be suppressed");

a_failure_denies_subsequents_stores: assert property (
rvfi_instr_if.is_pma_data_fault
|->
(rvfi_instr_if.rvfi_mem_wmask != rvfi_instr_if.rvfi_mem_wmask_intended)
||
(rvfi_instr_if.rvfi_mem_wmask == 'd 0)
) else `uvm_error(info_tag, "accesses aftmr pma fault should be suppressed");

property p_partial_pma_allow (exc_cause);
Expand All @@ -174,6 +182,16 @@ module uvmt_cv32e40s_pma_assert
);


// PMA-deny on instr, no mem op (vplan: Not a vplan item. Inspo from a_failure_denies_subsequents.)

a_failure_denies_memops: assert property (
rvfi_instr_if.is_pma_instr_fault
|->
(rvfi_instr_if.rvfi_mem_wmask == '0) &&
(rvfi_instr_if.rvfi_mem_rmask == '0)
) else `uvm_error(info_tag, "pma-blocked instrs shouldn't access the bus");


// MPU-accepted transactions must reach OBI (vplan: not a vplan item)

property p_eventually_mpu2obi;
Expand Down
Loading

0 comments on commit 9d15b81

Please sign in to comment.