+2009-10-14 Doug Evans <dje@sebabeach.org>
+
+ * ifield.scm (<ifield>, value): Provide default initial value.
+ (ifield-encode-mode): Delete
+ (ifield-decode-mode): Delete duplicate definition.
+ (<derived-ifield>, 'make!): Initialize members encode, decode.
+
2009-10-05 Dave Korn <dave.korn.cygwin@googlemail.com>
* sim-model.scm (@cpu@_prepare_run): Use @prefix@, not @cpu@,
; here and partially in the operand.
encode decode
- ; Value of field, if there is one.
+ ; Value of field, if there is one, or #f.
; Possible types are: integer, <operand>, ???
- value
+ (value . #f)
)
nil)
)
(define (ifld-word-offset f) (bitrange-word-offset (/ifld-bitrange f)))
(define (ifld-word-length f) (bitrange-word-length (/ifld-bitrange f)))
-; Return the mode of the value passed to the encode rtl.
-; This is the mode of the result of the decode rtl.
+; Return the mode of the decoded value of <ifield> F.
+; ??? This is made easy because we require the decode expression to have
+; an explicit mode.
-(define (ifld-encode-mode f)
- (if (ifld-decode f)
- ; cadr/cadr gets WI in ((value pc) (sra WI ...))
- ; FIXME: That's wrong for a fully canonical expression like
- ; ((value pc) (sra () WI ...)).
- (mode:lookup (cadr (cadr (ifld-decode f))))
- (ifld-mode f))
+(define (ifld-decode-mode f)
+ (assert (elm-bound? f 'decode))
+ (let ((d (ifld-decode f)))
+ (if d
+ ;; FIXME: Does this work with canonicalized rtl?
+ (mode:lookup (cadr (cadr d)))
+ (ifld-mode f)))
)
-; Return the mode of the value passed to the decode rtl.
-; This is the mode of the field.
-
-(define (ifld-decode-mode f) (ifld-mode f))
-
; Return start of ifield.
(method-make!
(elm-set! self 'attrs attrs)
(elm-set! self 'mode UINT)
(elm-set! self 'bitrange (make <bitrange> 0 0 0 0 #f))
+ (elm-set! self 'encode #f)
+ (elm-set! self 'decode #f)
(elm-set! self 'owner owner)
(elm-set! self 'subfields subfields)
self)
(> (ifld-word-offset f) 0)
)
-; Return the mode of the decoded value of <ifield> F.
-; ??? This is made easy because we require the decode expression to have
-; an explicit mode.
-
-(define (ifld-decode-mode f)
- (if (not (elm-bound? f 'decode))
- (ifld-mode f)
- (let ((d (ifld-decode f)))
- (if d
- (mode:lookup (cadr (cadr d)))
- (ifld-mode f))))
-)
-
; Return <hardware> object to use to hold value of <ifield> F.
; i.e. one of h-uint, h-sint.
; NB: Should be defined in terms of `hardware-for-mode'.