DMux4Way Error

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

DMux4Way Error

flaviorcb
Hi,

Why my code is wrong?
I can't get the point.

Sorry my poor english, I'm brazilian.

thanks.

CHIP DMux4Way {
    IN in, sel[2];

    OUT a, b, c, d;

    PARTS:
    // Put your code here.
        Not(in=sel[0],out=notsel0);
        Not(in=sel[1],out=notsel1);
       
        And(a=notsel0,b=notsel1,out=temp1);
        And(a=temp1,b=in,out=a);
       
        And(a=notsel0,b=sel[1],out=temp2);
        And(a=temp2,b=in,out=b);
       
        And(a=sel[0],b=notsel1,out=temp3);
        And(a=temp3,b=in,out=c);
       
        And(a=sel[0],b=sel[1],out=temp4);
        And(a=temp4,b=in,out=d);
}
Reply | Threaded
Open this post in threaded view
|

Re: DMux4Way Error

cadet1620
Administrator
If you look at the difference between the compare output and your output, you will see that the test failure is when sel=01 and your c outout is true instead of the expected b output.  This suggests that your use of sel[0] and sel[1] is backwards.

Note that bus indexes go from right to left -- the reverse of what you may be used to for array indexes.

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

Re: DMux4Way Error

cadet1620
Administrator
In reply to this post by flaviorcb
You might also think about how you can make a DMux4Way from 3 DMux.  The technique can be extended to make DMux8Way with a DMux and 2 DMux4Way.  Saves a lot of typing for the DMux8Way.

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

Re: DMux4Way Error

flaviorcb
thanks very much

it is working now.

I did miss this: "Note that bus indexes go from right to left".
Reply | Threaded
Open this post in threaded view
|

Re: DMux4Way Error

flaviorcb
I will try in this way.