简体   繁体   中英

Setting FPGA clock frequency using Timing Constraints

I am (slowly) moving my way through an "introductory" course on FPGA programming using Xilinx Spartan-6 Eval Board, and am looking at clock timings and how you can add necessary timing constraints. It has led me to a couple of questions. For this demonstration I have used a simple program to just make an LED blink (code at the bottom).

I then added this constraint to my constraints file:

NET "CLK" TNM_NET = CLK;
TIMESPEC TS_CLK = PERIOD "CLK" 200 MHz HIGH 50%; # What effect does the 200 Mhz enforce?

What does the constraint actually enforce? Because when I attempt to scale it in order to make an LED blink at 1 Hz I find it makes no difference whether I put a timing constraint of 200 MHz, or any other number!

Thanks very much! My entire source code is below for reference.

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity LED_Blink is
    port(
        CLK : in  std_logic;
        LED        : out std_logic
    );

end LED_Blink;

architecture Behavioral of LED_Blink is
    signal CLK_1Hz : std_logic;
    signal counter : std_logic_vector(26 downto 0);
begin
    prescaler : process(CLK)
    begin
        if rising_edge(CLK) then
            if (counter < 1000000) then --possibly change to number in binary
                counter <= counter + 1;
            else
                CLK_1Hz <= not CLK_1Hz;
                counter <= (others => '0');
            end if;
        end if;
    end process;

    LED <= CLK_1Hz;

end Behavioral;

NET "CLK" LOC ="K21";
NET "LED" LOC = "D21";
NET "CLK" TNM_NET = CLK;
TIMESPEC TS_CLK = PERIOD "CLK" 5 ns HIGH 50%;

Timing constraint are parameters for Static Timing Analysis (STA). An STA tool like Xilinx trace can tell you if your code - generated, mapped, placed and finally routed netlist - will meet all timing requirements.

Every part of your described circuit (LUTs, registers and wires) has a delay. STA ensures you that the overall delay is less than your clock period minus some uncertenty. (see the Xilinx timing guide for more information on 'setup' and 'hold' times.)

So setting CLK to 200 MHz checks if your circuit will run at up to 200 MHz. It does not change the behavior like a blinking frequency.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM