我正在尝试构建一个基于整数计数器的时钟分频器。模拟工作正常,但综合失败,出现上述错误并标记第 25 行。 我不明白为什么它不可合成。
代码:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.numeric_std.all;
entity divider is
Port (clk_100M: in std_logic;
reset: in std_logic;
clk_5, clk_500: buffer std_logic := '0' );
end divider;
architecture Behavioral of divider is
begin
CLK_GEN:
process(clk_100M)
variable count_5: integer:=0;
variable count_500: integer:=0;
begin
if rising_edge(reset) then
clk_5 <= '0';
clk_500 <= '0';
count_5 := 0;
count_500 := 0;
elsif rising_edge(clk_100M) then
count_5 := count_5 + 1;
count_500 := count_500 + 1;
end if;
if count_5 = 5000000 then
clk_5 <= NOT(clk_5);
count_5 := 0;
end if;
if count_500 = 50000 then
clk_500 <= NOT(clk_500);
count_500 := 0;
end if;
end process;
end Behavioral;
综合期望所有逻辑都受到时钟条件的保护。对于重置,这是一个电平检查。因此,您的代码需要重构以适应这一点:
CLK_GEN:
process(clk_100M)
variable count_5: integer:=0;
variable count_500: integer:=0;
begin
if reset = '1' then
clk_5 <= '0';
clk_500 <= '0';
count_5 := 0;
count_500 := 0;
elsif rising_edge(clk_100M) then
count_5 := count_5 + 1;
count_500 := count_500 + 1;
if count_5 = 5000000 then
clk_5 <= NOT(clk_5);
count_5 := 0;
end if;
if count_500 = 50000 then
clk_500 <= NOT(clk_500);
count_500 := 0;
end if;
end if;
end process;