PDA

View Full Version : Can we write verilog events in the member functions of a class?



vikassinghal21
01-16-2008, 05:18 AM
In the file src/base/ovm_event.sv, events are used in the member function of class ovm_event and I think, this is a non LRM compliant functionality (atleast according to the definition of verilog). I searched the system verilog LRM but didn't find anything related to this.

Example (from ovm_event.sv):

function void ovm_event::trigger (ovm_object data=null);
int skip;
skip=0;
if (this.callbacks.size()) begin
for (int i=0;i<callbacks.size();i++) begin="">
ovm_event_callback tmp;
tmp=this.callbacks[i];
skip = skip + tmp.pre_trigger(this,data);
end
end
if (skip==0) begin
->m_event;
if (this.callbacks.size()) begin
for (int i=0;i<this.callbacks.size();i++) begin="">
ovm_event_callback tmp;
tmp=this.callbacks[i];
tmp.post_trigger(this,data);
end
end
this.num_waiters = 0;
this.on = 1;
this.trigger_time = $time;
this.trigger_data = data;
end
//return 1; no timeout yet, so don't need
endfunction<callbacks.size();i++) begin=""><this.callbacks.size();i++) begin=""><callbacks.size();i++) begin=""><this.callbacks.size();i++) begin="">

The same functionality is used at various places in OVM-1.0.</this.callbacks.size();i++)></callbacks.size();i++)></this.callbacks.size();i++)></callbacks.size();i++)></this.callbacks.size();i++)></callbacks.size();i++)>

jgg
01-16-2008, 11:03 AM
Do you mean the event_trigger expression (->m_event)?

The SV BNF certainly allows this statement within a function context. The production is:

function_body_declaration
function_statement_or_null
function_statement
statement
statement_item
event_trigger

dlong
01-16-2008, 11:30 AM
Unfortunately, the BNF in the SystemVerilog LRM is not always consistent.

Personally I think it makes sense to trigger an event within a class method but I suspect vikassinghal21 has probably looked at clause 13.4 where point d) says "a function shall not have any event triggers".

Regards,
Dave
============
David Long
Doulos
http://www.doulos.com

dave_59
01-16-2008, 12:53 PM
Unfortunately, the BNF in the SystemVerilog LRM is not always consistent.

Personally I think it makes sense to trigger an event within a class method but I suspect vikassinghal21 has probably looked at clause 13.4 where point d) says "a function shall not have any event triggers".

Regards,
Dave
============
David Long
Doulos
http://www.doulos.com

The same enhancement (http://www.eda-stds.org/svdb/view.php?id=1336) that allows fork/join_none in a function also allows event triggers in a function.

Dave