Skip to content

Commit

Permalink
Add support for the unratified Zalasr extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendan Sweeney committed Mar 7, 2025
1 parent 37cbd6d commit eba666f
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile.old
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ SAIL_DEFAULT_INST += riscv_insts_zbkb.sail
SAIL_DEFAULT_INST += riscv_insts_zbkx.sail

SAIL_DEFAULT_INST += riscv_insts_zicond.sail
SAIL_DEFAULT_INST += riscv_insts_zalasr.sail

SAIL_DEFAULT_INST += riscv_insts_vext_utils.sail
SAIL_DEFAULT_INST += riscv_insts_vext_fp_utils.sail
Expand Down
1 change: 1 addition & 0 deletions model/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ foreach (xlen IN ITEMS 32 64)
${vext_srcs}
"riscv_insts_zicbom.sail"
"riscv_insts_zicboz.sail"
"riscv_insts_zalasr.sail"
)

if (variant STREQUAL "rmem")
Expand Down
2 changes: 2 additions & 0 deletions model/riscv_extensions.sail
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ enum clause extension = Ext_Zaamo
enum clause extension = Ext_Zabha
// Load-Reserved/Store-Conditional Instructions
enum clause extension = Ext_Zalrsc
// Load-Acquire/Store-Release Instructions
enum clause extension = Ext_Zalasr

// Additional Floating-Point Instructions
enum clause extension = Ext_Zfa
Expand Down
53 changes: 53 additions & 0 deletions model/riscv_insts_zalasr.sail
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*=======================================================================================*/
/* 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 */
/*=======================================================================================*/

/* *********************************************************************** */
/* This file specifies the atomic instructions in the 'Zalasr' extension. */

/* *********************************************************************** */

function clause extensionEnabled(Ext_Zalasr) = true

union clause ast = LOADAQ : (bool, bool, regidx, word_width, regidx)

mapping clause encdec = LOADAQ(aq, rl, rs1, size, rd) if extensionEnabled(Ext_Zalasr)
<-> 0b00110 @ bool_bits(aq) @ bool_bits(rl) @ 0b00000 @ rs1 @ 0b0 @ size_enc(size) @ rd @ 0b0101111 if extensionEnabled(Ext_Zalasr)

function clause execute(LOADAQ(aq, rl, rs1, width, rd)) = {
// load-acquire is required to have the acquire bit set
if not(aq)
then { handle_illegal(); RETIRE_FAIL }
else {
execute(LOAD(zeros(), rs1, rd, false, width, aq, rl))
}
}

mapping clause assembly = LOADAQ(aq, rl, rs1, size, rd)
<-> "l" ^ size_mnemonic(size)
^ maybe_aq(aq) ^ maybe_rl(rl)
^ spc() ^ reg_name(rd)
^ sep() ^ "(" ^ reg_name(rs1) ^ ")"

union clause ast = STORERL : (bool, bool, regidx, regidx, word_width)
mapping clause encdec = STORERL(aq, rl, rs2, rs1, size) if extensionEnabled(Ext_Zalasr)
<-> 0b00111 @ bool_bits(aq) @ bool_bits(rl) @ rs2 @ rs1 @ 0b0 @ size_enc(size) @ 0b00000 @ 0b0101111 if extensionEnabled(Ext_Zalasr)

function clause execute (STORERL(aq, rl, rs2, rs1, width)) = {
// store-release is required to have the release bit set
if not(rl)
then { handle_illegal(); RETIRE_FAIL }
else {
execute(STORE(zeros(), rs2, rs1, width, aq, rl))
}
}

mapping clause assembly = STORERL(aq, rl, rs2, rs1, size)
<-> "s" ^ size_mnemonic(size)
^ maybe_aq(aq) ^ maybe_rl(rl)
^ spc() ^ reg_name(rs2)
^ sep() ^ "(" ^ reg_name(rs1) ^ ")"
Binary file added test/riscv-tests/rv32ua-p-zalasr.elf
Binary file not shown.
Binary file added test/riscv-tests/rv64ua-p-zalasr.elf
Binary file not shown.

0 comments on commit eba666f

Please sign in to comment.