Skip to content

6.25 MHz reference clock for CP2100 PLL #1

@aspdigital

Description

@aspdigital

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.

  1. clk_625MHz_cnt is reset in the process but clk_625MHz is 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.
  2. You constrained the range of your counter, which is correct, although I do not understand the 15 downto 0. It should be natural 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions