【发布时间】:2015-01-04 08:52:03
【问题描述】:
我正在尝试使用 Peter Ashenden 的书“The Designer's Guide to VHDL”来学习 VHDL,但似乎无法摆脱我错过了与敏感度列表相关的基本项目的感觉。
例如,一个问题是“编写一个模型,表示一个简单的 ALU,具有整数输入和输出,以及位类型的函数选择输入。如果函数选择为 '0',则 ALU 输出应该是输入,否则输出应该是输入的差。"
我的解决方案是
entity ALU is
port (
a : in integer; -- A port
b : in integer; -- B port
sel : in bit; -- Fun select
z : out integer); -- result
end entity ALU;
architecture behav of ALU is
begin -- architecture behav
alu_proc: process is
variable result : integer := 0;
begin -- process alu_proc
wait on sel;
if sel = '0' then
result := a + b;
else
result := a - b;
end if;
z <= result;
end process alu_proc;
end architecture behav;
与测试台
entity alu_test is
end entity alu_test;
architecture alu_tb of alu_test is
signal a, b, z : integer;
signal sel : bit;
begin -- architecture alu_tb
dut: entity work.alu(behav)
port map (a, b, sel, z);
test_proc: process is
begin -- process test_proc
a <= 5; b <= 5; wait for 5 ns; sel <= '1'; wait for 5 ns;
assert z = 0;
a <= 10; b <= 5; wait for 5 ns; sel <= '0'; wait for 5 ns;
assert z = 15;
wait;
end process test_proc;
end architecture alu_tb;
我的问题与流程中的敏感度列表有关。由于它对选择位的变化很敏感,我必须按顺序执行这些功能,首先是减法,然后是加法,然后是在测试台上再次减法。在这个问题中,我觉得你应该能够按顺序做几个加法,之间没有减法。当然,我可以添加一个启用信号并使过程对此敏感,但我认为应该在问题中说明这一点。我错过了语言中的某些内容还是我的解决方案“正确”?
【问题讨论】:
-
等待语句敏感度子句“定义了等待语句的敏感度集,即等待语句对其敏感的信号集。敏感度列表中的每个信号名称将给定信号标识为敏感集的成员。” (权威 IEEE Std 1076-2008,10.2 等待声明)。敏感度列表中没有
a或b,它们也可以在流程声明声明中提供。 (11.3 过程声明)。 Morten 的答案是基于 Ashenden 的书中首次出现的“敏感列表”和“敏感条款”,结构良好的搜索。
标签: vhdl