-
Notifications
You must be signed in to change notification settings - Fork 251
Add Zilsd/Zclsd Support #765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
trdthg
wants to merge
5
commits into
riscv:master
Choose a base branch
from
trdthg:zilsd
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| /*=======================================================================================*/ | ||
| /* This Sail RISC-V architecture model, comprising all files and */ | ||
| /* directories except where otherwise noted is subject the BSD */ | ||
| /* two-clause license in the LICENSE file. */ | ||
| /* */ | ||
| /* SPDX-License-Identifier: BSD-2-Clause */ | ||
| /*=======================================================================================*/ | ||
|
|
||
| function clause currentlyEnabled(Ext_Zclsd) = hartSupports(Ext_Zilsd) & currentlyEnabled(Ext_Zca) & not(hartSupports(Ext_Zcf)) & xlen == 32 | ||
|
|
||
| // RV32Zclsd requires even register pairs | ||
| function validZclsdReg(reg : regidx) -> bool = { | ||
| if encdec_reg(reg)[0] == 0b1 | ||
| then match rv32load_store_pair_odd_register_reserved_behavior { | ||
| LoadStorePair_Fatal => reserved_behavior("Zclsd used odd-numbered register " ^ dec_str(unsigned(encdec_reg(reg)))), | ||
| LoadStorePair_Illegal => return false, | ||
| }; | ||
| true | ||
| } | ||
|
|
||
| function validZclsdCReg(reg : cregidx) -> bool = | ||
| validZclsdReg(creg2reg_idx(reg)) | ||
|
|
||
| /* ****************************************************************** */ | ||
| union clause instruction = ZCLSD_C_LDSP : (bits(9), regidx) | ||
|
|
||
| $[wavedrom "C.LDSP offset[5] dest offset[4:3] offset[8:6] C2"] | ||
| mapping clause encdec_compressed = ZCLSD_C_LDSP(uimm @ 0b000, rd) | ||
| <-> 0b011 @ uimm[2] @ encdec_reg(rd) @ uimm[1..0] @ uimm[5..3] @ 0b10 | ||
| when currentlyEnabled(Ext_Zclsd) & validZclsdReg(rd) & rd != zreg | ||
|
|
||
| function clause execute ZCLSD_C_LDSP(imm, rd) = { | ||
| ExecuteAs(ZILSD_LD(zero_extend(imm), sp, rd)) | ||
| } | ||
|
|
||
| mapping clause assembly = ZCLSD_C_LDSP(uimm, rd) | ||
| <-> "c.ldsp" ^ spc() ^ reg_name(rd) ^ sep() ^ hex_bits_9(uimm) | ||
| when rd != zreg | ||
|
|
||
| /* ****************************************************************** */ | ||
| union clause instruction = ZCLSD_C_SDSP : (bits(9), regidx) | ||
|
|
||
| $[wavedrom "C.SDSP offset[5:3] offset[8:6] src C2"] | ||
| mapping clause encdec_compressed = ZCLSD_C_SDSP(uimm @ 0b000, rs2) | ||
| <-> 0b111 @ uimm[2 .. 0] @ uimm[5 .. 3] @ encdec_reg(rs2) @ 0b10 | ||
| when currentlyEnabled(Ext_Zclsd) & validZclsdReg(rs2) | ||
|
|
||
| function clause execute ZCLSD_C_SDSP(uimm, rs2) = { | ||
| ExecuteAs(ZILSD_SD(zero_extend(uimm), rs2, sp)) | ||
| } | ||
|
|
||
| mapping clause assembly = ZCLSD_C_SDSP(uimm, rs2) | ||
| <-> "c.sdsp" ^ spc() ^ reg_name(rs2) ^ sep() ^ hex_bits_9(uimm) | ||
|
|
||
| /* ****************************************************************** */ | ||
| union clause instruction = ZCLSD_C_LD : (bits(8), cregidx, cregidx) | ||
|
|
||
| $[wavedrom "C.LD offset[5:3] base offset[7:6] dest C0"] | ||
| mapping clause encdec_compressed = ZCLSD_C_LD(uimm @ 0b000, rs1, rd) | ||
| <-> 0b011 @ uimm[2 .. 0] @ encdec_creg(rs1) @ uimm[4 .. 3] @ encdec_creg(rd) @ 0b00 | ||
| when currentlyEnabled(Ext_Zclsd) & validZclsdCReg(rd) | ||
|
|
||
| function clause execute ZCLSD_C_LD(uimm, rsc, rdc) = { | ||
| let rd = creg2reg_idx(rdc); | ||
| let rs = creg2reg_idx(rsc); | ||
| ExecuteAs(ZILSD_LD(zero_extend(uimm), rs, rd)) | ||
| } | ||
|
|
||
| mapping clause assembly = ZCLSD_C_LD(uimm, rsc, rdc) | ||
| <-> "c.ld" ^ spc() ^ creg_name(rdc) ^ sep() ^ creg_name(rsc) ^ sep() ^ hex_bits_8(uimm) | ||
|
|
||
| /* ****************************************************************** */ | ||
| union clause instruction = ZCLSD_C_SD : (bits(8), cregidx, cregidx) | ||
|
|
||
| $[wavedrom "C.SD offset[5:3] base offset[7:6] src C0"] | ||
| mapping clause encdec_compressed = ZCLSD_C_SD(uimm @ 0b000, rs1, rs2) | ||
| <-> 0b111 @ uimm[2 .. 0] @ encdec_creg(rs1) @ uimm[4 .. 3] @ encdec_creg(rs2) @ 0b00 | ||
| when currentlyEnabled(Ext_Zclsd) & validZclsdCReg(rs2) | ||
|
|
||
| function clause execute ZCLSD_C_SD(uimm, rsc1, rsc2) = { | ||
| let rs1 = creg2reg_idx(rsc1); | ||
| let rs2 = creg2reg_idx(rsc2); | ||
| ExecuteAs(ZILSD_SD(zero_extend(uimm), rs2, rs1)) | ||
| } | ||
|
|
||
| mapping clause assembly = ZCLSD_C_SD(uimm, rsc1, rsc2) | ||
| <-> "c.sd" ^ spc() ^ creg_name(rsc1) ^ sep() ^ creg_name(rsc2) ^ sep() ^ hex_bits_8(uimm) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| /*=======================================================================================*/ | ||
| /* This Sail RISC-V architecture model, comprising all files and */ | ||
| /* directories except where otherwise noted is subject the BSD */ | ||
| /* two-clause license in the LICENSE file. */ | ||
| /* */ | ||
| /* SPDX-License-Identifier: BSD-2-Clause */ | ||
| /*=======================================================================================*/ | ||
|
|
||
| function clause currentlyEnabled(Ext_Zilsd) = hartSupports(Ext_Zilsd) & xlen == 32 | ||
|
|
||
| // Zilsd requires even register pairs | ||
| function validZilsdReg(reg : regidx) -> bool = { | ||
| if encdec_reg(reg)[0] == 0b1 | ||
| then match rv32load_store_pair_odd_register_reserved_behavior { | ||
| LoadStorePair_Fatal => reserved_behavior("Zilsd used odd-numbered register " ^ dec_str(unsigned(encdec_reg(reg)))), | ||
| LoadStorePair_Illegal => return false, | ||
| }; | ||
| true | ||
| } | ||
|
|
||
| // TODO: According to the spec, an implementation can generate a | ||
| // misaligned trap when performing these instructions at 4B-aligned | ||
| // but not 8B-aligned addresses. The implementation below does not | ||
| // model this, since it always performs word accesses. | ||
|
|
||
| /* ****************************************************************** */ | ||
| union clause instruction = ZILSD_LD : (bits(12), regidx, regidx) | ||
|
|
||
| $[wavedrom "offset[11:5] base width=D dest LOAD"] | ||
| mapping clause encdec = ZILSD_LD(imm, rs1, rd) | ||
| <-> imm @ encdec_reg(rs1) @ 0b011 @ encdec_reg(rd) @ 0b0000011 | ||
| when currentlyEnabled(Ext_Zilsd) & validZilsdReg(rd) | ||
|
|
||
| function clause execute ZILSD_LD(imm, rs1, rd) = { | ||
| assert(xlen == 32); | ||
| let access = Load(Data); | ||
| match vmem_read(rs1, sign_extend(imm), 4, access, false, false, false) { | ||
| Ok(lo) => { | ||
| match vmem_read(rs1, sign_extend(imm + 4), 4, access, false, false, false) { | ||
| Ok(hi) => { X_pair(rd) = hi @ lo; RETIRE_SUCCESS }, | ||
| Err(e) => e, | ||
| } | ||
| }, | ||
| Err(e) => e, | ||
| } | ||
| } | ||
| mapping clause assembly = ZILSD_LD(imm, rs1, rd) <-> "ld" ^ spc() ^ reg_name(rd) ^ sep() ^ hex_bits_signed_12(imm) ^ "(" ^ reg_name(rs1) ^ ")" | ||
|
|
||
|
|
||
| /* ****************************************************************** */ | ||
| union clause instruction = ZILSD_SD : (bits(12), regidx, regidx) | ||
|
|
||
| $[wavedrom "offset[11:5] src base width=D offset[4:0] STORE"] | ||
| mapping clause encdec = ZILSD_SD(imm, rs2, rs1) | ||
| <-> imm[11 .. 5] @ encdec_reg(rs2) @ encdec_reg(rs1) @ 0b011 @ imm[4 .. 0] @ 0b0100011 | ||
| when currentlyEnabled(Ext_Zilsd) & validZilsdReg(rs2) | ||
|
|
||
| function clause execute ZILSD_SD(imm, rs2, rs1) = { | ||
| assert(xlen == 32); | ||
| let value = X_pair(rs2); | ||
| let access = Store(Data); | ||
| match vmem_write(rs1, sign_extend(imm), 4, value[31 .. 0], access, false, false, false) { | ||
| Ok(_) => { | ||
| match vmem_write(rs1, sign_extend(imm + 4), 4, value[63 .. 32], access, false, false, false) { | ||
| Ok(_) => RETIRE_SUCCESS, | ||
| Err(e) => e, | ||
| } | ||
| }, | ||
| Err(e) => e, | ||
| } | ||
| } | ||
|
|
||
| mapping clause assembly = ZILSD_SD(offset, rs2, rs1) <-> "sd" ^ spc() ^ reg_name(rs2) ^ sep() ^ hex_bits_signed_12(offset) ^ "(" ^ reg_name(rs1) ^ ")" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.