{"id":48,"date":"2009-09-11T23:08:33","date_gmt":"2009-09-12T06:08:33","guid":{"rendered":"https:\/\/blogs.mentor.com\/nosimulation\/?p=48"},"modified":"2026-03-27T08:51:37","modified_gmt":"2026-03-27T12:51:37","slug":"sv-coding-guidelines","status":"publish","type":"post","link":"https:\/\/blogs.sw.siemens.com\/verificationhorizons\/2009\/09\/11\/sv-coding-guidelines\/","title":{"rendered":"SystemVerilog Coding Guidelines"},"content":{"rendered":"<p>I have lots of blog entries about 95% ready to publish. This entry is from an e-mail I wrote a few months ago when somebody asked about SystemVerilog coding guidelines. I thought it would make a good article. It\u2019s been sitting as a draft because I always have trouble finding the right title or opening words to catch people&#8217;s attention. I couldn\u2019t come up with anything better, so here it is: <em><a href=\"https:\/\/verificationacademy.com\/cookbook\/sv\/guidelines\" target=\"_blank\" rel=\"noopener\">SystemVerilog Coding Guidelines<\/a>.<\/em><\/p>\n<p>My official position about this is that you pick a style and stick to it.<\/p>\n<p>Which style you pick is far less important than developing the required culture that will follow it. People can spend hours arguing over the merits of camelCaps versus under_score, but once the decision is made, people on the project need to document it, adhere to it, and police it. Otherwise you\u2019re just wasting everyone\u2019s time.<\/p>\n<p>Why are coding guidelines so important? So someone else can read your code, or maybe you can read your own code six months after you wrote it. Good comments and documentation are an import part, but you still need to be able to <strong>read the code<\/strong>.<\/p>\n<p>This concept of reading someone else\u2019s code without understanding the underlying conventions reminds me of the classic short article &#8220;<a href=\"http:\/\/www.ecphorizer.com\/EPS\/site_page.php?issue=7&amp;page=29\" target=\"_blank\" rel=\"noopener\">Meihem In Ce Klasrum<\/a>\u201d by Dolton Edwards. The article was written as a satirical response to George Bernhard Shaw&#8217;s final wishes to simplify the English language. See how easy the last paragraph is to read once you understand the new writing conventions. Reading your code should be just like that (although not as cryptic).<\/p>\n<p>My advice would be to pick a style from industry and adapt it to fit SystemVerilog. For example, from Google: <a href=\"http:\/\/google-styleguide.googlecode.com\/svn\/trunk\/cppguide.xml\" target=\"_blank\" rel=\"noopener\">http:\/\/google-styleguide.googlecode.com\/svn\/trunk\/cppguide.xml<\/a> or from the Free Software Foundation: <a href=\"http:\/\/www.gnu.org\/prep\/standards\/\" target=\"_blank\" rel=\"noopener\">http:\/\/www.gnu.org\/prep\/standards\/<\/a><\/p>\n<p>All of these rules for naming conventions, indentation, and file organization still apply to SystemVerilog. Additional rules would be for unsupported constructs, which should be in the release notes for the tool(s) you are using. Finally, there are a few constructs to avoid, like <a href=\"https:\/\/blogs.sw.siemens.com\/verificationhorizons\/2009\/05\/07\/programblocks\/\">program blocks<\/a> and wildcard indexes for associative arrays, most of which might be worth hours of debate, each.<\/p>\n<p>Dave Rich<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have lots of blog entries about 95% ready to publish. This entry is from an e-mail I wrote a&#8230;<\/p>\n","protected":false},"author":71589,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spanish_translation":"","french_translation":"","german_translation":"","italian_translation":"","polish_translation":"","japanese_translation":"","chinese_translation":"","footnotes":""},"categories":[1],"tags":[690,751,819],"industry":[],"product":[],"coauthors":[979],"class_list":["post-48","post","type-post","status-publish","format-standard","hentry","category-news","tag-rtl","tag-systemverilog","tag-verification"],"_links":{"self":[{"href":"https:\/\/blogs.sw.siemens.com\/verificationhorizons\/wp-json\/wp\/v2\/posts\/48","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.sw.siemens.com\/verificationhorizons\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.sw.siemens.com\/verificationhorizons\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/verificationhorizons\/wp-json\/wp\/v2\/users\/71589"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/verificationhorizons\/wp-json\/wp\/v2\/comments?post=48"}],"version-history":[{"count":1,"href":"https:\/\/blogs.sw.siemens.com\/verificationhorizons\/wp-json\/wp\/v2\/posts\/48\/revisions"}],"predecessor-version":[{"id":18357,"href":"https:\/\/blogs.sw.siemens.com\/verificationhorizons\/wp-json\/wp\/v2\/posts\/48\/revisions\/18357"}],"wp:attachment":[{"href":"https:\/\/blogs.sw.siemens.com\/verificationhorizons\/wp-json\/wp\/v2\/media?parent=48"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/verificationhorizons\/wp-json\/wp\/v2\/categories?post=48"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/verificationhorizons\/wp-json\/wp\/v2\/tags?post=48"},{"taxonomy":"industry","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/verificationhorizons\/wp-json\/wp\/v2\/industry?post=48"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/verificationhorizons\/wp-json\/wp\/v2\/product?post=48"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/verificationhorizons\/wp-json\/wp\/v2\/coauthors?post=48"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}