From 67cf4100c6af724bad547723719c5892a84d65ce Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Sun, 16 Oct 2022 17:27:08 -0400 Subject: [PATCH] descrambler: Break up locking logic This (un)locking logic was on the critical path. Break it up into multiple parts to allow achieving our desired clock frequency. Signed-off-by: Sean Anderson --- rtl/descramble.v | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/rtl/descramble.v b/rtl/descramble.v index 620e065..fd1889f 100644 --- a/rtl/descramble.v +++ b/rtl/descramble.v @@ -13,7 +13,8 @@ module descramble ( output reg [1:0] unscrambled, unscrambled_valid ); - reg locked_next; + reg relock, relock_next, locked_next; + initial relock = 0; reg [1:0] ldd, unscrambled_next; reg [10:0] lfsr, lfsr_next; @@ -73,15 +74,20 @@ module descramble ( idle_counter_next = CONSECUTIVE_IDLES; end - locked_next = 1; - unlock_counter_next = unlock_counter; + relock_next = 0; if (!idle_counter_next[4:1]) begin - unlock_counter_next = test_mode ? TEST_UNLOCK_TIME : UNLOCK_TIME; /* * Reset the counter to 2 to ensure we can always * subtract idles without underflowing */ idle_counter_next = 2; + relock_next = 1; + end + + locked_next = 1; + unlock_counter_next = unlock_counter; + if (relock) begin + unlock_counter_next = test_mode ? TEST_UNLOCK_TIME : UNLOCK_TIME; end else if (|unlock_counter) begin unlock_counter_next = unlock_counter - 1; end else begin @@ -94,12 +100,14 @@ module descramble ( if (signal_status) begin lfsr <= lfsr_next; idle_counter <= idle_counter_next; + relock <= relock_next; unlock_counter <= unlock_counter_next; locked <= locked_next; unscrambled_valid <= scrambled_valid; end else begin lfsr <= 0; idle_counter <= CONSECUTIVE_IDLES; + relock <= 0; unlock_counter <= 0; locked <= 0; unscrambled_valid <= 0;