ScarletNX / xspe models / gs
gs: regs.lisp
the GS's general registers as an ISA: addresses, fields, semantics.
Page 1 2
0/1 a fixed bit, name a field, a bit the decoder ignores
Transfer rectangles' corners and the direction of a local copy
| 63 | 62 | 61 | 60 | 59 | 58 | 57 | 56 | 55 | 54 | 53 | 52 | 51 | 50 | 49 | 48 | 47 | 46 | 45 | 44 | 43 | 42 | 41 | 40 | 39 | 38 | 37 | 36 | 35 | 34 | 33 | 32 |
| | | dir | dsay | | | | | | dsax |
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| | | | | ssay | | | | | | ssax |
(defgsreg TRXPOS #x51 ((ssax 0 11) (ssay 16 11) (dsax 32 11) (dsay 48 11) (dir 59 2))
"Transfer rectangles' corners and the direction of a local copy")
Transfer rectangle size
| 63 | 62 | 61 | 60 | 59 | 58 | 57 | 56 | 55 | 54 | 53 | 52 | 51 | 50 | 49 | 48 | 47 | 46 | 45 | 44 | 43 | 42 | 41 | 40 | 39 | 38 | 37 | 36 | 35 | 34 | 33 | 32 |
| | | | | | | | | | | | | | | | | | | | rrh |
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| | | | | | | | | | | | | | | | | | | | rrw |
(defgsreg TRXREG #x52 ((rrw 0 12) (rrh 32 12))
"Transfer rectangle size")
Transfer activation: 0 host to local, 1 local to host, 2 local to local, 3 none
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | xdir |
(defgsreg TRXDIR #x53 ((xdir 0 2))
"Transfer activation: 0 host to local, 1 local to host, 2 local to local, 3 none"
(gs-xfer-start g xdir))
Transfer data, host to local
(defgsreg HWREG #x54 ()
"Transfer data, host to local"
(gs-hwreg g value))
SIGNAL event: SIGLBLID's signal id under the mask, CSR.SIGNAL
| 63 | 62 | 61 | 60 | 59 | 58 | 57 | 56 | 55 | 54 | 53 | 52 | 51 | 50 | 49 | 48 | 47 | 46 | 45 | 44 | 43 | 42 | 41 | 40 | 39 | 38 | 37 | 36 | 35 | 34 | 33 | 32 |
| idmsk |
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| id |
(defgsreg SIGNAL #x60 ((id 0 32) (idmsk 32 32))
"SIGNAL event: SIGLBLID's signal id under the mask, CSR.SIGNAL"
(let* ((old (aref (gsm-priv g) 24))
(sig (logior (logand (ldb (byte 32 0) old) (wrap 32 (lognot idmsk))) (logand id idmsk))))
(setf (aref (gsm-priv g) 24) (logior (logand old #xFFFFFFFF00000000) sig)))
(gs-event g 0))
FINISH event: CSR.FINISH once drawing is done (at once here)
(defgsreg FINISH #x61 ()
"FINISH event: CSR.FINISH once drawing is done (at once here)"
(gs-event g 1))
SIGLBLID's label id under the mask
| 63 | 62 | 61 | 60 | 59 | 58 | 57 | 56 | 55 | 54 | 53 | 52 | 51 | 50 | 49 | 48 | 47 | 46 | 45 | 44 | 43 | 42 | 41 | 40 | 39 | 38 | 37 | 36 | 35 | 34 | 33 | 32 |
| idmsk |
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| id |
(defgsreg LABEL #x62 ((id 0 32) (idmsk 32 32))
"SIGLBLID's label id under the mask"
(let ((old (aref (gsm-priv g) 24)))
(setf (aref (gsm-priv g) 24)
(logior (logand old #xFFFFFFFF)
(ash (logior (logand (ash old -32) (wrap 32 (lognot idmsk))) (logand id idmsk)) 32)))))
Other definitions
(defmacro defgsreg) source
(defmacro defgsreg (name addresses fields &rest doc-and-body)
(let* ((addresses (if (listp addresses) addresses (list addresses)))
(doc (if (stringp (car doc-and-body)) (car doc-and-body) ""))
(body (if (stringp (car doc-and-body)) (cdr doc-and-body) doc-and-body)))
`(eval-when (:compile-toplevel :load-toplevel :execute)
(setq *gs-regs* (append (remove ',name *gs-regs* :key #'car)
(list '(,name ,addresses ,fields ,doc ,body))))
',name)))
(defmacro greg) source
(defmacro greg (name &optional (ctx 0))
(let ((as (gs-reg-addresses name)))
(unless as (error "no GS register ~A" name))
(if (cdr as)
`(aref (gsm-reg g) (+ ,(first as) ,ctx))
`(aref (gsm-reg g) ,(first as)))))
(defun gs-event) source
(defun gs-event (g bit)
"the SIGNAL (BIT 0) or FINISH (1) event: its CSR bit; a machine reads CSR and IMR for the interrupt"
(declare (type gsm g) (type (unsigned-byte 8) bit))
(setf (gsm-csr g) (logior (gsm-csr g) (ash 1 bit)))
(setf (gsm-events g) (wrap 32 (+ (gsm-events g) 1)))
nil)
(defmacro define-gs-write) source
(defmacro define-gs-write ()
`(defun gs-write (g addr value)
"write VALUE to the general register at ADDR: store it, then its semantics"
(declare (type gsm g) (type (unsigned-byte 8) addr) (type (unsigned-byte 64) value))
(setf (aref (gsm-reg g) (logand addr #x7F)) value)
(case addr
,@(loop for r in *gs-regs* append (gs-reg-case-clause r))
(otherwise (setf (gsm-unknown g) (wrap 32 (+ (gsm-unknown g) 1)))))
nil))
Page 1 2