Update latency tester

* Enable operation with all sources
* Measure strobe length on low-persistence displays
This commit is contained in:
marqs committed 2017-10-28 12:10:54 +03:00
1 parent 4ae3423acb
commit a24d6b0e3a
23 files changed
+1469 -1299

No files matched your search

+61 -26
View File
@@ -17,8 +17,14 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
`define LT_STATE_IDLE 2'h0
`define LT_STATE_LAT_MEAS 2'h1
`define LT_STATE_STB_MEAS 2'h2
`define LT_STATE_FINISHED 2'h3
module lat_tester (
input clk27,
input pclk,
input active,
input armed,
input sensor,
@@ -26,47 +32,76 @@ module lat_tester (
input VSYNC_in,
input [1:0] mode_in,
output reg [2:0] mode_synced,
output reg [15:0] result
output reg [15:0] lat_result,
output reg [11:0] stb_result,
output reg finished
);
reg VSYNC_in_L, VSYNC_in_LL, VSYNC_in_LLL;
reg running;
reg VSYNC_in_L, VSYNC_in_LL, trigger_L, trigger_LL;
reg [8:0] clk27_ctr;
reg [1:0] state;
always @(posedge clk27) begin
always @(posedge pclk) begin
VSYNC_in_L <= VSYNC_in;
VSYNC_in_LL <= VSYNC_in_L;
VSYNC_in_LLL <= VSYNC_in_LL;
end
always @(posedge clk27) begin
if (VSYNC_in_LLL && !VSYNC_in_LL)
always @(posedge pclk) begin
if (VSYNC_in_LL && !VSYNC_in_L)
mode_synced <= mode_in;
end
always @(posedge clk27) begin
if (!active) begin
running <= 0;
end else begin
if ((result==0) && (clk27_ctr==0) && armed && trigger) begin
running <= 1;
end else if (running && ((sensor==0) || (result==16'hffff))) begin
running <= 0;
end
end
trigger_L <= trigger;
trigger_LL <= trigger_L;
end
always @(posedge clk27) begin
if (!active || !armed) begin
result <= 0;
clk27_ctr <= 0;
end else if (running) begin
if (clk27_ctr == 270-1) begin
clk27_ctr <= 0;
result <= result + 1'b1;
end else begin
clk27_ctr <= clk27_ctr + 1'b1;
end
if (!active) begin
state <= `LT_STATE_IDLE;
end else begin
case (state)
default: begin //STATE_IDLE
finished <= 1'b0;
lat_result <= 0;
stb_result <= 0;
clk27_ctr <= 0;
if (armed && trigger_LL)
state <= `LT_STATE_LAT_MEAS;
end
`LT_STATE_LAT_MEAS: begin
if (sensor==0) begin
state <= `LT_STATE_STB_MEAS;
clk27_ctr <= 0;
end else if (lat_result==16'hffff) begin
state <= `LT_STATE_FINISHED;
end else begin
if (clk27_ctr == 270-1) begin
clk27_ctr <= 0;
lat_result <= lat_result + 1'b1;
end else begin
clk27_ctr <= clk27_ctr + 1'b1;
end
end
end
`LT_STATE_STB_MEAS: begin
if (((sensor==1) && (stb_result >= 12'd100)) || (stb_result == 12'hfff)) begin
state <= `LT_STATE_FINISHED;
end else begin
if (clk27_ctr == 270-1) begin
clk27_ctr <= 0;
stb_result <= stb_result + 1'b1;
end else begin
clk27_ctr <= clk27_ctr + 1'b1;
end
end
end
`LT_STATE_FINISHED: begin
finished <= 1'b1;
if (!armed)
state <= `LT_STATE_IDLE;
end
endcase
end
end