64 lines
1.4 KiB
VHDL
64 lines
1.4 KiB
VHDL
|
library ieee;
|
||
|
use ieee.std_logic_1164.all;
|
||
|
|
||
|
entity fsm_tb is
|
||
|
end entity;
|
||
|
|
||
|
architecture fsm_tb_arch of fsm_tb is
|
||
|
|
||
|
-- Déclarations
|
||
|
signal clk_tb : std_logic;
|
||
|
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;
|
||
|
|
||
|
component fsm
|
||
|
generic(sim : std_logic := '0');
|
||
|
port (
|
||
|
clk : in std_logic;
|
||
|
rst : in std_logic;
|
||
|
defaut : in std_logic;
|
||
|
rouge : out std_logic;
|
||
|
orange : out std_logic;
|
||
|
vert : out std_logic);
|
||
|
end component;
|
||
|
|
||
|
constant clk_period: time := 1 ms; -- inverse de 1kHz
|
||
|
|
||
|
begin
|
||
|
|
||
|
fsm_1: entity work.fsm
|
||
|
port map (
|
||
|
clk => clk_tb,
|
||
|
rst => rst_tb,
|
||
|
defaut => defaut_tb,
|
||
|
rouge => rouge_tb,
|
||
|
orange => orange_tb,
|
||
|
vert => vert_tb);
|
||
|
|
||
|
STIM: process
|
||
|
begin
|
||
|
-- Génération d'une horloge de 1kHz
|
||
|
clk_tb <= not clk_tb;
|
||
|
wait for clk_period/2;
|
||
|
-- 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;
|
||
|
wait;
|
||
|
end process;
|
||
|
|
||
|
end architecture;
|