这个模块的目的是什么?
What is the purpose of this module?
module InoutConnect(
.X1(internal),
.X2(internal)
);
parameter width = 1;
inout [ width - 1 : 0 ] internal;
endmodule // InoutConnect
上面代码中使用的格式是什么,
我知道在实例化模块时 .x1 用于匹配变量名,但是模块定义呢?
这里是什么意思?
它被称为explicit port declaration
,这意味着外部世界将通过其显式名称X1和X2[=24=知道这个端口] 在您的情况下,尽管在内部相同的端口在您的情况下将被称为 internal。
因此,在您的示例中,您将两个端口都连接到同一个内部变量(对我来说看起来很糟糕 :))不过,这是一种可能的用途,特别是如果您需要相同的输出端口。另一个例子是将内部结构或数组重新映射到多个 potrts:
module m(
output .arr1(array[2:0]),
output .arr2(array[7:3]),
input logic [7:0] input_array
)
logic [7:0] array;
...
always_ff @(posedge clk)
array <= input_array;
...
endmodule
所以,上面你可以在内部使用你的数组作为一个整体,但它在外部世界会有不同的表示。
有关详细信息,请参阅 23.2.2.2 ANSI style list of port declarations
。
InoutConnect 模块用于在两个不同的信号名称之间创建别名。例如
wire [7:0] color;
wire [7:0] colour;
InoutConnect #7 a1(color,colour);
现在,颜色和颜色是同一信号的两个名称。
SystemVerilog 添加了 alias
结构来完成同样的事情,而无需创建单独的模块。
module InoutConnect(
.X1(internal),
.X2(internal)
);
parameter width = 1;
inout [ width - 1 : 0 ] internal;
endmodule // InoutConnect
上面代码中使用的格式是什么, 我知道在实例化模块时 .x1 用于匹配变量名,但是模块定义呢? 这里是什么意思?
它被称为explicit port declaration
,这意味着外部世界将通过其显式名称X1和X2[=24=知道这个端口] 在您的情况下,尽管在内部相同的端口在您的情况下将被称为 internal。
因此,在您的示例中,您将两个端口都连接到同一个内部变量(对我来说看起来很糟糕 :))不过,这是一种可能的用途,特别是如果您需要相同的输出端口。另一个例子是将内部结构或数组重新映射到多个 potrts:
module m(
output .arr1(array[2:0]),
output .arr2(array[7:3]),
input logic [7:0] input_array
)
logic [7:0] array;
...
always_ff @(posedge clk)
array <= input_array;
...
endmodule
所以,上面你可以在内部使用你的数组作为一个整体,但它在外部世界会有不同的表示。
有关详细信息,请参阅 23.2.2.2 ANSI style list of port declarations
。
InoutConnect 模块用于在两个不同的信号名称之间创建别名。例如
wire [7:0] color;
wire [7:0] colour;
InoutConnect #7 a1(color,colour);
现在,颜色和颜色是同一信号的两个名称。
SystemVerilog 添加了 alias
结构来完成同样的事情,而无需创建单独的模块。