- Joined
- May 10, 2007
- Messages
- 1
- Reaction score
- 0
I'm trying to use both edges of my clock signal to count for a clock divider using VHDL. Behaviorally, the simulation works, but it won't synthesize. I'm using a Xilinx Spartan-3e FPGA. I tried it in Verilog and I'm getting the same results. Is this something that VHDL is not allowing me to do or is it my FPGA? Here's an example:
----------------------------------------------------------------------
count : process (clk)
begin
if ( rising_edge(clk) or falling_edge(clk) )then
if num = 20 then
new_clk <= not new_clk;
num <= 0;
else
num <= num + 1;
end if;
clk_slow <= new_clk;
end if;
end process count;
---------------------------------------------------------------------
this didn't work.. so I tried this:
---------------------------------------------------------------------
count : process (clk)
begin
if rising_edge(clk) then
if num = 0 then
new_clk <= not new_clk;
num <= 0;
else
num <= num + 1;
end if;
elsif falling_edge(clk) then
if num = 0 then
new_clk <= not new_clk;
num <= 0;
else
num <= num + 1;
end if;
end if;
clk_slow <= new_clk;
end process count;
---------------------------------------------------------------------
And that gave me errors because of the way I'm synchronizing my signal "num". Any ideas?
Travis
----------------------------------------------------------------------
count : process (clk)
begin
if ( rising_edge(clk) or falling_edge(clk) )then
if num = 20 then
new_clk <= not new_clk;
num <= 0;
else
num <= num + 1;
end if;
clk_slow <= new_clk;
end if;
end process count;
---------------------------------------------------------------------
this didn't work.. so I tried this:
---------------------------------------------------------------------
count : process (clk)
begin
if rising_edge(clk) then
if num = 0 then
new_clk <= not new_clk;
num <= 0;
else
num <= num + 1;
end if;
elsif falling_edge(clk) then
if num = 0 then
new_clk <= not new_clk;
num <= 0;
else
num <= num + 1;
end if;
end if;
clk_slow <= new_clk;
end process count;
---------------------------------------------------------------------
And that gave me errors because of the way I'm synchronizing my signal "num". Any ideas?
Travis