//John Barr //testing registers with combinational logic // Register4 is the PC. s = 0 will take the value of the PC from start[4] // s=1 will take the pc from an incremented value // bits 1 and 0 of the pc are used to specify the write register and the read register. // So if you begin with s=0, start=0 you will reset the PC // If you then set s=1, the pc will begin incrementing. // Note that even though the PC will increment from 0 to 15, only bits 1 and 0 are used // as input to the Register44. So Register44 access will cycle from 0 to 1 to 2 to 3 // and back to 0. // To test, set s=0, start=0, load = 1 and in=some value. Go through a complete cycle. // Now set s=1. Set in=value 2. go through a complete cycle. // leave s=1, set in = value3. go through a complete cycle. // leave s=1, set in = value 4. go through a complete cycle. // Now leave s=1 and set load=0. As you go through cycles, you will see your // values reappear as the PC value increases (and the lower two bits go from 0 to 3). CHIP pcExample { IN in[4], load,s, start[4]; OUT outBus[4], pc[4]; PARTS: Mux24(a=start, b=pcInc, s=s, out=muxOut); Register4(in=muxOut,load=true, out[0]=r0,out[1]=r1,out[2]=r2,out[3]=r3); Or(a=r0, b=false, out=pc[0]); Or(a=r1, b=false, out=pc[1]); Or(a=r2, b=false, out=pc[2]); Or(a=r3, b=false, out=pc[3]); Register44(in = in, add[0]=r0,add[1]=r1, load = load, chipselect=true, out=outBus); add4(a[0]=r0, a[1]=r1, a[2]=r2, a[3]=r3, b[0]=true, b[1]=false, b[2]=false, b[3]=false, cin=false, sum=pcInc); }