anchor.diff:           3: be16 = 16'hFFF0;
            default: be16 = 16'hFFFF;
         endcase
  +      let last = (rg_dwcount <= 4);
  +      let data = (even) ? fAxiRc.first.data[127:0]: fAxiRc.first.data[255:128];
         TLPData#(16) tlp16 = TLPData{sof: False,
  -                                   eof: (rg_dwcount <= 4),
  +                                   eof: last,
                                      hit: 0,
                                      be: be16,
  -                                   data: pack(fAxiRc.first.data[127:0])};
  +                                   data: pack(data)};
         frc.enq(tlp16);
  -      fAxiRc.deq;
  +      if (last || !even)
  +         fAxiRc.deq;
  +      even <= (last) ? True : !even;
      endrule
   
      Reg#(DWCount) cc_dwcount <- mkReg(0, clocked_by pcie_ep.user_clk, reset_by user_reset_n);
  
positive.code:       rq_last_be <= last_be;
        fAxiRq.enq(AxiStRq {data: zeroExtend(pack(rq_desc)), //FIXME:
                         last: frq_tlps.first.eof,
                         keep: 8'hFF,
                         first_be: first_be,
                         last_be: last_be});
        frq_tlps.deq;
  
negative.code:    Bit #(8)      be;
  } AxiStRc deriving (Bits, Eq);
  
  function TLPData#(16) convertCQDescriptorToTLP16(CQDescriptor desc, Bit#(32) data, TLPFirstDWBE first, TLPLastDWBE last);
     TLPMemoryIO3DWHeader header = defaultValue;
     header.format     = tpl_1(convertCQReqTypeToTLPFmtType(desc.reqtype));
     header.pkttype    = tpl_2(convertCQReqTypeToTLPFmtType(desc.reqtype));
     header.tclass     = desc.tclass;
     header.relaxed    = desc.relaxed;
     header.nosnoop    = desc.nosnoop;
     header.length     = (desc.dwcount == 1024) ? 0 : truncate(desc.dwcount);
     header.reqid      = desc.reqid;
     header.tag        = desc.tag;
     header.lastbe     = last;
     header.firstbe    = first;
     header.addr       = truncate(desc.address);
     header.data       = convertDW(data);
     
     Bool is3DW = isReadReqType(desc.reqtype);
     Bool is3Or4DW = isReadReqType(desc.reqtype) || (desc.dwcount == 1);
  
     TLPData#(16) retval = defaultValue;
     retval.sof   = True;
     retval.eof   = is3Or4DW;
     retval.hit   = (1 << pack(desc.barid));
     retval.data  = pack(header);
     retval.be    = (is3DW ? 16'hFFF0 : 16'hFFFF);
     
     return retval;
  endfunction
  
  function TLPData#(16) convertRCDescriptorToTLP16(RCDescriptor desc, Bit#(32) data);
     TLPCompletionHeader header = defaultValue;
     header.tclass    = desc.tclass;
     header.relaxed   = desc.relaxed;
     header.nosnoop   = desc.nosnoop;
     header.cmplid    = desc.complid;
     header.tag       = desc.tag;
     header.reqid     = desc.reqid;
     header.poison    = desc.poisoned;
     header.cstatus   = desc.status;
     header.length    = (desc.dwcount == 1024) ? 0 : truncate(desc.dwcount);
     header.bytecount = (desc.bytecount == 4096) ? 0 : truncate(desc.bytecount);
     header.loweraddr = truncate(desc.loweraddr);
     header.data      = convertDW(data);
  
     Bool is3DW = (desc.dwcount == 0);
     Bool is3Or4DW = (desc.dwcount == 0) || (desc.dwcount == 1);
     TLPData#(16) retval = defaultValue;
     retval.sof   = True;
     retval.eof   = is3Or4DW;
     retval.hit   = 1; // XXX
     retval.data  = pack(header);
     retval.be    = (is3DW ? 16'hFFF0 : 16'hFFFF);
     
     return retval;
  endfunction
  
  `ifdef BOARD_vc709
  typedef 8 PcieLanes;
  typedef 8 NumLeds;
  