qinhailiang Posted June 3, 2011 Report Share Posted June 3, 2011 (edited) 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 June 3, 2011 by qhl0222_cn Quote Link to comment Share on other sites More sharing options...
gordon Posted June 3, 2011 Report Share Posted June 3, 2011 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. Quote Link to comment Share on other sites More sharing options...
qinhailiang Posted June 4, 2011 Author Report Share Posted June 4, 2011 thanks a lot for your reply!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.