2021-11-07 13:40:01 +01:00
|
|
|
library ieee;
|
|
|
|
use ieee.std_logic_1164.all;
|
|
|
|
|
|
|
|
entity fsm_tb is
|
|
|
|
end entity;
|
|
|
|
|
|
|
|
architecture fsm_tb_arch of fsm_tb is
|
|
|
|
|
|
|
|
-- Déclarations
|
2021-11-08 11:19:13 +01:00
|
|
|
signal run : std_logic := '1';
|
|
|
|
|
|
|
|
signal clk_tb : std_logic := '1';
|
|
|
|
signal rst_tb : std_logic;
|
|
|
|
signal defaut_tb : std_logic;
|
|
|
|
signal rouge_tb : std_logic;
|
|
|
|
signal orange_tb : std_logic;
|
|
|
|
signal vert_tb : std_logic;
|
2021-11-07 13:40:01 +01:00
|
|
|
|
|
|
|
constant clk_period: time := 1 ms; -- inverse de 1kHz
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
2021-11-08 13:42:18 +01:00
|
|
|
fsm_tb: entity work.fsm
|
2021-11-08 11:19:13 +01:00
|
|
|
generic map (
|
|
|
|
sim => '1')
|
2021-11-07 13:40:01 +01:00
|
|
|
port map (
|
|
|
|
clk => clk_tb,
|
|
|
|
rst => rst_tb,
|
|
|
|
defaut => defaut_tb,
|
|
|
|
rouge => rouge_tb,
|
|
|
|
orange => orange_tb,
|
|
|
|
vert => vert_tb);
|
|
|
|
|
2021-11-08 11:19:13 +01:00
|
|
|
-- Génération d'une horloge de 1kHz
|
|
|
|
clk_tb <= not clk_tb after clk_period/2 when run = '1' else '0';
|
|
|
|
|
|
|
|
simulation: process
|
2021-11-07 13:40:01 +01:00
|
|
|
begin
|
|
|
|
-- Initialisation de rst à 1 et de defaut à 0
|
|
|
|
rst_tb <= '1';
|
|
|
|
defaut_tb <= '0';
|
|
|
|
-- Passer rst à 0 après 4 ms
|
|
|
|
wait for 4 ms;
|
|
|
|
rst_tb <= '0';
|
|
|
|
-- Passer defaut à 1 après 8 secondes
|
|
|
|
wait for 8000 ms;
|
|
|
|
defaut_tb <= '1';
|
|
|
|
-- Passer defaut à 0 après 1 seconde
|
|
|
|
wait for 1000 ms;
|
|
|
|
defaut_tb <= '0';
|
|
|
|
-- Terminer la simulation après 1 seconde
|
|
|
|
wait for 1000 ms;
|
2021-11-08 11:19:13 +01:00
|
|
|
run <= '1';
|
2021-11-07 13:40:01 +01:00
|
|
|
wait;
|
|
|
|
end process;
|
|
|
|
|
|
|
|
end architecture;
|