Jump to content

communication between SystemC module and C++ code


bailin7134
 Share

Recommended Posts

Hi there,

I am right now trying to implement a SystemC module so that I can call it from my c++ code. It seems there are two methods:

1. directly instantiate the SystemC module and using sc_start() to run it.

2. using socket that SystemC module and C++ code can transmit message between each other.

I tried to do something as attach figure shows, but it seems sc_main() is a must to run SystemC module. So could you please supply a simple example to show how can I achieve this goal?

 

Best regards,

Lin

Screenshot from 2022-02-04 12-58-50.png

Link to comment
Share on other sites

6 hours ago, DavidC said:

I'm not entirely sure if I understand your specific goal (beyond running your testbench, that is).

But if you simply rename your

int main(void)

with

int sc_main(int argc, char *argv[])

then at least it should start doing something !

Hi thank you for the reply. I understand if using sc_main, the code works. But what I want to do is calling the SystemC module from my c++ program. Suppose I have a c++ function. Inside of it, I want to instantiate systemC module and run it. Hope this explanation is clear.

Link to comment
Share on other sites

Before calling any of the SystemC stuf you need to initialize the SystemC kernel. This is done in the main function provided by the reference simulation and this main in turn calls the user provided sc_main function. Since3 sc_main is a C++ function you can move all your C++ code here without any hassle. If you need to provide a main function with your code for whatever reason you need to implement something like this: https://github.com/accellera-official/systemc/blob/master/src/sysc/kernel/sc_main_main.cpp

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.

 Share

×
×
  • Create New...