|
Hi,
I've written Not, And, Or, Xor. They've all passed the tests successfully. Some of them even use Not as a part, no problem there.
Now I've come to writing Mux and when I use Not it always returns 1 (regardless of the input). I've even tried using the built-in Not and it also return 1 all the time.
I have a feeling that something is wrong with my Mux file, but I just can't pinpoint it.
This is the Mux implementation:
// 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 {
IN a, b, sel;
OUT out;
PARTS:
Not(in=sel, out=not1out);
And(a=a, b=not1out, out=and1out);
And(a=sel, b=b, out=and2out);
Or(a=and1out, b=and2out, out=or1out);
}
|