出错的代码有可能是类似下面两对代码的结构
1.在一个进程中 if 和 elsif 的判断条件都为上升沿,执行语句对同一个信号赋值,导致电路无法综合。
process (c, r) is begin
if r'event and r = '1' then
q <= '0';
elsif c'event and c = '1' then
q <= d;
end if;
end process;
- 在一个进程中出现了两个 if 判断语句,对同一个信号赋值,这样综合的电路会有冲突导致出错,
process (c, r) is begin
if (r = '1' ) then
q <= '0';
if c'event and c = '1' then
q <= d;
end if;
end if;
end process;
解决方法
对于第一种形式的代码没有好的解决方案,因为用两个上升沿作为if elsif的条件是不被允许的。对于第二种我们可以将代码更改为if elsif的语句或者是一个条件下嵌入另外一个语句,这样电路就可以综合了。
process (clk, reset) is begin
if clk'event and clk = '1' then -- topmost if statement
if reset = '1' then -- synchronous reset
q <= '0';
else
q <= d;
end if;
end if;
end process;
process (clk, reset) is begin
if reset = '1' then
q <= '0';
elsif clk'event and clk = '1' then
q <= d;
end if;
end process;