RE: [sv-ec] FW: [sv-bc] query about semaphore

From: Rich, Dave <Dave_Rich_at_.....>
Date: Mon Aug 14 2006 - 08:23:23 PDT
Soumya,

In general, anytime the base class has new function with arguments, the
extended class will also need a new function with arguments and call
super.new.

An implicit new function with no arguments is created for every class
and every extended class. If you want your argument (-11) to be passed
to the semaphore base class's new function, then you have to both define
a new function with an argument, and pass that argument to super.new.
i.e.

function new (int k = 0;
super.new(k);
endfunction


If you had called new without any arguments, then the base new function
will be called using its default argument value 0.

Dave




> -----Original Message-----
> From: owner-sv-ec@server.eda-stds.org [mailto:owner-sv-ec@server.eda-
> stds.org] On Behalf Of Bresticker, Shalom
> Sent: Monday, August 14, 2006 1:57 AM
> To: sv-ec@server.eda-stds.org
> Cc: Soumya Jyoti Wadader
> Subject: [sv-ec] FW: [sv-bc] quary about semaphore
> 
> Forwarding to sv-ec
> 
> -----Original Message-----
> From: owner-sv-bc@server.eda-stds.org
> [mailto:owner-sv-bc@server.eda-stds.org] On Behalf Of Soumya Jyoti
> Wadader
> Sent: Monday, August 14, 2006 10:05 AM
> To: sv-bc@server.eda.org
> Subject: [sv-bc] quary about semaphore
> 
> Hi,
> I have query regarding the following testcase::
> 
> module semaphore16 (input [7:0] in1,in2, output reg [7:0]
> out1,out2,out3,out4);
> class semaExtend extends semaphore;
> real r;
> shortreal sr;
> time t;
> function bit [1:0] func(input reg [15:0] rg);
> r = rg;
> sr = rg;
> t = rg;
> func = ++rg;
> endfunction
> endclass
> semaExtend p = new(-11);
> always @(in1,in2)
> begin
>   out1 = p.func(in1^in2);
>   out2 = p.r;
>   out3 = p.sr;
>   out4 = p.t;
> end
> endmodule
> Is it necessary to define new() method : function new (int keycount =
> 0);
> 
> super.new(keycount);
> 
> endfunction
> in derived class.
> 
> Thanx
> Soumya
Received on Mon Aug 14 08:23:34 2006

This archive was generated by hypermail 2.1.8 : Mon Aug 14 2006 - 08:23:44 PDT