Jump to content

waiting for a resource in a method


Phani Karthik

Recommended Posts

Hi All,

Greetings.

Iam new to systemC and Iam stuck in a scenario while using methods and want the community's help kindly.

Basically My scenario is like the one snap i have attached.

Iam deep inside a call stack of methods and at one point I will check if a resource (timer in this case) is available.

Now If I was using a thread here, I would have used WAIT() for an event that informs that timers are available now.

But since iam inside method, I cannot wait here nor loop here waiting for the resource.

Can you please help suggest how should I handle this scenario? 

What I tried:

a) If i return back from the inner check, then nce the timer is available, will not be able to 

    come back to the same point as no context will be saved.

b) I cannot do a busy wait as simulation time will not proceed.(Timers will never be available)

 

PS: Iam only allowed to systemc method (and NOT a thread).

 

Thanks & Regards,

Phani

image.thumb.png.43d00af5b1e5d2e3d052b9a46bcd6216.png

 

 

 

Link to comment
Share on other sites

Why use SC_METHOD instead of SC_THREAD?

If your answer is performance, you are very likely committing the sin of premature optimization. The overhead of SC_THREAD is very minimal (a few percentage points), and the benefit of easier coding is very high. SystemC is as much about faster coding as it is about high-performance models.

Anything you can do in SC_THREAD can be accomplished in SC_METHOD, but with a complexity cost (i.e., increased development time and the likelihood of bugs). You could use next_trigger( time); return, and add some state to your code in order to resume at the proper point.

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...