// ********************************************************************
// This modules helps filter the Touch coordinates.  When the Bus
// Control asserts Done and all 4 bytes of the touch coordinates are
// ready it comes into this filter and is stored. Only want to change
// output when TouchDone changes.

module TCHFLTR (CLK, FirstByte, SecondByte, ThirdByte, FourthByte, TouchDone, Sending_T, RST, TouchXY) ;

input CLK;
input [7:0] FirstByte ;
input [7:0] SecondByte ;
input [7:0] ThirdByte ;
input [7:0] FourthByte ;
input TouchDone ;
input Sending_T ;  // Send is zero when MuxSel is chosing Motor
input RST ;
output [31:0] TouchXY ;

reg [31:0] TouchXY;

wire [31:0] Data;

assign Data = {FirstByte,SecondByte,ThirdByte,FourthByte};

`define RESET_VALUE 16'b1000_0001_0000_0000  // 256 with a one in the MSB to indicate
                           // that this is Touch data, not Motor data
                           // Motor data has a zero as its MSB

always @(posedge CLK) begin

    if (RST)
    begin
        TouchXY = {`RESET_VALUE, `RESET_VALUE};
    end
 
    else
    begin

      if (TouchDone)
      begin
        // only update touch coordinates when TouchDone is asserted
    TouchXY = Data;
    end
    end
end // end always block
 

endmodule
 
 

Back to Report