added ebreak support
This commit is contained in:
@@ -15,6 +15,11 @@ rv32imac_tests.bin: rv32imac_tests.elf
|
||||
|
||||
run: rv32imac_tests.bin
|
||||
$(EMULATOR) rv32imac_tests.bin
|
||||
@echo "Testing standard ebreak..."
|
||||
@echo "115 0 16 0" | awk -f amach.awk 2>&1 | grep -q "Fatal: EBREAK"
|
||||
@echo "Testing compressed c.ebreak..."
|
||||
@echo "2 144" | awk -f amach.awk 2>&1 | grep -q "Fatal: EBREAK"
|
||||
@echo "All EBREAK tests PASSED!"
|
||||
|
||||
clean:
|
||||
rm -f rv32imac_tests.elf rv32imac_tests.bin
|
||||
|
||||
@@ -32,7 +32,7 @@ POSIXLY_CORRECT=1 awk -f amach.awk [-v LVA=...] -- path/to/program.dec
|
||||
|
||||
## Support
|
||||
|
||||
Currently, A-machine only supports the **unprivileged** RV32IMAC instruction set with a few additional `ecall` syscalls: 63 (sys_read, for fd 0 only), 64 (sys_write, for fd 1 and 2 only) and 93 (sys_exit). For completeness, `fence` instruction is also supported but yields a no-op.
|
||||
Currently, A-machine only supports the **unprivileged** RV32IMAC instruction set with a few additional `ecall` syscalls: 63 (sys_read, for fd 0 only), 64 (sys_write, for fd 1 and 2 only) and 93 (sys_exit). For completeness, `fence` instruction is also supported but yields a no-op, and both `ebreak` and `c.ebreak` are supported to halt execution with a debug message.
|
||||
|
||||
## Plans (from higher to lower priority)
|
||||
|
||||
|
||||
@@ -170,6 +170,7 @@ function amach_imm(opcode, f3, rd, rs1, immval, r1, ur1, shamt) {
|
||||
pc = r1 + immval
|
||||
} else if(opcode == 115) { # 0x73, system call / csr
|
||||
if(immval == 0) handle_ecall(getreg(17), getreg(10), getreg(11), getreg(12), getreg(13), getreg(14), getreg(15))
|
||||
else if(immval == 1) trapout(sprintf("EBREAK at 0x%X", pc-4))
|
||||
else trapout(sprintf("Unimplemented external system call at 0x%X", pc-4))
|
||||
} else trapout(sprintf("Illegal instruction at 0x%X", pc-4))
|
||||
}
|
||||
@@ -317,9 +318,8 @@ function amach_comp(instr, op, f3, b12, r11_7, r9_7, r6_2, r4_2, shamt, imm, ba
|
||||
} else setreg(r11_7, getreg(r6_2)) # C.MV
|
||||
} else {
|
||||
if(r6_2 == 0) {
|
||||
if(r11_7 == 0) { # C.EBREAK
|
||||
trapout(sprintf("EBREAK at 0x%X", pc-2))
|
||||
} else { # C.JALR
|
||||
if(r11_7 == 0) trapout(sprintf("EBREAK at 0x%X", pc-2)) # C.EBREAK
|
||||
else { # C.JALR
|
||||
imm = getreg(r11_7)
|
||||
setreg(1, pc)
|
||||
pc = imm
|
||||
|
||||
Binary file not shown.
@@ -795,6 +795,12 @@ _start:
|
||||
li a7, 93
|
||||
ecall
|
||||
|
||||
# Unreachable: placed to verify standard/compressed ebreak compilation
|
||||
ebreak
|
||||
.option rvc
|
||||
c.ebreak
|
||||
.option norvc
|
||||
|
||||
report_error:
|
||||
la a0, str_some_failed
|
||||
jal print_string
|
||||
|
||||
Reference in New Issue
Block a user