// 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: DMux8Way(in=load, sel[0..1]=address[12..13], sel[2]=false, a=s0, b=s1, c=s2, d=s3, e=s4, f=s5, g=s6, h=s7); RAM4K(in=in, load=s0, address=address[0..11], out=r0s); RAM4K(in=in, load=s1, address=address[0..11], out=r1s); RAM4K(in=in, load=s2, address=address[0..11], out=r2s); RAM4K(in=in, load=s3, address=address[0..11], out=r3s); RAM4K(in=in, load=s4, address=address[0..11], out=r4s); RAM4K(in=in, load=s5, address=address[0..11], out=r5s); RAM4K(in=in, load=s6, address=address[0..11], out=r6s); RAM4K(in=in, load=s7, address=address[0..11], out=r7s); Mux8Way16(a=r0s, b=r1s, c=r2s, d=r3s, e=r4s, f=r5s, g=r6s, h=r7s, sel[0..1]=address[12..13], sel[2]=false, out=out); }