-- pwm_generator.vhd -- Eurobot 2004 : APB Team -- Auteur : Fidèle GAFAN et Pierre-André Galmes -- Bloc générant le signal pwm lorsqu'il recoit la valeur -- provenant de convert_pwm. library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all; use work.nono_const.all; use work.pwm_const.all; --ENTITE entity pwm_generator is port ( rst : in std_logic; clk : in std_logic; -- clk 200ns pwm_in : in T_DOUBLE_OCTET; pwm_out : out std_logic ); end entity; --ARCHITECTURE architecture RTL of pwm_generator is signal compt : T_DOUBLE_OCTET; signal reg : T_DOUBLE_OCTET; begin process(rst, clk) begin if (rst = '1') then compt <= x"0000"; reg <= x"0000"; pwm_out <= '0'; elsif (clk'event and clk = '1') then compt <= compt + x"0001"; if (compt < reg) then pwm_out <= '1'; else pwm_out <= '0'; if (compt = PWM_NB_CYCLE_PERIODE) then compt <= x"0000"; reg <= pwm_in; end if; end if; end if; end process; end RTL;