Jump to content

How SystemC kernel is implemented !!


ANKUR SAINI

Recommended Posts

I have recently going through an online document centered on - "multi-threading of SystemC scheduler". Though I couldn't able to figure out the topic itself for initial time, but definitely it raised up lot of curiosity inside me to read it. While reading, there was a statement - "Single threaded simulation kernel inherent to SystemC prevents it from utilizing the computing power of multi-CPU machines to speed up the simulation."

I would like to understand what it means by single threaded simulation kernel.

Link to comment
Share on other sites

You should probably read a book about multi-threaded programming to understand what thread means. A good book about standard C++ threads is C++ Concurrency in Action by Anthony Williams

SystemC is indeed a single thread. Most of other cycle-accurate (RTL) and TLM simulators are also single-threaded. In theory, you can write a parallel scheduler that can utilize multiple HW threads to evaluate a single delta-cycle (because SystemC standard does not restrict the order of process evaluation inside delta cycle) . However, amount of work performed in a single delta cycle is usually small, so instead of speedup you will get a slow down.

To utilize power of multicore CPUs you should parallelize your test environment. Instead of running multiple tests sequentially in a single simulator, you can run different tests in parallel on different simulators. Personally, I integrate my tests with CTest : https://cmake.org/cmake/help/latest/manual/ctest.1.html  and then run in parallel simply by specifying number processes I want to utilize, for example "ctest -j 8"

Link to comment
Share on other sites

@Roman Popov: Thanks for the information.. Appreciate that..

I got your point that SystemC is basically running as single thread only on my OS. But how exactly SystemC threads are modeled then ?
Also, what is the significance of sc_simcontext() in SystemC. What it means by having multiple contexts in a simulation. I know I am little confused with all these terms, but that's why I need some clarification on these..

Link to comment
Share on other sites

8 hours ago, ANKUR SAINI said:

But how exactly SystemC threads are modeled then ?
Also, what is the significance of sc_simcontext() in SystemC. What it means by having multiple contexts in a simulation. 

SC_THREADS are coroutines https://en.wikipedia.org/wiki/Coroutine. SystemC uses different coroutines implementations depending on platform (Fibers, QuickThreads..).

Function of sc_simcontext is not standartized. But in open-source SystemC it contains main simulator loop.

Link to comment
Share on other sites

If you are interested in the elaboration and simulation semantics of SystemC, have a look to clause 4 of IEEE Std 1666-2011. The simulation semantics are based on the discrete-event model of computation and employ the concept of delta cycles to achieve determinism of the simulation results. This is very close to other hardware description languages such as VHDL. Using your favourite search engine, you can find additional information such as the following two tutorials:

which give a brief summary of these semantics and the core ideas of SystemC. Though, please take into account that both tutorials are 10+ years old, which means that certain aspects have evolved considerably. For a good introduction to SystemC, I suggest that you read a good book on the topic, such as "SystemC from the Ground Up" by David Black et al. To efficiently use SystemC, you have to master the core concepts of C++ first.

Link to comment
Share on other sites

Regarding sc_simcontext, this class is not part of IEEE Std 1666-2011! It is an implementation artefact, which should not concern you as a user. The proof-of-concept implementation uses it for house-keeping and managing the global state of the simulation kernel.

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