我不明白这段代码在vhdl中是如何工作的?

问题描述 投票:0回答:1
ARCHITECTURE behavior OF testbench IS 
   signal a,b : integer := 0;

BEGIN
 p1:process
    begin 
        a<= b +1  after 3 ns ;
        wait on a;
 end process;


 p2:process
    begin 
        b<= a+1 after 5 ns ;
        wait on a;
 end process;

  END;
vhdl
1个回答
0
投票

那么你有哪部分不明白呢?上面的代码是一个很好的例子,对于一个只能模拟的代码来说,它是不能合成的,因为它的 after 语句。你不能在硬件上实现这种语句。

而且你的代码也没有什么作用。开始仿真并观察波形图。

enter image description here

然后试着逐行理解你的代码的功能。测试台执行 a <= b + 1 3 ns后的指令,所以你的 a 将增加一。你的 b. 现在 process 正在等待 a. A process 在你的设计中是一个顺序的部分,所以在你的设计中,变化的 a 不影响 wait for a因为该部分是在 wait on a. 你的第二个过程也是如此。两个进程都是并行的,但每个进程都是顺序的。

也许当你改变你的代码时,你会更好地了解发生了什么。

p2:process
    begin 
        b <= 1 after 5 ns ;
        wait on a;
        b <= 2 ;
end process;

enter image description here

现在你看到你的 b 将被设置为 2 在你 a 改变,因为 wait on a 已经结束。5 ns后 b 被设置为 1因为你的 after 已过期。

额外的,你会发现这些过程是平行的,因为 a 影响 b 同时。

© www.soinside.com 2019 - 2024. All rights reserved.