它似乎接近工作,显然只是在第 7 行搞砸了?
/**
* 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);
}
我已经按如下方式实现了我的 DMux,我只是把它当作一棵树来使用:
/**
* 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);
}