Skip to content
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

Add Zilsd/Zclsd Support #765

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add Zilsd/Zclsd Support #765

wants to merge 1 commit into from

Conversation

trdthg
Copy link
Contributor

@trdthg trdthg commented Mar 4, 2025

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

Copy link

github-actions bot commented Mar 4, 2025

Test Results

392 tests  ±0   392 ✅ ±0   1m 20s ⏱️ -1s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit a28bd1b. ± Comparison against base commit 2dfc4ff.

♻️ This comment has been updated with latest results.

Comment on lines 27 to 22
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 },
},
}
}
}
Copy link

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.

Copy link
Contributor Author

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

@jordancarlin jordancarlin added the extension Adds support for a RISC-V extension label Mar 5, 2025
/* SPDX-License-Identifier: BSD-2-Clause */
/*=======================================================================================*/

function clause extensionEnabled(Ext_Zclsd) = true & extensionEnabled(Ext_Zilsd) & extensionEnabled(Ext_Zca) & not(extensionEnabled(Ext_Zcf)) & xlen == 32
Copy link
Collaborator

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).

function clause extensionEnabled(Ext_Zilsd) = true & xlen == 32

/* ****************************************************************** */
union clause ast = LOAD_RV32 : (bits(12), regidx, regidx)
Copy link
Collaborator

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.


function clause execute LOAD_RV32(imm, rs1, rd) = {
// Use of misaligned (odd-numbered) registers is reserved.
assert(regidx_to_regno(rd) % 2 == 0);
Copy link
Collaborator

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.

@christian-herber-nxp
Copy link

how does this relate to #490?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension Adds support for a RISC-V extension
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants