DMux4Way. Slept over it, and got it immediately on first try

This commit is contained in:
Nemo 2020-05-20 14:37:46 +05:30
parent 559499e879
commit db67c53052
3 changed files with 35 additions and 3 deletions

View File

@ -23,5 +23,5 @@ Build order as per the website. Cost for each gate in NAND in brackets.
- [x] `Or8Way` (21)
- [x] `Mux4Way16` (339)
- [x] `Mux8Way16` (791)
- [ ] `DMux4Way` ()
- [x] `DMux4Way` (37, Fun)
- [ ] `DMux8Way` ()

View File

@ -16,5 +16,28 @@ CHIP DMux4Way {
OUT a, b, c, d;
PARTS:
// Put your code here:
}
/**
* Demultiplexor:
* {x, y} = {in, 0} if sel[0] == 0
* {0, in} if sel[0] == 1
*/
DMux(in=in, sel=sel[0], a=x, b=y);
// Now we can copy x,y to abcd as {x|0,y|0,x|0,y|0}
// depending on sel[1]
// sel| 00 | 01 || 10 | 11
//S[1]| 0 || 1
//----|----|----||----|---
// x | in | 0 || in | 0
// y | 0 | in || 0 | in
//----|----|----||----|---
// a | in | 0 || 0 | 0
// b | 0 | in || 0 | 0
// c | 0 | 0 || in | 0
// d | 0 | 0 || 0 | in
Mux(a=x, b=false, sel=sel[1], out=a);
Mux(a=y, b=false, sel=sel[1], out=b);
Mux(a=false, b=x, sel=sel[1], out=c);
Mux(a=false, b=y, sel=sel[1], out=d);
}

9
projects/01/DMux4Way.out Normal file
View File

@ -0,0 +1,9 @@
| in | sel | a | b | c | d |
| 0 | 00 | 0 | 0 | 0 | 0 |
| 0 | 01 | 0 | 0 | 0 | 0 |
| 0 | 10 | 0 | 0 | 0 | 0 |
| 0 | 11 | 0 | 0 | 0 | 0 |
| 1 | 00 | 1 | 0 | 0 | 0 |
| 1 | 01 | 0 | 1 | 0 | 0 |
| 1 | 10 | 0 | 0 | 1 | 0 |
| 1 | 11 | 0 | 0 | 0 | 1 |