RV64's architected state and the accessors every semantics body uses.
(defisa rv64) source(defisa rv64 :width 32 :endian :little :state rv64
:doc "RISC-V RV64 (RV64I so far): the skeleton of a new ISA, docs/isa.md")(defstruct rv64) source(defstruct (rv64 (:conc-name rv64-))
(x (make-array 32 :element-type '(unsigned-byte 64) :initial-element 0)
:type (simple-array (unsigned-byte 64) (32)))
(pc 0 :type (unsigned-byte 64)) ; the instruction being executed
(npc 0 :type (unsigned-byte 64)) ; the next one (a taken branch writes it)
(exc 0 :type (unsigned-byte 8)))(defconstant +exc-none+) source(defconstant +exc-none+ 0)(defconstant +exc-illegal+) source(defconstant +exc-illegal+ 1)(defmacro gpr) source(defmacro gpr (n) `(aref (rv64-x cpu) ,n))(defmacro set-gpr) source(defmacro set-gpr (n v) `(unless (= ,n 0) (setf (gpr ,n) ,v)))(defmacro rv-load) source(defmacro rv-load (n a) `(bswap ,n (mem-read ,n ,a)))(defmacro rv-store) source(defmacro rv-store (n a v) `(mem-write ,n ,a (bswap ,n (wrap ,n ,v))))(defmacro i-imm) source(defmacro i-imm () `(sext 12 imm12))(defmacro s-imm) source(defmacro s-imm () `(sext 12 (logior (ash imm12hi 5) imm12lo)))(defmacro b-imm) source(defmacro b-imm ()
`(sext 13 (logior (ash (bit-at bimm12hi 6) 12) (ash (bit-at bimm12lo 0) 11)
(ash (bit-field bimm12hi 0 6) 5) (ash (bit-field bimm12lo 1 4) 1))))(defmacro branch-to) source(defmacro branch-to (target) `(setf (rv64-npc cpu) (wrap 64 ,target)))Made from xspe at b2fac33349db by tools/gen-xspe.py. xspe is GPL-3.0-or-later.