等待语句可合成
Wait statement to be synthesizable
我在 VHDL 合成方面遇到了这个问题。我在多篇文章中读到,如果我只使用一个 "wait until"/进程,"wait" 语句是可综合的,所以我就是这样做的。所以我试着做一个计数器来显示我在哪一层(我的项目包括逻辑设计中的一部电梯),它应该在预定的楼层开门 5 秒。问题出在 wait 语句上。我不知道用什么替换它才能使其在 ISE 中也能正常工作。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity counter is
port(clk1: in std_logic;
enable2:in std_logic;
input_mux: in std_logic;
dir: in std_logic;
reset,s_g,s_u: in std_logic;
q_open: out std_logic;
q: out std_logic_vector(3 downto 0));
end counter;
architecture c1 of counter is
signal flag: std_logic:='0';
component test
port(clock: in std_logic;
a: in std_logic_vector(3 downto 0);
notify: out std_logic);
end component;
begin
delay: test port map(clk1,"0101",flag);
process
variable temp:std_logic_vector(3 downto 0):="0000";
variable q_open_var:std_logic:='0';
begin
if (enable2='1') then
if (s_g='1' and s_u='1') then
if (RESET='1') then
temp:="0000";
elsif (CLK1'EVENT and CLK1='1') then
if (DIR='1') then
temp:=temp+1;
elsif(DIR='0') then
temp:=temp-1;
end if;
end if;
end if;
end if;
if (input_mux='1') then
q_open_var:='1';
q_open<=q_open_var;
wait until (flag'event and flag='1');
q_open_var:='0';
end if;
q<=temp;
q_open<=q_open_var;
wait on clk1, reset;
end process;
end c1;
尽管支持此结构,但您超出了支持的限制。综合工具必须根据您的代码生成寄存器。寄存器确实有时钟和复位输入,但综合工具不知道 clk1
和 reset
这两个词。 IE。你写了吗
wait on clk1, reset;
该工具不知道重置是什么,也不知道时钟是什么。实际上,这两个信号都被认为是时钟触发器。
但是你的设计问题更大,因为你在异步复位和时钟触发之前有if语句。虽然支持时钟门控,但您可能并不打算这样做。
然后你的语句中有一个/second/时钟触发器:wait until (flag'event and flag='1');
。我不知道你在那里做什么,但你如何想象这会在硬件中实现?
您真的应该坚持 standard/advised 编码风格以获得可预测的行为。即
library ieee;
use ieee.numeric_std.all;
[...]
signal temp : unsigned(3 downto 0) := (others => '0');
begin
temp_proc: process(clk1, reset)
variable q_open_var : std_logic := '0';
begin
if rising_edge(clk1) then
if enable2='1' and s_g='1' and s_u='1' then
if dir = '1' then
temp <= temp + 1;
elsif dir = '0' then
temp <= temp - 1;
end if;
end if;
end if;
if reset = '1' then
temp <= (others => '0');
end if;
end process;
q <= std_logic_vector(temp);
(我省略了 q_open
部分,因为不清楚你想要什么。为此做一个单独的过程,因为它不依赖于 reset
)
p.s。我最喜欢 end if;
的五行 ;) 下次请使用适当的缩进。并使用 'elsif' 而不是 'else if'.
我在 VHDL 合成方面遇到了这个问题。我在多篇文章中读到,如果我只使用一个 "wait until"/进程,"wait" 语句是可综合的,所以我就是这样做的。所以我试着做一个计数器来显示我在哪一层(我的项目包括逻辑设计中的一部电梯),它应该在预定的楼层开门 5 秒。问题出在 wait 语句上。我不知道用什么替换它才能使其在 ISE 中也能正常工作。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity counter is
port(clk1: in std_logic;
enable2:in std_logic;
input_mux: in std_logic;
dir: in std_logic;
reset,s_g,s_u: in std_logic;
q_open: out std_logic;
q: out std_logic_vector(3 downto 0));
end counter;
architecture c1 of counter is
signal flag: std_logic:='0';
component test
port(clock: in std_logic;
a: in std_logic_vector(3 downto 0);
notify: out std_logic);
end component;
begin
delay: test port map(clk1,"0101",flag);
process
variable temp:std_logic_vector(3 downto 0):="0000";
variable q_open_var:std_logic:='0';
begin
if (enable2='1') then
if (s_g='1' and s_u='1') then
if (RESET='1') then
temp:="0000";
elsif (CLK1'EVENT and CLK1='1') then
if (DIR='1') then
temp:=temp+1;
elsif(DIR='0') then
temp:=temp-1;
end if;
end if;
end if;
end if;
if (input_mux='1') then
q_open_var:='1';
q_open<=q_open_var;
wait until (flag'event and flag='1');
q_open_var:='0';
end if;
q<=temp;
q_open<=q_open_var;
wait on clk1, reset;
end process;
end c1;
尽管支持此结构,但您超出了支持的限制。综合工具必须根据您的代码生成寄存器。寄存器确实有时钟和复位输入,但综合工具不知道 clk1
和 reset
这两个词。 IE。你写了吗
wait on clk1, reset;
该工具不知道重置是什么,也不知道时钟是什么。实际上,这两个信号都被认为是时钟触发器。
但是你的设计问题更大,因为你在异步复位和时钟触发之前有if语句。虽然支持时钟门控,但您可能并不打算这样做。
然后你的语句中有一个/second/时钟触发器:wait until (flag'event and flag='1');
。我不知道你在那里做什么,但你如何想象这会在硬件中实现?
您真的应该坚持 standard/advised 编码风格以获得可预测的行为。即
library ieee;
use ieee.numeric_std.all;
[...]
signal temp : unsigned(3 downto 0) := (others => '0');
begin
temp_proc: process(clk1, reset)
variable q_open_var : std_logic := '0';
begin
if rising_edge(clk1) then
if enable2='1' and s_g='1' and s_u='1' then
if dir = '1' then
temp <= temp + 1;
elsif dir = '0' then
temp <= temp - 1;
end if;
end if;
end if;
if reset = '1' then
temp <= (others => '0');
end if;
end process;
q <= std_logic_vector(temp);
(我省略了 q_open
部分,因为不清楚你想要什么。为此做一个单独的过程,因为它不依赖于 reset
)
p.s。我最喜欢 end if;
的五行 ;) 下次请使用适当的缩进。并使用 'elsif' 而不是 'else if'.