Add AMO + timer testcase
This commit is contained in:
parent
4c532240f8
commit
c57a80f358
|
@ -0,0 +1,5 @@
|
|||
SRCS := ../common/init.S main.c
|
||||
APP := amo_timer_irq
|
||||
CCFLAGS = -march=rv32imac -Os
|
||||
|
||||
include ../common/src_only_app.mk
|
|
@ -0,0 +1,46 @@
|
|||
[*]
|
||||
[*] GTKWave Analyzer v3.3.103 (w)1999-2019 BSI
|
||||
[*] Sat Dec 4 23:25:19 2021
|
||||
[*]
|
||||
[dumpfile] "amo_timer_irq_run.vcd"
|
||||
[dumpfile_mtime] "Sat Dec 4 23:21:36 2021"
|
||||
[dumpfile_size] 6246687
|
||||
[savefile] "/home/luke/proj/hazard3/test/sim/amo_smoke/amo_smoke.gtkw"
|
||||
[timestart] 420
|
||||
[size] 1975 1095
|
||||
[pos] -1 -1
|
||||
*-3.000000 458 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
|
||||
[treeopen] core.
|
||||
[sst_width] 233
|
||||
[signals_width] 246
|
||||
[sst_expanded] 1
|
||||
[sst_vpaned_height] 317
|
||||
@22
|
||||
core.d_pc[31:0]
|
||||
@28
|
||||
core.mw_local_exclusive_reserved
|
||||
core.m_stall
|
||||
core.x_stall
|
||||
core.x_stall_on_amo
|
||||
@200
|
||||
-
|
||||
@22
|
||||
d_haddr[31:0]
|
||||
@28
|
||||
d_htrans[1:0]
|
||||
d_hsize[2:0]
|
||||
@29
|
||||
d_hexcl
|
||||
@28
|
||||
d_hwrite
|
||||
d_hready
|
||||
@22
|
||||
d_hwdata[31:0]
|
||||
d_hrdata[31:0]
|
||||
@200
|
||||
-
|
||||
@22
|
||||
core.x_rs2_bypass[31:0]
|
||||
core.xm_store_data[31:0]
|
||||
[pattern_trace] 1
|
||||
[pattern_trace] 0
|
|
@ -0,0 +1,45 @@
|
|||
#include "tb_cxxrtl_io.h"
|
||||
#include <stdint.h>
|
||||
|
||||
// Serve timer IRQs in the background whilst performing AMOs in a loop in the
|
||||
// foreground.
|
||||
|
||||
#define IRQ_INTERVAL 201
|
||||
#define N_AMOS 1000
|
||||
|
||||
#define test_assert(cond, ...) if (!(cond)) {tb_printf(__VA_ARGS__); return -1;}
|
||||
|
||||
volatile uint32_t amo_count, irq_count;
|
||||
|
||||
void __attribute__((interrupt)) isr_machine_timer() {
|
||||
mm_timer->mtimecmp = mm_timer->mtimecmp + IRQ_INTERVAL;
|
||||
++irq_count;
|
||||
}
|
||||
|
||||
int main() {
|
||||
amo_count = 0;
|
||||
irq_count = 0;
|
||||
|
||||
asm volatile ("csrw mie, %0" : : "r" (0x80));
|
||||
mm_timer->mtime = 0;
|
||||
// Will take first timer interrupt immediately:
|
||||
asm volatile ("csrsi mstatus, 0x8");
|
||||
|
||||
for (uint32_t i = 0; i < N_AMOS; i = i + 1) {
|
||||
uint32_t fetch;
|
||||
asm volatile (
|
||||
"amoadd.w %0, %1, (%2)"
|
||||
: "=r" (fetch)
|
||||
: "r" (1), "r" (&amo_count)
|
||||
);
|
||||
test_assert(fetch == i, "Bad fetch, expected %u, got %u\n", i, fetch);
|
||||
}
|
||||
|
||||
asm volatile ("csrci mstatus, 0x8");
|
||||
uint32_t current_time = mm_timer->mtime;
|
||||
tb_printf("At time %u, received %u IRQs\n", current_time, irq_count);
|
||||
test_assert(current_time / IRQ_INTERVAL + 1 == irq_count, "Bad IRQ count\n");
|
||||
test_assert(amo_count == N_AMOS, "Bad final AMO count %u\n", N_AMOS);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue