Mux4Way16 HELP

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

Mux4Way16 HELP

stuart
This post was updated on .
Hello i made this circuit for my Mux4Way16 gate and i tried to write it on HDL but it doesn't work i have an error which says "sub bus of an internal pin might not be used".

Here is the circuit :



And here is my code :

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

PARTS:
    And(a=sel[0], b=sel[1], out=sel0Andsel1);
    Not(in=sel[1], out=Notsel1);
    And(a=sel[0], b=Notsel1, out=sel0AndNotsel1);
    Mux16(a=a, b=b, sel=sel0AndNotsel1, out=Muxab);
    Mux16(a=c, b=d, sel=sel0Andsel1, out=Muxcd);
    And(a=Muxcd[0], b=sel[1], out=Muxcd0Andsel1);
    And(a=Muxcd[1], b=sel[1], out=Muxcd1Andsel1);
    And(a=Muxcd[2], b=sel[1], out=Muxcd2Andsel1);
    And(a=Muxcd[3], b=sel[1], out=Muxcd3Andsel1);
    And(a=Muxcd[4], b=sel[1], out=Muxcd4Andsel1);
    And(a=Muxcd[5], b=sel[1], out=Muxcd5Andsel1);
    And(a=Muxcd[6], b=sel[1], out=Muxcd6Andsel1);
    And(a=Muxcd[7], b=sel[1], out=Muxcd7Andsel1);
    And(a=Muxcd[8], b=sel[1], out=Muxcd8Andsel1);
    And(a=Muxcd[9], b=sel[1], out=Muxcd9Andsel1);
    And(a=Muxcd[10], b=sel[1], out=Muxcd10Andsel1);
    And(a=Muxcd[11], b=sel[1], out=Muxcd11Andsel1);
    And(a=Muxcd[12], b=sel[1], out=Muxcd12Andsel1);
    And(a=Muxcd[13], b=sel[1], out=Muxcd13Andsel1);
    And(a=Muxcd[14], b=sel[1], out=Muxcd14Andsel1);
    And(a=Muxcd[15], b=sel[1], out=Muxcd15Andsel1);
    Or(a=Muxab[0], b=Muxcd0Andsel1, out=out[0]);
    Or(a=Muxab[1], b=Muxcd1Andsel1, out=out[1]);
    Or(a=Muxab[2], b=Muxcd2Andsel1, out=out[2]);
    Or(a=Muxab[3], b=Muxcd3Andsel1, out=out[3]);
    Or(a=Muxab[4], b=Muxcd4Andsel1, out=out[4]);
    Or(a=Muxab[5], b=Muxcd5Andsel1, out=out[5]);
    Or(a=Muxab[6], b=Muxcd6Andsel1, out=out[6]);
    Or(a=Muxab[7], b=Muxcd7Andsel1, out=out[7]);
    Or(a=Muxab[8], b=Muxcd8Andsel1, out=out[8]);
    Or(a=Muxab[9], b=Muxcd9Andsel1, out=out[9]);
    Or(a=Muxab[10], b=Muxcd10Andsel1, out=out[10]);
    Or(a=Muxab[11], b=Muxcd11Andsel1, out=out[11]);
    Or(a=Muxab[12], b=Muxcd12Andsel1, out=out[12]);
    Or(a=Muxab[13], b=Muxcd13Andsel1, out=out[13]);
    Or(a=Muxab[14], b=Muxcd14Andsel1, out=out[14]);
    Or(a=Muxab[15], b=Muxcd15Andsel1, out=out[15]);
}
Reply | Threaded
Open this post in threaded view
|

Re: Mux4Way16 HELP

WBahn
Administrator
The way you are going about it is making if far, far more difficult than it needs to be. Your design uses 37 instances of four different parts. You can implement this design using just three instances of the same part.

As for the error, the problem is that you can't use sub buses of internal signals, only the input and output pins. It's a somewhat unrealistic limitation of the simulator.

To do what you are trying to do you would need to do something like the following:

    Mux16(a=a, b=b, sel=sel0AndNotsel1, out[0]=Muxab0, out[1]=Muxab1, out[2]=Muxab2, ...);
    Mux16(a=c, b=d, sel=sel0Andsel1, out=Muxcd);
    And(a=Muxcd0, b=sel[1], out=Muxcd0Andsel1);
    And(a=Muxcd1, b=sel[1], out=Muxcd1Andsel1);
    ...
Reply | Threaded
Open this post in threaded view
|

Re: Mux4Way16 HELP

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

    PARTS:
    And(a=sel[0], b=sel[1], out=sel0Andsel1);
    Not(in=sel[1], out=Notsel1);
    And(a=sel[0], b=Notsel1, out=sel0AndNotsel1);
    Mux16(a=a, b=b, sel=sel0AndNotsel1, out=Muxab);
    Mux16(a=c, b=d, sel=sel0Andsel1, out=Muxcd);
    And16(a=Muxcd, b=sel[1], out=MuxcdAndsel1);  //Here Muxcd is a 16 bit buses and sel is a 2 bit buses
    Or16(a=Muxab, b=MuxcdAndsel1, out=out);
}
the real question is how to AND sel[1] with every single bit in Muxcd
Reply | Threaded
Open this post in threaded view
|

Re: Mux4Way16 HELP

WBahn
Administrator
You are way overthinking this.

Look at what you are doing with your two Mux16 parts. Each has two 16-bit signals coming in and you use a signal to control which of those two signals comes out of each one.

So after the two Muxes, you have two 16-bit signals and you want one of them to become the 16 bit output of the chip. Sounds like the exact same task that the other two Mux16 parts are doing, doesn't it?
Reply | Threaded
Open this post in threaded view
|

Re: Mux4Way16 HELP

stuart
Yes it does thank for the advice i didnt think about it  :)