library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity ReductorVelocidad is
generic(
DIVISOR : natural := 2 -- Valor del divisor de frecuencia
);
port(
clk : in std_logic; --Entrada de reloj
pwm_out: out std_logic-- Salida de señal PWM para controlar la velocidad del motor
);
end entity ReductorVelocidad;
architecture Behavioral of ReductorVelocidad is
signal count: natural range 0 to DIVISOR - 1 := 0;
begin
process(clk)
begin
if rising_edge(clk) then
count <= count + 1;
if count = DIVISOR - 1 then
pwm_out <= '1'; --Encender la señal PWM durante un ciclo de reloj
count <= 0;
else
pwm_out <= '0'; --Apagar la señal PWM durante los ciclos restantes del divisor
end if;
end if;
end process;
end architecture Behavioral;