From f4dcbfd853456c837d5367273c5bb0cd4298c1fd Mon Sep 17 00:00:00 2001 From: Nemo Date: Wed, 20 May 2020 14:46:14 +0530 Subject: [PATCH] Adds Dmux8Way. Not as fun as the last one --- projects/01/DMux4Way.hdl | 2 ++ projects/01/DMux8Way.hdl | 25 +++++++++++++++++++++++-- projects/01/DMux8Way.out | 17 +++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 projects/01/DMux8Way.out diff --git a/projects/01/DMux4Way.hdl b/projects/01/DMux4Way.hdl index eaefeee..a9b4b82 100644 --- a/projects/01/DMux4Way.hdl +++ b/projects/01/DMux4Way.hdl @@ -11,6 +11,8 @@ * {0, 0, 0, in} if sel == 11 */ +// COST = 37 + CHIP DMux4Way { IN in, sel[2]; OUT a, b, c, d; diff --git a/projects/01/DMux8Way.hdl b/projects/01/DMux8Way.hdl index e24fcaa..88f2a47 100644 --- a/projects/01/DMux8Way.hdl +++ b/projects/01/DMux8Way.hdl @@ -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: -} \ No newline at end of file + + // 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); +} diff --git a/projects/01/DMux8Way.out b/projects/01/DMux8Way.out new file mode 100644 index 0000000..ebf9304 --- /dev/null +++ b/projects/01/DMux8Way.out @@ -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 |