VHDL is different from other languages in that signal assign by <=
does not take effect for read until after a delta delay, thus if you do:
temp2 <= seed;
temp1 <= std_logic_vector((unsigned(temp2)*unsigned(multiply)));
seed <= std_logic_vector(unsigned(temp1(31 downto 0)) + unsigned(add));
then the temp2
not actually updated for read in the expression used to assign temp1
until a delta delay has passed.
Depending on the details about your design, you can consider declaring the intermediate variables as variables:
variable temp1: std_logic_vector(63 downto 0);
variable temp2: std_logic_vector(31 downto 0);
and then assign like:
temp2 := seed;
temp1 := std_logic_vector((unsigned(temp2)*unsigned(multiply)));
seed <= std_logic_vector(unsigned(temp1(31 downto 0)) + unsigned(add));
In this case the intermediate variables temp1
and temp2
will have the result ready for read right after the assign, and the seed
will have the value after a delta delay, assuming that you will not do the next iteration until next cycle.
It will clarify the intention in the code if constants are declared as such, doing:
constant MULTIPLY : std_logic_vector(31 downto 0) := x"41C64E6D";
constant ADD : std_logic_vector(31 downto 0) := x"00003039";
A comment on you calculation, then the VHDL design truncates the result of the multiplication, thus doing:
seed = (seed*1103515245) mod (2**32) + 12345