What happened to my DMux 4 way?

It seems like he's close to work, he's just useless on line 7, apparently?

/**
 * 4-way demultiplexor.
 * {a,b,c,d} = {in,0,0,0} if sel==00
 *             {0,in,0,0} if sel==01
 *             {0,0,in,0} if sel==10
 *             {0,0,0,in} if sel==11
 */


CHIP DMux4Way {
    IN in, sel[2];
    OUT a, b, c, d;

    PARTS:
    DMux(in = in, sel = sel[0], a = out1, b = out2);

    DMux(in = out1, sel = sel[1], a = a, b = b);
    DMux(in = out2, sel = sel[1], a = c, b = d);
}

I implemented my DMux as follows, and I just use it as if it were a tree:

/**
 * Dmultiplexor.
 * {a,b} = {in,0} if sel==0
 *         {0,in} if sel==1
 */


CHIP DMux {
    IN in, sel;
    OUT a, b;

    PARTS:
    Not(in = sel, out = notsel);
    And(a = in, b = notsel, out = a);
    And(a = in, b = sel, out = b);
}
+8
source share
2 answers

You have the right idea! But you started by narrowing sel [0] as opposed to sel [1], which corresponds to the left column.

PS: I know I'm late

Edit: Added a fixed code as requested below. Thanks for the feedback.

CHIP DMux4Way {
    IN in, sel[2];
    OUT a, b, c, d;

    PARTS:
    DMux(in = in, sel = sel[1], a = out1, b = out2);

    DMux(in = out1, sel = sel[0], a = a, b = b);
    DMux(in = out2, sel = sel[0], a = c, b = d);
}

When narrowing down what will refer to the left column in the truth table (that is, sel [1], don't forget to start from the right side when counting), you would effectively separate the parameters right in the middle

+9
source

, , ( , , ):

b c , :

CHIP DMux4Way {

IN in, sel[2];
OUT a, b, c, d;

PARTS:
// Put your code here:
DMux(in=in, sel=sel[0], a=dOut1, b=dOut2);

DMux(in=dOut1, sel=sel[1], a=a, b=c);

DMux(in=dOut2, sel=sel[1], a=b, b=d);

}

, , , [0]

0

All Articles