verilog - Verilog 模块实例化顺序重要吗?
问题描述
module parity (
a , // First input
b , // Second input
c , // Third Input
d , // Fourth Input
y // Parity output
);
// Input Declaration
input a ;
input b ;
input c ;
input d ;
// Ouput Declaration
output y ;
// port data types
wire a ;
wire b ;
wire c ;
wire d ;
wire y ;
// Internal variables
wire out_0 ;
wire out_1 ;
// Code starts Here
xor u0 (out_0,a,b);
xor u1 (out_1,c,d);
xor u2 (y,out_0,out_1);
endmodule // End Of Module parity
假设我有上面的模块。xor 模块声明的顺序是否重要?如果我像这样重新排序声明:
xor u1 (out_1,c,d);
xor u2 (y,out_0,out_1);
xor u0 (out_0,a,b);
合成电路会一样吗?
解决方案
Verilog 语言用于描述连接的类似硬件的元素和算法的行为。这些连接定义了在模拟过程中如何评估元素以及如何合成它们。模拟调度(和硬件行为)基于连接网络中发生的事件。
因此,如果正确连接它们,实例化这些元素的顺序无关紧要。例如
module a(input i, output o);
endmodule
module b(input i, output o);
endmodule
module top(input i, output o);
a a1(i, t);
b b1(t, o);
endmodule
一旦模块a a1
的输出连接到模块的输入b b1
,它的行为将与此处相同:
module top(input i, output o);
b b1(t, o);
a a1(i, t);
endmodule
出于可读性原因,您可能更喜欢第一个版本。
推荐阅读
- javascript - PASTE 事件是异步的吗?处理这个问题的最佳方法是什么?
- python - 使用用于 GUI 的 python Tkinter 命令时出现 Tcl 错误
- javascript - 无法将西班牙语日期转换为 unix 时间戳;它返回楠
- reactjs - 如何在 Next js 项目中创建会话?
- symfony - 使用转发时,无法在 Symfony 控制器中访问 POST-Params?
- c# - 无论如何使用 ProducesResponseType 属性和招摇来表示 void 返回类型?
- javascript - 使用非 ISO 日期格式在 jquery datepicker 中获取日期
- python - Seaborn 自定义范围热图
- cakephp-4.x - 检查同一用户是否从其他设备(网络或移动设备)登录
- c# - MVC 和 SPA 应用程序之间基于 Identity Server 4 的共享身份验证