Altera_Forum
Honored Contributor
9 years agoGated clocks
Hi folks. I have noticed in an Altera help page that gated clocks are not recommended:
-----> http://quartushelp.altera.com/15.1/index.htm#reference/glossary/def_gatedclk.htm In another page, Altera provides guidelines for implementing a gated clock: -----> http://quartushelp.altera.com/15.1/index.htm#verify/da/comp_file_rules_clock.htm It seems convenient to do this for generating a SPI clock, for example, using the chip select signal as a clock enable. Is there a better alternative? Here are my code and resulting RTL snapshot for reference. This example incorporates both methods outlined in the help page. Any comments greatly appreciated!
clock_enable_n : process(clk, reset_n)
begin
if (reset_n = '0') then
clk_enable_n <= '0';
elsif rising_edge(clk) then
clk_enable_n <= clock_en_n;
end if;
end process clock_enable_n;
clock_out_n <= clk or clk_enable_n;
clock_enable : process(clk, reset_n)
begin
if (reset_n = '0') then
clk_enable <= '0';
elsif falling_edge(clk) then
clk_enable <= not(clock_en_n);
end if;
end process clock_enable;
clock_out <= clk and clk_enable;