如何在VHDL中实现时钟使能?

时间:2018-10-29 14:37:20

标签: vhdl counter clock

因此,基本上我想做的是在一定时间后激活和停用时钟。这是我正在寻找的一个小例子:`

library ieee;
use ieee.std_logic_1164.ALL;
use ieee.numeric_std.all;

entity example is
  generic (
    clk1       : in  std_logic; --- 100hz
    clk2 : in std_logic ;       --- 10hz

    );
end example;

architecture example_arch of example is

signal clk_count1, clk_count2 : integer range 0 to 1000:= 0;
signal clk_enable1 :  std_logic := '1';
signal clk_enable2 :  std_logic := '0';

begin

process (clk1)
  begin
    if rising_edge(clk1) and clk_enable1 = '1' then
        if clk_count = 1000 then
             clk_enable1 <= '0'; 
             clk_enable2 <= '1'; 
             clk_count1  <= 0; 
        else
             clk_count1 <= clk_count1 + 1;
             [...] --- do what you want to do while you are using clk1
        end if;
   end if;
  end process;

process (clk2)
      begin
        if rising_edge(clk2) and clk_enable2 = '1' then
            if clk_count2 = 1000 then
                 clk_enable1 <= '1'; 
                 clk_enable2 <= '0'; 
                 clk_count2  <= 0; 
            else
                 clk_count2 <= clk_count2 + 1;
                 [...] --- do what you want to do while you are using clk2
            end if;
       end if;
      end process;

end example_arch;

` 因此,在此示例中,我们有两个时钟,其中clk1的频率大于clk2的频率。当clk_enable1为'1'时,我们正在处理第一个进程,而当clk_enable2为'1'时,我们正在处理第二个进程。

此代码的问题在于,即使我们知道clk_enable的值为'1',它仍然允许两个进程在两个时钟的每个时钟事件发生后自行执行。我正在尝试做的是在使用另一个时钟时停用时钟,这样就不会有与已停用时钟有关的时钟事件,因此我们在执行时钟时永远不会执行此时钟的过程。其他过程。换句话说,当时钟可以为1或0时,另一个处于高阻抗(Z)。我想要这样的东西:

flip-flop

感谢您的帮助,希望我能找到解决方案。

0 个答案:

没有答案
相关问题