Verilog 模块实例化顺序重要吗?
Does Verilog Module Instantiation Order Matter?
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 语言用于描述已连接 hardware-like 元素和算法的行为。连接定义了元素在仿真过程中如何被评估以及它们是如何被合成的。模拟调度(和硬件行为)基于连接网络中发生的事件。
因此,如果正确连接它们,实例化这些元素的顺序是无关紧要的。例如
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
出于可读性原因,您可能更喜欢第一个版本。
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 语言用于描述已连接 hardware-like 元素和算法的行为。连接定义了元素在仿真过程中如何被评估以及它们是如何被合成的。模拟调度(和硬件行为)基于连接网络中发生的事件。
因此,如果正确连接它们,实例化这些元素的顺序是无关紧要的。例如
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
出于可读性原因,您可能更喜欢第一个版本。