Altera_Forum
Honored Contributor
8 years agoAdjustable frequency generator
Hi,
I am trying to implement adjustable rectangular wave generator in MAX10. The code below:library ieee;use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity DIVIDER_2 is
port(
clk: in STD_LOGIC;
O : out STD_LOGIC
);
end DIVIDER_2;
architecture DIVIDER_2 of DIVIDER_2 is
signal divider: integer range 0 to 20000:=666; -- USTAWIAMY DZIELNIK
signal counter: integer range 0 to 2000:=0;
signal OI : STD_LOGIC;
begin
O <= OI;
process (clk) is
begin
if rising_edge (clk) then
if (counter < divider) then
counter <= counter + 1;
else
OI <= not OI;
counter <= 0;
divider <= divider + 1;
end if;
end if;
end process;
end DIVIDER_2; It doesn't work. Without incrementation divider each half cycle, works well. Does anyone have any idea what is wrong?