|
So comrades, I've used a little bit of time developing a 4 way multiplexor with nands, but for some motive it is not giving me the expected output.
It was my first try, and it occupies 28 nand gates when it could occupy only 21, but for now it's just a case study.
I've analised it some times, and can't find where the error is. I've developed a .tst and an .cmp to it, but when the output of A, B, C, D, S[0], S[1](0, 0, 0, 0, 0, 0) is being 1.
Doing the same test manually the output is 0 (maybe I'm failing in realising something, but if so, I've failed some times).
Well, here is the code:
CHIP Mux4Way {
IN a, b, c, d, sel[2];
OUT out;
PARTS:
Not(in=a, out=an); //Beginning the Not definitions
Not(in=b, out=bn);
Not(in=sel[0], out=s0n);
Not(in=sel[1], out=s1n);
Not(in=c, out=cn);
Not(in=d, out=dn); //End
Nand(a=an, b=s0n, out=out00); //First step of selection
Nand(a=sel[0], b=bn, out=out01);
Nand(a=out00, b=out01, out=out10); //End (out10)
Nand(a=s0n, b=sel[1], out=outs00); //Defining if Sel[0]=0 then true
Nand(a=s0n, b=s1n, out=outs01);
Nand(a=outs00, b=outs01, out=outs1); //End (outs1)
Not(in=outs1, out=outs1n); //Defining Not outs1
Nand(a=cn, b=outs1, out=out02); //Second step of selection
Nand(a=outs1n, b=dn, out=out03);
Nand(a=out02, b=out03, out=out11); //End (out11)
Nand(a=s0n, b=sel[1], out=outs10); //Defining if Sel[1]=1 then true
Nand(a=sel[0], b=sel[1], out=outs11);
Nand(a=outs10, b=outs11, out=outs0); //End (outs0)
Not(in=out10, out=out10n); //Defining Not first selection
Not(in=outs0, out=outs0n); //Not (if Sel[1]=1 then true)
Not(in=out11, out=out11n); //Not second selection
Nand(a=out10n, b=outs0n, out=out1); //Third step of selection
Nand(a=outs0, b=out11n, out=out2);
Nand(a=out1, a=out2, out=out); //End
}
So, what's happening?
Cheers!
|