Commit e33f95f9 authored by Alexey Grebenkin's avatar Alexey Grebenkin

small adjustments

parent 9f7bbe7d
...@@ -92,7 +92,7 @@ always @ (posedge clk) ...@@ -92,7 +92,7 @@ always @ (posedge clk)
retry_timer <= rst | ~(state == STATE_AWAITCOMWAKE) ? 32'h0 : retry_timer + 1'b1; retry_timer <= rst | ~(state == STATE_AWAITCOMWAKE) ? 32'h0 : retry_timer + 1'b1;
reg [31:0] wait_timer; reg [31:0] wait_timer;
assign wait_interval_elapsed = wait_timer == 32'd1000; assign wait_interval_elapsed = wait_timer == 32'd4096;
always @ (posedge clk) always @ (posedge clk)
wait_timer <= rst | ~(state == STATE_SENDALIGN) ? 32'h0 : wait_timer + 1'b1; wait_timer <= rst | ~(state == STATE_SENDALIGN) ? 32'h0 : wait_timer + 1'b1;
......
...@@ -37,15 +37,22 @@ assign addr1 = {inisk[1], indata[15:8]}; ...@@ -37,15 +37,22 @@ assign addr1 = {inisk[1], indata[15:8]};
// table[i] [9:0] in case of current disparity +, [19:10] in case of - // table[i] [9:0] in case of current disparity +, [19:10] in case of -
wire [31:0] table0_out; wire [31:0] table0_out;
wire [31:0] table1_out; wire [31:0] table1_out;
reg [19:0] table0_r;
reg [19:0] table1_r;
wire [19:0] table0; wire [19:0] table0;
wire [19:0] table1; wire [19:0] table1;
assign table0 = table0_out[19:0]; assign table0 = table0_out[19:0];
assign table1 = table1_out[19:0]; assign table1 = table1_out[19:0];
always @ (posedge clk)
begin
table0_r <= table0;
table1_r <= table1;
end
// encoded bytes // encoded bytes
wire [9:0] enc0; wire [9:0] enc0;
wire [9:0] enc1; wire [9:0] enc1;
reg [9:0] enc0_r; //reg [9:0] enc0_r;
reg [9:0] enc1_r; //reg [9:0] enc1_r;
// running displarity, 0 = -, 1 = + // running displarity, 0 = -, 1 = +
reg disparity; reg disparity;
...@@ -65,8 +72,8 @@ always @ (posedge clk) ...@@ -65,8 +72,8 @@ always @ (posedge clk)
// select encoded bytes depending on a previous disparity // select encoded bytes depending on a previous disparity
assign enc0 = {10{~disparity}} & table0[19:10] | {10{disparity}} & table0[9:0]; assign enc0 = {10{~disparity}} & table0_r[19:10] | {10{disparity}} & table0_r[9:0];
assign enc1 = {10{~disparity_interm}} & table1[19:10] | {10{disparity_interm}} & table1[9:0]; assign enc1 = {10{~disparity_interm}} & table1_r[19:10] | {10{disparity_interm}} & table1_r[9:0];
// latch output data // latch output data
reg [19:0] outdata_l; reg [19:0] outdata_l;
......
...@@ -76,9 +76,12 @@ assign window = {indata, indata_r}; ...@@ -76,9 +76,12 @@ assign window = {indata, indata_r};
// there is only 1 matched subwindow due to 20-bit comma's non-repetative pattern // there is only 1 matched subwindow due to 20-bit comma's non-repetative pattern
wire [19:0] subwindow [19:0]; wire [19:0] subwindow [19:0];
wire [19:0] comma_match; wire [19:0] comma_match;
wire [19:0] comma_match_p;
reg [19:0] aligned_data; reg [19:0] aligned_data;
reg [19:0] comma_match_prev; reg [19:0] comma_match_prev;
wire comma_detected; wire comma_detected;
wire [19:0] comma_p = 20'b10101010100101111100;
wire [19:0] comma_n = 20'b10101010101010000011;
genvar ii; genvar ii;
generate generate
...@@ -87,7 +90,8 @@ generate ...@@ -87,7 +90,8 @@ generate
assign subwindow[ii] = window[ii + 19:ii]; assign subwindow[ii] = window[ii + 19:ii];
// assign comma_match[ii] = subwindow[ii] == 20'b01010101010011111010 | subwindow[ii] == 20'b01010101011100000101; // assign comma_match[ii] = subwindow[ii] == 20'b01010101010011111010 | subwindow[ii] == 20'b01010101011100000101;
// stream comes inverted // stream comes inverted
assign comma_match[ii] = subwindow[ii] == 20'b10101010100101111100 | subwindow[ii] == 20'b10101010101010000011; assign comma_match_p[ii] = subwindow[ii] == comma_p;
assign comma_match[ii] = comma_match_p[ii] | subwindow[ii] == comma_n;
end end
endgenerate endgenerate
...@@ -97,8 +101,25 @@ assign comma_detected = |comma_match; ...@@ -97,8 +101,25 @@ assign comma_detected = |comma_match;
always @ (posedge clk) always @ (posedge clk)
comma_match_prev <= rst ? 20'h1 : comma_detected ? comma_match : comma_match_prev; comma_match_prev <= rst ? 20'h1 : comma_detected ? comma_match : comma_match_prev;
// shift // shift
/* TODO
wire [38:0] shifted_window; wire [38:0] shifted_window;
assign shifted_window = comma_detected ? {window >> (comma_match - 1)} : {window >> (comma_match_prev - 1)}; assign shifted_window = comma_detected ? {window >> (comma_match - 1)} : {window >> (comma_match_prev - 1)};
*/
// temp shift
wire [19:0] shifted_window;
wire [19:0] ored_subwindow [19:0];
wire [19:0] ored_subwindow_comdet [19:0];
assign ored_subwindow_comdet[0] = {20{comma_match_p[0]}} & comma_p | {20{~comma_match_p[0] & comma_match[0]}} & comma_n;
assign ored_subwindow[0] = {20{comma_match_prev[0]}} & subwindow[0];
generate
for (ii = 1; ii < 20; ii = ii + 1)
begin: or_all_possible_windows
assign ored_subwindow_comdet[ii] = {20{comma_match_p[ii]}} & comma_p | {20{~comma_match_p[ii] & comma_match[ii]}} & comma_n | ored_subwindow_comdet[ii-1];
assign ored_subwindow[ii] = {20{comma_match_prev[ii]}} & subwindow[ii] | ored_subwindow[ii-1];
end
endgenerate
assign shifted_window = comma_detected ? ored_subwindow_comdet[19] : ored_subwindow[19];
always @ (posedge clk) always @ (posedge clk)
// aligned_data <= comma_detected ? {window >> (comma_match - 1)}[19:0] : {window >> (comma_match_prev - 1)}[19:0]; // aligned_data <= comma_detected ? {window >> (comma_match - 1)}[19:0] : {window >> (comma_match_prev - 1)}[19:0];
aligned_data <= shifted_window[19:0]; aligned_data <= shifted_window[19:0];
......
...@@ -197,9 +197,10 @@ gtx_8x10enc gtx_8x10enc( ...@@ -197,9 +197,10 @@ gtx_8x10enc gtx_8x10enc(
wire xclk; wire xclk;
// assuming GTX interface width = 20 bits // assuming GTX interface width = 20 bits
// comma aligner // comma aligner
wire [19:0] rxdata_comma_in; reg [19:0] rxdata_comma_in;
wire [19:0] rxdata_comma_out; wire [19:0] rxdata_comma_out;
assign rxdata_comma_in = {rxdisperr_gtx[1], rxcharisk_gtx[1], rxdata_gtx[15:8], rxdisperr_gtx[0], rxcharisk_gtx[0], rxdata_gtx[7:0]}; always @ (posedge xclk)
rxdata_comma_in <= {rxdisperr_gtx[1], rxcharisk_gtx[1], rxdata_gtx[15:8], rxdisperr_gtx[0], rxcharisk_gtx[0], rxdata_gtx[7:0]};
// aligner status generation // aligner status generation
// if we detected comma & there was 1st realign after non-aligned state -> triggered, we wait until the next comma // if we detected comma & there was 1st realign after non-aligned state -> triggered, we wait until the next comma
......
...@@ -408,6 +408,7 @@ begin ...@@ -408,6 +408,7 @@ begin
$display("[Host] OOB: Started continious align sending"); $display("[Host] OOB: Started continious align sending");
end end
end end
`endif
always @ (posedge clk) always @ (posedge clk)
rxcom_timer <= rst | rxcominit_done & state_wait_cominit | rxcomwake_done & state_wait_comwake | rxcominitdet & state_wait_cominit | rxcomwakedet & state_wait_comwake ? 10'h0 : cominit_req_l & state_idle | rxcominitdet_l & state_wait_cominit | rxcomwakedet_l & state_wait_comwake ? rxcom_timer + CLK_TO_TIMER_CONTRIB : 10'h0; rxcom_timer <= rst | rxcominit_done & state_wait_cominit | rxcomwake_done & state_wait_comwake | rxcominitdet & state_wait_cominit | rxcomwakedet & state_wait_comwake ? 10'h0 : cominit_req_l & state_idle | rxcominitdet_l & state_wait_cominit | rxcomwakedet_l & state_wait_comwake ? rxcom_timer + CLK_TO_TIMER_CONTRIB : 10'h0;
......
...@@ -234,7 +234,7 @@ begin ...@@ -234,7 +234,7 @@ begin
end end
*/ */
initial begin initial begin
#100000; #150000;
$display("[Test] Failed"); $display("[Test] Failed");
$display("============= TIMELIMIT ============="); $display("============= TIMELIMIT =============");
$finish; $finish;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment