-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtum_rvm.core_desc
63 lines (56 loc) · 2.14 KB
/
tum_rvm.core_desc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import "rv_base/RVM.core_desc"
InstructionSet tum_rvm extends RV32M {
functions {
signed<XLEN> mulh(signed<XLEN> x, signed<XLEN> y) {
signed<MUL_LEN> res = (signed<MUL_LEN>)x * (signed<MUL_LEN>)y;
return (signed<XLEN>)(res >> XLEN);
}
signed<XLEN> mulhsu(signed<XLEN> x, unsigned<XLEN>y) {
signed<MUL_LEN> res = (signed<MUL_LEN>)x * (unsigned<MUL_LEN>)y;
return (signed<XLEN>)(res >> XLEN);
}
unsigned<XLEN> mulhu(unsigned<XLEN> x, unsigned<XLEN>y) {
unsigned<MUL_LEN> res = (unsigned<MUL_LEN>)x * (unsigned<MUL_LEN>)y;
return (unsigned<XLEN>)(res >> XLEN);
}
}
instructions {
MUL {
encoding: 7'b0000001 :: rs2[4:0] :: rs1[4:0] :: 3'b000 :: rd[4:0] :: 7'b0110011;
assembly:"{name(rd)}, {name(rs1)}, {name(rs2)}";
behavior: {
if ((rd % RFS) != 0) {
signed<XLEN> res = (signed)X[rs1 % RFS] * (signed)X[rs2 % RFS];
X[rd % RFS] = (unsigned<XLEN>)res;
}
}
}
MULH {
encoding: 7'b0000001 :: rs2[4:0] :: rs1[4:0] :: 3'b001 :: rd[4:0] :: 7'b0110011;
assembly:"{name(rd)}, {name(rs1)}, {name(rs2)}";
behavior: {
if ((rd % RFS) != 0) {
X[rd % RFS] = mulh((signed)X[rs1 % RFS], (signed)X[rs2 % RFS]);
}
}
}
MULHSU {
encoding: 7'b0000001 :: rs2[4:0] :: rs1[4:0] :: 3'b010 :: rd[4:0] :: 7'b0110011;
assembly:"{name(rd)}, {name(rs1)}, {name(rs2)}";
behavior: {
if ((rd % RFS) != 0) {
X[rd % RFS] = mulhsu((signed)X[rs1 % RFS], X[rs2 % RFS]);
}
}
}
MULHU {
encoding: 7'b0000001 :: rs2[4:0] :: rs1[4:0] :: 3'b011 :: rd[4:0] :: 7'b0110011;
assembly:"{name(rd)}, {name(rs1)}, {name(rs2)}";
behavior: {
if ((rd % RFS) != 0) {
X[rd % RFS] = mulhu(X[rs1 % RFS], X[rs2 % RFS]);
}
}
}
}
}