// This file is part of www.nand2tetris.org // and the book "The Elements of Computing Systems" // by Nisan and Schocken, MIT Press. // File name: projects/03/b/RAM16K.hdl /** * Memory of 16K registers, each 16 bit-wide. Out holds the value * stored at the memory location specified by address. If load==1, then * the in value is loaded into the memory location specified by address * (the loaded value will be emitted to out from the next time step onward). */ CHIP RAM16K { IN in[16], load, address[14]; OUT out[16]; PARTS: // Put your code here: DMux8Way(in=load, sel[0..1]=address[12..13], a=load0, b=load1, c=load2, d=load3); RAM4K(in[0..15]=in[0..15], load=load0, address[0..11]=address[0..11], out[0..15]=out0); RAM4K(in[0..15]=in[0..15], load=load1, address[0..11]=address[0..11], out[0..15]=out1); RAM4K(in[0..15]=in[0..15], load=load2, address[0..11]=address[0..11], out[0..15]=out2); RAM4K(in[0..15]=in[0..15], load=load3, address[0..11]=address[0..11], out[0..15]=out3); Mux8Way16(a[0..15]=out0, b[0..15]=out1, c[0..15]=out2, d[0..15]=out3, sel[0..1]=address[12..13], out[0..15]=out[0..15]); }