Z
Zanan
Guest
I'm trying to figure out how to use a (initial) for-loop to access an
instance array.
But my simulator (Modelsim PE Student 6.2g) doesn't seem to allow
non-constant
index-value for either instance-arrays, or loop-generated instances!
Is there a way around this?
module my_xor(x, y, z );
input x;
input y;
output z;
assign z = y^x;
endmodule
module testbench;
genvar g;
generate for (g = 0; g < 2; g = g + 1 ) begin : aa
my_xor genxors( .x(), .y(), .z() ); // <-- my generate(d) instances
end
endgenerate
my_xor xors[1:0] (.x(), .y(), .z() ); // <-- my instance array!
integer i;
initial begin
for ( i = 0; i < 2; i = i + 1 )
$display( "xors[%0d].x = 1'b%b", xors.x ); // simulator error --
non-constant index to instance-array not allowed!
for ( i = 0; i < 2; i = i + 1 )
$display( "xors[%0d].x = 1'b%b", aa.genxors.x ); // simulator
error -- same complaint against generated-hierarchy!
#1 $finish;
end
endmodule
instance array.
But my simulator (Modelsim PE Student 6.2g) doesn't seem to allow
non-constant
index-value for either instance-arrays, or loop-generated instances!
Is there a way around this?
module my_xor(x, y, z );
input x;
input y;
output z;
assign z = y^x;
endmodule
module testbench;
genvar g;
generate for (g = 0; g < 2; g = g + 1 ) begin : aa
my_xor genxors( .x(), .y(), .z() ); // <-- my generate(d) instances
end
endgenerate
my_xor xors[1:0] (.x(), .y(), .z() ); // <-- my instance array!
integer i;
initial begin
for ( i = 0; i < 2; i = i + 1 )
$display( "xors[%0d].x = 1'b%b", xors.x ); // simulator error --
non-constant index to instance-array not allowed!
for ( i = 0; i < 2; i = i + 1 )
$display( "xors[%0d].x = 1'b%b", aa.genxors.x ); // simulator
error -- same complaint against generated-hierarchy!
#1 $finish;
end
endmodule