Add solutions for part 1
This commit is contained in:
31
projects/03/a/RAM8.hdl
Normal file
31
projects/03/a/RAM8.hdl
Normal file
@@ -0,0 +1,31 @@
|
||||
// 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/a/RAM8.hdl
|
||||
|
||||
/**
|
||||
* Memory of 8 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 RAM8 {
|
||||
IN in[16], load, address[3];
|
||||
OUT out[16];
|
||||
|
||||
PARTS:
|
||||
|
||||
DMux8Way(in=load, sel=address, a=s0, b=s1, c=s2, d=s3, e=s4, f=s5, g=s6, h=s7);
|
||||
|
||||
Register(in=in, load=s0, out=r0s);
|
||||
Register(in=in, load=s1, out=r1s);
|
||||
Register(in=in, load=s2, out=r2s);
|
||||
Register(in=in, load=s3, out=r3s);
|
||||
Register(in=in, load=s4, out=r4s);
|
||||
Register(in=in, load=s5, out=r5s);
|
||||
Register(in=in, load=s6, out=r6s);
|
||||
Register(in=in, load=s7, out=r7s);
|
||||
|
||||
Mux8Way16(a=r0s, b=r1s, c=r2s, d=r3s, e=r4s, f=r5s, g=r6s, h=r7s, sel=address, out=out);
|
||||
}
|
||||
Reference in New Issue
Block a user