Advertisement
Guest User

4wayDemux

a guest
Mar 1st, 2011
2,169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.80 KB | None | 0 0
  1. // This file is part of the materials accompanying the book
  2. // "The Elements of Computing Systems" by Nisan and Schocken,
  3. // MIT Press. Book site: www.idc.ac.il/tecs
  4. // File name: projects/01/DMux4Way.hdl
  5.  
  6. /**
  7.  * 4-way demultiplexor.  The 2-bit sel input selects the output to which
  8.  * the in input will be channeled: 00 to a, 01 to b, 10 to c, 11 to d.
  9.  * The other outputs are set to 0.
  10.  */
  11.  
  12. CHIP DMux4Way {
  13.  
  14.     IN  in, sel[2];
  15.     OUT a, b, c, d;
  16.  
  17.     PARTS:
  18.     Not(in=sel[0], out=ns0);
  19.     Not(in=sel[1], out=ns1);
  20.    
  21.     And(a=sel[0], b=sel[1], out=s1);
  22.     And(a=ns0, b=sel[1], out=ns);
  23.     And(a=sel[0], b=ns1, out=sn);
  24.     And(a=ns0, b=ns1, out=s0);
  25.    
  26.     And(a=in, b=s0, out=a);
  27.     And(a=in, b=ns, out=c);
  28.     And(a=in, b=sn, out=b);
  29.     And(a=in, b=s1, out=d);  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement