You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
beautiful-racket/beautiful-racket/br/demo/hdl/Xor2.hdl

21 lines
475 B
Plaintext

#lang reader "hdl-reader.rkt"
CHIP Xor {
IN a, b;
OUT out;
PARTS:
Not(in=a, out=nota);
Not(in=b, out=notb);
And(a=a, b=notb, out=w1);
And(a=nota, b=b, out=w2);
Or(a=w1, b=w2, out=out);
}
(module+ test
(require rackunit)
(check-equal? (Xor #:a 0 #:b 0) 0)
(check-equal? (Xor #:a 0 #:b 1) 1)
(check-equal? (Xor #:a 1 #:b 0) 1)
(check-equal? (Xor #:a 1 #:b 1) 0))