From: Adam Krolnik (adamk@cyrix.com)
Date: Wed Apr 14 1999 - 07:26:10 PDT
Good morning Tom;
<p>Generated instance names are strings! They are not arrays.
As such, one can't use a loop to iterate through several of them.
One must use explicit generation of them.
module top;
integer j;
wire[3:0] b;
reg [3:0] a,c[0:3];
genvar i;
parameter N = 4; // ACK added for example.
generate for (i = 0; i < N; i = i+1)
foo f(a[i],b[i]);
endgenerate
initial begin
c[0] = f[0].bar;
c[1] = f[1].bar;
c[2] = f[2].bar;
c[3] = f[3].bar;
end
endmodule
And to show the weakness of the generate proposal, one can't build that initial
block with any generate statement except for something like this:
generate case (N)
2: begin
initial begin
c[0] = f[0].bar;
c[1] = f[1].bar;
end
end
3: begin
initial begin
c[0] = f[0].bar;
c[1] = f[1].bar;
c[2] = f[2].bar;
end
end
4: begin
initial begin
c[0] = f[0].bar;
c[1] = f[1].bar;
c[2] = f[2].bar;
c[3] = f[3].bar;
end
end
endgenerate
A better approach would be simply:
genvar j;
initial begin
generate for(j=0;j<N;j=j+1)
c[j] = f[j].bar;
endgenerate
end
But one can't have a generate statement within any block or instantiation.
<p><p> Adam Krolnik
Verification Engineer
Cyrix - NSC.
Richardson TX. 75085
This archive was generated by hypermail 2.1.4
: Mon Jul 08 2002 - 12:53:26 PDT
and
sponsored by Boyd Technology, Inc.