-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
I saw this in your clock manager code:
6.25MHz generator signal declarations
signal clk_625MHz_cnt : integer range 15 downto 0;
signal clk_625MHz : std_logic;
and in the architecture:
process (clk100_i)
begin
if (rising_edge(clk100_i) then
if (rst_i = '1') then
clk_625MHz_cnt <= 0;
else
clk_625MHz_cnt <= clk_625MHz_cnt + 1;
if (clk_625MHz_cnt < 8) then
clk_625MHz <= '1';
else
clk_625MHz <= '0';
end if;
end if;
end if;
end process;
There are two problems here.
clk_625MHz_cntis reset in the process butclk_625MHzis not. Synthesis tools like Synplify and Vivado will do weird things when your process has a reset but signals assigned in that process are not reset. Either you reset everything in the process or nothing.- You constrained the range of your counter, which is correct, although I do not understand the
15 downto 0. It should benatural range 0 to 15. However, the real issue is that your counter is not checked for overflow, and in simulation, when its value is 15 and it increments, the simulation will fail when it increments to an invalid value. You always want simulation and synthesis to match. Yes, the synthesizer will see that you've set a range for that integer and use only four flip-flops, but that's not the point.
You need to test for the overflow and reset the counter when it happens:
if clk_625MHz_cnt = 15 then
clk_625MHz_cnt <= 0;
else
clk_625MHz_cnt <= clk_625MHz_cnt + 1;
end if;
and it's instructive to look at the synthesized code to see whether the overflow test added any extra logic.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels