PDA

View Full Version : Clocking Blocks inside Generate



nickcollins3
07-21-2009, 06:50 PM
This seems like it should be possible. Inside my interface, I have this code for multiple clocking blocks...



interface the_if;
localparam NUM = 16;

logic [NUM-1:0] targ_clk;
logic [NUM-1:0] targ_rst_n;
logic [NUM-1:0] targ_sig;

generate
for (genvar N = 0; N < NUM; N++) begin : CB_GEN
clocking targ_cb @(posedge targ_clk[N]);
default input #1step output #2ps;
output targ_rst_n = targ_rst_n[N];
inout targ_sig = targ_sig[N];
endclocking
end
endgenerate

Then in my driver that is connected to this virtual interface, I have:



the_if.CB_GEN[id].targ_cb.targ_rst_n <= 1'b0;


Here, "id" is an integer in the class and is within range. I don't understand why VCS chokes and says it cannot find CB_GEN for the line above. Could this be a VCS issue?

priya
09-02-2009, 04:32 AM
The correct usage of the code is given below, hope it solves your issue......



interface the_if;
localparam NUM = 16;

logic [NUM-1:0] targ_clk;
logic [NUM-1:0] targ_rst_n;
logic [NUM-1:0] targ_sig;

generate
for (genvar N = 0; N < NUM; N++) begin : CB_GEN
clocking targ_cb @(posedge targ_clk[N]);
default input #1step output #2ps;
output targ_rst_n = targ_rst_n[N];
inout targ_sig = targ_sig[N];
endclocking
end
endgenerate

endinterface

module mod; //(interface intf);
the_if I();

class cls#(int id = 10);
// int id = 10;
task t;
the_if.CB_GEN[id].targ_cb.targ_rst_n <= 1'b0;
endtask
endclass

cls c = new;

initial
c.t;
endmodule




-----------------------------------
Regards
Priya dev

nickcollins3
04-05-2010, 03:54 PM
Hi, Priya. I did not see much difference in your code from what I originally posted. I still get the same error:

Doing common elaboration
.
Error-[MFNF] Member not found
monitor.sv, 143
"this.u_the_intf."
Could not find member 'CB_GEN' in interface
'TB_LIB.the_intf_0000', at
"/the_intf.sv", 21.
1 error
common elaboration failed

dave_59
04-05-2010, 04:14 PM
Nick,

You cannot dynamically index into the scopes created by a generate loop in Veriog/SystemVerilog. What you can do is use generate to create an array of interfaces and assign each interface instance to an element of an array of virtual interfaces. Then you can dynamic index the virtual interface array.

Dave