Reset in Register

This commit is contained in:
Yannick Reiß 2024-08-08 08:04:29 +02:00
parent 8b5b3095a0
commit 59cb94480e
No known key found for this signature in database
GPG Key ID: 5A3AF456F0A0338C
1 changed files with 10 additions and 14 deletions

View File

@ -40,23 +40,19 @@ architecture structure of registers is
begin
-- react only on clock changes
process (clk) -- runs only, when clk changed
begin
if rising_edge(clk) then
-- check if write is enabled
if to_integer(unsigned(write_enable)) = 1 then
-- write data_in to wr_idx
registerbench(to_integer(unsigned(wr_idx))) <= data_in;
end if;
registerbench(0) <= std_logic_vector(to_unsigned(0, wordWidth));
end if;
end process;
-- reset if reset is activated
process (reset)
process (clk, reset) -- runs only, when clk changed
begin
if falling_edge(reset) then
registerbench <= initRegs;
else
if rising_edge(clk) then
-- check if write is enabled
if to_integer(unsigned(write_enable)) = 1 then
-- write data_in to wr_idx
registerbench(to_integer(unsigned(wr_idx))) <= data_in;
end if;
registerbench(0) <= std_logic_vector(to_unsigned(0, wordWidth));
end if;
end if;
end process;