虽然未命名generate块没有可用于层级的名称,但它仍需要有一个名称,以便外部接口可以引用它。为此,系统将自动为每个未命名的generate块分配一个名称。
给定作用域中的每个generate结构体都有一个编号。在该作用域中以文本形式首次出现的结构体的编号为 1,其后每个generate结构体的编号都将增加 1。所有未命名的生成块都将被命名为 “genblk<n>”,其中 <n> 是分配给其外层generate结构体的编号。如果该名称与显式声明的名称相冲突,则会在数字前面加上前导零,直到名称不冲突为止。例如:
module top;
parameter genblk2 = 0;
genvar i;
// The following generate block is implicitly named genblk1
if (genblk2) reg a; // top.genblk1.a
else reg b; // top.genblk1.b
// The following generate block is implicitly named genblk02
// as genblk2 is already a declared identifier
if (genblk2) reg a; // top.genblk02.a
else reg b; // top.genblk02.b
// The following generate block would have been named genblk3
// but is explicitly named g1
for (i = 0; i < 1; i = i + 1) begin : g1 // block name
// The following generate block is implicitly named genblk1
// as the first nested scope inside of g1
if (1) reg a; // top.g1[0].genblk1.a
end
// The following generate block is implicitly named genblk4 since
// it belongs to the fourth generate construct in scope "top".
// The previous generate block would have been
// named genblk3 if it had not been explicitly named g1
for (i = 0; i < 1; i = i + 1)
// The following generate block is implicitly named genblk1
// as the first nested generate block in genblk4
if (1) reg a; // top.genblk4[0].genblk1.a
// The following generate block is implicitly named genblk5
if (1) reg a; // top.genblk5.a
endmodule
点赞加关注博主(ID:FPGA小飞)的博文,咱们一起系统学习verilog最终标准IEEE Std 1364-2005吧!