fetch0: a_sel=7, b_sel=7, alu_sel=AND, r6_write, mar_sel=LOAD; fetch1: a_sel=6, alu_sel=ADDA, c_in, r7_write, read, ir0_sel=LOAD, if wait then goto fetch1 else goto fetch2 endif; fetch2: a_sel=7, b_sel=7, alu_sel=AND, r6_write, mar_sel=LOAD; fetch3: a_sel=6, alu_sel=ADDA, c_in, r7_write, read, ir1_sel=LOAD, if wait then goto fetch3 else goto fetch4 endif; fetch4: goto opcode[IR_OPCODE]; opcode[0]: goto fetch0; // no-op opcode[1]: ri_sel, rj_sel, rk_sel, alu_sel=ADD, goto fetch0; // ri<-rj+rk opcode[2]: ri_sel, result_sel=IR_CONST8, goto fetch0; // ri<-const8 opcode[3]: rj_sel, alu_sel=SUBA, r6_write, result_sel=IR_CONST4, if c_out then goto branch else goto fetch0 endif; opcode[4]: ri_sel, rj_sel, alu_sel=ADDA, goto fetch0; // ri<-rj opcode[5]: rj_sel, alu_sel=ADDA, mar_sel=LOAD, goto opcode5a; // store: mem[rj]<- rk opcode[6]: rj_sel, alu_sel=ADDA, mar_sel=LOAD, goto opcode6a; // load: ri<-mem[rj] opcode[7]: ri_sel, rj_sel, rk_sel, alu_sel=SUB, c_in, goto fetch0; // subtract opcode[8]: goto opcode[8]; // halt branch: r7_write, a_sel=7, b_sel=6, alu_sel=ADD, goto fetch0; opcode5a: a_sel=5, b_sel=5, alu_sel=SUB, c_in, r5_write, goto opcode5b; opcode5b: rk_sel, a_sel=5, alu_sel=OR, mdr_sel=LOAD_ALU, goto memwrite; memwrite: write, if wait then goto memwrite else goto fetch0 endif; opcode6a: read, mdr_sel=LOAD_MEM, if wait then goto opcode6a else goto opcode6b endif; opcode6b: result_sel=MDR, ri_sel, goto fetch0;