Files
psi-tp4/tick1s.vhdl
Tiago Batista Cardoso 6e000cdcaa working implementation
2025-12-26 12:20:48 +01:00

66 lines
1.7 KiB
VHDL

library ieee;
use ieee.std_logic_1164.all;
entity tick1s is
port (
rst,
clk : in std_logic;
output : out std_logic
);
end entity tick1s;
architecture V1 of tick1s is
component count is
port(
rst,
clk : in std_logic;
input : in std_logic_vector (31 downto 0);
output : out std_logic_vector (31 downto 0)
);
end component;
component tick1ms is
port (
rst,
clk : in std_logic;
output : out std_logic
);
end component;
signal counter_in : std_logic_vector (31 downto 0) := (others => '0');
signal counter_out : std_logic_vector (31 downto 0);
signal ms_clk : std_logic;
begin
G1: entity work.tick1ms(V1)
port map(
rst => rst,
clk => clk,
output => ms_clk
);
G2: entity work.count(V1)
port map(
rst => rst,
-- on utilise le signal de sortie du tick1ms comme clock pour notre counter.
clk => ms_clk,
in_s => counter_in,
out_s => counter_out
);
process(clk)
begin
if rising_edge(clk) then
if rst = '1' then
output <= '0';
--elsif counter_out = x"000003e8" then (Valeur pour une vraie seconde)
elsif counter_out = x"0000000A" then -- Valeur utilisee pour tester sans simuler un nombre trop consequent de tour d'horloges
output <= '1';
counter_in <= (others => '0');
else
output <= '0';
if ms_clk = '1' then
counter_in <= counter_out;
end if;
end if;
end if;
end process;
end architecture V1;