diff options
author | Friedrich Beckmann <friedrich.beckmann@tha.de> | 2024-05-10 19:08:32 +0200 |
---|---|---|
committer | Friedrich Beckmann <friedrich.beckmann@hs-augsburg.de> | 2024-05-28 12:22:40 +0200 |
commit | c6ee080fc68079392e9e66961bd11ebf52ab852d (patch) | |
tree | 533032cda8b117fcbe9ae7f252e27f9a7dbb2239 /src/pwm.vhd | |
parent | cb1ff76e82fa1b77016530d61d16b426a9e1d5e3 (diff) |
add top_count solutions
Diffstat (limited to 'src/pwm.vhd')
-rw-r--r-- | src/pwm.vhd | 8 |
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; |