Add solutions for part 1
This commit is contained in:
30
projects/03/b/RAM512.hdl
Normal file
30
projects/03/b/RAM512.hdl
Normal file
@@ -0,0 +1,30 @@
|
||||
// This file is part of the materials accompanying the book
|
||||
// "The Elements of Computing Systems" by Nisan and Schocken,
|
||||
// MIT Press. Book site: www.idc.ac.il/tecs
|
||||
// File name: projects/03/b/RAM512.hdl
|
||||
|
||||
/**
|
||||
* Memory of 512 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 RAM512 {
|
||||
IN in[16], load, address[9];
|
||||
OUT out[16];
|
||||
|
||||
PARTS:
|
||||
DMux8Way(in=load, sel=address[6..8], a=s0, b=s1, c=s2, d=s3, e=s4, f=s5, g=s6, h=s7);
|
||||
|
||||
RAM64(in=in, load=s0, address=address[0..5], out=r0s);
|
||||
RAM64(in=in, load=s1, address=address[0..5], out=r1s);
|
||||
RAM64(in=in, load=s2, address=address[0..5], out=r2s);
|
||||
RAM64(in=in, load=s3, address=address[0..5], out=r3s);
|
||||
RAM64(in=in, load=s4, address=address[0..5], out=r4s);
|
||||
RAM64(in=in, load=s5, address=address[0..5], out=r5s);
|
||||
RAM64(in=in, load=s6, address=address[0..5], out=r6s);
|
||||
RAM64(in=in, load=s7, address=address[0..5], out=r7s);
|
||||
|
||||
Mux8Way16(a=r0s, b=r1s, c=r2s, d=r3s, e=r4s, f=r5s, g=r6s, h=r7s, sel=address[6..8], out=out);
|
||||
}
|
||||
Reference in New Issue
Block a user