Jump to content

Error when initiating a transaction indirectly from a C source file


Recommended Posts


I'm implemented a small virtual prototype using SystemC. The CPU model of my system is very simple and only has a function read and a function to write to a memory mapped address. I need to be able to call this functions from a C file, not a C++ file. Hoewver, when trying to do this and compile everything together I get an error: 

/cad/gnu/gcc/systemc-2.3.1/include/sysc/packages/boost/config/select_stdlib_config.hpp:20:19: fatal error: utility: No such file or directory
 #include <utility>
compilation terminated.
make[2]: *** [prj/CMakeFiles/mpslvp.x.dir/src/mpslvp/c_test.c.o] Error 1
make[1]: *** [prj/CMakeFiles/mpslvp.x.dir/all] Error 2
make: *** [all] Error 2

The problem has to do with the fact that my C file includes the header file of the CPU module which of course includes the systemc library. When removing the systemc dependencies, the code compiles. Is it possible to have a C file implementing functions that indirectly start a SystemC transaction? Hope I explained myself. Thanks in advance!

Link to comment
Share on other sites

If you separate application code and read/write implementation code, you can keep your C code application and compile it still for your CPU module. Yes, you will need a C++ compiler then, but it also allows you to port your application to e.g. a commercial CPU model which could use plain C. You'd only need to replace your read/write C++ implementation with a C implementation.

// C header file
#ifndef C_H
#define C_H
#ifdef __cplusplus
extern "C"
#endif /* __cplusplus */
void mywrite(uint32_t address, uint32_t value);
void myread (uint32_t address, uint32_t *value);
#ifdef __cplusplus
#endif /* __cplusplus */
#endif /* C_H */


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