vhdl - 无条件 WAIT 语句对 VHDL 中进程的影响
问题描述
wait
关于以无条件语句结尾的 VHDL 过程,我有一些不明白的地方。为了说明我的问题,我需要比较以下 2 个片段:
片段1:
library ieee;
use ieee.std_logic_1164.all;
entity foo is
end entity;
architecture sim of foo is
signal clk : std_logic := '0';
signal s : std_logic;
begin
clk <= not clk after 10 ns;
-- driver1
s <= '0';
-- driver2
process (clk) is
begin
s <= clk;
end process;
end architecture;
信号 s 有双重分配:Driver1 将信号 s 驱动为“0”,而 driver2 交替将其驱动为“0”和“1”。正如我们在波形图上看到的,当 clk 为“0”时,生成的 s 为“0”(绿色段),但当 clk 为“1”时,生成的 s 为“X”(红色段)。 =>我理解这种行为,那没问题。
如果我通过将 driver1 更改为以无条件wait
指令结束的进程来稍微修改此代码:
片段2:
library ieee;
use ieee.std_logic_1164.all;
entity foo is
end entity;
architecture sim of foo is
signal clk : std_logic := '0';
signal s : std_logic;
begin
clk <= not clk after 10 ns;
-- driver1
-- s <= '0';
process
begin
s <= '0';
wait;
end process;
-- driver2
process (clk) is
begin
s <= clk;
end process;
end architecture;
令人惊讶的是,对我来说,snipet 2 产生了与 snipet 1 相同的波形。我的理解是,带有最终“无条件”wait
语句的进程内的指令将永远停止,这意味着它们的代码在第一次执行运行后将处于非活动状态。但如果情况确实如此,我希望 snipet 2 中的 driver1 在第一次运行后处于非活动状态,并且从那时起 driver2 仍然是信号 s 的唯一活动驱动程序,始终为其分配 clk 的替代 '1' 和 '0'。
为什么不是这样?
解决方案
当您在流程中分配信号时,会为该信号创建一个驱动程序,从它分配的那一刻到模拟结束。所以在这里,两个代码片段在功能上是等效的,您从时间 0 创建 driver1,从第一个时钟创建 driver2。
推荐阅读
- python - MongoDB(PyMongo)分页具有不同的不给出一致的结果
- javascript - 如何使十进制以在 amCharts 中占用最多两 (2) 个系列值?
- android - Ionic 3:更新到 cordova-android 9 后无法从驱动器中选择文件
- javascript - Vue组合API调用子组件方法
- rabbitmq - 发现在 AMQP 默认交换上发布的内容
- excel - 从包含文本框和表格的 PowerPoint 幻灯片中提取文本以粘贴到 Excel 工作表中
- laravel - Laravel 无法以附加模式打开流或文件“storage/laravel.log”:无法打开流:RHEL8 中的权限被拒绝
- azure-devops - 如何在错误下编辑“已解决的原因”?
- linux - 为什么 linux rpath 只影响某些库
- python - 未知键中的字典值