2 use ieee.std_logic_1164.all;
5 use UNISIM.vcomponents.all;
7 entity clock_generator is
9 CLK_INPUT_HZ : positive := 100000000;
10 CLK_OUTPUT_HZ : positive := 100000000
13 ext_clk : in std_logic;
14 pll_rst_in : in std_logic;
15 pll_clk_out : out std_logic;
16 pll_locked_out : out std_logic);
17 end entity clock_generator;
19 architecture rtl of clock_generator is
20 signal clkfb : std_ulogic;
22 type pll_settings_t is record
23 clkin_period : real range 0.000 to 52.631;
24 clkfbout_mult : integer range 2 to 64;
25 clkout_divide : integer range 1 to 128;
26 divclk_divide : integer range 1 to 56;
27 force_rst : std_ulogic;
30 function gen_pll_settings (
31 constant input_hz : positive;
32 constant output_hz : positive)
33 return pll_settings_t is
35 constant bad_settings : pll_settings_t :=
46 return (clkin_period => 10.0,
52 return (clkin_period => 10.0,
58 report "Unsupported output frequency" severity failure;
62 report "Unsupported input frequency" severity failure;
65 end function gen_pll_settings;
67 constant pll_settings : pll_settings_t := gen_pll_settings(clk_input_hz,
73 BANDWIDTH => "OPTIMIZED",
74 CLKFBOUT_MULT => pll_settings.clkfbout_mult,
75 CLKIN1_PERIOD => pll_settings.clkin_period,
76 CLKOUT0_DIVIDE => pll_settings.clkout_divide,
77 DIVCLK_DIVIDE => pll_settings.divclk_divide,
78 STARTUP_WAIT => "FALSE")
80 CLKOUT0 => pll_clk_out,
87 LOCKED => pll_locked_out,
90 RST => pll_rst_in or pll_settings.force_rst,