1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// ======================================================================================= // This Sail RISC-V architecture model, comprising all files and // directories except where otherwise noted is subject the BSD // two-clause license in the LICENSE file. // // SPDX-License-Identifier: BSD-2-Clause // ======================================================================================= // Mapping of csr addresses to their names. val csr_name_map : csreg <-> string scattered mapping csr_name_map val csr_name : csreg -> string function csr_name(csr) = csr_name_map(csr) overload to_str = {csr_name} // returns whether a CSR exists val is_CSR_accessible : (csreg, Privilege, bool) -> bool scattered function is_CSR_accessible // returns the value of the CSR if it is defined val read_CSR : csreg -> xlenbits scattered function read_CSR // returns new value (after legalisation) if the CSR is defined, // otherwise a unit value indicating an illegal instruction. val write_CSR : (csreg, xlenbits) -> result(xlenbits, unit) scattered function write_CSR