jesd204: rx: Use standalone counter for lane latency monitor

Use a single standalone counter that counts the number of beats since the
release of the SYNC~ signal, rather than re-using the LMFC counter plus a
dedicated multi-frame counter.

This is slightly simpler in terms of logic and also easier for software to
interpret the data.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
main
Lars-Peter Clausen 2017-06-20 13:01:06 +02:00
parent 9e50f5afa8
commit 71cc052825
3 changed files with 7 additions and 24 deletions

View File

@ -51,44 +51,33 @@ module jesd204_lane_latency_monitor #(
input [NUM_LANES-1:0] lane_ready,
input [NUM_LANES*2-1:0] lane_frame_align,
input lmfc_edge,
input [7:0] lmfc_counter,
output [14*NUM_LANES-1:0] lane_latency,
output [NUM_LANES-1:0] lane_latency_ready
);
reg [2:0] mframe_counter;
reg [11:0] beat_counter;
reg [11:0] lane_latency_mem[0:NUM_LANES-1];
reg [NUM_LANES-1:0] lane_captured = 'h00;
always @(posedge clk) begin
if (reset == 1'b1) begin
mframe_counter <= 'h0;
end else if (lmfc_edge == 1'b1 && mframe_counter != 'h7) begin
mframe_counter <= mframe_counter + 1'b1;
beat_counter <= 'h0;
end else if (beat_counter != 'hfff) begin
beat_counter <= beat_counter + 1'b1;
end
end
generate
genvar i;
reg [7:0] lmfc_counter_d1;
reg [7:0] lmfc_counter_d2;
always @(posedge clk) begin
lmfc_counter_d1 <= lmfc_counter;
lmfc_counter_d2 <= lmfc_counter_d1;
end
for (i = 0; i < NUM_LANES; i = i + 1) begin
always @(posedge clk) begin
if (reset == 1'b1) begin
lane_latency_mem[i] <= 'h00;
lane_captured[i] <= 1'b0;
end else if (lane_ready[i] == 1'b1 && lane_captured[i] == 1'b0) begin
lane_latency_mem[i] <= {mframe_counter,lmfc_counter_d2};
lane_latency_mem[i] <= beat_counter;
lane_captured[i] <= 1'b1;
end
end

View File

@ -336,9 +336,6 @@ jesd204_lane_latency_monitor #(
.clk(clk),
.reset(latency_monitor_reset),
.lmfc_edge(lmfc_edge),
.lmfc_counter(lmfc_counter),
.lane_ready(ifs_ready_mux),
.lane_frame_align(frame_align),
.lane_latency_ready(status_lane_ifs_ready),

View File

@ -291,14 +291,11 @@ module loopback_tb;
reg [NUM_LANES-1:0] lane_latency_match;
generate for (i = 0; i < NUM_LANES; i = i + 1) begin
localparam LANE_OFFSET = BASE_LATENCY + LANE_DELAY + i;
localparam LANE_OFFSET_MFRAMES = LANE_OFFSET / BEATS_PER_MULTIFRAME + 1;
localparam LANE_OFFSET_BEATS = LANE_OFFSET % BEATS_PER_MULTIFRAME;
localparam LANE_OFFSET = BASE_LATENCY + LANE_DELAY + BEATS_PER_MULTIFRAME + i;
always @(posedge clk) begin
if (rx_status_lane_ifs_ready[i] == 1'b1 &&
rx_status_lane_latency[i*14+13:i*14+10] == LANE_OFFSET_MFRAMES &&
rx_status_lane_latency[i*14+9:i*14+2] == LANE_OFFSET_BEATS) begin
rx_status_lane_latency[i*14+13:i*14+2] == LANE_OFFSET) begin
lane_latency_match[i] <= 1'b1;
end else begin
lane_latency_match[i] <= 1'b0;