Feco
Newbie level 6
- Joined
- May 13, 2013
- Messages
- 12
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,371
Hello everyone.
I'm new to the FPGA world and a got a little problem.
I wanted to make a simple frequency divider with changeable frequency rate. The first part works good (there are lot of tutorials), but the second...
I have 8 buttons, with them I wanted to change the frequency between 0 and 255 Hz. It seemed, that it is an easy task. I coded it and its working, but not properly. When I use the buttons there is a delay time around 3-4 seconds (or even more). I don't think it should work that way. Is there any possibility to correct that delay?
Here is the code:
Maybe the type conversion takes long time?
If it matter, I use Digilent Nexys3 board with Spartan 6 FPGA.
Thanks.
I'm new to the FPGA world and a got a little problem.
I wanted to make a simple frequency divider with changeable frequency rate. The first part works good (there are lot of tutorials), but the second...
I have 8 buttons, with them I wanted to change the frequency between 0 and 255 Hz. It seemed, that it is an easy task. I coded it and its working, but not properly. When I use the buttons there is a delay time around 3-4 seconds (or even more). I don't think it should work that way. Is there any possibility to correct that delay?
Here is the code:
Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.NUMERIC_STD.ALL;
entity clk_div is
Port ( CLK : in STD_LOGIC;
Freq : in STD_LOGIC_VECTOR(7 downto 0);
CLK2 : out STD_LOGIC);
end clk_div;
architecture Behavioral of clk_div is
signal max : integer := (100000000/(to_integer(signed(Freq))*2))-1;
signal CLK_count : STD_LOGIC_VECTOR (30 downto 0);
signal sCLK2 : STD_LOGIC;
begin
process(CLK, max)
begin
if (rising_edge(CLK)) then
if (CLK_count = max) then
CLK_count <= (others => '0');
sCLK2 <= not(sCLK2);
else
CLK_count <= CLK_count + 1;
end if;
else
null;
end if;
end process;
CLK2 <= sCLK2;
end Behavioral;
Maybe the type conversion takes long time?
If it matter, I use Digilent Nexys3 board with Spartan 6 FPGA.
Thanks.