Jump to content
Sign in to follow this  
richpodraza

Wondering about SystemC coding conventions

Recommended Posts

I am wondering if there is a preferred (official or unofficial) coding and style convention in the SystemC community? I'm talking about things like variable and class names, member data prefixes, function parameter prefixes, automatic variable prefixes, etc. If there is no consensus feel free to comment on YOUR favorite!

Share this post


Link to post
Share on other sites

There is no "SystemC" standard. Remember that SystemC is really just a C++ library (API). Using a common C++ coding standard of which there are several (e.g. JSF) is a good place to start. Here are a few ideas:

  • Indentation (a hotly debated topic) - I prefer two spaces. Look for tools support to automate this aspect.
  • Variable names should not be abbreviated, but rather use lowercase and separate words with underscore.
  • Classes should start with Uppercase letter.
  • Member data other than channels/sockets, should be prefixed with m_.
  • Class static variables should be prefixed with s_.
  • Suffixes should indicate process types (i.e. _thread, _method, _cthread), channels (_channel), events (_event), ports/sockets (_port/_socket).

 

More importantly, if you are going to use a standard, there should be a tool that can help enforce/code.

 

WARNING: You might want to avoid any standard suggesting leading underscores and a few other things. See the following Stack Overflow article for a discussion of this <http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-a-c-identifier>.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×