# Mux4Way16 not working, can someone help me please?

4 messages
Open this post in threaded view
|

## Mux4Way16 not working, can someone help me please?

 Hello! My Mux4Way16 code is not working and I don't know what I did wrong, can someone tell me please?I prove it again and again and I think it is ok...     Mux(a=a[0], b=c[0], sel=sel[0], out=x0);     Mux(a=a[1], b=c[1], sel=sel[0], out=x1);       Mux(a=a[2], b=c[2], sel=sel[0], out=x2);       Mux(a=a[3], b=c[3], sel=sel[0], out=x3);       Mux(a=a[4], b=c[4], sel=sel[0], out=x4);       Mux(a=a[5], b=c[5], sel=sel[0], out=x5);       Mux(a=a[6], b=c[6], sel=sel[0], out=x6);       Mux(a=a[7], b=c[7], sel=sel[0], out=x7);       Mux(a=a[8], b=c[8], sel=sel[0], out=x8);       Mux(a=a[9], b=c[9], sel=sel[0], out=x9);       Mux(a=a[10], b=c[10], sel=sel[0], out=x10);     Mux(a=a[11], b=c[11], sel=sel[0], out=x11);     Mux(a=a[12], b=c[12], sel=sel[0], out=x12);     Mux(a=a[13], b=c[13], sel=sel[0], out=x13);     Mux(a=a[14], b=c[14], sel=sel[0], out=x14);     Mux(a=a[15], b=c[15], sel=sel[0], out=x15);     Mux(a=b[0], b=d[0], sel=sel[0], out=y0);     Mux(a=b[1], b=d[1], sel=sel[0], out=y1);     Mux(a=b[2], b=d[2], sel=sel[0], out=y2);     Mux(a=b[3], b=d[3], sel=sel[0], out=y3);     Mux(a=b[4], b=d[4], sel=sel[0], out=y4);     Mux(a=b[5], b=d[5], sel=sel[0], out=y5);     Mux(a=b[6], b=d[6], sel=sel[0], out=y6);     Mux(a=b[7], b=d[7], sel=sel[0], out=y7);     Mux(a=b[8], b=d[8], sel=sel[0], out=y8);     Mux(a=b[9], b=d[9], sel=sel[0], out=y9);     Mux(a=b[10], b=d[10], sel=sel[0], out=y10);     Mux(a=b[11], b=d[11], sel=sel[0], out=y11);     Mux(a=b[12], b=d[12], sel=sel[0], out=y12);     Mux(a=b[13], b=d[13], sel=sel[0], out=y13);     Mux(a=b[14], b=d[14], sel=sel[0], out=y14);     Mux(a=b[15], b=d[15], sel=sel[0], out=y15);     Mux(a=x0, b=y0, sel=sel[1], out=out[0]);     Mux(a=x1, b=y1, sel=sel[1], out=out[1]);     Mux(a=x2, b=y2, sel=sel[1], out=out[2]);     Mux(a=x3, b=y3, sel=sel[1], out=out[3]);     Mux(a=x4, b=y4, sel=sel[1], out=out[4]);     Mux(a=x5, b=y5, sel=sel[1], out=out[5]);     Mux(a=x6, b=y6, sel=sel[1], out=out[6]);     Mux(a=x7, b=y7, sel=sel[1], out=out[7]);     Mux(a=x8, b=y8, sel=sel[1], out=out[8]);     Mux(a=x9, b=y9, sel=sel[1], out=out[9]);     Mux(a=x10, b=y10, sel=sel[1], out=out[10]);     Mux(a=x11, b=y11, sel=sel[1], out=out[11]);     Mux(a=x12, b=y12, sel=sel[1], out=out[12]);     Mux(a=x13, b=y13, sel=sel[1], out=out[13]);     Mux(a=x14, b=y14, sel=sel[1], out=out[14]);     Mux(a=x15, b=y15, sel=sel[1], out=out[15]);
Open this post in threaded view
|

## Re: Mux4Way16 not working, can someone help me please?

 Administrator First, don't use individual MUX parts. You have a MUX16. Use it. That will map directly to the three-part schematic you've shown. Second, your schematic doesn't indicate which input signal of each MUX is selected with the control signal is HI. Don't force people to make assumptions about stuff like this. Assuming that the bottom signal is selected when the control signal is HI, this would say that Signal a is selected when Sel = 00, which sounds reasonable. Which signal is selected when Sel = 01  (i.e., when Sel[1] = 0 and Sel[0] = 1)? Does that seem reasonable?
Open this post in threaded view
|

## Re: Mux4Way16 not working, can someone help me please?

 Ok, thank you for your response. I use the Mux16 gate...     PARTS:     Mux16(a=a[0..15], b=c[0..15], sel=sel[0], out=x);     Mux16(a=b[0..15], b=d[0..15], sel=sel[0], out=y);     Mux16(a=x, b=y, sel=sel[1], out=out); it runs correctly, but when the test script run the following inputs: set a %B0001001000110100, set b %B1001100001110110, set c %B1010101010101010, set d %B0101010101010101, it stops at "set sel 2", giving me a "Comparison failure at line 7". This line should output c (1010101010101010, which I think is 43690 in decimal), but it outputs -21846 (which is kind of similar to the d value 0101010101010101, in decimal 21845). Again, I don't know what I did wrong. I think that the design of the gate is ok
Open this post in threaded view
|

## Re: Mux4Way16 not working, can someone help me please?

 Administrator Look at Line 7 in the .cmp file and you will see that, for this test, sel = 01, meaning that sel[1] = 0 and sel[0] = 0. The output for this line should be 'b'. But you are outputting 'c'. Remember that values that start with a 1 are negative numbers. So look at what your logic is doing for the case that is failing, namely when sel = 1, meaning that sel[1] = 0 and sel[0] = 1. With sel[0] = 1, the 'x' signal is 'c' and the 'y' signal is 'd'. That right there means that the final output cannot be 'b', it must either be 'c' or 'd'. With sel[1] = 0, the 'x' signal is chosen, so the final output is therefore 'c'. Let's see if this agrees with what you are observing. c = B1010101010101010 This is a negative number in 2's complement and is equal to -21,846.