IEEE.std_logic_1164.
IEEE.STD_LOGIC_TEXTIO.
STD.TEXTIO.
file RESULTS: TEXT
open WRITE_MODE
is "results.txt";
component Peak_Detect
port (
LOG_L: in STD_LOGIC_VECTOR (3 downto 0);
LOG_R: in STD_LOGIC_VECTOR (3 downto 0);
FLAG: in STD_LOGIC;
MAX_L: out STD_LOGIC_VECTOR (3 downto 0);
MAX_R: out STD_LOGIC_VECTOR (3 downto 0);
PEAK_L: out STD_LOGIC_VECTOR (3 downto 0);
PEAK_R: out STD_LOGIC_VECTOR (3 downto 0)
);
end component;
shared variable count: INTEGER
range 0
to 256;
shared variable end_sim: BOOLEAN := false;
signal FLAG: STD_LOGIC;
signal LOG_L: STD_LOGIC_VECTOR (3
downto 0);
signal LOG_R: STD_LOGIC_VECTOR (3
downto 0);
signal MAX_L: STD_LOGIC_VECTOR (3
downto 0);
signal MAX_R: STD_LOGIC_VECTOR (3
downto 0);
signal PEAK_L: STD_LOGIC_VECTOR (3
downto 0);
signal PEAK_R: STD_LOGIC_VECTOR (3
downto 0);
procedure WRITE_RESULTS (
FLAG: STD_LOGIC;
LOG_L: STD_LOGIC_VECTOR;
LOG_R: STD_LOGIC_VECTOR;
MAX_L: STD_LOGIC_VECTOR;
MAX_R: STD_LOGIC_VECTOR;
PEAK_L: STD_LOGIC_VECTOR;
PEAK_R: STD_LOGIC_VECTOR
)
is
variable V_OUT: LINE;
begin
write(V_OUT, now, right, 100, ns);
write(V_OUT, FLAG, right, 2);
write(V_OUT, LOG_L, right, 16);
write(V_OUT, LOG_R, right, 16);
write(V_OUT, MAX_L, right, 16);
write(V_OUT, MAX_R, right, 16);
write(V_OUT, PEAK_L, right, 16);
write(V_OUT, PEAK_R, right, 16);
writeline(RESULTS,V_OUT);
end WRITE_RESULTS;
UUT: Peak_Detect
port map (
FLAG => FLAG,
LOG_L => LOG_L,
LOG_R => LOG_R,
MAX_L => MAX_L,
MAX_R => MAX_R,
PEAK_L => PEAK_L,
PEAK_R => PEAK_R
);
CLK_IN:
process
begin
if end_sim = false
then
FLAG <= '1';
wait for 22676 ns;
FLAG <='0';
wait for 22676 ns;
else
wait;
end if;
end process;
STIMULUS:
process
begin
for count
in 1
to 50
loop
case count
is
when 5 =>
LOG_L <= "1111";
LOG_R <= "0001";
when others =>
LOG_L <= "0001";
LOG_R <= "0001";
end case;
wait for 45352 ns;
LOG_L <= "0010";
LOG_R <= "0011";
wait for 45352 ns;
LOG_L <= "0011";
LOG_R <= "0011";
wait for 45352 ns;
LOG_L <= "0100";
LOG_R <= "0100";
wait for 45352 ns;
LOG_L <= "0101";
LOG_R <= "0110";
wait for 45352 ns;
LOG_L <= "0110";
LOG_R <= "0110";
wait for 45352 ns;
LOG_L <= "0111";
LOG_R <= "0111";
wait for 45352 ns;
case count
is
when 2 =>
LOG_L <= "1100";
LOG_R <= "1100";
when 3 =>
LOG_L <= "1110";
LOG_R <= "1100";
when 7 =>
LOG_L <= "1000";
LOG_R <= "1111";
when 47 =>
LOG_L <= "1000";
LOG_R <= "1100";
when others =>
LOG_L <= "1000";
LOG_R <= "1000";
end case;
wait for 45352 ns;
LOG_L <= "0111";
LOG_R <= "0111";
wait for 45352 ns;
LOG_L <= "0101";
LOG_R <= "0110";
wait for 45352 ns;
LOG_L <= "0100";
LOG_R <= "0101";
wait for 45352 ns;
LOG_L <= "0100";
LOG_R <= "0100";
wait for 45352 ns;
LOG_L <= "0011";
LOG_R <= "0011";
wait for 45352 ns;
LOG_L <= "0010";
LOG_R <= "0010";
wait for 45352 ns;
LOG_L <= "0001";
LOG_R <= "0001";
wait for 45352 ns;
case count
is
when 4 =>
LOG_L <= "0001";
LOG_R <= "1001";
when others =>
LOG_L <= "0001";
LOG_R <= "0001";
end case;
wait for 45352 ns;
end loop;
end_sim :=true;
wait;
end process;
WRITE_TO_FILE: WRITE_RESULTS(FLAG,LOG_L,LOG_R,MAX_L,MAX_R,PEAK_L,PEAK_R);