Okay, etwas ausführlicher
library bla bla bla
use ...
entity pwm_entity is
port (
clk : in std_logic;
Taste1 : in std_logic;
Taste2 : in std_logic;
pwm : out std_logic);
end pwm_entity;
architecture arch of pwm_entity is
constant cMAX_PWM : integefr := 64;
constant cMAX_PWM_RANGE : integefr := 32;
signal cnt : integer range 0 to cMAX_PWM;
signal pwm_range : integer range 0 to cMAX_PWM_RANGE;
signal PWM : std_logic;
begin
process(clk)
begin
if clk = '1' and clk'event then
-- PWM Counter
if cnt < cMAX_PWM then
cnt <= cnt + 1;
else
cnt <= 0;
end if;
-- PWM ausgeben
if cnt < pwm_range then
PWM <= '1';
else
PWM <= '0';
end if;
-- Tasten abfragen / Tastverhältnis verändern
if Taste1 = '1' and pwm_range < cMAX_PWM_RANGE then
pwm_range <= pwm_range + 1;
elsif Taste2 = '1' and pwm_range > 0 then
pwm_range <= pwm_range - 1;
end if;
end if;
end process;
ich übernehme keine Garantie, dass alles richtig ist. Aber so, oder so
ähnlich funktioniert es
Kest