how do you test circuits with output signals which feedback into the input circuit?
Below is an example of a test bench i wrote, the current_iteration
and current_address
should feedback into the inputs of previous_iteration
and previous_address
. However in the simulation it shows that the inputs are basically uninitialized shown by U
.
How to solve this problem, would creating another entity which transfers the output signals into the inputs work?
library IEEE;
library work;
use IEEE.STD_LOGIC_1164.ALL;
entity addr_iter_tb is
end addr_iter_tb;
architecture Behavioral of addr_iter_tb is
--Clocking signals
signal clk_tb : std_logic:='0';
constant time_period : time:= 1 ns;
--Stimulus signals
signal reset: std_logic:='1'; --Active low reset
signal enable: std_logic:='1'; --By default enabled
signal previous_address: std_logic_vector(2 downto 0);
signal max_iteration: std_logic_vector(4 downto 0);
signal previous_iteration: std_logic_vector(4 downto 0);
signal cycle_iteration_out: std_logic;
signal bm_completed: std_logic;
signal read_address: std_logic_vector(2 downto 0);
signal current_address: std_logic_vector(2 downto 0);
signal current_iteration: std_logic_vector(4 downto 0);
begin
addr_iter_instance : entity work.addr_iter port map (
clk=>clk_tb, reset=>reset, enable=>enable, previous_address=>current_address,
max_iteration=>max_iteration, previous_iteration=>current_iteration,
cycle_iteration_out=>cycle_iteration_out, bm_completed=>bm_completed,
read_address=>read_address, current_address=>current_address,
current_iteration=>current_iteration
);
clocking_process : process begin
wait for time_period;
clk_tb <= not clk_tb;
end process;
stimulus_process : process begin
wait for 5 ns;
reset <= '0';
wait for 1 ns;
reset <= '1';
enable <= '1';
max_iteration <= "00010";
wait;
end process;
end Behavioral;