Jump to content

Wondering about SystemC coding conventions


richpodraza

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!

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

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...