diff --git a/test/sim/sw_testcases/csr_id.c b/test/sim/sw_testcases/csr_id.c new file mode 100644 index 0000000..0d0ccab --- /dev/null +++ b/test/sim/sw_testcases/csr_id.c @@ -0,0 +1,21 @@ +#include "tb_cxxrtl_io.h" +#include "hazard3_csr.h" + +// This is a new CSR for priv-1.12. Most compilers (maybe binutils?) don't know about it. +#define mconfigptr 0xf15 + +int main() { + // Expected value: 32'hdeadbeef, set in tb Makefile + tb_printf("mvendorid: %08x\n", read_csr(mvendorid )); + // Expected value: 27, the registered ID for Hazard3 + tb_printf("marchid: %08x\n", read_csr(marchid )); + // Expected value: 32'h12345678, set in tb Makefile + tb_printf("mimpid: %08x\n", read_csr(mimpid )); + // Expected value: 0 + tb_printf("mhartid: %08x\n", read_csr(mhartid )); + // Expected value: 32'h9abcdef0, set in tb Makefile + tb_printf("mconfigptr: %08x\n", read_csr(mconfigptr)); + // Expected value: 40801105, RV32I + A C M X + tb_printf("misa: %08x\n", read_csr(misa )); + return 0; +} diff --git a/test/sim/sw_testcases/csr_id.expected_output b/test/sim/sw_testcases/csr_id.expected_output new file mode 100644 index 0000000..783037e --- /dev/null +++ b/test/sim/sw_testcases/csr_id.expected_output @@ -0,0 +1,6 @@ +mvendorid: deadbeef +marchid: 0000001b +mimpid: 12345678 +mhartid: 00000000 +mconfigptr: 9abcdef0 +misa: 40801105 diff --git a/test/sim/tb_cxxrtl/Makefile b/test/sim/tb_cxxrtl/Makefile index abdfd14..fa15e2c 100644 --- a/test/sim/tb_cxxrtl/Makefile +++ b/test/sim/tb_cxxrtl/Makefile @@ -15,6 +15,10 @@ MUL_FAST := 1 MULH_FAST := 1 REDUCED_BYPASS := 0 +MVENDORID_VAL := 32'hdeadbeef +MIMPID_VAL := 32'h12345678 +MCONFIGPTR_VAL := 32'h9abcdef0 + .PHONY: clean all all: tb @@ -33,6 +37,9 @@ SYNTH_CMD += chparam -set REDUCED_BYPASS $(REDUCED_BYPASS) $(TOP); SYNTH_CMD += chparam -set MULDIV_UNROLL $(MULDIV_UNROLL) $(TOP); SYNTH_CMD += chparam -set MUL_FAST $(MUL_FAST) $(TOP); SYNTH_CMD += chparam -set MULH_FAST $(MULH_FAST) $(TOP); +SYNTH_CMD += chparam -set MVENDORID_VAL $(MVENDORID_VAL) $(TOP); +SYNTH_CMD += chparam -set MIMPID_VAL $(MIMPID_VAL) $(TOP); +SYNTH_CMD += chparam -set MCONFIGPTR_VAL $(MCONFIGPTR_VAL) $(TOP); SYNTH_CMD += hierarchy -top $(TOP); SYNTH_CMD += write_cxxrtl dut.cpp