mirror of
https://github.com/StepanovPlaton/Nand2Tetris.git
synced 2026-04-03 20:30:47 +04:00
Complete project 2
This commit is contained in:
18
Assignments/1_Boolean_Logic/Mux.hdl
Normal file
18
Assignments/1_Boolean_Logic/Mux.hdl
Normal file
@@ -0,0 +1,18 @@
|
||||
// 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/1/Mux.hdl
|
||||
/**
|
||||
* Multiplexor:
|
||||
* if (sel = 0) out = a, else out = b
|
||||
*/
|
||||
CHIP Mux {
|
||||
IN a, b, sel;
|
||||
OUT out;
|
||||
|
||||
PARTS:
|
||||
Not(in=sel, out=nsel);
|
||||
And(a=nsel, b=a, out=aa);
|
||||
And(a=sel, b=b, out=bb);
|
||||
Or(a=aa, b=bb, out=out);
|
||||
}
|
||||
Reference in New Issue
Block a user