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

×
×
  • Create New...