/*=======================================================================================*/ /* 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 // TODO: These csr_name_map definitions should be moved to the files // corresponding to their extensions rather than all be here. /* user floating-point context */ mapping clause csr_name_map = 0x001 <-> "fflags" mapping clause csr_name_map = 0x002 <-> "frm" mapping clause csr_name_map = 0x003 <-> "fcsr" /* user entropy source */ mapping clause csr_name_map = 0x015 <-> "seed" /* counter/timers */ mapping clause csr_name_map = 0xC00 <-> "cycle" mapping clause csr_name_map = 0xC01 <-> "time" mapping clause csr_name_map = 0xC02 <-> "instret" mapping clause csr_name_map = 0xC03 <-> "hpmcounter3" mapping clause csr_name_map = 0xC04 <-> "hpmcounter4" mapping clause csr_name_map = 0xC05 <-> "hpmcounter5" mapping clause csr_name_map = 0xC06 <-> "hpmcounter6" mapping clause csr_name_map = 0xC07 <-> "hpmcounter7" mapping clause csr_name_map = 0xC08 <-> "hpmcounter8" mapping clause csr_name_map = 0xC09 <-> "hpmcounter9" mapping clause csr_name_map = 0xC0A <-> "hpmcounter10" mapping clause csr_name_map = 0xC0B <-> "hpmcounter11" mapping clause csr_name_map = 0xC0C <-> "hpmcounter12" mapping clause csr_name_map = 0xC0D <-> "hpmcounter13" mapping clause csr_name_map = 0xC0E <-> "hpmcounter14" mapping clause csr_name_map = 0xC0F <-> "hpmcounter15" mapping clause csr_name_map = 0xC10 <-> "hpmcounter16" mapping clause csr_name_map = 0xC11 <-> "hpmcounter17" mapping clause csr_name_map = 0xC12 <-> "hpmcounter18" mapping clause csr_name_map = 0xC13 <-> "hpmcounter19" mapping clause csr_name_map = 0xC14 <-> "hpmcounter20" mapping clause csr_name_map = 0xC15 <-> "hpmcounter21" mapping clause csr_name_map = 0xC16 <-> "hpmcounter22" mapping clause csr_name_map = 0xC17 <-> "hpmcounter23" mapping clause csr_name_map = 0xC18 <-> "hpmcounter24" mapping clause csr_name_map = 0xC19 <-> "hpmcounter25" mapping clause csr_name_map = 0xC1A <-> "hpmcounter26" mapping clause csr_name_map = 0xC1B <-> "hpmcounter27" mapping clause csr_name_map = 0xC1C <-> "hpmcounter28" mapping clause csr_name_map = 0xC1D <-> "hpmcounter29" mapping clause csr_name_map = 0xC1E <-> "hpmcounter30" mapping clause csr_name_map = 0xC1F <-> "hpmcounter31" mapping clause csr_name_map = 0xC80 <-> "cycleh" mapping clause csr_name_map = 0xC81 <-> "timeh" mapping clause csr_name_map = 0xC82 <-> "instreth" mapping clause csr_name_map = 0xC83 <-> "hpmcounter3h" mapping clause csr_name_map = 0xC84 <-> "hpmcounter4h" mapping clause csr_name_map = 0xC85 <-> "hpmcounter5h" mapping clause csr_name_map = 0xC86 <-> "hpmcounter6h" mapping clause csr_name_map = 0xC87 <-> "hpmcounter7h" mapping clause csr_name_map = 0xC88 <-> "hpmcounter8h" mapping clause csr_name_map = 0xC89 <-> "hpmcounter9h" mapping clause csr_name_map = 0xC8A <-> "hpmcounter10h" mapping clause csr_name_map = 0xC8B <-> "hpmcounter11h" mapping clause csr_name_map = 0xC8C <-> "hpmcounter12h" mapping clause csr_name_map = 0xC8D <-> "hpmcounter13h" mapping clause csr_name_map = 0xC8E <-> "hpmcounter14h" mapping clause csr_name_map = 0xC8F <-> "hpmcounter15h" mapping clause csr_name_map = 0xC90 <-> "hpmcounter16h" mapping clause csr_name_map = 0xC91 <-> "hpmcounter17h" mapping clause csr_name_map = 0xC92 <-> "hpmcounter18h" mapping clause csr_name_map = 0xC93 <-> "hpmcounter19h" mapping clause csr_name_map = 0xC94 <-> "hpmcounter20h" mapping clause csr_name_map = 0xC95 <-> "hpmcounter21h" mapping clause csr_name_map = 0xC96 <-> "hpmcounter22h" mapping clause csr_name_map = 0xC97 <-> "hpmcounter23h" mapping clause csr_name_map = 0xC98 <-> "hpmcounter24h" mapping clause csr_name_map = 0xC99 <-> "hpmcounter25h" mapping clause csr_name_map = 0xC9A <-> "hpmcounter26h" mapping clause csr_name_map = 0xC9B <-> "hpmcounter27h" mapping clause csr_name_map = 0xC9C <-> "hpmcounter28h" mapping clause csr_name_map = 0xC9D <-> "hpmcounter29h" mapping clause csr_name_map = 0xC9E <-> "hpmcounter30h" mapping clause csr_name_map = 0xC9F <-> "hpmcounter31h" /* supervisor trap setup */ mapping clause csr_name_map = 0x100 <-> "sstatus" mapping clause csr_name_map = 0x104 <-> "sie" mapping clause csr_name_map = 0x105 <-> "stvec" mapping clause csr_name_map = 0x106 <-> "scounteren" /* supervisor trap handling */ mapping clause csr_name_map = 0x140 <-> "sscratch" mapping clause csr_name_map = 0x141 <-> "sepc" mapping clause csr_name_map = 0x142 <-> "scause" mapping clause csr_name_map = 0x143 <-> "stval" mapping clause csr_name_map = 0x144 <-> "sip" /* supervisor protection and translation */ mapping clause csr_name_map = 0x180 <-> "satp" /* supervisor envcfg */ mapping clause csr_name_map = 0x10A <-> "senvcfg" /* machine information registers */ mapping clause csr_name_map = 0xF11 <-> "mvendorid" mapping clause csr_name_map = 0xF12 <-> "marchid" mapping clause csr_name_map = 0xF13 <-> "mimpid" mapping clause csr_name_map = 0xF14 <-> "mhartid" mapping clause csr_name_map = 0xF15 <-> "mconfigptr" /* machine trap setup */ mapping clause csr_name_map = 0x300 <-> "mstatus" mapping clause csr_name_map = 0x301 <-> "misa" mapping clause csr_name_map = 0x302 <-> "medeleg" mapping clause csr_name_map = 0x303 <-> "mideleg" mapping clause csr_name_map = 0x304 <-> "mie" mapping clause csr_name_map = 0x305 <-> "mtvec" mapping clause csr_name_map = 0x306 <-> "mcounteren" mapping clause csr_name_map = 0x320 <-> "mcountinhibit" /* machine envcfg */ mapping clause csr_name_map = 0x30A <-> "menvcfg" mapping clause csr_name_map = 0x31A <-> "menvcfgh" /* hardware performance counter event selection */ mapping clause csr_name_map = 0x323 <-> "mhpmevent3" mapping clause csr_name_map = 0x324 <-> "mhpmevent4" mapping clause csr_name_map = 0x325 <-> "mhpmevent5" mapping clause csr_name_map = 0x326 <-> "mhpmevent6" mapping clause csr_name_map = 0x327 <-> "mhpmevent7" mapping clause csr_name_map = 0x328 <-> "mhpmevent8" mapping clause csr_name_map = 0x329 <-> "mhpmevent9" mapping clause csr_name_map = 0x32A <-> "mhpmevent10" mapping clause csr_name_map = 0x32B <-> "mhpmevent11" mapping clause csr_name_map = 0x32C <-> "mhpmevent12" mapping clause csr_name_map = 0x32D <-> "mhpmevent13" mapping clause csr_name_map = 0x32E <-> "mhpmevent14" mapping clause csr_name_map = 0x32F <-> "mhpmevent15" mapping clause csr_name_map = 0x330 <-> "mhpmevent16" mapping clause csr_name_map = 0x331 <-> "mhpmevent17" mapping clause csr_name_map = 0x332 <-> "mhpmevent18" mapping clause csr_name_map = 0x333 <-> "mhpmevent19" mapping clause csr_name_map = 0x334 <-> "mhpmevent20" mapping clause csr_name_map = 0x335 <-> "mhpmevent21" mapping clause csr_name_map = 0x336 <-> "mhpmevent22" mapping clause csr_name_map = 0x337 <-> "mhpmevent23" mapping clause csr_name_map = 0x338 <-> "mhpmevent24" mapping clause csr_name_map = 0x339 <-> "mhpmevent25" mapping clause csr_name_map = 0x33A <-> "mhpmevent26" mapping clause csr_name_map = 0x33B <-> "mhpmevent27" mapping clause csr_name_map = 0x33C <-> "mhpmevent28" mapping clause csr_name_map = 0x33D <-> "mhpmevent29" mapping clause csr_name_map = 0x33E <-> "mhpmevent30" mapping clause csr_name_map = 0x33F <-> "mhpmevent31" /* machine trap handling */ mapping clause csr_name_map = 0x340 <-> "mscratch" mapping clause csr_name_map = 0x341 <-> "mepc" mapping clause csr_name_map = 0x342 <-> "mcause" mapping clause csr_name_map = 0x343 <-> "mtval" mapping clause csr_name_map = 0x344 <-> "mip" /* machine protection and translation */ mapping clause csr_name_map = 0x3A0 <-> "pmpcfg0" mapping clause csr_name_map = 0x3A1 <-> "pmpcfg1" mapping clause csr_name_map = 0x3A2 <-> "pmpcfg2" mapping clause csr_name_map = 0x3A3 <-> "pmpcfg3" mapping clause csr_name_map = 0x3A4 <-> "pmpcfg4" mapping clause csr_name_map = 0x3A5 <-> "pmpcfg5" mapping clause csr_name_map = 0x3A6 <-> "pmpcfg6" mapping clause csr_name_map = 0x3A7 <-> "pmpcfg7" mapping clause csr_name_map = 0x3A8 <-> "pmpcfg8" mapping clause csr_name_map = 0x3A9 <-> "pmpcfg9" mapping clause csr_name_map = 0x3AA <-> "pmpcfg10" mapping clause csr_name_map = 0x3AB <-> "pmpcfg11" mapping clause csr_name_map = 0x3AC <-> "pmpcfg12" mapping clause csr_name_map = 0x3AD <-> "pmpcfg13" mapping clause csr_name_map = 0x3AE <-> "pmpcfg14" mapping clause csr_name_map = 0x3AF <-> "pmpcfg15" mapping clause csr_name_map = 0x3B0 <-> "pmpaddr0" mapping clause csr_name_map = 0x3B1 <-> "pmpaddr1" mapping clause csr_name_map = 0x3B2 <-> "pmpaddr2" mapping clause csr_name_map = 0x3B3 <-> "pmpaddr3" mapping clause csr_name_map = 0x3B4 <-> "pmpaddr4" mapping clause csr_name_map = 0x3B5 <-> "pmpaddr5" mapping clause csr_name_map = 0x3B6 <-> "pmpaddr6" mapping clause csr_name_map = 0x3B7 <-> "pmpaddr7" mapping clause csr_name_map = 0x3B8 <-> "pmpaddr8" mapping clause csr_name_map = 0x3B9 <-> "pmpaddr9" mapping clause csr_name_map = 0x3BA <-> "pmpaddr10" mapping clause csr_name_map = 0x3BB <-> "pmpaddr11" mapping clause csr_name_map = 0x3BC <-> "pmpaddr12" mapping clause csr_name_map = 0x3BD <-> "pmpaddr13" mapping clause csr_name_map = 0x3BE <-> "pmpaddr14" mapping clause csr_name_map = 0x3BF <-> "pmpaddr15" mapping clause csr_name_map = 0x3C0 <-> "pmpaddr16" mapping clause csr_name_map = 0x3C1 <-> "pmpaddr17" mapping clause csr_name_map = 0x3C2 <-> "pmpaddr18" mapping clause csr_name_map = 0x3C3 <-> "pmpaddr19" mapping clause csr_name_map = 0x3C4 <-> "pmpaddr20" mapping clause csr_name_map = 0x3C5 <-> "pmpaddr21" mapping clause csr_name_map = 0x3C6 <-> "pmpaddr22" mapping clause csr_name_map = 0x3C7 <-> "pmpaddr23" mapping clause csr_name_map = 0x3C8 <-> "pmpaddr24" mapping clause csr_name_map = 0x3C9 <-> "pmpaddr25" mapping clause csr_name_map = 0x3CA <-> "pmpaddr26" mapping clause csr_name_map = 0x3CB <-> "pmpaddr27" mapping clause csr_name_map = 0x3CC <-> "pmpaddr28" mapping clause csr_name_map = 0x3CD <-> "pmpaddr29" mapping clause csr_name_map = 0x3CE <-> "pmpaddr30" mapping clause csr_name_map = 0x3CF <-> "pmpaddr31" mapping clause csr_name_map = 0x3D0 <-> "pmpaddr32" mapping clause csr_name_map = 0x3D1 <-> "pmpaddr33" mapping clause csr_name_map = 0x3D2 <-> "pmpaddr34" mapping clause csr_name_map = 0x3D3 <-> "pmpaddr35" mapping clause csr_name_map = 0x3D4 <-> "pmpaddr36" mapping clause csr_name_map = 0x3D5 <-> "pmpaddr37" mapping clause csr_name_map = 0x3D6 <-> "pmpaddr38" mapping clause csr_name_map = 0x3D7 <-> "pmpaddr39" mapping clause csr_name_map = 0x3D8 <-> "pmpaddr40" mapping clause csr_name_map = 0x3D9 <-> "pmpaddr41" mapping clause csr_name_map = 0x3DA <-> "pmpaddr42" mapping clause csr_name_map = 0x3DB <-> "pmpaddr43" mapping clause csr_name_map = 0x3DC <-> "pmpaddr44" mapping clause csr_name_map = 0x3DD <-> "pmpaddr45" mapping clause csr_name_map = 0x3DE <-> "pmpaddr46" mapping clause csr_name_map = 0x3DF <-> "pmpaddr47" mapping clause csr_name_map = 0x3E0 <-> "pmpaddr48" mapping clause csr_name_map = 0x3E1 <-> "pmpaddr49" mapping clause csr_name_map = 0x3E2 <-> "pmpaddr50" mapping clause csr_name_map = 0x3E3 <-> "pmpaddr51" mapping clause csr_name_map = 0x3E4 <-> "pmpaddr52" mapping clause csr_name_map = 0x3E5 <-> "pmpaddr53" mapping clause csr_name_map = 0x3E6 <-> "pmpaddr54" mapping clause csr_name_map = 0x3E7 <-> "pmpaddr55" mapping clause csr_name_map = 0x3E8 <-> "pmpaddr56" mapping clause csr_name_map = 0x3E9 <-> "pmpaddr57" mapping clause csr_name_map = 0x3EA <-> "pmpaddr58" mapping clause csr_name_map = 0x3EB <-> "pmpaddr59" mapping clause csr_name_map = 0x3EC <-> "pmpaddr60" mapping clause csr_name_map = 0x3ED <-> "pmpaddr61" mapping clause csr_name_map = 0x3EE <-> "pmpaddr62" mapping clause csr_name_map = 0x3EF <-> "pmpaddr63" /* machine counters/timers */ mapping clause csr_name_map = 0xB00 <-> "mcycle" mapping clause csr_name_map = 0xB02 <-> "minstret" mapping clause csr_name_map = 0xB03 <-> "mhpmcounter3" mapping clause csr_name_map = 0xB04 <-> "mhpmcounter4" mapping clause csr_name_map = 0xB05 <-> "mhpmcounter5" mapping clause csr_name_map = 0xB06 <-> "mhpmcounter6" mapping clause csr_name_map = 0xB07 <-> "mhpmcounter7" mapping clause csr_name_map = 0xB08 <-> "mhpmcounter8" mapping clause csr_name_map = 0xB09 <-> "mhpmcounter9" mapping clause csr_name_map = 0xB0A <-> "mhpmcounter10" mapping clause csr_name_map = 0xB0B <-> "mhpmcounter11" mapping clause csr_name_map = 0xB0C <-> "mhpmcounter12" mapping clause csr_name_map = 0xB0D <-> "mhpmcounter13" mapping clause csr_name_map = 0xB0E <-> "mhpmcounter14" mapping clause csr_name_map = 0xB0F <-> "mhpmcounter15" mapping clause csr_name_map = 0xB10 <-> "mhpmcounter16" mapping clause csr_name_map = 0xB11 <-> "mhpmcounter17" mapping clause csr_name_map = 0xB12 <-> "mhpmcounter18" mapping clause csr_name_map = 0xB13 <-> "mhpmcounter19" mapping clause csr_name_map = 0xB14 <-> "mhpmcounter20" mapping clause csr_name_map = 0xB15 <-> "mhpmcounter21" mapping clause csr_name_map = 0xB16 <-> "mhpmcounter22" mapping clause csr_name_map = 0xB17 <-> "mhpmcounter23" mapping clause csr_name_map = 0xB18 <-> "mhpmcounter24" mapping clause csr_name_map = 0xB19 <-> "mhpmcounter25" mapping clause csr_name_map = 0xB1A <-> "mhpmcounter26" mapping clause csr_name_map = 0xB1B <-> "mhpmcounter27" mapping clause csr_name_map = 0xB1C <-> "mhpmcounter28" mapping clause csr_name_map = 0xB1D <-> "mhpmcounter29" mapping clause csr_name_map = 0xB1E <-> "mhpmcounter30" mapping clause csr_name_map = 0xB1F <-> "mhpmcounter31" mapping clause csr_name_map = 0xB80 <-> "mcycleh" mapping clause csr_name_map = 0xB82 <-> "minstreth" mapping clause csr_name_map = 0xB83 <-> "mhpmcounter3h" mapping clause csr_name_map = 0xB84 <-> "mhpmcounter4h" mapping clause csr_name_map = 0xB85 <-> "mhpmcounter5h" mapping clause csr_name_map = 0xB86 <-> "mhpmcounter6h" mapping clause csr_name_map = 0xB87 <-> "mhpmcounter7h" mapping clause csr_name_map = 0xB88 <-> "mhpmcounter8h" mapping clause csr_name_map = 0xB89 <-> "mhpmcounter9h" mapping clause csr_name_map = 0xB8A <-> "mhpmcounter10h" mapping clause csr_name_map = 0xB8B <-> "mhpmcounter11h" mapping clause csr_name_map = 0xB8C <-> "mhpmcounter12h" mapping clause csr_name_map = 0xB8D <-> "mhpmcounter13h" mapping clause csr_name_map = 0xB8E <-> "mhpmcounter14h" mapping clause csr_name_map = 0xB8F <-> "mhpmcounter15h" mapping clause csr_name_map = 0xB90 <-> "mhpmcounter16h" mapping clause csr_name_map = 0xB91 <-> "mhpmcounter17h" mapping clause csr_name_map = 0xB92 <-> "mhpmcounter18h" mapping clause csr_name_map = 0xB93 <-> "mhpmcounter19h" mapping clause csr_name_map = 0xB94 <-> "mhpmcounter20h" mapping clause csr_name_map = 0xB95 <-> "mhpmcounter21h" mapping clause csr_name_map = 0xB96 <-> "mhpmcounter22h" mapping clause csr_name_map = 0xB97 <-> "mhpmcounter23h" mapping clause csr_name_map = 0xB98 <-> "mhpmcounter24h" mapping clause csr_name_map = 0xB99 <-> "mhpmcounter25h" mapping clause csr_name_map = 0xB9A <-> "mhpmcounter26h" mapping clause csr_name_map = 0xB9B <-> "mhpmcounter27h" mapping clause csr_name_map = 0xB9C <-> "mhpmcounter28h" mapping clause csr_name_map = 0xB9D <-> "mhpmcounter29h" mapping clause csr_name_map = 0xB9E <-> "mhpmcounter30h" mapping clause csr_name_map = 0xB9F <-> "mhpmcounter31h" /* trigger/debug */ mapping clause csr_name_map = 0x7a0 <-> "tselect" mapping clause csr_name_map = 0x7a1 <-> "tdata1" mapping clause csr_name_map = 0x7a2 <-> "tdata2" mapping clause csr_name_map = 0x7a3 <-> "tdata3" /* vector csrs */ mapping clause csr_name_map = 0x008 <-> "vstart" mapping clause csr_name_map = 0x009 <-> "vxsat" mapping clause csr_name_map = 0x00A <-> "vxrm" mapping clause csr_name_map = 0x00F <-> "vcsr" mapping clause csr_name_map = 0xC20 <-> "vl" mapping clause csr_name_map = 0xC21 <-> "vtype" mapping clause csr_name_map = 0xC22 <-> "vlenb" val csr_name : csreg -> string overload to_str = {csr_name} /* Extensions may want to add additional CSR registers to the CSR address map. * These scattered functions support access to such registers. * * The default implementation provides access to the CSRs added by the 'N' * extension. */ /* returns whether a CSR exists */ val is_CSR_defined : (csreg) -> bool scattered function is_CSR_defined /* 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 */ val write_CSR : (csreg, xlenbits) -> xlenbits scattered function write_CSR