riscv-utils

Scheme utility procedures for the RISC-V instruction set architecture

git clone https://git.8pit.net/riscv-utils.git

 1(test-group "byte order converison"
 2  (test "le->instr"
 3    lui-instr
 4    (le->instr lui-instr))
 5
 6  (test "be->instr"
 7    lui-instr
 8    (be->instr #x37feffff))
 9
10  (test "instr->le"
11    beq-instr
12    (instr->le beq-instr))
13
14  (test "instr->be"
15    beq-instr
16    (instr->be #x6300b502)))
17
18(test-group "output conversion"
19  (test "instr->bin hex"
20    "#b100011"
21    (instr->bin #x23))
22
23  (test "instr->bin binary"
24    "#b111111111111"
25    (instr->bin #b111111111111))
26
27  (test "instr->hex with beqi-instr"
28    "#x2b50063"
29    (instr->hex beq-instr))
30
31  (test "instr->hex with large value"
32    "#x2b3f67135a4"
33    (instr->hex #x02b3f67135a4))
34
35  (test "instr->hex with zero"
36    "#x0"
37    (instr->hex 0)))