diff --git a/rtl/descramble.v b/rtl/descramble.v index e39d6fa..dd07d08 100644 --- a/rtl/descramble.v +++ b/rtl/descramble.v @@ -38,21 +38,19 @@ module descramble ( * We use a LFSR for the unlock counter in order to relax the timing * requirements. Although we could use a 16-bit register, we use * a 17-bit one to reduce the number of taps we need. Values were - * generated with the following python script: + * generated with: * - * lfsr = 0x1ffff - * for _ in range(2**17 - cycles - 1): - * lfsr = ((lfsr << 1) & 0x1ffff) | (((lfsr >> 16) & 1) ^ ((lfsr >> 13) & 1)) + * $ scripts/lfsr.py 0x12000 90460 45125 625 * - * The amount of time without recieving consecutive idles before we + * The amount of time without receiving consecutive idles before we * unlock. This must be greater than 361us (7.2.3.3(f)), which is * 45125 cycles at 125MHz. */ - localparam UNLOCK_VALUE = 17'h29fc; + localparam UNLOCK_VALUE = 17'h05b08; /* One 9000-byte jumbo frame plus an extra preamble */ - localparam JUMBO_UNLOCK_VALUE = 17'h12d84; + localparam JUMBO_UNLOCK_VALUE = 17'h053f9; /* One minimum-length packet plus some extra (5us or 625 cycles) */ - localparam TEST_UNLOCK_VALUE = 17'h11077; + localparam TEST_UNLOCK_VALUE = 17'h020ef; reg [16:0] unlock_counter, unlock_counter_next; always @(*) begin diff --git a/rtl/led_blinker.v b/rtl/led_blinker.v index 59e07e5..0314386 100644 --- a/rtl/led_blinker.v +++ b/rtl/led_blinker.v @@ -21,9 +21,14 @@ module led_blinker ( parameter LEDS = 2; + /* + * $ scripts/lfsr.py 0x140000 0x1fffff 16 + * + * 16.78 ms + */ localparam TIMER_RESET = 21'h1ffffe; - /* 16 cycles before the end */ - localparam TEST_TIMER_RESET = 21'h0ccccf; + /* 16 cycles */ + localparam TEST_TIMER_RESET = 21'h13333f; reg active, active_next; reg [LEDS - 1:0] out_next, triggered, triggered_next; @@ -50,7 +55,7 @@ module led_blinker ( active_next = 1; out_next = triggered; end - lfsr_next = test_mode ? 21'hCCCCF : 21'h1FFFFE; + lfsr_next = test_mode ? TEST_TIMER_RESET : TIMER_RESET; end end diff --git a/rtl/phy_core.v b/rtl/phy_core.v index 25a8c5c..b1feed3 100644 --- a/rtl/phy_core.v +++ b/rtl/phy_core.v @@ -88,14 +88,13 @@ module phy_core ( ); /* - * LFSR counter; see descramble.v for details on how these values were - * generated. + * $ scripts/lfsr.py 0x12000 41250 16 * - * 50000 cycles or 400 us at 125MHz + * 41250 cycles or 330 us at 125MHz */ - localparam STABILIZE_VALUE = 17'h1ac86; + localparam STABILIZE_VALUE = 17'h1590c; /* 16 cycles; there's no instability while testing */ - localparam TEST_STABILIZE_VALUE = 17'h11c71; + localparam TEST_STABILIZE_VALUE = 17'h038e3; reg link_status_next; initial link_status = 0; diff --git a/rtl/uart_rx.v b/rtl/uart_rx.v index 5a0cd2a..a6be59d 100644 --- a/rtl/uart_rx.v +++ b/rtl/uart_rx.v @@ -25,10 +25,14 @@ module uart_rx ( output reg frame_error ); - /* 1085 cycles, for 115200 baud with a 125 MHz clock */ + /* + * $ scripts/lfsr.py 0x500 1085 543 31 16 + * + * 115200 baud with a 125 MHz clock + */ parameter SLOW_FULL = 11'h78c; parameter SLOW_HALF = 11'h202; - /* 31 cycles, for 4M baud with a 125 MHz clock */ + /* 4M baud with a 125 MHz clock */ parameter FAST_FULL = 11'h68e; parameter FAST_HALF = 11'h34c; diff --git a/rtl/uart_tx.v b/rtl/uart_tx.v index 57f7aa9..7fbac9c 100644 --- a/rtl/uart_tx.v +++ b/rtl/uart_tx.v @@ -20,9 +20,13 @@ module uart_tx ( input high_speed ); - /* 1085 cycles, for 115200 baud with a 125 MHz clock */ + /* + * $ scripts/lfsr.py 0x500 1085 31 + * + * 115200 baud with a 125 MHz clock + */ parameter SLOW_VALUE = 11'h78c; - /* 31 cycles, for 4M baud with a 125 MHz clock */ + /* 4M baud with a 125 MHz clock */ parameter FAST_VALUE = 11'h68e; reg ready_next;