Verilog模块实例化顺序重要吗?

时间:2019-07-18 01:53:03

标签: verilog system-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);

合成电路会一样吗?

1 个答案:

答案 0 :(得分:1)

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

出于可读性原因,您可能更喜欢第一个版本。