/** * 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];
/** * Memory of 64 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 RAM64 { IN in[16], load, address[6]; OUT out[16];
/** * 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];
/** * Memory of 4K 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 RAM4K { IN in[16], load, address[12]; OUT out[16];
/** * Memory of 16K 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 RAM16K { IN in[16], load, address[14]; OUT out[16];
into nested three-level if-else statements. Since Mux can only choose which state to keep, and cannot choose what state is needed before calculating that state, we have to analyze this nested if-else statement from the innermost level outwards. And, in terms of requirements, the top requirement will override the bottom requirement, i.e. the reset instruction will hide the load instruction, and the load instruction will hide the inc instruction. By working from the bottom up, we achieve exactly this override.
In order to use Mux, it is logical to find out what the new state of the current state (original) should be after reset, load and inc. The new state after reset is false, and the new state after load is in, without any computation. Only the state after inc needs to be obtained using Inc16, in this case which is increased.
Next, the original. At first I thought this was in, but in fact, because of the sequential logic, all operations here should be done on the basis of the current state of the chip in the PC. So, here the current state is noted as original and this original is updated on the last line.