I am trying to divide my input clock signal by 10 - effectively setting my out HIGH 5 of ten clock pulses and LOW the other 5. However, my counter idea does not work - the clk_ou2 signal doesn't update at all, and I do not know why.
1 | library ieee; |
2 | use ieee.std_logic_1164.all; |
3 | use ieee.numeric_std.all; |
4 | |
5 | entity Taktteiler is |
6 | |
7 | port ( |
8 | clk_in : in std_logic; |
9 | clk_out : out std_logic; |
10 | reset : in std_logic |
11 | );
|
12 | end Taktteiler; |
13 | |
14 | architecture rtl of Taktteiler is |
15 | |
16 | signal counter : unsigned(3 downto 0); |
17 | signal clk_out2 : std_logic := '0'; |
18 | |
19 | begin
|
20 | process(clk_in) |
21 | begin
|
22 | if(rising_edge(clk_in)) then |
23 | counter <= counter + 1; |
24 | if std_logic_vector(counter) = "101" then --reset the counter at 101 |
25 | counter <= (others => '0'); |
26 | clk_out2 <= clk_out2 XOR '1'; --toggle the out2 signal |
27 | end if; |
28 | end if; |
29 | if reset = '1' then --reset on HIGH reset input |
30 | counter <= (others => '0'); |
31 | clk_out2 <= '0'; |
32 | end if; |
33 | end process; |
34 | clk_out <= clk_out2; |
35 | end architecture rtl; |