2 use ieee.std_logic_1164.all;
5 use UNISIM.vcomponents.all;
7 entity clock_generator is
9 clk_period_hz : positive := 100000000);
11 ext_clk : in std_logic;
12 pll_rst_in : in std_logic;
13 pll_clk_out : out std_logic;
14 pll_locked_out : out std_logic);
15 end entity clock_generator;
17 architecture rtl of clock_generator is
19 signal clkfb : std_ulogic;
21 type pll_settings_t is record
22 clkin_period : real range 0.000 to 52.631;
23 clkfbout_mult : integer range 2 to 64;
24 clkout_divide : integer range 1 to 128;
25 divclk_divide : integer range 1 to 56;
26 end record pll_settings_t;
28 function gen_pll_settings (
29 constant freq_hz : positive)
30 return pll_settings_t is
32 if freq_hz = 100000000 then
33 return (clkin_period => 10.0,
38 report "Unsupported input frequency" severity failure;
39 -- return (clkin_period => 0.0,
40 -- clkfbout_mult => 0,
41 -- clkout_divide => 0,
42 -- divclk_divide => 0);
44 end function gen_pll_settings;
46 constant pll_settings : pll_settings_t := gen_pll_settings(clk_period_hz);
51 BANDWIDTH => "OPTIMIZED",
52 CLKFBOUT_MULT => pll_settings.clkfbout_mult,
53 CLKIN1_PERIOD => pll_settings.clkin_period,
54 CLKOUT0_DIVIDE => pll_settings.clkout_divide,
55 DIVCLK_DIVIDE => pll_settings.divclk_divide,
56 STARTUP_WAIT => "FALSE")
58 CLKOUT0 => pll_clk_out,
65 LOCKED => pll_locked_out,