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-demo/hdl-demo/Mux.hdl.rkt

24 lines
468 B
Racket

8 years ago
#lang hdl-demo
9 years ago
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Mux.hdl
/**
* Multiplexor:
* out = a if sel == 0
* b otherwise
*/
CHIP Mux {
9 years ago
IN a, b[15], sel[8];
9 years ago
OUT out;
PARTS:
9 years ago
Not(in=sel, out=not-sel);
And(a=a, b=not-sel, out=a-and-not-sel);
And(a=b, b=sel, out=b-and-sel);
Or(a=a-and-not-sel, b=b-and-sel, out=out);
9 years ago
}