[DV] Enable aligned load/store test (#242)

* Add unaligned load/store test

* Enable unaligned load/store test, remove obsolete files
This commit is contained in:
taoliug 2019-08-14 17:41:13 -07:00 committed by udinator
parent 7eecbd1b05
commit 0e91a30496
6 changed files with 43 additions and 204 deletions

View file

@ -2,40 +2,41 @@
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
DV_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
GEN_DIR := $(realpath ${DV_DIR}/../../vendor/google_riscv-dv)
TOOLCHAIN := ${RISCV_TOOLCHAIN}
OUT := "${DV_DIR}/out"
DV_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
GEN_DIR := $(realpath ${DV_DIR}/../../vendor/google_riscv-dv)
TOOLCHAIN := ${RISCV_TOOLCHAIN}
OUT := "${DV_DIR}/out"
# Run time options for the instruction generator
GEN_OPTS :=
GEN_OPTS :=
# Run time options for ibex RTL simulation
SIM_OPTS :=
SIM_OPTS :=
# Enable waveform dumping
WAVES := 1
WAVES := 1
# Enable coverage dump
COV := 0
COV := 0
# RTL simulator
SIMULATOR := "vcs"
SIMULATOR := "vcs"
# ISS (spike, ovpsim)
ISS := "spike"
ISS := "spike"
# ISA
ISA := "rv32imc"
ISA := "rv32imc"
# Test name (default: full regression)
TEST := "all"
TEST := "all"
# Seed for instruction generator and RTL simulation
SEED := -1
SEED := -1
# Verbose logging
VERBOSE :=
VERBOSE :=
# Number of iterations for each test, assign a non-zero value to override the
# iteration count in the test list
ITERATIONS := 0
ITERATIONS := 0
# LSF CMD
LSF_CMD :=
LSF_CMD :=
# Generator timeout limit in seconds
TIMEOUT := 1800
# Privileged CSR YAML description file
CSR_FILE := ${DV_DIR}/riscv_dv_extension/csr_description.yaml
CSR_FILE := ${DV_DIR}/riscv_dv_extension/csr_description.yaml
# Pass/fail signature address at the end of test
END_SIGNATURE_ADDR := 0x8ffffffc
END_SIGNATURE_ADDR := 8ffffffc
# Value written to END_SIGNATURE_ADDR that indicates test success
PASS_VAL := 0x1
# Value written to END_SIGNATURE_ADDR that indicates test failure
@ -65,7 +66,7 @@ endif
# Options used for privileged CSR test generation
CSR_OPTS=--csr_yaml=${CSR_FILE} \
--isa=${ISA} \
--end_signature_addr=${END_SIGNATURE_ADDR}
--end_signature_addr=0x${END_SIGNATURE_ADDR}
# Generate random instructions
.SILENT gen:
@ -74,6 +75,7 @@ CSR_OPTS=--csr_yaml=${CSR_FILE} \
python3 ./run.py \
--o=${OUT}/instr_gen ${GEN_OPTS} \
--steps=gen \
--gen_timeout=${TIMEOUT} \
--lsf_cmd="${LSF_CMD}" \
${COMMON_OPTS} \
${CSR_OPTS} \
@ -89,6 +91,7 @@ gcc_compile:
--o=${OUT}/instr_gen ${GEN_OPTS} \
--steps=gcc_compile \
${COMMON_OPTS} \
--gcc_opts=-mno-strict-align \
--isa=${ISA} \
--mabi=ilp32

View file

@ -1,57 +0,0 @@
#!/bin/bash
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
RUN_DIR="$1"
report_file="$1/regr.log"
rm -rf "$report_file"
script_path="../../vendor/google_riscv-dv"
compare_log () {
spike_log="$1"
ibex_log="$2"
# -----------------------------------------------------------------------------
# Convert spike log to standard instruction trace csv
# -----------------------------------------------------------------------------
# Remove all the init spike boot instructions
# 0xffffffff80000080 is the first user instruction
sed -i '/0xffffffff80000080/,$!d' "$spike_log"
# Remove all instructions after ecall (end of program excecution)
sed -i '/ecall/q' "$spike_log"
# Convert the spike log to riscv_instr_trace.proto format
spike_csv=$(echo "$spike_log" | sed 's/\.log/.csv/g')
python $script_path/scripts/spike_log_to_trace_csv.py \
--log $spike_log --csv $spike_csv >> $report_file
# -----------------------------------------------------------------------------
# Convert ibex log to standard instruction trace csv
# -----------------------------------------------------------------------------
# Remove all instructions after ecall (end of program excecution)
sed -i '/ecall/q' "$ibex_log"
# Convert the spike log to riscv_instr_trace.proto format
ibex_csv=$(echo "$ibex_log" | sed 's/\.log/.csv/g')
python ./riscv_dv_extension/ibex_log_to_trace_csv.py \
--log $ibex_log --csv $ibex_csv >> $report_file
# -----------------------------------------------------------------------------
# Compare the trace log
# -----------------------------------------------------------------------------
python $script_path/scripts/instr_trace_compare.py $spike_csv $ibex_csv \
"spike" "ibex" >> $report_file
}
echo "compare simulation result under $RUN_DIR"
while read asm_test; do
SRC=$(echo "$asm_test" | sed 's/^.*\///g' | sed 's/\.S>*$//g')
echo "Test: $asm_test" >> $report_file
compare_log $RUN_DIR/instr_gen/spike_sim/$SRC.S.o.log \
$RUN_DIR/rtl_sim/$SRC/trace_core_00_0.log
done <"$RUN_DIR/asm_test_list"
passed_cnt="$(grep -c PASS $report_file)"
failed_cnt="$(grep -c FAIL $report_file)"
echo "$passed_cnt tests PASSED, $failed_cnt tests FAILED" >> $report_file
cat $report_file

View file

@ -27,6 +27,8 @@ def process_ibex_sim_log(ibex_log, csv):
trace_csv = RiscvInstructiontTraceCsv(csv_fd)
trace_csv.start_new_trace()
for line in f:
if re.search("ecall", line):
break
# Extract instruction infromation
m = re.search(r"^\s*(?P<time>\d+)\s+(?P<cycle>\d+) " \
"(?P<pc>[0-9a-f]+) (?P<bin>[0-9a-f]+) (?P<instr>.*)" \

View file

@ -1,21 +0,0 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
//====================================================================
// Test name : iterations : options
//--------------------------------------------------------------------
riscv_arithmetic_basic_test : 20 :
riscv_machine_mode_rand_test : 20 :
riscv_privileged_mode_rand_test : 0 :
riscv_rand_instr_test : 20 :
riscv_rand_jump_test : 20 :
riscv_mmu_stress_test : 20 :
riscv_page_table_exception_test : 0 :
riscv_no_fence_test : 10 :
riscv_sfence_exception_test : 0 :
riscv_illegal_instr_test : 10 :
riscv_hint_instr_test : 10 :
riscv_ebreak_test : 20 :
riscv_wfi_test : 5 : +enable_interrupt=1
//--------------------------------------------------------------------

View file

@ -30,7 +30,7 @@
- test: riscv_rand_instr_test
description: >
Random instruction stress test
iterations: 20
iterations: 10
gen_test: riscv_instr_base_test
gen_opts: >
+instr_cnt=10000
@ -58,7 +58,7 @@
description: >
Test with different patterns of load/store instructions, stress test MMU
operations.
iterations: 20
iterations: 10
gen_test: riscv_instr_base_test
gen_opts: >
+instr_cnt=10000
@ -75,7 +75,7 @@
instruction and handle corresponding exception properly. An exception
handling routine is designed to resume execution after illegal
instruction exception.
iterations: 20
iterations: 10
gen_test: riscv_rand_instr_test
gen_opts: >
+enable_illegal_instruction=1
@ -150,3 +150,18 @@
no_iss: 1
rtl_test: core_ibex_csr_test
no_post_compare: 1
- test: riscv_unaligned_load_store_test
description: >
Unaligned load/store test, ibex should handle it correctly without raising any exception
iterations: 5
gen_test: riscv_instr_base_test
gen_opts: >
+instr_cnt=10000
+num_of_sub_program=5
+directed_instr_0=riscv_load_store_rand_instr_stream,20
+directed_instr_1=riscv_load_store_hazard_instr_stream,20
+directed_instr_2=riscv_cache_line_stress_instr_stream,20
+directed_instr_3=riscv_multi_page_load_store_instr_stream,20
+enable_unaligned_load_store=1
rtl_test: core_ibex_base_test

View file

@ -1,103 +0,0 @@
#!/usr/bin/env bash
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
# Script to run the assembly tests generated by the riscv-dv instruction generator.
# Test directory
RUN_DIR="./"
# Assembly test file name
TEST=""
# Seed
RAND_SEED=1
SEED=""
# Wavform dump options
WAVES=0
WAVES_OPTS=""
# Coveragedump options
COV=0
COV_OPTS=""
# Process command line options
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-dir)
RUN_DIR="$2"
shift
;;
-test)
TEST="$2"
shift
;;
-waves)
WAVES="$2"
shift
;;
-cov)
COV="$2"
shift
;;
-seed)
SEED="$2"
RAND_SEED=0
shift
;;
*)
echo "unknown option $1"
exit 1
;;
esac
shift
done
# If the test is specified through "-test" option, run a single test rather
# than all tests under RUN_DIR.
if [[ $TEST == "" ]]; then
find "$RUN_DIR" -name "*.S" > "$RUN_DIR/asm_test_list"
else
echo "$TEST" > "$RUN_DIR/asm_test_list"
fi
OUT="$RUN_DIR/rtl_sim"
CWD=`pwd`
# Run each test
while read asm_test; do
OPTS=""
SRC=$(echo "$asm_test" | sed 's/^.*\///g' | sed 's/\.S>*$//g')
BINFILE="$asm_test.bin"
mkdir -p $OUT/$SRC
cd $OUT/$SRC
if [[ $RAND_SEED == 1 ]]; then
SEED=$RANDOM
fi
if [[ $WAVES == 1 ]]; then
WAVES_OPTS="-ucli -do $CWD/vcs.tcl"
fi
if [[ $COV == 1 ]]; then
COV_OPTS="-cm line+tgl+assert+fsm+branch \
-cm_dir ${RUN_DIR}/rtl_sim/test.vdb \
-cm_log /dev/null \
-assert nopostproc \
-cm_name test_${SEED}"
fi
if [[ "$BINFILE" =~ "ebreak" ]]; then
OPTS="+enable_debug_seq=1"
fi
if [[ "$BINFILE" =~ "wfi" ]]; then
OPTS="+enable_irq_seq=1"
fi
CMD="$OUT/vcs_simv +UVM_TESTNAME=core_ibex_base_test \
${WAVES_OPTS} +ntb_random_seed=${SEED} +vcs+lic+wait ${COV_OPTS}\
+UVM_MAX_QUIT_COUNT=5 +bin=$BINFILE -l sim.log ${OPTS}"
echo "Running simulation for : $CMD"
$CMD
done <"$RUN_DIR/asm_test_list"