anchor.diff:     return rv;
   endmodule
   
  +typedef struct {
  +    Bit#(BurstLenSize) len;
  +    Bool               last;
  +} NextReq deriving (Bits, Eq);
  +
  +function NextReq getNext(Bit#(32) len, Bit#(BurstLenSize) burst);
  +   NextReq v;
  +   v.last = (len <= extend(burst));
  +   v.len = v.last ? truncate(len) : burst;
  +   return v;
  +endfunction
  +
   module mkMemReadEngineBuff#(Integer bufferSizeBytes) (MemReadEngine#(busWidth, userWidth, cmdQDepth, numServers))
      provisos (Div#(busWidth,8,busWidthBytes),
   	     Mul#(busWidthBytes,8,busWidth),
  
positive.code:    Vector#(numServers, FIFOF#(MemDataF#(userWidth))) clientDataFifo <- replicateM(mkSizedBRAMFIFOF(bufferSizeBeats));
     Vector#(numServers, FIFO#(MemengineCmd)) clientRequest <- replicateM(mkFIFO());
     Vector#(numServers, Reg#(Bit#(32)))      clientLen <- replicateM(mkReg(unpack(0)));
     Vector#(numServers, Reg#(Bit#(32))) clientBase <- replicateM(mkReg(unpack(0)));
     
     FIFO#(Tuple4#(Bit#(serverIdxSz),Bool,Bool,Bit#(BurstLenSize)))              serverCheckAvail <- mkSizedFIFO(1);
     FIFO#(Tuple6#(Bit#(serverIdxSz),SGLId,Bit#(32),Bit#(MemTagSize),Bool,Bit#(BurstLenSize))) serverRequest <- mkSizedFIFO(valueOf(cmdQDepth));
  
negative.code:    endrule
           
     for (Integer idx = 0; idx < valueOf(numServers); idx = idx + 1)
        rule rule_startNew if (!clientInFlight[idx]);
  	 let cmd <- toGet(clientRequest[idx]).get();
  	 clientInFlight[idx] <= True;
  	 clientCommand[idx] <= cmd;
           clientLen[idx] <= cmd.len - extend(cmd.burstLen);
           clientBase[idx] <= cmd.base;
           clientNext[idx] <= getNext(cmd.len, cmd.burstLen);
  	 if (verbose) $display("mkMemReadEngineBuff::%d rule_startNew %d %d", counter, idx, clientAvail[idx].read);
        endrule
  
     Reg#(Bit#(TAdd#(1,serverIdxSz))) loadIdx <- mkReg(0);
     rule rule_checkAvail;
        if (clientInFlight[loadIdx]) begin
           let cmd_len = clientNext[loadIdx].len;
           let last_burst = clientNext[loadIdx].last;
  	 let cond0 <- clientAvail[loadIdx].maybeDecrement(unpack(extend(cmd_len>>beatShift)));
  	 serverCheckAvail.enq(tuple4(truncate(loadIdx),cond0,last_burst,cmd_len));
  	 if (verbose) $display("mkMemReadEngineBuff::%d rule_checkAvail avail[%d] %d burstLen %d cond0 %d last_burst %d", counter, loadIdx, clientAvail[loadIdx].read(), cmd_len>>beatShift, cond0, last_burst);
        end
        if(loadIdx+1 >= fromInteger(valueOf(numServers)))
           loadIdx <= 0;
  