|
|
|
@ -24,18 +24,12 @@
|
|
|
|
|
num-or-wire
|
|
|
|
|
(hash-ref! wire-cache num-or-wire num-or-wire)))))
|
|
|
|
|
|
|
|
|
|
(define (mod-16bit x)
|
|
|
|
|
(define max-16bit (expt 2 16))
|
|
|
|
|
(define remainder (modulo x max-16bit))
|
|
|
|
|
(if (not (negative? remainder))
|
|
|
|
|
remainder
|
|
|
|
|
(mod-16bit (+ max-16bit remainder))))
|
|
|
|
|
|
|
|
|
|
(define 16bit-max (expt 2 16))
|
|
|
|
|
(define-macro (define-16bit ID+ARGS BODY)
|
|
|
|
|
#'(define ID+ARGS (mod-16bit BODY)))
|
|
|
|
|
#'(define ID+ARGS (modulo BODY 16bit-max)))
|
|
|
|
|
|
|
|
|
|
(define-16bit (AND arg1 arg2) (bitwise-and arg1 arg2))
|
|
|
|
|
(define-16bit (OR arg1 arg2) (bitwise-ior arg1 arg2))
|
|
|
|
|
(define-16bit (LSHIFT arg1 arg2) (arithmetic-shift arg1 arg2))
|
|
|
|
|
(define-16bit (RSHIFT arg1 arg2) (arithmetic-shift arg1 (- arg2)))
|
|
|
|
|
(define-16bit (AND x y) (bitwise-and x y))
|
|
|
|
|
(define-16bit (OR x y) (bitwise-ior x y))
|
|
|
|
|
(define-16bit (LSHIFT x y) (arithmetic-shift x y))
|
|
|
|
|
(define-16bit (RSHIFT x y) (LSHIFT x (- y)))
|
|
|
|
|
(define-16bit (NOT arg) (bitwise-not arg))
|