4way16 mux

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

4way16 mux

sarab
Guys this code is not working ...please tell me what's wrong with this..

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:
    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:
    Mux4Way16(a=a,b=c,c=e,d=g,sel[0]=sel[0],sel[1]=sel[1],out[0]=w1,out[1]=w2,out[2]=w3,out[3]=w4,out[4]=w5,out[5]=w6,out

[6]=w7,out[7]=w8);
    Mux4Way16(a=b,b=d,c=f,d=h,sel[0]=sel[0],sel[1]=sel[1],out[0]=w9,out[1]=w10,out[2]=w11,out[3]=w12,out[4]=w13,out[5]

=w14,out[6]=w15,out[7]=w16);
    Mux16(a[0]=w1,a[1]=w2,a[2]=w3,a[3]=w4,a[4]=w5,a[5]=w6,a[6]=w7,a[7]=w8,b[0]=w9,b[1]=w10,b[2]=w11,b[3]=w12,b[4]

=w13,b[5]=w14,b[6]=w15,b[7]=w16,sel=sel[2],out=out);
}
Reply | Threaded
Open this post in threaded view
|

Re: 4way16 mux

ybakos
Did you try drawing this on paper?

I'm curious about why you chose to wire every other Mux8Way16 input to the Mux4Way16 input. (This isn't right.)

Also, here's a tip. You can simplify your HDL that uses parts of buses with some syntax like this:

Mux4Way16(.... , sel=sel[0..1], out= ... )

Reply | Threaded
Open this post in threaded view
|

Re: 4way16 mux

cadet1620
Administrator
In reply to this post by sarab
When you run the test, keep hitting the >> button so that you have more than one miscompare to look at.

Look at the Mux4Way16.cmp and Mux4Way16.out files in a text editor or use a visual compare tool like windiff.

The first thing that you should see is that all your "out" values always have bits 8..15 always 0 -- you are missing half the required connections between the Mux4Way16s and the Mux16.

You can eliminate the many "out[0]=w1, out[1]=w2" and the need to add the missing connections by using internal buses instead of individual wires:
    Mux4Way16(a=a,b=c,c=e,d=g,sel[0]=sel[0],sel[1]=sel[1],out=aceg);
    ...
    Mux16(a=aceg, ...
Then when you run the test as above, you will get full width values, but they will still be wrong values.

The hint to fix that is that hardware bits are numbered from right to left. "sel = 001" has "sel[0] = 1".

So you can fix the selection problem either by rearranging the Mux4Way16 input connections as ybakos mentioned, or by rearranging the "sel" connections for all the muxes.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: 4way16 mux

sarab
That's was cool...
but it's not working....can you tell me what's wrong below..


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:
    Mux4Way16(a=a,b=c,c=e,d=g,sel[0]=sel[1],sel[1]=sel[2],out=aceg);
    Mux4Way16(a=b,b=d,c=f,d=h,sel[0]=sel[1],sel[1]=sel[2],out=bdfh);
    Mux16(a=aceg,b=bdfh,sel=sel[0],out=out);
}
Reply | Threaded
Open this post in threaded view
|

Re: 4way16 mux

sarab
In reply to this post by ybakos
thanx but
but it's not working....can you tell me what's wrong below..


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:
    Mux4Way16(a=a,b=c,c=e,d=g,sel[0]=sel[1],sel[1]=sel[2],out=aceg);
    Mux4Way16(a=b,b=d,c=f,d=h,sel[0]=sel[1],sel[1]=sel[2],out=bdfh);
    Mux16(a=aceg,b=bdfh,sel=sel[0],out=out);
}
Reply | Threaded
Open this post in threaded view
|

Re: 4way16 mux

ybakos
sarab wrote
why you chose to wire every other Mux8Way16 input to the Mux4Way16 input. (This isn't right.)
@sarab, can you answer my question above? Why did you wire the inputs to each Mux4Way16 the way you did?

Also, take a look at your Mux4Way16... it is similar in structure to the Mux8Way16.
Reply | Threaded
Open this post in threaded view
|

Re: 4way16 mux

cadet1620
Administrator
In reply to this post by sarab
Your latest version, the one with
    Mux4Way16(a=a,b=c,c=e,d=g,sel[0]=sel[1],sel[1]=sel[2],out=aceg);
works for me. There may be a problem with one of your other chips.

Rename your Mux4Way16.hdl and Mux16.hdl to something else so that the Hardware Simulator will use the built-in version. (I use names like *.hdlX for temporary renames when I'm debugging.)

--Mark

BTW, you  can do this to get the same connections.
    Mux4Way16(a=a,b=c,c=e,d=g,sel=sel[1..2],out=aceg);
Reply | Threaded
Open this post in threaded view
|

Re: 4way16 mux

sarab
Yes , again....it worked

there is problem in my  mux16...don't know what :\

I want to ask something....can we simulate every project using built-in functions?
Reply | Threaded
Open this post in threaded view
|

Re: 4way16 mux

sarab
In reply to this post by ybakos
thnx sir....there's problem in mux16 :)
Reply | Threaded
Open this post in threaded view
|

Re: 4way16 mux

ybakos
Take a look at the chip specification, and make sure you have a and b wired correctly.