diff options
author | Prashanth Mundkur <prashanth.mundkur@gmail.com> | 2019-05-14 14:57:27 -0700 |
---|---|---|
committer | Prashanth Mundkur <prashanth.mundkur@gmail.com> | 2019-05-14 15:37:37 -0700 |
commit | 64933000be3f9ce0bf8d20b48e512d3c62830893 (patch) | |
tree | 4b0f3bfca583bb343826d4681312ba9db72de2a7 /model/riscv_csr_ext.sail | |
parent | 2b0984ab49d48651e6daff0bcc3c37b8b49e2602 (diff) | |
download | sail-riscv-64933000be3f9ce0bf8d20b48e512d3c62830893.zip sail-riscv-64933000be3f9ce0bf8d20b48e512d3c62830893.tar.gz sail-riscv-64933000be3f9ce0bf8d20b48e512d3c62830893.tar.bz2 |
Improve the interface to access CSRs in extensions.
Diffstat (limited to 'model/riscv_csr_ext.sail')
-rw-r--r-- | model/riscv_csr_ext.sail | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/model/riscv_csr_ext.sail b/model/riscv_csr_ext.sail new file mode 100644 index 0000000..ea4f065 --- /dev/null +++ b/model/riscv_csr_ext.sail @@ -0,0 +1,20 @@ +/* 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 + +/* returns the value of the CSR if it is defined */ +function ext_read_CSR(csr : csreg) -> option(xlenbits) = + read_NExt_CSR(csr) + +/* 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) |