// 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: // Put your code here: DMux8Way(in=load, sel[0..2]=address[0..2], a=load0, b=load1, c=load2, d=load3, e=load4, f=load5, g=load6, h=load7); //途中のワイヤーに関しては、out1[0..15]のような記載はだめらしい Register(in[0..15]=in[0..15], load=load0, out[0..15]=out0); Register(in[0..15]=in[0..15], load=load1, out[0..15]=out1); Register(in[0..15]=in[0..15], load=load2, out[0..15]=out2); Register(in[0..15]=in[0..15], load=load3, out[0..15]=out3); Register(in[0..15]=in[0..15], load=load4, out[0..15]=out4); Register(in[0..15]=in[0..15], load=load5, out[0..15]=out5); Register(in[0..15]=in[0..15], load=load6, out[0..15]=out6); Register(in[0..15]=in[0..15], load=load7, out[0..15]=out7); Mux8Way16(a[0..15]=out0, b[0..15]=out1, c[0..15]=out2, d[0..15]=out3, e[0..15]=out4, f[0..15]=out5, g[0..15]=out6, h[0..15]=out7, sel[0..2]=address[0..2], out[0..15]=out[0..15]); }