Skip to content
4YCAaaa edited this page Jan 4, 2023 · 1 revision
  • 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:
    // Put your code here:
    //input
    DMux8Way(in=load,sel=address[0..2],a=r0,b=r1,c=r2,d=r3,e=r4,f=r5,g=r6,h=r7);
    Register(in=in,load=r0,out=r0out);
    Register(in=in,load=r1,out=r1out);
    Register(in=in,load=r2,out=r2out);
    Register(in=in,load=r3,out=r3out);
    Register(in=in,load=r4,out=r4out);
    Register(in=in,load=r5,out=r5out);
    Register(in=in,load=r6,out=r6out);
    Register(in=in,load=r7,out=r7out);
    //output
    Mux8Way16(a=r0out,b=r1out,c=r2out,d=r3out,e=r4out,f=r5out,g=r6out,h=r7out,sel=address[0..2],out=out);
}
Clone this wiki locally