Adds Dmux8Way. Not as fun as the last one

This commit is contained in:
Nemo 2020-05-20 14:46:14 +05:30
parent db67c53052
commit f4dcbfd853
3 changed files with 42 additions and 2 deletions

View File

@ -11,6 +11,8 @@
* {0, 0, 0, in} if sel == 11
*/
// COST = 37
CHIP DMux4Way {
IN in, sel[2];
OUT a, b, c, d;

View File

@ -11,10 +11,31 @@
* {0, 0, 0, 0, 0, 0, 0, in} if sel == 111
*/
// COST = 37 + 8*8 = 101
CHIP DMux8Way {
IN in, sel[3];
OUT a, b, c, d, e, f, g, h;
PARTS:
// Put your code here:
}
// This makes our "repeated building block" - which we repeat twice
// Same as how we do it in DMux4Way
DMux4Way(in=in, sel[0]=sel[0], sel[1]=sel[1], a=w, b=x, c=y, d=z);
// If sel[2] is 1:
// set a,b,c,d to 0
// else set a,b,c,d to w,x,y,z
Mux(a=w, b=false, sel=sel[2], out=a);
Mux(a=x, b=false, sel=sel[2], out=b);
Mux(a=y, b=false, sel=sel[2], out=c);
Mux(a=z, b=false, sel=sel[2], out=d);
// If sel[2] is 0:
// set e,f,g,h to 0
// else set e,f,g,h to w,x,y,z
Mux(a=false, b=w, sel=sel[2], out=e);
Mux(a=false, b=x, sel=sel[2], out=f);
Mux(a=false, b=y, sel=sel[2], out=g);
Mux(a=false, b=z, sel=sel[2], out=h);
}

17
projects/01/DMux8Way.out Normal file
View File

@ -0,0 +1,17 @@
| in | sel | a | b | c | d | e | f | g | h |
| 0 | 000 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 001 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 010 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 011 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 100 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 101 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 110 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 000 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 001 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 010 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
| 1 | 011 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
| 1 | 100 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
| 1 | 101 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
| 1 | 110 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
| 1 | 111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |