-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
liweiwei
committed
Jan 12, 2022
1 parent
5549f15
commit 3e05453
Showing
22 changed files
with
241 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* ****************************************************************** */ | ||
/* This file specifies the instructions in the Zicbom extension */ | ||
|
||
|
||
/* ****************************************************************** */ | ||
union clause ast = RISCV_ZICBOM : (cbop_zicbom, regidx) | ||
|
||
mapping encdec_cbop : cbop_zicbom <-> bits(12) = { | ||
CBO_CLEAN <-> 0b000000000001, | ||
CBO_FLUSH <-> 0b000000000010, | ||
CBO_INVAL <-> 0b000000000000 | ||
} | ||
|
||
mapping clause encdec = RISCV_ZICBOM(cbop, rs1) if haveZicbom() | ||
<-> encdec_cbop(cbop) @ rs1 @ 0b010 @ 0b00000 @ 0b0001111 if haveZicbom() | ||
|
||
mapping cbop_mnemonic : cbop_zicbom <-> string = { | ||
CBO_CLEAN <-> "cbo.clean", | ||
CBO_FLUSH <-> "cbo.flush", | ||
CBO_INVAL <-> "cbo.inval" | ||
} | ||
|
||
mapping clause assembly = RISCV_ZICBOM(cbop, rs1) | ||
<-> cbop_mnemonic(cbop) ^ spc() ^ reg_name(rs1) | ||
|
||
val process_clean_inval : (xlenbits, xlenbits, bool, bool) -> Retired effect {escape, rmem, rmemt, rreg, wmv, wmvt, wreg} | ||
function process_clean_inval(vaddr, width, clean, inval) = { | ||
match ext_data_get_addr(zeros(), vaddr, Read(Data), BYTE) { | ||
Ext_DataAddr_Error(e) => { ext_handle_data_check_error(e); RETIRE_FAIL }, | ||
Ext_DataAddr_OK(vaddr) => { | ||
let data: option(ExceptionType) = match translateAddr(vaddr, Read(Data)) { | ||
TR_Address(paddr, _) => pmpCheck_xlen(paddr, width, Read(Data), cur_privilege), | ||
TR_Failure(e, _) => Some(e) | ||
}; | ||
match data { | ||
None() => RETIRE_SUCCESS, | ||
Some(e) => { | ||
match (e) { | ||
E_Load_Access_Fault() => { handle_mem_exception(vaddr, E_SAMO_Access_Fault()); RETIRE_FAIL }, | ||
E_Load_Page_Fault() => { handle_mem_exception(vaddr, E_SAMO_Page_Fault()); RETIRE_FAIL } | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
function cbo_clean_flush_enable(p : Privilege) -> bool = { | ||
~(((p != Machine) & (menvcfg.CBCFE() == 0b0)) | ((p == User) & (senvcfg.CBCFE() == 0b0))) | ||
} | ||
|
||
function cbop_for_cbo_inval(p : Privilege) -> option(cbop_zicbom) = { | ||
let illegal = ((p != Machine) & (menvcfg.CBIE() == 0b00)) | | ||
((p == User) & (senvcfg.CBIE() == 0b00)); | ||
let flush = ((p != Machine) & (menvcfg.CBIE() == 0b01)) | | ||
((p == User) & (senvcfg.CBIE() == 0b01)); | ||
if illegal then None() | ||
else if flush then Some(CBO_FLUSH) | ||
else Some(CBO_INVAL) | ||
} | ||
|
||
function clause execute(RISCV_ZICBOM(cbop, rs1)) = { | ||
let rs1_val = X(rs1); | ||
let cache_block_size = plat_cache_block_size(); | ||
let vaddr = rs1_val & ~(cache_block_size - EXTZ(0b1)); | ||
let cbcfe = cbo_clean_flush_enable(cur_privilege); | ||
let final_op : option(cbop_zicbom) = match (cbop, cbcfe) { | ||
(CBO_CLEAN, true) => Some(CBO_CLEAN), | ||
(CBO_CLEAN, false) => None(), | ||
(CBO_FLUSH, true) => Some(CBO_FLUSH), | ||
(CBO_FLUSH, false) => None(), | ||
(CBO_INVAL, _) => cbop_for_cbo_inval(cur_privilege) | ||
}; | ||
match final_op { | ||
None() => { handle_illegal(); RETIRE_FAIL }, | ||
Some(CBO_CLEAN) => process_clean_inval(vaddr, cache_block_size, true, false), | ||
Some(CBO_FLUSH) => process_clean_inval(vaddr, cache_block_size, true, true), | ||
Some(CBO_INVAL) => process_clean_inval(vaddr, cache_block_size, false, true) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* ****************************************************************** */ | ||
/* This file specifies the instructions in the Zicboz extension */ | ||
union clause ast = RISCV_ZICBOZ : (regidx) | ||
mapping clause encdec = RISCV_ZICBOZ(rs1) if haveZicboz() | ||
<-> 0b000000000100 @ rs1 @ 0b010 @ 0b00000 @ 0b0001111 if haveZicboz() | ||
|
||
mapping clause assembly = RISCV_ZICBOZ(rs1) | ||
<-> "cbo.zero" ^ spc() ^ reg_name(rs1) | ||
|
||
function get_envcfg_cbze(p : Privilege) -> bool = { | ||
~(((p != Machine) & (menvcfg.CBZE() == 0b0)) | ((p == User) & (senvcfg.CBZE() == 0b0))) | ||
} | ||
|
||
val process_cbo_zero : (xlenbits, xlenbits) -> Retired effect {eamem, escape, rmem, rmemt, rreg, wmv, wmvt, wreg} | ||
function process_cbo_zero(vaddr, width) = { | ||
offset : xlenbits = zeros(); | ||
failed : bool = false; | ||
while (offset <_u width) & (failed == false) do { | ||
let addr = vaddr + offset; | ||
match ext_data_get_addr(zeros(), addr, Write(Data), BYTE) { | ||
Ext_DataAddr_Error(e) => { ext_handle_data_check_error(e); failed = true }, | ||
Ext_DataAddr_OK(vaddr) => | ||
match translateAddr(vaddr, Write(Data)) { | ||
TR_Failure(e, _) => { handle_mem_exception(vaddr, e); failed = true }, | ||
TR_Address(paddr, _) => { | ||
let eares : MemoryOpResult(unit) = mem_write_ea(paddr, 1, false, false, false); | ||
match (eares) { | ||
MemException(e) => { handle_mem_exception(vaddr, e); failed = true }, | ||
MemValue(_) => { | ||
let res : MemoryOpResult(bool) = mem_write_value(paddr, 1, zeros(), false, false, false); | ||
match (res) { | ||
MemValue(true) => offset = offset + EXTZ(0b1), | ||
MemValue(false) => internal_error("store got false from mem_write_value"), | ||
MemException(e) => { handle_mem_exception(vaddr, e); failed = true } | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
}; | ||
if failed then RETIRE_FAIL | ||
else RETIRE_SUCCESS | ||
} | ||
|
||
function clause execute(RISCV_ZICBOZ(rs1)) = { | ||
let rs1_val = X(rs1); | ||
let cache_block_size = plat_cache_block_size(); | ||
let vaddr = rs1_val & ~(cache_block_size - EXTZ(0b1)); | ||
if get_envcfg_cbze(cur_privilege) then | ||
process_cbo_zero(vaddr, cache_block_size) | ||
else { | ||
handle_illegal(); | ||
RETIRE_FAIL | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.