Convert all reg assignments to initial

As it turns out,

	reg foo = 0;

is not the same as

	reg foo; initial foo = 0;

but instead is equivalent to

	reg foo; always @(*) foo = 0;

This is rather silly. Convert all existing (lucky) examples to the
second form.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
This commit is contained in:
Sean Anderson 2022-10-16 17:46:04 -04:00
parent 2832c79ff0
commit 548e5b5b51
6 changed files with 12 additions and 7 deletions

View File

@ -30,7 +30,8 @@ module descramble (
* required in certain situations.
*/
localparam CONSECUTIVE_IDLES = 5'd29;
reg [4:0] idle_counter = CONSECUTIVE_IDLES, idle_counter_next;
reg [4:0] idle_counter, idle_counter_next;
initial idle_counter = CONSECUTIVE_IDLES;
/*
* The amount of time without recieving consecutive idles before we

View File

@ -48,8 +48,9 @@ module mdio (
reg [15:0] data_next;
reg bad, bad_next, saved_err, saved_err_next;
reg [2:0] state = IDLE, state_next;
reg [2:0] state, state_next;
reg [4:0] state_counter, state_counter_next;
initial state = IDLE;
/*
* NB: stb_next and data_next are assigned to stb and data_write every

View File

@ -23,7 +23,8 @@ module mdio_io (
reg mdi_next;
reg [1:0] last_mdc;
/* Two clock delay to allow the level shifter to reverse direction */
reg [2:0] oe = 0;
reg [2:0] oe;
initial oe = 0;
`ifdef SYNTHESIS
SB_IO #(

View File

@ -26,7 +26,6 @@ module mii_io_tx (
reg ce_next, raw_enable;
reg tx_clk_p_next, tx_clk_n, tx_clk_n_next;
reg [2:0] counter, counter_next;
/* I have no idea why we need to use initial... */
initial counter = 4;
always @(*) begin

View File

@ -112,8 +112,10 @@ module pmd_io (
localparam C = 2;
localparam D = 3;
reg [1:0] state = A, state_next;
reg valid = 0, valid_next;
reg [1:0] state, state_next;
initial state = A;
reg valid, valid_next;
initial valid = 0;
reg [1:0] pmd_data_rx_next, pmd_data_rx_valid_next;
reg [3:0] rx_r, rx_f;

View File

@ -12,7 +12,8 @@ module scramble (
);
reg lfsr_next;
reg [10:0] lfsr = 10'h3ff;
reg [10:0] lfsr;
initial lfsr = 10'h3ff;
always @(*) begin
lfsr_next = lfsr[8] ^ lfsr[10];