From d0cc13ca9e8507de10dde70ef1b5772304cedb38 Mon Sep 17 00:00:00 2001 From: Ved Shanbhogue Date: Fri, 18 Aug 2023 15:59:52 -0500 Subject: [PATCH] add amocas specific addr check --- model/riscv_addr_checks.sail | 7 +++++++ model/riscv_insts_aext.sail | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/model/riscv_addr_checks.sail b/model/riscv_addr_checks.sail index 33091d93e..5ffd442bf 100644 --- a/model/riscv_addr_checks.sail +++ b/model/riscv_addr_checks.sail @@ -121,6 +121,13 @@ function ext_data_get_addr(base : regidx, offset : xlenbits, acc : AccessType(ex let addr = X(base) + offset in Ext_DataAddr_OK(addr) +/* Default AMO data addr is just base register. + Extensions might override and add additional checks. */ +function ext_data_get_amo_addr(base : regidx, acc : AccessType(ext_access_type), width : amo_word_width) + -> Ext_DataAddr_Check(ext_data_addr_error) = + let addr = X(base) in + Ext_DataAddr_OK(addr) + function ext_handle_data_check_error(err : ext_data_addr_error) -> unit = () diff --git a/model/riscv_insts_aext.sail b/model/riscv_insts_aext.sail index fe5e7dce2..e9edaec23 100644 --- a/model/riscv_insts_aext.sail +++ b/model/riscv_insts_aext.sail @@ -298,9 +298,8 @@ function clause execute (AMO(op, aq, rl, rs2, rs1, width, rd)) = { if haveAtomics() then { /* Get the address, X(rs1) (no offset). * Some extensions perform additional checks on address validity. - * For obtaining virtual address, the width is not needed. */ - match ext_data_get_addr(rs1, zeros(), ReadWrite(Data, Data), BYTE) { + match ext_data_get_amo_addr(rs1, ReadWrite(Data, Data), width) { Ext_DataAddr_Error(e) => { ext_handle_data_check_error(e); RETIRE_FAIL }, Ext_DataAddr_OK(vaddr) => { match translateAddr(vaddr, ReadWrite(Data, Data)) {