anchor.diff:         selectdelay <= selected.read();
      endrule
   
  +   rule capturer if(bscan.sel() == 1 && bscan.capture() == 1);
  +       shiftReg <= tojtag.read();
  +   endrule
      rule sendwrite if(bscan.sel() == 1 && bscan.update() == 1);
          startWrite.send();
      endrule
  -   rule readr;
  -       readData <= startWrite.pulse();
  +
  +   rule shiftrule if (bscan.sel() == 1 && bscan.shift() == 1);
  +       shiftReg <= { bscan.tdi(), shiftReg[dsz-1:1] };
  +       widthReg <= widthReg + 1;
      endrule
  -
  -   rule tdo;
  -      bscan.tdo(shiftReg[0]);
  -   endrule
  -   rule shiftextrarule;
  -      shiftextra <= bscan.shift() == 1;
  -   endrule
  -
  -   rule shiftrule if (bscan.sel() == 1 && (bscan.capture() == 1 || bscan.shift() == 1 || shiftextra));
  -       let data = { bscan.tdi(), shiftReg[dsz-1:1] };
  -       if (bscan.capture() == 1)
  -           data = tojtag.read();
  -       shiftReg <= data;
  +   rule clearwidth if (bscan.sel() == 0);
  +       widthReg <= 0;
      endrule
   
      rule clearRule if (selected.read() && !selectdelay);
  -       addrReg <= fromInteger(-1);  // first time USER1 selected, reset address
  +       addrReg <= fromInteger(0);  // first time USER1 selected, reset address
  +       readData <= True;
      endrule
      rule updateRule if (startWrite.pulse());
          addrReg <= addrReg + 1;
  +       readData <= True;
      endrule
  +   rule readClear if (readData);
  +       readData <= False;
  +   endrule
  +
  +   SyncBitIfc#(Bit#(8)) widthSync <- mkSyncBits(0, tck, rst, defaultClock, defaultReset);
  +   rule syncw;
  +       widthSync.send(widthReg);
  +   endrule
  +   method atype getAddr;
  +       return unpack(addrReg);
  +   endmethod
  +   method Bit#(1) getSelected();
  +       return pack(selected.read());
  +   endmethod
  +   method Bit#(8) getWidth();
  +       return widthSync.read();
  +   endmethod
   
      interface BRAMClient bramClient;
         interface Get request;
  
positive.code: // Example usage: http://ohm.bu.edu/~dean/G-2TrackerWORKING/uart_test.vhd
  
  interface BscanBram#(type atype, type dtype);
     interface Clock jtagClock;
     interface Reset jtagReset;
     interface BRAMClient#(atype, dtype) bramClient;
  
negative.code:        tojtag.send(fromBram);
     endrule
  
     rule tdo;
        bscan.tdo(shiftReg[0]);
     endrule
  
     rule updater;
         selected.send(bscan.sel() == 1);
     endrule
  