Mux4way16, problem using the Mux16

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

Mux4way16, problem using the Mux16

Phil
Hi,
I've been trying to make the 4wayMux16 for a while now and I've managed to make one that worked using one bit Mux chips a grand total of 48 times (that's after trying with 120+ Ands and Ors, which didn't work), so I figured it was time to start using the Mux16. However, I think I'm stuck at a language problem, I don't really know how to use the 16 bit chips whitout getting error messages from the simulator.
Here's what I last tried, which is my working 4wayMux16 written with 3 Mux16's instead of 48 Mux's.

CHIP Mux4Way16 {
    IN a[16], b[16], c[16], d[16], sel[2];

    OUT out[16];

    PARTS:

Mux16(a=a[0..15], b=b[0..15], sel=sel[0], out=ab[16]);
Mux16(a=c[0..15], b=d[0..15], sel=sel[0], out=cd[16]);
Mux16(a=ab[0..15], b=cd[0..15], sel=sel[1], out=out[16]);
}

This gives me the "ab[16]: sub bus of an internal node may not be used" error, to which I've become quite used by now.
The logic part seems to go just fine since it works when using single bit Mux's, but can someone give me clues on how to write the code to use the Mux16?
Reply | Threaded
Open this post in threaded view
|

Re: Mux4way16, problem using the Mux16

cadet1620
Administrator
Phil wrote
Mux16(a=a[0..15], b=b[0..15], sel=sel[0], out=ab[16]);
I'm going to use abcd for Mux16 pins and ABCD for Mux4Way16 pins to try to limit confusion.  They all need to be lowercase in your real HDL

CHIP Mux4Way16 {
    IN A[16], B[16], C[16], D[16], sel[2];

CHIP Mux16 {
    IN a[16], b[16], c[16], d[16], sel[2];

Since A and a are both 16-bit buses, you can simple connect them together; no subscripting required.
    Mux16(a=A, ...

Whenever you create a new wire by connecting to an output that is a bus, the new wire is a bus of the same width; again, no subscripting required.
    Mux16(..., out=ab)
creates an internal wire in Mux4Way16 named ab.

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

Re: Mux4way16, problem using the Mux16

Phil
Wow, it worked!
Today begins an era where I won't have to write 100 lines of code when only three are necessary!
 
What I mean is: thanks a lot Mark.
Reply | Threaded
Open this post in threaded view
|

Re: Mux4way16, problem using the Mux16

skyline1
Just been reading this thread it's solved it for me too just use three MUXs one to MUX the first 2 the select decoding works itself out It's a bit like building the 8 input Or

Thanks fellas
Reply | Threaded
Open this post in threaded view
|

Re: Mux4way16, problem using the Mux16

ismithers
Another thanks from me, I've just started working through these things and go to the multi-bit mux chips and got a bit stuck. But this helped steer me back on the right track, nice work, thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Mux4way16, problem using the Mux16

blinda
In reply to this post by cadet1620
also having a hard time before reading this thread. Thank you~ and then it went on much more smoothly with the Mux8Way16.