Jump to content

What are two very different contexts?


Recommended Posts

On the page 131 In SV-2009, there is a passage described as follow:

SystemVerilog provides a mechanism for initializing an instance at the time the object is created. When an object is created, for example,

Packet p = new;

The system executes the new function associated with the class:

class Packet;

integer command;

function new();

command = IDLE;

endfunction

endclass

As show new is now being used in two very different contexts with very different semantics.

Would everyone like to tell me which are two very different contexts?

Thanks a lot inadvance!

Edited by qhl0222_cn
Link to comment
Share on other sites

The text is just referring to the fact that 'new' is not just an ordinary function method, it does two entirely different things at once:

(context 1) when you 'call' it, it acts as an R-value of an expression, appearing to act like a static function method which 'returns' a handle for the new object. It's role appears to be just 'allocate some memory and return a handle'

(context 2) but under the hood, the object is created FIRST by the simulator and then the new() method is called with that object as 'context'. The role here is to set up the initial dynamic state of the new object, including that of its superclass hierarchy if any.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...