mirror of
https://github.com/ringtailsoftware/uvm32.git
synced 2026-06-05 22:43:39 +00:00
Test that invalid lX opcodes trigger mini-rv32 internal core error
This commit is contained in:
parent
fe51154698
commit
a5305d64dc
5 changed files with 54 additions and 1 deletions
|
|
@ -5,7 +5,8 @@ TESTS = \
|
||||||
syscall_args \
|
syscall_args \
|
||||||
meter \
|
meter \
|
||||||
extram \
|
extram \
|
||||||
badcode
|
badcode \
|
||||||
|
invalid_opcodes
|
||||||
|
|
||||||
RUNCMD = $(foreach TEST,${TESTS},make -C ${TEST} &&)
|
RUNCMD = $(foreach TEST,${TESTS},make -C ${TEST} &&)
|
||||||
CLEANCMD = $(foreach TEST,${TESTS},make -C ${TEST} clean &&)
|
CLEANCMD = $(foreach TEST,${TESTS},make -C ${TEST} clean &&)
|
||||||
|
|
|
||||||
2
test/invalid_opcodes/Makefile
Normal file
2
test/invalid_opcodes/Makefile
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
TOPDIR=../..
|
||||||
|
include ${TOPDIR}/test/common/makefile.common
|
||||||
2
test/invalid_opcodes/rom/Makefile
Normal file
2
test/invalid_opcodes/rom/Makefile
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
TOPDIR=../../..
|
||||||
|
include ${TOPDIR}/test/common/makefile-rom.common
|
||||||
5
test/invalid_opcodes/rom/rom.c
Normal file
5
test/invalid_opcodes/rom/rom.c
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include "uvm32_target.h"
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
}
|
||||||
|
|
||||||
43
test/invalid_opcodes/test/tests.c
Normal file
43
test/invalid_opcodes/test/tests.c
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
#include <string.h>
|
||||||
|
#include "unity.h"
|
||||||
|
#include "uvm32.h"
|
||||||
|
#include "../common/uvm32_common_custom.h"
|
||||||
|
|
||||||
|
#include "rom-header.h"
|
||||||
|
|
||||||
|
static uvm32_state_t vmst;
|
||||||
|
static uvm32_evt_t evt;
|
||||||
|
|
||||||
|
void setUp(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void tearDown(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_invalid_opcode_rd_extram(void) {
|
||||||
|
// https://www.cs.sfu.ca/~ashriram/Courses/CS295/assets/notebooks/RISCV/RISCV_CARD.pdf
|
||||||
|
// lb,lbu etc only have funct3 values of 0,1,2,4,5
|
||||||
|
uint8_t bad_funct3_3[] = {
|
||||||
|
0xb7, 0x0f, 0x00, 0x10, // lui t6,0x10000
|
||||||
|
0x83, 0xB2, 0x0f, 0x00 // l? t0,0(t6)
|
||||||
|
};
|
||||||
|
|
||||||
|
uvm32_init(&vmst);
|
||||||
|
uvm32_load(&vmst, bad_funct3_3, 8);
|
||||||
|
uvm32_run(&vmst, &evt, 100);
|
||||||
|
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_ERR);
|
||||||
|
TEST_ASSERT_EQUAL(evt.data.err.errcode, UVM32_ERR_INTERNAL_CORE);
|
||||||
|
|
||||||
|
uint8_t bad_funct3_6[] = {
|
||||||
|
0xb7, 0x0f, 0x00, 0x10, // lui t6,0x10000
|
||||||
|
0x83, 0xE2, 0x0f, 0x00 // l? t0,0(t6)
|
||||||
|
};
|
||||||
|
|
||||||
|
uvm32_init(&vmst);
|
||||||
|
uvm32_load(&vmst, bad_funct3_6, 8);
|
||||||
|
uvm32_run(&vmst, &evt, 100);
|
||||||
|
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_ERR);
|
||||||
|
TEST_ASSERT_EQUAL(evt.data.err.errcode, UVM32_ERR_INTERNAL_CORE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue