Skip to content

Commit

Permalink
Add Zabha extension
Browse files Browse the repository at this point in the history
  • Loading branch information
ved-rivos committed Jun 22, 2024
1 parent a462c51 commit 1904212
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
11 changes: 6 additions & 5 deletions model/riscv_insts_aext.sail
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function aqrl_str(aq : bool, rl : bool) -> string =
}

function lrsc_width_str(width : word_width) -> string =
match (width) {
match width {
BYTE => ".b",
HALF => ".h",
WORD => ".w",
Expand All @@ -33,14 +33,15 @@ function lrsc_width_str(width : word_width) -> string =
* RISC-V Zabha extension defines AMOs for byte and halfword
*/
function lrsc_width_valid(size : word_width) -> bool = {
match(size) {
match size {
WORD => true,
DOUBLE => sizeof(xlen) >= 64,
_ => false
}
}

function amo_width_valid(size : word_width) -> bool = {
match(size) {
match size {
BYTE => haveZabha(),
HALF => haveZabha(),
WORD => true,
Expand Down Expand Up @@ -132,7 +133,7 @@ function clause execute (STORECON(aq, rl, rs2, rs1, width, rd)) = {
TR_Failure(e, _) => { handle_mem_exception(vaddr, e); RETIRE_FAIL },
TR_Address(addr, _) => {
let eares = mem_write_ea(addr, width_bytes, aq & rl, rl, true);
match (eares) {
match eares {
MemException(e) => { handle_mem_exception(vaddr, e); RETIRE_FAIL },
MemValue(_) => {
let rs2_val = X(rs2);
Expand Down Expand Up @@ -194,7 +195,7 @@ function clause execute (AMO(op, aq, rl, rs2, rs1, width, rd)) = {
TR_Address(addr, _) => {
let eares = mem_write_ea(addr, width_bytes, aq & rl, rl, true);
let rs2_val = X(rs2)[width_bytes * 8 - 1 .. 0];
match (eares) {
match eares {
MemException(e) => { handle_mem_exception(vaddr, e); RETIRE_FAIL },
MemValue(_) => {
match mem_read(ReadWrite(Data, Data), addr, width_bytes, aq, aq & rl, true) {
Expand Down
3 changes: 3 additions & 0 deletions model/riscv_sys_regs.sail
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ function haveZalrsc() -> bool = haveAtomics()
/* Zicond extension support */
function haveZicond() -> bool = true

/* Zabha extension support */
function haveZabha() -> bool = true

/*
* Illegal values legalized to least privileged mode supported.
* Note: the only valid combinations of supported modes are M, M+U, M+S+U.
Expand Down

0 comments on commit 1904212

Please sign in to comment.