From 2b1a755131970a20e68253d5e93f7877465c19d9 Mon Sep 17 00:00:00 2001 From: Dan Smathers Date: Tue, 29 Aug 2023 09:53:40 -0600 Subject: [PATCH] Update model_test.h to match changes for spike updated to match changes to https://github.com/riscv-software-src/riscv-isa-sim/blob/master/arch_test_target/spike/model_test.h changes: update set_msw/clear_msw/set_mtimer/clear_mtimer Added ifndef to clint addresses instead of hard-coding Added clear_msw and clear mtimer Signed-off-by: Dan Smathers --- .../setup/sail_cSim/env/model_test.h | 46 +++++++++++++++++-- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/riscof/Templates/setup/sail_cSim/env/model_test.h b/riscof/Templates/setup/sail_cSim/env/model_test.h index 386ffdf..dc233d1 100644 --- a/riscof/Templates/setup/sail_cSim/env/model_test.h +++ b/riscof/Templates/setup/sail_cSim/env/model_test.h @@ -43,13 +43,51 @@ //RVTEST_IO_ASSERT_DFPR_EQ #define RVMODEL_IO_ASSERT_DFPR_EQ(_D, _R, _I) -#define RVMODEL_SET_MSW_INT +#ifndef RVMODEL_MCLINTBASE + #define RVMODEL_MCLINTBASE 0x02000000 +#endif -#define RVMODEL_CLEAR_MSW_INT +#ifndef RVMODEL_MSIP_OFFSET + #define RVMODEL_MSIP_OFFSET 0x0 +#endif -#define RVMODEL_CLEAR_MTIMER_INT +#ifndef RVMODEL_MTIMECMP_OFFSET + #define RVMODEL_MTIMECMP_OFFSET 0x4000 +#endif -#define RVMODEL_CLEAR_MEXT_INT +#ifndef RVMODEL_MTIMECMPH_OFFSET + #define RVMODEL_MTIMECMPH_OFFSET 0x4004 +#endif + +#define RVMODEL_SET_MSW_INT \ + lui t0, ((RVMODEL_MCLINTBASE + RVMODEL_MSIP_OFFSET)>> 12); \ + addi t0, t0, ((RVMODEL_MCLINTBASE + RVMODEL_MSIP_OFFSET) & 0xFFF); \ + li t1, 1; \ + sw t1, (t0); \ + +#define RVMODEL_CLEAR_MSW_INT \ + lui t0, ((RVMODEL_MCLINTBASE + RVMODEL_MSIP_OFFSET)>> 12); \ + addi t0, t0, ((RVMODEL_MCLINTBASE + RVMODEL_MSIP_OFFSET) & 0xFFF); \ + sw x0, (t0); \ +#define RVMODEL_SET_MTIMER_INT \ + lui t0, ((RVMODEL_MCLINTBASE + RVMODEL_MTIMECMP_OFFSET)>> 12); \ + addi t0, t0, ((RVMODEL_MCLINTBASE + RVMODEL_MTIMECMP_OFFSET) & 0xFFF); \ + sw x0, (t0); \ + lui t0, ((RVMODEL_MCLINTBASE + RVMODEL_MTIMECMPH_OFFSET)>> 12); \ + addi t0, t0, ((RVMODEL_MCLINTBASE + RVMODEL_MTIMECMPH_OFFSET) & 0xFFF); \ + sw x0, (t0); \ + +#define RVMODEL_CLEAR_MTIMER_INT \ + addi t1,x0,1; \ + neg t1,t1; \ + lui t0, ((RVMODEL_MCLINTBASE + RVMODEL_MTIMECMPH_OFFSET)>> 12); \ + addi t0, t0, ((RVMODEL_MCLINTBASE + RVMODEL_MTIMECMPH_OFFSET) & 0xFFF); \ + sw t1, (t0); \ + lui t0, ((RVMODEL_MCLINTBASE + RVMODEL_MTIMECMP_OFFSET)>> 12); \ + addi t0, t0, ((RVMODEL_MCLINTBASE + RVMODEL_MTIMECMP_OFFSET) & 0xFFF); \ + sw t1, (t0); \ + +#define RVMODEL_CLEAR_MEXT_INT #endif // _COMPLIANCE_MODEL_H