Hi All,
A small clarification, where does memory gets created for the following process.
Because memory are basically into stack , heap memory.
→ For object allocation the tool is going to use the heap memory.
→ For initialized variables and static variables the tool is going to use the stack memory.
→ For recursive functions and re-entrant task what type of memory is been used by the tool??
Kindly let me know the same and as well correct me if I am wrong.
Thanks,
Desperado → “Basics always important for mighty works”
It isn’t really that simple, nor is it necessarily the same in any implementation. There are some aspects of memory lifetime that are peculiar in SV. For example, what one would normally consider a “stack” variable in C (a local in a subprogram) can actually outlive the frame of the call in SV due to fork…join_none blocks. As another example, a deep (possibly recursive) task call can suspend a process; the recursive state must be retained for an arbitrary time.
Such issues don’t allow one to easily map SV code into what you would expect in C code. Since the details of what really happens are implementation dependent, I won’t comment on those details.
HI gordonv,
I am asking the above things completely from the SV point of perspective. It would be good if you discusses some of the outline involving in the memory creation of these process.
Thanks,
Desperado
Desperado,
Verilog/SystemVerilog is unlike C/C++ in that it was designed so that the user is completely unaware of the platform or implementation it is running on. The kinds of questions you are asking would only be relevant to a developer of simulation tool.
Dave
Hi Dave,
Very true on from your side, but as since we daily work thorough these tools, just curious to know how does the memory gets created & where when such process takes like I had mentioned above! Kindly brief me out!!
Thanks For all your replies,
Desperado → “Salutes people helping out”
I suggest you read the LRM Section 6.21 Scope and Lifetime and then read http://www.gnu.org/s/libc/manual/html_node/Memory-Allocation-and-C.html. An SV class object is dynamically allocated when you call its constructor. However the class handle variable that holds the reference the the object could be static or automatic. A queue or dynamic array variable could also be declared with a static or automatic lifetime, but elements of that variable are dynamically allocated.
If you already understand the difference between the stack and heap memory allocation, you might think of automatic variables as stack allocated and dynamic variables as heap allocated. But as gordonv mentioned earlier, and my example of a queue, it may not be actually implemented that way by the simulator.