resume in dmux4way

pull/2/head
Matthew Butterick 9 years ago
parent fdc8f6831f
commit b1afb39b78

@ -16,6 +16,7 @@ CHIP DMux {
OUT a, b;
PARTS:
And(a=in, b=sel, out=a);
Not(in=sel, out=not-sel);
And(a=in, b=not-sel, out=a);
And(a=in, b=sel, out=b);
}

@ -0,0 +1,28 @@
#lang racket
(require "DMux4Way.hdl.rkt")
(require rackunit)
(DMux4Way-in (random 2))
(DMux4Way-sel #b00)
(check-equal? (DMux4Way-a) (DMux4Way-in))
(check-equal? (DMux4Way-b) 0)
(check-equal? (DMux4Way-c) 0)
(check-equal? (DMux4Way-d) 0)
(DMux4Way-sel #b01)
(check-equal? (DMux4Way-a) 0)
(check-equal? (DMux4Way-b) (DMux4Way-in))
(check-equal? (DMux4Way-c) 0)
(check-equal? (DMux4Way-d) 0)
(DMux4Way-sel #b10)
(check-equal? (DMux4Way-a) 0)
(check-equal? (DMux4Way-b) 0)
(check-equal? (DMux4Way-c) (DMux4Way-in))
(check-equal? (DMux4Way-d) 0)
(DMux4Way-sel #b11)
(check-equal? (DMux4Way-a) 0)
(check-equal? (DMux4Way-b) 0)
(check-equal? (DMux4Way-c) 0)
(check-equal? (DMux4Way-d) (DMux4Way-in))

@ -0,0 +1,23 @@
#lang racket
(require "DMux.hdl.rkt")
(require rackunit)
(DMux-in 0)
(DMux-sel 0)
(check-equal? (DMux-a) 0)
(check-equal? (DMux-b) 0)
(DMux-in 0)
(DMux-sel 1)
(check-equal? (DMux-a) 0)
(check-equal? (DMux-b) 0)
(DMux-in 1)
(DMux-sel 0)
(check-equal? (DMux-a) 1)
(check-equal? (DMux-b) 0)
(DMux-in 1)
(DMux-sel 1)
(check-equal? (DMux-a) 0)
(check-equal? (DMux-b) 1)

@ -14,9 +14,11 @@
*/
CHIP DMux4Way {
// todo: how should sel subscripting work?
IN in, sel[2];
OUT out;
OUT a, b, c, d;
PARTS:
Not(in=sel[0], out=out);
DMux(in=in, sel[0]=sel, a=a, b=b);
DMux(in=in, sel[1]=sel, a=c, b=d);
}

@ -17,7 +17,7 @@
(define-input-bus _input-pin _input-width ...) ...
_part ...
(provide prefixed-output-pin ...)
(define-output-bus prefixed-output-pin (λ () (_output-pin)) _output-width ...) ...)))
(define-output-bus prefixed-output-pin _output-pin _output-width ...) ...)))
(define #'(part _prefix [_suffix . _args] ...)

@ -20,7 +20,7 @@ part : partname /"(" pin-val-pair [/"," pin-val-pair]* /")" /";"
/pin-val-pair : ID [/"[" bus-range /"]"] /"=" pin-val
@bus-range : NUMBER [/"." /"." NUMBER]
@bus-range : (NUMBER | BINARY-NUMBER) [/"." /"." (NUMBER | BINARY-NUMBER)]
@pin-val : ID
| BINARY-NUMBER

Loading…
Cancel
Save