我在 Xilinx 中综合此代码时遇到错误。这个错误是:
“信号 Z_1 无法合成,同步描述错误”
entity uk3 is
port(
rst : in BIT;
C : in INTEGER;
clk : in BIT;
S : out INTEGER
);
end uk3;
--}} End of automatically maintained section
architecture uk3 of uk3 is
begin
process (C,clk,rst)
variable Z_1 : integer:=0;
begin
if rst='1' then Z_1:=0;
elsif rst='0'and clk'event and clk='1'and C=1
then
Z_1:=Z_1 + 1;
elsif rst='0'and clk'event and clk='1'and C=2
then
Z_1:=Z_1 + 2;
else
Z_1:=Z_1;
end if;
S<=Z_1;
end process;
-- enter your statements here --
end uk3;
why?
你有一个if
子句包含对复位条件的检查,然后是两个单独的门控时钟条件,然后是一个else
条款。我认为没有任何工具可以综合这一点,因为你不太可能真正想要你所描述的东西,而且无论如何都很难放入硬件中。您需要阅读有关 HDL 和同步设计基础知识的更多信息。
这样想一下:如果您像编译器一样从上到下逐行阅读您编写的代码,那么您实际上将如何构建执行您所描述的功能的硬件?如何构建一个硬件,使其在一个时钟上执行一项操作,在另一个时钟上执行另一项操作,以及在完全不应用时钟时执行第三项操作?如何在 FPGA LUT 中实现这一点?
简而言之,为了让你的代码正常工作,你需要摆脱else
子句,无论如何它什么也不做,合成器通常不喜欢else
or elsif
- 时钟条件旁边的子句(if rising_egde(clk)
or if clk'event and clk = '1'
)。的条件C
应单独检查if
主时钟语句中的子句。另外,去掉检查rst = '0'
in the elsif
条款。您已经检查过rst = '1'
in the if
声明和一份bit
信号只能是'1'
or '0'.
可合成的代码如下所示:
process (clk, rst)
if rst = '1' then
-- your reset condition
elsif clk'event and clk = '1' then -- if you use a bit type clk, otherwise use elsif rising_edge(clk) then
if signal = condition then
-- whatever you need doing
else
-- whatever you need doing
end if;
end if;
end process;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)