| #!/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 |