如何在“生成”块中定义“ register_bank”的数组并使用它们? 我的意思是这样的:
genvar i;
generate
for(i = 0; i < 4; i = i + 1)
being
reg [15:0] register_bank [0:31];
always @(posedge clk)
begin
if(we)
begin
register[i][addr] <= data_i[i * 16 +: 16];
end
else
begin
data_o[i * 16 +: 16] <= register[i][addr];
end
end
end
endgenerate
答案 0 :(得分:0)
我刚找到答案。我们可以使用块的名称来做到这一点。就像下面的代码一样:
genvar i;
generate
for(i = 0; i < 4; i = i + 1)
being : my_reg_bank
reg [15:0] register_bank [0:31];
always @(posedge clk)
begin
if(we)
begin
my_reg_bank[i].register[addr] <= data_i[i * 16 +: 16];
end
else
begin
data_o[i * 16 +: 16] <= my_reg_bank[i].register[addr];
end
end
end
endgenerate