`define num =4
module enhance();
logic ssp , br ,clk , reset;
genvar i,j;
generate
begin:upstream
for(i=0;i<2*`num;i++)begin
ocp_level ocp(clk,reset); //interface
assign i.data = `wrapper.signal.val;
assign i.mdata= `wrapper.signal.read;
if(j<`num) begin
ocp_level ocp(clk,reset); //interface
assign i.updata = `wrapper.signal.val;
assign i.upmdata= `wrapper.signal.read;
end
j=(i/2)+1; ----------------1.
end
end
endgenerate
Here I am using generate block .
case1. when both j and i is defined as genvar, than increment done in point 1 is not valid one, as we cannot update genvar inside the generate block.
or
case2 . if I take j as int than increment done in point 1 is valid but it throw error at if statement saying that it should elaboration time constant.
but cant even add initial begin becz I have interface in my code which I want it to work with generate loop.
So please suggest the way I can increment the if loop.
`num 3;
module abc
genvar j,var,i;
generate
begin: up
for(j=0;j<2*`num;j++) begin:inst
interface cond(clk,rst);
assign cond.cmd=value;
for(i=j;i<=j;i++)begin: block
if(i<`num)begin
interface cond(clk,rst);
assign cond.cmddd=value;
end
end
end
end
endgenerate
inteface xyz;
inital begin
for(int a=0;a<`num;a++)begin inst_val
up.inst[a].obj=new();
if(a<`num-`val)begin
up.inst[a].obj_ip=new();
end
end
end
endmodule
over here at pt1 facing error [XMRE]cross module refernce resolution…how to solve this error.Tried to change the hierarchy of generate block but still facing the same issue.
num 3; module abc genvar j,var,i; generate begin: up for(j=0;j<2*num;j++) begin:inst
interface cond(clk,rst);
containet #(virtual interface) obj_ds;
assign cond.cmd=value;
for(i=j;i<=j;i++)begin: block
if(i<`num)begin
interface cond(clk,rst);
containet #(virtual interface) obj_us;
assign cond.cmddd=value;
end
end
end
end
endgenerate
inteface xyz;
inital begin
for(int a=0;a<num;a++)begin inst_val up.inst[a].obj_ds=new(); if(a<num-`val)begin
up.inst[a].obj_us=new();
end
end
end
endmodule
To be more presice please see above code . Here i am facing cross modulation error
`define num 3
`define val 2
interface intf();
int a;
endinterface : intf
module abc();
class containet;
endclass : containet
genvar j,i;
generate
begin: up
for(j=0;j<2*`num;j++) begin:inst
containet obj_ds;
intf ivf();
for(i=j;i<=j;i++)begin: block
if(i<`num) begin : block_if // Here give name to if block
intf ivf1();
containet obj_us;
end
end
end
end
endgenerate
genvar a;
generate
for(a=0;a<`num;a++)begin
initial begin
up.inst[a].obj_ds=new();
if(a<`num-`val)begin
up.inst[a].block[a].block_if.obj_us = new(); // Here , use proper hierarchical name.
end
end
end
endgenerate
endmodule
Its illegal to use ‘int a’ variable for generate block array. You have to use generate block array inside generate block using genvar type.