aboutsummaryrefslogtreecommitdiff
path: root/src/pwm.vhd
diff options
context:
space:
mode:
Diffstat (limited to 'src/pwm.vhd')
-rw-r--r--src/pwm.vhd8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/pwm.vhd b/src/pwm.vhd
index b23a170..9274bb9 100644
--- a/src/pwm.vhd
+++ b/src/pwm.vhd
@@ -11,7 +11,11 @@ entity pwm is
end entity;
architecture rtl of pwm is
+ signal cnt, ncnt : unsigned(3 downto 0);
begin
-
-end architecture rtl;
+ cnt <= "0000" when rst_n = '0' else ncnt when rising_edge(clk);
+ ncnt <= to_unsigned(0,cnt'length) when cnt = 14 else
+ cnt + 1;
+pwm_o <= '1' when cnt < unsigned(ctrl_i) else '0';
+end architecture rtl;