Skip to content

Commit 4fd40f9

Browse files
committed
Update the F/D and vector loads/stores to use the vmem_utils helpers.
For writes, this involves appropriate wrappers to access source registers of different types (i.e. reg, freg, vreg). Add some comments on the API available from `vmem_utils`. Update Makefile.old for SMT properties.
1 parent 633efb2 commit 4fd40f9

File tree

5 files changed

+203
-355
lines changed

5 files changed

+203
-355
lines changed

Makefile.old

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ SAIL_SYS_SRCS += riscv_zicntr_control.sail
9292
SAIL_SYS_SRCS += riscv_softfloat_interface.sail riscv_fdext_regs.sail riscv_fdext_control.sail
9393
SAIL_SYS_SRCS += riscv_sys_control.sail # general exception handling
9494
SAIL_SYS_SRCS += riscv_smcntrpmf.sail
95+
SAIL_SYS_SRCS += riscv_inst_retire.sail
9596

9697
SAIL_VM_SRCS += riscv_vmem_pte.sail
9798
SAIL_VM_SRCS += riscv_vmem_ptw.sail
@@ -115,7 +116,6 @@ SAIL_ARCH_SRCS += riscv_sstc.sail
115116
SAIL_ARCH_SRCS += riscv_mem.sail $(SAIL_VM_SRCS)
116117
SAIL_ARCH_RVFI_SRCS = $(PRELUDE) rvfi_dii.sail riscv_extensions.sail riscv_types_common.sail riscv_types_ext.sail riscv_types.sail riscv_vmem_types.sail $(SAIL_REGS_SRCS) $(SAIL_SYS_SRCS) riscv_platform.sail riscv_mem.sail $(SAIL_VM_SRCS) riscv_types_kext.sail riscv_inst_retire.sail
117118
SAIL_ARCH_SRCS += riscv_types_kext.sail riscv_zvk_utils.sail # Shared/common code for the cryptography extension.
118-
SAIL_ARCH_SRCS += riscv_inst_retire.sail
119119

120120
SAIL_STEP_SRCS = riscv_step_common.sail riscv_step_ext.sail riscv_decode_ext.sail riscv_fetch.sail riscv_step.sail
121121
RVFI_STEP_SRCS = riscv_step_common.sail riscv_step_rvfi.sail riscv_decode_ext.sail riscv_fetch_rvfi.sail riscv_step.sail

doc/ReadingGuide.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,15 @@ such as the platform memory map.
8080
appropriate access fault. This file also contains definitions that
8181
are used in the weak memory concurrency model.
8282

83-
- The `riscv_vmem_*.sail` files describe the S-mode address
84-
translation. See the [Virtual Memory Notes](./notes_Virtual_Memory.adoc)
85-
for details.
83+
- The `riscv_vmem_{types,pte,ptw,tlb}.sail` and `riscv_vmem.sail`
84+
files describe the S-mode address translation.
85+
See the [Virtual Memory Notes](./notes_Virtual_Memory.adoc) for
86+
details.
87+
88+
- The `riscv_vmem_utils.sail` file provides a higher level interface
89+
to virtual memory for load/store style instructions that handles
90+
address translation and accesses to misaligned addresses taking
91+
platform configuration options into account.
8692

8793
- The `riscv_addr_checks_common.sail` and `riscv_addr_checks.sail`
8894
contain extension hooks to support the checking and transformation

model/riscv_insts_fext.sail

+7-43
Original file line numberDiff line numberDiff line change
@@ -295,24 +295,9 @@ function clause execute(LOAD_FP(imm, rs1, rd, width)) = {
295295
assert(width_bytes <= flen_bytes);
296296

297297
let offset : xlenbits = sign_extend(imm);
298-
/* Get the address, X(rs1) + offset.
299-
Some extensions perform additional checks on address validity. */
300-
match ext_data_get_addr(rs1, offset, Read(Data), width_bytes) {
301-
Ext_DataAddr_Error(e) => RETIRE_FAIL(Ext_DataAddr_Check_Failure(e)),
302-
Ext_DataAddr_OK(vaddr) => {
303-
if check_misaligned(vaddr, width)
304-
then RETIRE_FAIL(Memory_Exception(vaddr, E_Load_Addr_Align()))
305-
else match translateAddr(vaddr, Read(Data)) {
306-
TR_Failure(e, _) => RETIRE_FAIL(Memory_Exception(vaddr, e)),
307-
TR_Address(addr, _) => {
308-
let (aq, rl, res) = (false, false, false);
309-
match mem_read(Read(Data), addr, width_bytes, aq, rl, res) {
310-
Ok(result) => { F(rd) = nan_box(result); RETIRE_SUCCESS },
311-
Err(e) => RETIRE_FAIL(Memory_Exception(vaddr, e)),
312-
}
313-
},
314-
}
315-
}
298+
match vmem_read(rs1, offset, width_bytes, false, false, false) {
299+
Ok(result) => { F(rd) = nan_box(result); RETIRE_SUCCESS },
300+
Err(e) => { RETIRE_FAIL(e) }
316301
}
317302
}
318303

@@ -355,31 +340,10 @@ function clause execute (STORE_FP(imm, rs2, rs1, width)) = {
355340
assert(width_bytes <= flen_bytes);
356341

357342
let offset : xlenbits = sign_extend(imm);
358-
let (aq, rl, con) = (false, false, false);
359-
/* Get the address, X(rs1) + offset.
360-
Some extensions perform additional checks on address validity. */
361-
match ext_data_get_addr(rs1, offset, Write(Data), width_bytes) {
362-
Ext_DataAddr_Error(e) => RETIRE_FAIL(Ext_DataAddr_Check_Failure(e)),
363-
Ext_DataAddr_OK(vaddr) => {
364-
if check_misaligned(vaddr, width)
365-
then RETIRE_FAIL(Memory_Exception(vaddr, E_SAMO_Addr_Align()))
366-
else match translateAddr(vaddr, Write(Data)) {
367-
TR_Failure(e, _) => RETIRE_FAIL(Memory_Exception(vaddr, e)),
368-
TR_Address(addr, _) => {
369-
match mem_write_ea(addr, width_bytes, aq, rl, false) {
370-
Err(e) => RETIRE_FAIL(Memory_Exception(vaddr, e)),
371-
Ok(_) => {
372-
let rs2_val = F(rs2);
373-
match mem_write_value(addr, width_bytes, rs2_val[width_bytes * 8 - 1 .. 0], aq, rl, con) {
374-
Ok(true) => RETIRE_SUCCESS,
375-
Ok(false) => { internal_error(__FILE__, __LINE__, "store got false from mem_write_value") },
376-
Err(e) => RETIRE_FAIL(Memory_Exception(vaddr, e))
377-
}
378-
},
379-
}
380-
}
381-
}
382-
}
343+
match vmem_write(rs1, offset, width_bytes, rs2) {
344+
Ok(true) => RETIRE_SUCCESS,
345+
Ok(false) => internal_error(__FILE__, __LINE__, "store got false from vmem_write"),
346+
Err(e) => RETIRE_FAIL(e),
383347
}
384348
}
385349

0 commit comments

Comments
 (0)