projet-fpga/DCC_Bit_1.vhd

88 lines
1.4 KiB
VHDL
Raw Normal View History

library ieee;
use ieee.std_logic_1164.all;
entity dcc_bit_1 is
port(
reset : in std_logic;
clk_100MHz : in std_logic;
clk_1MHz : in std_logic;
go : in std_logic;
fin : out std_logic;
dcc_1 : out std_logic
);
end dcc_bit_1;
architecture behaviour of dcc_bit_1 is
type state is (idle, out_0, out_1);
signal cs, fs : state;
signal inc_cpt : std_logic;
2022-03-21 12:19:58 +01:00
signal cpt : integer range 0 to 116;
signal out_value : std_logic := '0';
begin
dcc_1 <= out_value;
--MAE
process(clk_100MHz, reset)
begin
2022-03-21 12:19:58 +01:00
if reset = '1' then
fs <= idle;
elsif rising_edge(clk_100MHz) then
if cs = idle then
fin <= '0';
out_value <= '0';
if go = '1' then
inc_cpt <= '1';
fs <= out_0;
end if;
elsif cs = out_0 then
out_value <= '0';
2022-03-21 12:19:58 +01:00
if cpt >= 57 then
fs <= out_1;
end if;
elsif cs = out_1 then
out_value <= '1';
2022-03-21 12:19:58 +01:00
if cpt >= 115 then
fs <= idle;
2022-03-21 12:19:58 +01:00
out_value <= '0';
fin <= '1';
inc_cpt <= '0';
end if;
end if;
cs <= fs;
end if;
2022-03-21 12:19:58 +01:00
end process;
--Compteur de Temporisation
process(clk_1MHz, reset)
begin
if reset = '1' then
cpt <= 0;
elsif rising_edge(clk_1MHz) then
if inc_cpt = '1' then
cpt <= cpt + 1;
2022-03-21 12:19:58 +01:00
else
cpt <= 0;
end if;
end if;
end process;
2022-03-21 12:19:58 +01:00
end behaviour;