anchor.diff:        tmp[31] = datainbit;
         shifter <= tmp;
         if (count == 31) 
  -	 address <= tmp;
  -      if ((count == 63) && (address[31:1] == id[31:1]) && (address[0] == 1))
  -	 data <= tmp;
  -      if ((count[5] == 1) && (address[31:1] == id[31:1]) && (address[0] == 0))
  -	 dataoutwire <= data[count & 31];
  +	 begin
  +	    iswrite <= tmp[0] == 1;
  +            addressmatch <= (id[31:1] == tmp[31:1]);
  +         end
  +      if ((count == 63) && addressmatch && iswrite)
  +	 data <= truncate(tmp);
  +      if ((count[5] == 1) && addressmatch && (!iswrite))
  +          begin
  +	     if (valueof(asize) == 32)
  +		dataoutwire <= data[count & 31];
  +	     else
  +		begin
  +		   if ((count & 31) < fromInteger(valueof(asize)))
  +                      dataoutwire <= data[count & 31];
  +		end
  +	  end
         else
   	 dataoutwire <= datainbit;
      endrule
   
  -   interface SpiTapIn in;
  +   interface SpiTap tap;
      
  -      method Action frame(bit i );
  -	 frameinbit <= i ;
  -      endmethod
  +      interface SpiTapIn in;
  +   
  +	 method Action frame(bit i );
  +	    frameinbit <= i ;
  +	 endmethod
  +   
  +	 method Action data( bit i );
  +	    datainbit <= i;
  +	 endmethod
   
  -      method Action data( bit i );
  -	 datainbit <= i;
  -      endmethod
  +      endinterface
  +   
  +      interface SpiTapOut out;
  +      
  +	 method bit frame();
  +	    return frameinbit;
  +	 endmethod
  +      
  +	 method bit data();
  +	    return dataoutwire;
  +	 endmethod
  +   
  +      endinterface
  +   
  +   endinterface
   
  -   endinterface
  -   
  -   interface SpiTapOut out;
  -   
  -      method bit frame();
  -	 return frameinbit;
  +   interface Reg r;
  +
  +      method Action _write(a v);
  +	 data <= pack(v);
         endmethod
      
  -      method bit data();
  -	 return dataoutwire;
  +      method a _read();
  +	 return(unpack(data));
         endmethod
   
      endinterface
  
positive.code:    endmodule
  endinstance
  
  (* synthesize *)
  module mkSpiTap#(Bit#(32) id)(SpiTap);
     Reg#(bit) frameinbit <- mkReg(0);
     Reg#(bit) datainbit <- mkReg(0);
     Wire#(bit) dataoutwire <- mkDWire(0);
     
     Reg#(Bit#(6)) count <- mkReg(0);
     Reg#(Bit#(32)) shifter <- mkReg(0);
     Reg#(Bit#(32)) address <- mkReg(0);
     Reg#(Bit#(32)) data <- mkReg(0);
     
     rule handleFrame;
        if (frameinbit == 0)
  	 count <= 0;
        else
  	 count <= count + 1;
     endrule
  
negative.code:    interface SpiTapOut out;
  endinterface
  
  interface SpiReg#(type a);
     interface SpiTap tap;
     interface Reg#(a) r;
  endinterface
  
  instance Connectable#(SpiTapOut, SpiTapIn);
     module mkConnection#(SpiTapOut out, SpiTapIn in)(Empty);
        rule move_data;
  