- public Instruction readInstruction(long instr) {
- long inst = instr;
- switch((int)getField(WIDTH_WORD-1, WIDTH_WORD-2, inst)) {
- case 0: {
- Pump name = getBoxByInstAddr(getIntField(OFFSET_PUMP_ADDR+WIDTH_PUMP_ADDR-1, OFFSET_PUMP_ADDR, inst));
- Destination dest = getDestByAddr (getIntField(OFFSET_DEST+WIDTH_DEST_ADDR-1, OFFSET_DEST, inst));
- int count = getIntField( OFFSET_COUNT+WIDTH_COUNT-1, OFFSET_COUNT, inst);
- boolean tokenIn = getBit(OFFSET_TI, instr);
- boolean dataIn = getBit(OFFSET_DI, instr);
- boolean latch = getBit(OFFSET_DL, instr);
- boolean dataOut = getBit(OFFSET_DO, instr);
- boolean tokenOut = getBit(OFFSET_TO, instr);
- boolean requeue = getBit(OFFSET_RQ, instr);
- boolean dataOutDest = dataOut && tokenOut;
- boolean isLiteral = tokenIn && tokenOut && !dataOutDest;
- if (isLiteral)
- return new Instruction.LocalLiteral(name, getIntField(OFFSET_LITERAL+WIDTH_LITERAL-1, OFFSET_LITERAL, inst));
- if (latch & !dataIn) return new Instruction.Kill(name, count, tokenIn);
- return new Instruction.Executable(name, dest, count, tokenIn, dataIn, latch, dataOutDest,
- dataOut, tokenOut, requeue);
- }
- /*
- case 1: {
- Destination name = getDestByAddr(getField(WIDTH_WORD-3, WIDTH_WORD-3-WIDTH_DEST_ADDR+1, inst));
- long offset = getSignedField(WIDTH_WORD-3-WIDTH_DEST_ADDR, WIDTH_CODEBAG_SIZE, instr);
- long size = getSignedField(WIDTH_CODEBAG_SIZE-1, 0, instr);
- return new Instruction.Literal.CodeBagDescriptor(name, offset, size);
- }
- */
- case 2: {
- Destination name = getDestByAddr(getField(WIDTH_WORD-3, WIDTH_WORD-3-WIDTH_PUMP_ADDR+1, inst));
- return new Instruction.Literal.Absolute(name, getSignedField(WIDTH_WORD-3-WIDTH_PUMP_ADDR, 0, instr));
- }
-
- case 3: {
- Destination name = getDestByAddr(getField(WIDTH_WORD-3, WIDTH_WORD-3-WIDTH_PUMP_ADDR+1, inst));
- return new Instruction.Literal.Relative(name, getSignedField(WIDTH_WORD-3-WIDTH_PUMP_ADDR, 0, instr));
- }
-
- }
- return null;
-
+ public Instruction readInstruction(long inst) {
+ Pump name = getBoxByInstAddr(getIntField(OFFSET_PUMP_ADDR+WIDTH_PUMP_ADDR-1, OFFSET_PUMP_ADDR, inst));
+ Destination dest = getDestByAddr (getIntField(OFFSET_DEST+WIDTH_DEST_ADDR-1, OFFSET_DEST, inst));
+ int count = getIntField( OFFSET_COUNT+WIDTH_COUNT-1, OFFSET_COUNT, inst);
+ boolean tokenIn = getBit(OFFSET_TI, inst);
+ boolean dataIn = getBit(OFFSET_DI, inst);
+ boolean latch = getBit(OFFSET_DL, inst);
+ boolean dataOut = getBit(OFFSET_DO, inst);
+ boolean tokenOut = getBit(OFFSET_TO, inst);
+ boolean requeue = getBit(OFFSET_RQ, inst);
+ boolean ignoreUntilLast = getBit(OFFSET_IG, inst);
+ boolean dataOutDest = dataOut && tokenOut;
+ boolean isLiteral = getIntField(OFFSET_MASK_LITERAL+WIDTH_MASK_LITERAL-1, OFFSET_MASK_LITERAL, inst)==MASK_LITERAL;
+ if (isLiteral)
+ return new Instruction.LocalLiteral(name, getIntField(OFFSET_LITERAL+WIDTH_LITERAL-1, OFFSET_LITERAL, inst), count);
+ if (latch & !dataIn && !tokenIn && !dataOut && !tokenOut) return new Instruction.Clog(name);
+ if (latch & !dataIn && tokenIn) return new Instruction.UnClog(name);
+ if (latch & !dataIn) return new Instruction.Kill(name, count);
+ return new Instruction.Executable(name, dest, count, tokenIn, dataIn, latch, dataOutDest,
+ dataOut, tokenOut, requeue, ignoreUntilLast);