Verilog模块实例化顺序重要吗?
假设我有上面的模块。xor模块声明的顺序重要吗?如果我重新排序声明,如下所示:Verilog模块实例化顺序重要吗?,verilog,system-verilog,Verilog,System Verilog,假设我有上面的模块。xor模块声明的顺序重要吗?如果我重新排序声明,如下所示: module parity ( a , // First input b , // Second input c , // Third Input d , // Fourth Input y // Parity output ); // Input Declaration input a ; input b ;
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
合成电路是否相同?Verilog语言用于描述连接硬件的行为,如元件和算法。这些连接定义了在模拟期间如何评估图元以及如何合成图元。模拟调度(和硬件行为)基于连接网络中发生的事件 因此,如果正确连接这些元素,那么实例化这些元素的顺序是不相关的。比如说
xor u1 (out_1,c,d);
xor u2 (y,out_0,out_1);
xor u0 (out_0,a,b);
一旦模块a1的输出连接到模块b1的输入,其行为将与此处相同:
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
出于可读性的原因,您可能更喜欢第一个版本
module top(input i, output o);
b b1(t, o);
a a1(i, t);
endmodule