library ieee;use ieee.std_logic_1164.all;use ieee.numeric_std.all;library UNISIM;use UNISIM.vcomponents.all;entity clock_divider isgeneric (G_DIVISOR : positive := 2);port (i_clk : in std_logic;i_rst : in std_logic;o_clk : out std_logic);end entity clock_divider;architecture behavioral of clock_divider issubtype t_counter is natural range 0 to ( G_DIVISOR - 1 );signal s_counter : t_counter := 0;constant C_COUNTER : t_counter := G_DIVISOR / 2 - 1;signal s_clk_divided : std_logic;attribute clock_signal : string;attribute clock_signal of s_clk_divided : signal is "yes";beginassert ( G_DIVISOR > 1 ) report "The divisor should be greater than 1" severity failure;counting : process( i_clk )beginif( rising_edge(i_clk) ) thenif( i_rst = '1' ) thens_counter <= 0;s_clk_divided <= '0';elseif( s_counter = t_counter'high ) thens_counter <= 0;s_clk_divided <= '0';elses_counter <= s_counter + 1;if( s_counter = C_COUNTER ) thens_clk_divided <= '1';end if;end if;end if;end if;end process counting;BUFR_inst : BUFRgeneric map (BUFR_DIVIDE => "BYPASS", -- "BYPASS", "1", "2", "3", "4", "5", "6", "7", "8"SIM_DEVICE => "VIRTEX6") -- Specify target device, "VIRTEX4", "VIRTEX5", "VIRTEX6"port map (O => o_clk, -- Clock buffer outputCE => '1', -- Clock enable inputCLR => '0', -- Clock buffer reset inputI => s_clk_divided -- Clock buffer input);end architecture;