2 use ieee.std_logic_1164.
all;
3 use ieee.numeric_std.
all;
4 use work.pwm_reg_pack.
ALL;
12 -- signals from top module to registers sub-module
14 duty
: in std_logic_vector(DUTY_CYCLE_W
-1 downto 0);
15 pwm_out
: out std_logic
20 architecture rtl
of pwm
is
22 signal clk_en
: std_logic;
23 signal cnt
: unsigned
(PERIOD_W
-1 downto 0);
24 signal cnt_duty
: unsigned
(DUTY_CYCLE_W
-1 downto 0);
28 cnt_pr
: process(clk
, rst
)
31 cnt
<= (others => '0');
33 elsif (rising_edge
(clk
)) then
39 cnt
<= to_unsigned
(PERIOD
-1, cnt
'length);
48 cnt_duty_pr
: process(clk
, rst
)
51 cnt_duty
<= (others => '0');
53 elsif (rising_edge
(clk
)) then
54 if (clk_en
= '1') then
55 cnt_duty
<= cnt_duty
+ 1;
57 if (cnt_duty
< unsigned
(duty
)) then
63 end process cnt_duty_pr
;