anchor.diff:  		     k0jm1 <= k0j;  /* pipeline from previous cycle */
   		     k1jm1 <= k1j;
   		     /* start read of k0j */
  -		     matL.request.put(BRAMRequest{write: False, responseOnWrite: False, address: {1,jj}, datain: 0});
  +		     k0.portA.request.put(BRAMRequest{write: False, responseOnWrite: False, address: zeroExtend(jj), datain: 0});
   		  endaction
   		  action
   		     let ta <- strA.response.get();
   		     let tb <- strB.response.get();
  -		     let tk <- matL.response.get();
  +		     let tk <- k0.portA.response.get();
   		     aData <= ta;
   		     bData <= tb;
   		     k0j <= tk;
   		  endaction
  -		  /* $display("hirschB ii %d jj %d A %d B %d", ii, jj, aData, bData);	*/
  -		  if (aData == bData)
  -		     action
  -			k1j <= k0jm1 + 1;
  -			/*$display("   EQ L[%d][%d] = %d", ii, jj, ta+1); */
  -		     endaction
  -		  else
  -		     action
  -			let tmax = max(k0j,k1jm1);
  -			//$display("     L[%d][%d] = %d = max(%d, %d)", ii, jj, tmax, k0j, k1jm1);
  -			k1j <= tmax;
  -		     endaction
  -		  matL.request.put(BRAMRequest{write: True, responseOnWrite: False, address: {0,jj}, datain: k1j});
  +		  //$display("hirschB ii %d jj %d A %d B %d", ii, jj, aData, bData);
  +		  action
  +		     let tmp = ?;
  +		     if (aData == bData)
  +			tmp = k0jm1 + 1;
  +		     else
  +		        tmp = max(k0j,k1jm1);
  +		     matL.request.put(BRAMRequest{write: True, responseOnWrite: False, address: rStartReg + zeroExtend(jj), datain: tmp});
  +		     k1j <= tmp;
  +		  endaction
  +		     //$display("     L[%d][%d] = %d ", ii, jj, k1j);
   		  
   	       endseq
   	 endseq
  
positive.code: import BRAM::*;
  import MCSAlgorithm::*;
  
  module mkHirschB#(BRAMServer#(Bit#(strIndexWidth), Bit#(8)) strA, BRAMServer#(Bit#(strIndexWidth), Bit#(8)) strB, BRAMServer#(Bit#(lIndexWidth), Bit#(16)) matL)(MCSAlgorithm)
           provisos(Add#(0, 7, strIndexWidth),
  	       Add#(0, 14, lIndexWidth));
  
  
     Reg#(Bit#(7)) aStartReg <- mkReg(0);
     Reg#(Bit#(7)) bStartReg <- mkReg(0);
     Reg#(Bit#(7)) aLenReg <- mkReg(0);
     Reg#(Bit#(7)) bLenReg <- mkReg(0);
     Reg#(Bit#(14)) rLenReg <- mkReg(0);
     Reg#(Bit#(7)) ii <- mkReg(0);
     Reg#(Bit#(7)) jj <- mkReg(0);
     Reg#(Bit#(8)) aData <- mkReg(0);
  
negative.code: 	    /* Loop through string B */
  	    for (jj <= 1; jj <= bLenReg; jj <= jj + 1)
  	       seq
  		  //$display("hirschB jj = %d", jj);
  		  action
  		     /* Read a[i] and b[j] */
  		     strA.request.put(BRAMRequest{write: False, responseOnWrite: False, address: ii-1, datain: 0});
  