Jump to content

What happens in SC_HAS_PROCESS()?


Recommended Posts

I have three files:


#ifndef hello_h
#define hello_h
#include <systemc.h>

  Hello(sc_core::sc_module_name nm); //< Constructor
  void end_of_elaboration(void); //< Processes
  void Hello_thread(void); //< Processes
  virtual ~Hello(); //< Destructor


#include "hello.h"
#include <systemc.h>

using namespace std;
using namespace sc_core;

// Constructor <<
Hello::Hello(sc_module_name nm)
: sc_module(nm)
  cout << "Constructing "
       << name() << endl;

void Hello::end_of_elaboration(void) { //< callback
  cout << "End of elaboration" << endl;

void Hello::Hello_thread(void) { //< Process
  cout << "Hello World!" << endl;

Hello::~Hello() { //< Destructor
  cout << "Destroy " << name() << endl;


#include "hello.h"
#include <iostream>

using namespace std;
using namespace sc_core;

int sc_main(int argc, char *argv[]) 
  Hello top_i("top_i");
  cout << "Starting" << endl;
  cout << "Exiting" << endl;
  return 0;
}//end main

When I run them using


g++    -c -o main.o main.cc
g++    -c -o hello.o hello.cc
cc -o hello main.o hello.o -lsystemc -lstdc++ -lm

I got this output:


Constructing top_i
End of elaboration
Hello World!
Destroy top_i

I wonder how is the "end_of_elaboration" and what does the SC_HAS_PROCESS() does. I have tried to Google it but it seems like there is no any helpful answer.


Thank you.

Link to comment
Share on other sites

You should consult the language reference manual IEEE1666-2011. It is explaned there...

SC_HAS_PROCESS declares that the module has some processes  - essential it defines a name to be use later.

end_of_elaboration is one of the simulation phases. The simulation kernel calls this function for each module to allow some setup, initialization and alike before starting a simulation. There are more of them, you will find the declaration in include/sysc/kernel/sc_module.h of your SystemC installation

Link to comment
Share on other sites

To add a bit more to @Eyck:

SC_THREAD specifies the type and name of your SystemC process, but requires SC_HAS_PROCESS to provide a critical bit of information.

Alternately, you could have replaced those two lines with:

sc_core::sc_spawn( std::bind(&Hello::Hello_thread,this) );

For SC_METHOD style processes, the answer is similar, but more complicated when using sc_spawn.

Last, I recommend against include "systemc.h". You are better off using <systemc>.

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.

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