I have two examples of code for two registers writing from one bus. Which example is more suitable?
the first implementation
reg_n : process(r, clk, wrn)
variable t : unsigned(n'range);
begin
if r = '1' then
t := to_unsigned(0, t'length);
elsif rising_edge(clk) then
if wrn = '1' then
t := resize(d, t'length);
end if;
end if;
n <= t;
end process reg_n;
reg_k : process(r, clk, wrk, wrn)
variable t : unsigned(k'range);
begin
if r = '1' then
t := to_unsigned(0, t'length);
elsif rising_edge(clk) then
if wrk = '1' and wrn = '0' then
t := resize(d, t'length);
end if;
end if;
k <= t;
end process reg_k;
and the second implementaion
reg_n : process(r, wrn, wrk)
variable t : unsigned(n'range);
begin
if r = '1' then
t := to_unsigned(0, t'length);
elsif rising_edge(wrn) then
if wrk = '0' then
t := resize(d, t'length);
end if;
end if;
n <= t;
end process reg_n;
reg_k : process(r, wrk, wrn)
variable t : unsigned(k'range);
begin
if r = '1' then
t := to_unsigned(0, t'length);
elsif rising_edge(wrk) then
if wrn = '0' then
t := resize(d, t'length);
end if;
end if;
k <= t;
end process reg_k;