library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
entity count_tst is
end count_tst;
architecture my_test of count_tst is
component counter
port (
clk : in std_logic;
reset : in std_logic;
count : out std_logic_vector(7 downto 0));
end component;
signal clk : std_logic := '0';
signal reset : std_logic := '0';
signal countval : std_logic_vector(7 downto 0);
--
-- convert a std_logic value to a character
--
type stdlogic_to_char_t is array(std_logic) of character;
constant to_char : stdlogic_to_char_t := (
'U' => 'U',
'X' => 'X',
'0' => '0',
'1' => '1',
'Z' => 'Z',
'W' => 'W',
'L' => 'L',
'H' => 'H',
'-' => '-');
--
-- convert a std_logic_vector to a string
--
function to_string(inp : std_logic_vector)
return string
is
alias vec : std_logic_vector(1 to inp'length) is inp;
variable result : string(vec'range);
begin
for i in vec'range loop
result(i) := to_char(vec(i));
end loop;
return result;
end;
begin -- my_test
u1 : counter
port map (
clk => clk,
reset => reset,
count => countval);
testing: process
begin -- process testing
wait for 23 ns;
reset <= '1';
wait for 200 ns;
wait;
end process testing;
clk <= transport not clk after 5 ns;
process (clk)
begin -- process
if clk'event and clk = '1' then -- rising clock edge
assert false report "count = "&to_string(countval) severity note;
end if;
end process;
end my_test;