anchor.diff:          return rdy[idx] ? Valid (idx) : Invalid;
       endfunction
   
  -`ifdef SECURITY
  -    // speculation control: always turn off speculation in M mode; otherwise
  -    // controlled by mspec CSR
  -    Bool machineMode = csrf.decodeInfo.prv == prvM;
  -    Bool specNone = machineMode || csrf.rd(CSRmspec) == zeroExtend(mSpecNone);
  -    Bool specNonMem = !machineMode && csrf.rd(CSRmspec) == zeroExtend(mSpecNonMem);
  -
  -    //rule checkSpecNone(specNone);
  -    //    $fdisplay(stderr, "RENAME SPECULATION STOPS!!");
  -    //endrule
  -
  -`ifdef PERF_COUNT
  -    rule incSpecNoneCycles(inIfc.doStats && specNone);
  -        specNoneCycles.incr(1);
  -    endrule
  -    rule incSpecNonMemCycles(inIfc.doStats && specNonMem);
  -        specNonMemCycles.incr(1);
  -    endrule
  -`endif
  -`endif
  -
       // rename correct path inst
       rule doRenaming(
           !inIfc.pendingMMIOPRq // stall when MMIO pRq is pending
           && epochManager.checkEpoch[0].check(fetchStage.pipelines[0].first.main_epoch) // correct path
           && !isValid(firstTrap) // not trap
  +        && !firstReplay // not system inst
   `ifdef SECURITY
           // stall for ROB empty if we don't allow speculation at all
           && (!specNone || rob.isEmpty)
  +        // don't process mem inst if we don't allow speculation for mem inst only
  +        && !(specNonMem && firstMem)
   `endif
       );
  -        // we stop superscalar rename after
  -        // 1. epoch incremented (system inst)
  -        //    - This makes epochManager up-to-date when checking wrong path inst
  -        // 2. an instruction cannot be processed when
  -        //    (a) It has trap
  -        //    (b) It is wrong path
  -        //    (c) It is system inst, but not the first inst (we delay this inst to next cycle)
  -        //        because system inst need to wait all previous inst commit from ROB
  -        //    (d) It does not have enough resource
  +        // we stop superscalar rename when an instruction cannot be processed:
  +        // (a) It has trap
  +        // (b) It is wrong path
  +        // (c) It is system inst (we handle system inst in a separate rule)
  +        // (d) It does not have enough resource
           Bool stop = False;
           // We automatically stop after an inst cannot be deq from fetch stage
           // because canDeq signal for sup-fifo is consecutive
  +
  +        // Note that epoch will not change in this rule
   
           // track limited resource usage
           Vector#(AluExeNum, Bool) aluExeUsed = replicate(False);
  
positive.code:                 // Figure out if there is new speculation and if there is
                  // speculative renaming happening.
                  Bool new_speculation = False;
                  Bool speculative_renaming = False;
                  if (needReplay) begin
                      // since we are incrementing the epoch in epochManager
                      // without redirecting, we will not need to get a
                      // spec tag because no speculation will be done.
                      new_speculation = False;
                  end else if (dInst.execFunc matches tagged Br .br) begin
                      // This instruction can cause a redirection due to branch
                      // misprediction. Lets claim a checkpoint for this instruction.
                      // If this instruction is a JAL or JRAL instruction, then the
  
negative.code:                 if(isValid(getTrap(x))) begin
                      stop = True;
                  end
                  // for system inst, process in next cycle (in a different rule)
                  if(doReplay(dInst.iType)) begin
                      stop = True;
                  end
  `ifdef SECURITY
  