如何解决Verilog:在Always语句中可以多次引用同一个寄存器吗?
我正在编写一个Verilog HDL模块来消除按键的反弹。首先,我将使用两个名为sync_0
和sync_1
的触发器将印刷机与时钟同步,如下所示:
Input -> sync_0 -> sync_1
我的问题是,我可以将这两个操作合并到一个始终这样的始终块中吗?
// Synchronize the switch input to the clock
reg sync_0,sync_1;
always @(posedge clk)
begin
sync_0 <= switch_input;
sync_1 <= sync_0;
end
还是需要像这样分解:
// Synchronize the switch input to the clock
reg sync_0,sync_1;
always @(posedge clk)
begin
sync_0 <= switch_input;
end
always @(posedge clk)
begin
sync_1 <= sync_0;
end
编辑:更清楚地说,我的问题是:可以将sync_0放在非阻塞分配的左手侧和右手侧放在同一始终阻塞中。还是应该将这两个分配拆分为两个单独的Always块。两者都很好,我只是想知道哪种更好。
解决方法
语法正确。只要这些Origins and Spread https://www.snopes.com/collections/coronavirus-origins-treatments/?collection-id=238235
Prevention and Treatments https://www.snopes.com/collections/coronavirus-collection-prevention-treatments/?collection-id=238235
Prevention and Treatments II https://www.snopes.com/collections/coronavirus-collection-prevention-treatments-2/?collection-id=238235
International Response https://www.snopes.com/collections/coronavirus-international-rumors/?collection-id=238235
US Government Response https://www.snopes.com/collections/coronavirus-government-role/?collection-id=238235
Trump and the Pandemic https://www.snopes.com/collections/coronavirus-collection-trump/?collection-id=238235
Trump and the Pandemic II https://www.snopes.com/collections/coronavirus-collection-trump-2/?collection-id=238235
具有相同的敏感度列表,就可以将它们放在一个reg
块中。每个always
是一个独立的电路实体,具有自己的驱动锥并并行运行。工具将处理该问题。但是,在现实世界中,建议仅描述与功能相关的信号和/或在同一reg
中共享相同控制结构(例如相同或几乎相同的if-else
控件)的信号。根据您的情况,您当然可以将它们放在一个always
中。我希望这样做,因为在屏幕上阅读时可以看到更多代码。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。