-
Notifications
You must be signed in to change notification settings - Fork 204
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
base: master
Are you sure you want to change the base?
Conversation
model/riscv_insts_zilsd.sail
Outdated
match ext_data_get_addr(rs1, offset, Read(Data), width_bytes) { | ||
Ext_DataAddr_Error(e) => { ext_handle_data_check_error(e); RETIRE_FAIL }, | ||
Ext_DataAddr_OK(vaddr) => | ||
if check_misaligned(vaddr, width) | ||
then { handle_mem_exception(vaddr, E_Load_Addr_Align()); RETIRE_FAIL } | ||
else match translateAddr(vaddr, Read(Data)) { | ||
TR_Failure(e, _) => { handle_mem_exception(vaddr, e); RETIRE_FAIL }, | ||
TR_Address(paddr, _) => | ||
match mem_read(Read(Data), paddr, 8, false, false, false) { | ||
Ok(result) => { | ||
X(rd) = result[31..0]; | ||
X(rd + 1) = result[63..32]; | ||
RETIRE_SUCCESS | ||
}, | ||
Err(e) => { handle_mem_exception(vaddr, e); RETIRE_FAIL }, | ||
}, | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious, wouldn't it make more sense to replace LOAD_RV32
(and STORE_RV32
) with two sequential 32-bit load/store operations instead of one 64-bit load/store operation?
Most 32-bit systems have a 32-bit memory bus, so performing two 32-bit accesses would be more realistic than a single 64-bit access on such hardware.
This implementation would also allow us to test the more interesting case where interrupts could occur between the two operations, as explicitly permitted by the Zilsd specification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's definitely a good idea, I didn't think of that
a979234
to
a28bd1b
Compare
model/riscv_insts_zclsd.sail
Outdated
/* SPDX-License-Identifier: BSD-2-Clause */ | ||
/*=======================================================================================*/ | ||
|
||
function clause extensionEnabled(Ext_Zclsd) = true & extensionEnabled(Ext_Zilsd) & extensionEnabled(Ext_Zca) & not(extensionEnabled(Ext_Zcf)) & xlen == 32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to create a mutual cycle between extensionEnabled(Ext_Zclsd)
and extensionEnabled(Ext_Zcf)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the configuration system merged, update to config extensions.Zclsd.enabled
should resolve the issue.
model/riscv_insts_zilsd.sail
Outdated
function clause extensionEnabled(Ext_Zilsd) = true & xlen == 32 | ||
|
||
/* ****************************************************************** */ | ||
union clause ast = LOAD_RV32 : (bits(12), regidx, regidx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOAD_DOUBLE
might be a better name for the AST constructor than LOAD_RV32
. It's unfortunate that the spec re-uses LOAD
. (Could we ask the spec authors to change this before ratification?) Similarly for STORE_RV32
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw your reply at riscv/riscv-zilsd#64, so I update it to the format of EXT_INST
(ZILSD_LD...).
model/riscv_insts_zilsd.sail
Outdated
|
||
function clause execute LOAD_RV32(imm, rs1, rd) = { | ||
// Use of misaligned (odd-numbered) registers is reserved. | ||
assert(regidx_to_regno(rd) % 2 == 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of asserting here, it would be better to put this constraint on rd
in the encdec
clause. Similarly for rs2
in the store instruction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
how does this relate to #490? |
I didn't see it before. Currently, the code mainly has the following differences
|
d6533f5
to
d70a272
Compare
@trdthg Could you check with @christian-herber-nxp to make sure we're not missing anything from #490 and we get the appropriate co-authors? |
the author of the original PR should be clear from that, it is @simonacostinescu |
c1bff11
to
ea18ab9
Compare
UpdateI am trying to run act tests (there is already a PR, not merged yet), but encountered a few problems
I think you could review this after I finished those tests.
|
One of the tricky parts with this extension is that it is designed to have its instructions overridden by other extensions (like `Zicfiss`). This will be handled by relying on file order to override instructions. This is a little fragile with the current compilation method, where all `.sail` files are passed to the compiler. In future we will use a Sail project file which allows enforcing file order more robustly.
Co-authored-by: Simona Costinescu <[email protected]>
function clause execute ZILSD_LD(imm, rs1, rd) = { | ||
if rd != zreg then { | ||
let base_val = X(rs1); | ||
let _ = load_imm(imm, base_val, rd, WORD); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this cause issues if the first load fails? I think you need to check what it returns so that we get the RETIRE_FAIL
if the first load fails.
Right now if the first load fails but the second one succeeds (like if it is right on some memory region boundary) this instruction will act like it succeeded.
spec: https://github.com/riscv/riscv-zilsd/blob/main/zilsd.adoc#insns-sd
function clause extensionEnabled(Ext_Zclsd) = true & xxx
is a placeholder, waiting for config system