【发布时间】:2018-01-07 08:25:33
【问题描述】:
有时我们需要在某些来自 Process 之外的条件下执行一些顺序流程。我们可以为这种情况声明一些控制信号,例如:
Architecture ...
Signal C : std_logic;
begin
Process(SomeInputs)
begin
C <= '1';
end Process;
Process(Clock)
Variable Counter : Integer := 0;
begin
if (Clock'Event and Clock = '1') then
if C = '1' then
Counter := Counter + 1;
if Counter = 10 then
Counter := 0;
C <= '0';
end if;
end if;
end if;
end Process;
end;
end ... ;
在这种情况下,信号 C 是多源的,无法合成。
另一个例子是复位信号,当复位来自进程外部或组件外部时,我们不能反转它。
一种方法是制作这样的状态机:
Process(Clock)
begin
if (Clock'Event and Clock = '1') then
case Current_State is
when State_X =>
Current_State <= State_Y;
when State_Y =>
if C = '1' then
Current_State <= State_X;
else
Current_State <= State_Y;
end if;
...
end case;
end if;
end Process;
或者另一种处理这种情况的方法是声明这样的临时信号:
Architecture ...
Signal MySignal, MyTempSignal : std_logic_vector(N downto 0);
begin
Process(Clock)
Variable Counter : Integer := 0;
begin
if (Clock'Event and Clock = '1') then
if MySignal /= MyTempSignal then
Counter := Counter + 1;
if Counter = 10 then
Counter := 0;
MyTempSignal <= MySignal;
end if;
end if;
end if;
end Process;
end ...;
使用临时信号,我们可以在某些信号发生变化时进行一些处理。
另一种方法是在进程的敏感列表中添加条件信号,但是当进程与时钟顺序时,很难处理。
主要问题是每个信号都必须来自 1 个源(在一个进程中),问题是:
当我们需要一些控制信号(如“重置”)时,处理这种情况的最佳综合方法是什么?
【问题讨论】:
-
在您的第一个示例中,
Process(SomeInputs)块已经不正确。它可能在模拟中起作用,但不是适当的综合构造。你甚至可以推断出你绝对不想要的闩锁。但我不明白你的问题。你看到的问题在 HDL 中是很正常的。