diff options
author | Robert Norton <rmn30@cam.ac.uk> | 2019-09-10 17:16:01 +0100 |
---|---|---|
committer | Robert Norton <rmn30@cam.ac.uk> | 2019-09-10 17:16:01 +0100 |
commit | d07ded0537e9367bb6e8c53f75a02403b6cdc0e4 (patch) | |
tree | db46a8cebaa2434f9b544d69bdf1d608e9cf6708 /model/riscv_csr_ext.sail | |
parent | b80af4101067dd710f88602ba297afb359275cd9 (diff) | |
download | sail-riscv-d07ded0537e9367bb6e8c53f75a02403b6cdc0e4.zip sail-riscv-d07ded0537e9367bb6e8c53f75a02403b6cdc0e4.tar.gz sail-riscv-d07ded0537e9367bb6e8c53f75a02403b6cdc0e4.tar.bz2 |
Refactor CSR code to use scattered functions / mappings for ease of extension.
Diffstat (limited to 'model/riscv_csr_ext.sail')
-rw-r--r-- | model/riscv_csr_ext.sail | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/model/riscv_csr_ext.sail b/model/riscv_csr_ext.sail index ea4f065..8c0cc17 100644 --- a/model/riscv_csr_ext.sail +++ b/model/riscv_csr_ext.sail @@ -1,20 +1,13 @@ -/* Extensions may want to add additional CSR registers to the CSR address map. - * These functions support access to such registers. - * - * The default implementation provides access to the CSRs added by the 'N' - * extension. - */ -/* returns whether a CSR is defined and accessible at a given address - * and privilege - */ -function ext_is_CSR_defined(csr : csreg, p : Privilege) -> bool = - is_NExt_CSR_defined(csr, p) // 'N' extension +/* numeric fallback XXX apparent sail bug prevents this from compiling for C */ +//mapping clause csr_name_map = reg <-> "UNKNOWN CSR: " ^ hex_bits_12(reg) +end csr_name_map -/* returns the value of the CSR if it is defined */ -function ext_read_CSR(csr : csreg) -> option(xlenbits) = - read_NExt_CSR(csr) +function clause ext_is_CSR_defined(_, _) = false +end ext_is_CSR_defined -/* returns false if the CSR is not defined or if the write is unsuccessful */ -function ext_write_CSR(csr : csreg, value : xlenbits) -> bool = - write_NExt_CSR(csr, value) +function clause ext_read_CSR _ = None() +end ext_read_CSR + +function clause ext_write_CSR (_, _) = None() +end ext_write_CSR |