/* put things on the bus */ public void ClockCycleWrite(int clock) { if (StatusChanged) ALUopstart = clock; /* see if we can assert the result yet */ if (clock == ALUopstart + 60) { int op; long rightop = Rt_ALU; if (!IRALU) /* ALUop from IR */ op = ir.getALUop(); else /* ALUop from microcode */ { rightop = ALU_PLUS2 ? 2 : Rt_ALU; op = MC_op; } /* do the operations: */ switch (op) { default: case 0: /* nop */ ALUresult = 0; break; case 1: ALUresult = Lt_ALU + rightop; break; case 2: ALUresult = Lt_ALU - rightop; break; case 3: ALUresult = Lt_ALU & rightop; break; case 4: ALUresult = Lt_ALU | rightop; break; case 5: ALUresult = Lt_ALU ^ rightop; break; case 6: ALUresult = (0xfffff) ^ rightop; break; } /* set SR as appropriate. */ if (!sr.getSHFALU() && sr.getW_SR12()) { sr.setSR1(ALUresult > 0); sr.setSR2(ALUresult < 0); } ALUopstart = 0; } /* read from internal register */ if (R_ALU) { if (W_LALU || (W_RALU && !ALU_PLUS2)) throw new IllegalOperation("Writing to ALU registers while reading ALU output"); bus.setValue(ALUresult); } }
/** * get the enumerated type of the symbol as a semantic record type * * @return the SR type */ public SR getType() { SR sr = null; switch (type) { case "integer": sr = SR.intlit(); break; case "float": sr = SR.fixedlit(); break; case "string": sr = SR.stringlit(); break; case "boolean": sr = SR.bool(); break; default: sr = null; break; } return sr; }