MUX8WAY16 not working. I have no clue what is wrong.

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

MUX8WAY16 not working. I have no clue what is wrong.

HighSchoolerWhoAsksHowTooMuch
CHIP Mux8Way16 {
    IN a[16], b[16], c[16], d[16],
       e[16], f[16], g[16], h[16],
       sel[3];
    OUT out[16];

    PARTS:
    Mux16(a=a[0..15], b=e[0..15],sel = sel[0], out=z);
    Mux16(a=b[0..15], b=f[0..15],sel = sel[0], out=q);
    Mux16(a=c[0..15], b=g[0..15],sel = sel[0], out=r);
    Mux16(a=d[0..15], b=h[0..15],sel = sel[0], out=l);

    Mux4Way16(a=z, b=q, c=r, d=l,sel=sel[1..2],out=out[0..15]);

}




the output is

|        a         |        b         |        c         |        d         |        e         |        f         |        g         |        h         |  sel  |       out        |

| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 |  001  | 0101011001111000 |

Any help would be greatly appreciated!
Reply | Threaded
Open this post in threaded view
|

Re: MUX8WAY16 not working. I have no clue what is wrong.

WBahn
Administrator
The output you are seeing is exactly what you are telling it to be.

For sel=001, which of the eight inputs should the output be?

Which of the eight inputs are you seeing at the output?

Walk through your design and make note of what input signal is at the output of each of your Muxes.
Reply | Threaded
Open this post in threaded view
|

Re: MUX8WAY16 not working. I have no clue what is wrong.

HighSchoolerWhoAsksHowTooMuch
Thank you for the reply. The output should be b. The output is e.
sel:001
a:0
b:0
c:0
d:1
e:1
f:1
g:1
h:0

Mux(a,e sel[0]) ->0 = a
Mux(b,f sel[0]) ->0 = b
Mux(c,g sel[0]) ->0 = c
Mux(d,h sel[0]) ->1 = d

Mux16(0 = a, 0 = b, 0 = c, 1 = d, 01 = sel[1..2]) -> 0 = b


I think that I am misunderstanding Mux gates. I had a similar error on another chip and a random change fixed it.

Reply | Threaded
Open this post in threaded view
|

Re: MUX8WAY16 not working. I have no clue what is wrong.

WBahn
Administrator
If sel=001, what is the value of sel[0]?
Reply | Threaded
Open this post in threaded view
|

Re: MUX8WAY16 not working. I have no clue what is wrong.

HighSchoolerWhoAsksHowTooMuch
I see. I fixed the error now. However, I am concerned that there is a deeper error.

 Mux16(a=a[0..15], b=e[0..15],sel = sel[2], out=z);
    Mux16(a=b[0..15], b=f[0..15],sel = sel[2], out=q);
    Mux16(a=c[0..15], b=g[0..15],sel = sel[2], out=r);
    Mux16(a=d[0..15], b=h[0..15],sel = sel[2], out=l);

    Mux4Way16(a=z, b=q, c=r, d=l,sel3=sel[0..1],out=out[0..15]);

Shouldn't the last line cause an error because, in the case of sel[] = 001, sel3 would be 10, not 01?

Many thanks!



Reply | Threaded
Open this post in threaded view
|

Re: MUX8WAY16 not working. I have no clue what is wrong.

HighSchoolerWhoAsksHowTooMuch
In reply to this post by WBahn
Assume Sel[] = 001.

So this line: Mux4Way16(a=z, b=q, c=r, d=l,sel=sel[0..1],out=out[0..15]);
passes sel=10 into Mux4Way16?

Wouldn't this result c being chosen instead of b because then sel[0] = 0 and sel[1] = 1?

Below is Mux4Way16:

Mux16(a=a[0..15],b=d[0..15],sel=sel[1], out=q);
Mux16(a=c[0..15],b=b[0..15],sel=sel[0], out=z);
Xor(a=sel[0],b=sel[1],out=h);
Mux16(a=q, b=z, sel=h, out = out[0..15]);
Reply | Threaded
Open this post in threaded view
|

Re: MUX8WAY16 not working. I have no clue what is wrong.

HighSchoolerWhoAsksHowTooMuch
In reply to this post by WBahn
Never mind. I understand now. if 10 is passed in. 1 is passed in first and 0 is passed in second. Thus sel[0] = 1.

Thank you for your help!
Reply | Threaded
Open this post in threaded view
|

Re: MUX8WAY16 not working. I have no clue what is wrong.

WBahn
Administrator
In reply to this post by HighSchoolerWhoAsksHowTooMuch
The Mux4Way16 doesn't have a sel3 input, just a sel input that is two bits wide.
Reply | Threaded
Open this post in threaded view
|

Re: MUX8WAY16 not working. I have no clue what is wrong.

WBahn
Administrator
In reply to this post by HighSchoolerWhoAsksHowTooMuch
You got it.
Reply | Threaded
Open this post in threaded view
|

Re: MUX8WAY16 not working. I have no clue what is wrong.

HighSchoolerWhoAsksHowTooMuch
I hate to be a pest, but I think I had my last post backward. If sel[]=01, then wouldn't 1 be passed in first such that sel[0]=1? Thank you again!
Reply | Threaded
Open this post in threaded view
|

Re: MUX8WAY16 not working. I have no clue what is wrong.

WBahn
Administrator
Yes. I think I was looking at what you had earlier.

The bits are numbered with bit 0 being the lsb (least significant bit), or from right to left as we would normally write the value out on paper.

I would prefer that the authors used a[15..0] instead of a[0..15] as I think that is more intuitively consistent.
Reply | Threaded
Open this post in threaded view
|

Re: MUX8WAY16 not working. I have no clue what is wrong.

HighSchoolerWhoAsksHowTooMuch
I see. Thank you!!