1(test-group "decode R-type"
2 (test "parse add instruction opcode"
3 (get-opcode 'ADD)
4 (instr-opcode add-instr))
5
6 (test "parse add instruction rd"
7 11
8 (instr-rd add-instr))
9
10 (test "parse add instruction rs1"
11 12
12 (instr-rs1 add-instr))
13
14 (test "parse add instruction rs2"
15 10
16 (instr-rs2 add-instr))
17
18 (test "parse add instruction func3"
19 (get-funct3 'ADD)
20 (instr-funct3 add-instr))
21
22 (test "parse add instruction func7"
23 (get-funct7 'ADD)
24 (instr-funct7 add-instr)))
25
26(test-group "decode I-type"
27 (test "parse addi instruction opcode"
28 (get-opcode 'ADDI)
29 (instr-opcode addi-instr))
30
31 (test "parse addi instruction rd"
32 5
33 (instr-rd addi-instr))
34
35 (test "parse addi instruction rs1"
36 6
37 (instr-rs1 addi-instr))
38
39 (test "parse addi instruction imm"
40 42
41 (instr-i-imm addi-instr))
42
43 (test "parse addi instruction funct3"
44 (get-funct3 'ADDI)
45 (instr-funct3 addi-instr)))
46
47(test-group "decode S-type"
48 (test "parse sw instruction opcode"
49 (get-opcode 'SW)
50 (instr-opcode sw-instr))
51
52 (test "parse sw instruction rs1"
53 9
54 (instr-rs1 sw-instr))
55
56 (test "parse sw instruction rs2"
57 1
58 (instr-rs2 sw-instr))
59
60 (test "parse sw instruction imm"
61 23
62 (instr-s-imm sw-instr))
63
64 (test "parse sw instruction funct3"
65 (get-funct3 'SW)
66 (instr-funct3 sw-instr)))
67
68(test-group "decode U-type"
69 (test "parse lui instruction opcode"
70 (get-opcode 'LUI)
71 (instr-opcode lui-instr))
72
73 (test "parse lui instruction rd"
74 28
75 (instr-rd lui-instr))
76
77 (test "parse lui imm"
78 #xfffff
79 (instr-u-imm lui-instr)))
80
81(test-group "decode B-type"
82 (test "parse beq instruction opcode"
83 (get-opcode 'BEQ)
84 (instr-opcode beq-instr))
85
86 (test "parse beq instruction rs1"
87 10
88 (instr-rs1 beq-instr))
89
90 (test "parse beq instruction rs2"
91 11
92 (instr-rs2 beq-instr))
93
94 (test "parse beq instruction imm"
95 32
96 (instr-b-imm beq-instr))
97
98 (test "parse beq instruction funct3"
99 (get-funct3 'BEQ)
100 (instr-funct3 beq-instr)))
101
102(test-group "decode J-type"
103 (test "parse jal instruction opcode"
104 (get-opcode 'JAL)
105 (instr-opcode jal-instr))
106
107 (test "parse jal instruction rd"
108 1
109 (instr-rd jal-instr))
110
111 (test "parse jal instruction imm"
112 32
113 (instr-j-imm jal-instr)))