我想用VHDL写一个通用时钟分频器,如下所示:
entity Generic_Clk_Divider is
Generic(
INPUT_FREQ: integer := 100;
OUTPUT_FREQ: integer := 25;
);
Port (
Clk: in std_logic;
Rst: in std_logic;
Generated_Clk: out std_logic
);
end entity;
architecture Behavioral of Generic_Clk_Divider is
signal Cnt: integer := 0;
signal Gen_Clk : std_logic := '0';
constant MaxCnt: integer := (integer (INPUT_FREQ/OUTPUT_FREQ)) - 1;
begin
process(clk, Rst)
begin
if (Rst = '1') then
Cnt <= 0;
elsif rising_edge(Clk) then
Cnt <= Cnt + 1 ;
if (Cnt = MaxCnt) then
Gen_Clk <= not Gen_Clk;
Cnt <= 0;
end if;
end if;
Generated_Clk <= Gen_Clk;
end process;
end architecture;如果我用测试台测试它,它可以工作,但如果我在电路板上使用生成的Clk信号与另一个组件(本例中是VGA控制器)一起使用,它就不能工作。我的问题是关于两个整数之间的除法,董事会似乎不认识它。
发布于 2019-12-13 18:14:09
Integer/ Integer,返回一个整数,并丢弃余数。因此,对于输入/输出是彼此的整数倍的情况,这是很好的。但不然的话,它就不会起作用。
例如:
200/75 = 2
150/40 = 3等。
唯一有效的方法是使用实数类型,这样你就可以找到分数关系,然后使用一个更大的计数器值来获得确切的关系。
但是,这根本不会有任何帮助,因为像这样的时钟分割器是非常不受欢迎的。逻辑生成的时钟使时序分析变得困难,并导致时序问题。使用真实时钟并生成时钟使能要安全得多。
https://stackoverflow.com/questions/59319716
复制相似问题