Skip to content

Commit 02d3cc1

Browse files
committed
add Zclsd extension instructions
1 parent abc4553 commit 02d3cc1

File tree

4 files changed

+184
-0
lines changed

4 files changed

+184
-0
lines changed

arch/inst/Zclsd/c.ld.yaml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# yaml-language-server: $schema=../../../schemas/inst_schema.json
2+
3+
$schema: "inst_schema.json#"
4+
kind: instruction
5+
name: c.ld
6+
long_name: Load doubleword to even/odd register pair, 16-bit encoding
7+
description: |
8+
Loads a 64-bit value into registers rd' and rd'+1. It computes an effective address by adding the
9+
zero-extended offset, scaled by 8, to the base address in register rs1'.
10+
definedBy:
11+
anyOf: [Zclsd]
12+
assembly: c.ld rd', offset(rs1')
13+
encoding:
14+
match: 011-----------00
15+
variables:
16+
- name: rd
17+
location: 4-2
18+
- name: imm
19+
location: 9-7
20+
- name: rs1
21+
location: 12-10|6-5
22+
access:
23+
s: always
24+
u: always
25+
vs: always
26+
vu: always
27+
operation(): |
28+
29+
Bits<XLEN> base = X[rs1];
30+
Bits<XLEN> offset = imm << 3;
31+
Bits<XLEN> eff_addr = base + offset;
32+
33+
Bits<64> data = read_memory<64>(eff_addr, $encoding);
34+
35+
if (rd != 0 && (rd & 0x1) == 0) {
36+
X[rd] = data[31:0];
37+
X[rd+1] = data[63:32];
38+
}
39+
sail(): |
40+
let eff_addr = X(rs1') + (zero_extend(offset) << 3);
41+
let data : bits(64) = MEM_read(64, eff_addr);
42+
43+
X(rd') = data[31..0];
44+
X(rd'+1) = data[63..32];

arch/inst/Zclsd/c.ldsp.yaml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# yaml-language-server: $schema=../../../schemas/inst_schema.json
2+
3+
$schema: "inst_schema.json#"
4+
kind: instruction
5+
name: c.ldsp
6+
long_name: Stack-pointer based load doubleword to even/odd register pair
7+
description: |
8+
Loads stack-pointer relative 64-bit value into registers rd' and rd'+1. It computes its effective
9+
address by adding the zero-extended offset, scaled by 8, to the stack pointer, x2. It expands to ld
10+
rd, offset(x2). C.LDSP is only valid when rd≠x0; the code points with rd=x0 are reserved.
11+
definedBy:
12+
anyOf: [Zclsd]
13+
assembly: ld rd, offset(rs1)
14+
encoding:
15+
match: 011-----------01
16+
variables:
17+
- name: rd
18+
location: 11-7
19+
- name: imm
20+
location: 12|6-2
21+
access:
22+
s: always
23+
u: always
24+
vs: always
25+
vu: always
26+
operation(): |
27+
28+
Bits<XLEN> base = X[2];
29+
Bits<XLEN> offset = imm << 3;
30+
Bits<XLEN> eff_addr = base + offset;
31+
32+
Bits<64> data = read_memory<64>(eff_addr, $encoding);
33+
34+
if (rd != 0 && (rd & 0x1) == 0) {
35+
X[rd] = data[31:0];
36+
X[rd+1] = data[63:32];
37+
38+
}
39+
sail(): |
40+
let imm : xlenbits = zero_extend(imm_field) << 3;
41+
let ea : xlenbits = X(2) + imm;
42+
43+
let data_low : xlenbits = read_mem(ea, 32);
44+
let data_high : xlenbits = read_mem(ea + 4, 32);
45+
let data : bits(64) = data_high @ data_low;
46+
47+
if rd ≠ 0 & rd mod 2 == 0 & rd < 31 then {
48+
X(rd) = data[31..0];
49+
X(rd+1) = data[63..32];
50+
};
51+
52+
PC = PC + 2;

arch/inst/Zclsd/c.sd.yaml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# yaml-language-server: $schema=../../../schemas/inst_schema.json
2+
3+
$schema: "inst_schema.json#"
4+
kind: instruction
5+
name: c.sd
6+
long_name: Store doubleword from even/odd register pair
7+
description: |
8+
Stores a 64-bit value from registers rs2' and rs2'+1. It computes an effective address by adding
9+
the zero-extended offset, scaled by 8, to the base address in register rs1'. It expands to sd rs2',
10+
offset(rs1').
11+
definedBy:
12+
anyOf: [Zclsd]
13+
assembly: c.sd rs2', offset(rs1')
14+
encoding:
15+
match: 111-----------00
16+
variables:
17+
- name: rs2
18+
location: 4-2
19+
- name: rs1
20+
location: 9-7
21+
- name: imm
22+
location: 12-10|6-5
23+
access:
24+
s: always
25+
u: always
26+
vs: always
27+
vu: always
28+
operation(): |
29+
30+
Bits<XLEN> base = X[rs1];
31+
Bits<XLEN> offset = imm << 3;
32+
Bits<XLEN> eff_addr = base + offset;
33+
34+
Bits<64> data = {X[rs2+1], X[rs2]};
35+
36+
write_memory<64>(eff_addr, data, $encoding);
37+
38+
sail(): |
39+
let base = X(2);
40+
let offset = zero_extend(imm) << 3;
41+
let eff_addr = base + offset;
42+
43+
let data : bits(64) = X(rs2 + 1) @ X(rs2);
44+
45+
MEM_write(64, eff_addr, data);

arch/inst/Zclsd/c.sdsp.yaml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# yaml-language-server: $schema=../../../schemas/inst_schema.json
2+
3+
$schema: "inst_schema.json#"
4+
kind: instruction
5+
name: c.sdsp
6+
long_name: Stack-pointer based store doubleword from even/odd register pair
7+
description: |
8+
Stores a stack-pointer relative 64-bit value from registers rs2' and rs2'+1. It computes an effective
9+
address by adding the zero-extended offset, scaled by 8, to the stack pointer, x2. It expands to sd
10+
rs2, offset(x2).
11+
definedBy:
12+
anyOf: [Zclsd]
13+
assembly: c.sdsp rs2, offset(sp)
14+
encoding:
15+
match: 111-----------10
16+
variables:
17+
- name: rs2
18+
location: 6-2
19+
- name: imm
20+
location: 12-7
21+
access:
22+
s: always
23+
u: always
24+
vs: always
25+
vu: always
26+
operation(): |
27+
28+
Bits<XLEN> base = X[2];
29+
Bits<XLEN> offset = imm << 3;
30+
Bits<XLEN> eff_addr = base + offset;
31+
32+
Bits<64> data = {X[rs2+1], X[rs2]};
33+
34+
write_memory<64>(eff_addr, data, $encoding);
35+
36+
sail(): |
37+
let base = X(2);
38+
let offset = zero_extend(imm) << 3;
39+
let eff_addr = base + offset;
40+
41+
let data : bits(64) = X(rs2 + 1) @ X(rs2);
42+
43+
MEM_write(64, eff_addr, data);

0 commit comments

Comments
 (0)