resume in dmux4way
This commit is contained in:
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);
|
||||
}
|
||||
|
|
28
beautiful-racket/br/demo/hdl/DMux4Way-test.rkt
Normal file
28
beautiful-racket/br/demo/hdl/DMux4Way-test.rkt
Normal file
|
@ -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))
|
23
beautiful-racket/br/demo/hdl/Dmux-test.rkt
Normal file
23
beautiful-racket/br/demo/hdl/Dmux-test.rkt
Normal file
|
@ -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…
Reference in New Issue
Block a user