Please format your code with [code] and [/code] tags or [systemverilog] and [/systemverilog]

**Note** This post applies to the old forums. Now, Please use the format buttons available at the top of the edit box

Your source code will be much easier to read when it is formatted nice and pretty like this:

class packet;
   rand bit [31:0] data;
   rand bit [31:0] address;
   rand bit [7:0]  length;
   rand bit [7:0]  data[];

   constraint max_length {
      length == data.size();
   }
endclass: packet

instead of:

class packet;
   rand bit [31:0] data;
   rand bit [31:0] address;
   rand bit [7:0]  length;
   rand bit [7:0]  data[];

   constraint max_length {
      length == data.size();
   }
endclass: packet

All you have to do is embed your code between [code] and [/code] tags, like this: (or use the <> button above the text input form)

class packet;
   rand bit [31:0] data;
   rand bit [31:0] address;
   rand bit [7:0]  length;
   rand bit [7:0]  data[];

   constraint max_length {
      length == data.size();
   }
endclass: packet

You can also get syntax highlighting with tags [systemverilog] and [/systemverilog]

class packet;
   rand bit [31:0] data;
   rand bit [31:0] address;
   rand bit [7:0]  length;
   rand bit [7:0]  data[];

   constraint max_length {
      length == data.size();
   }
endclass: packet

You can also select the text you want to codify first, then click the <> button on the toolbar above the text editing pane.

Dave,
This tag looks awesome along with highlight.

Is there any plugin for VI editor/ nedit to format the code, do you aware of?

There is vim file to highlight the syntax.

John

In reply to John Verif:

I know there are a number of browser plug-ins to add the tags. I’m not aware of anything specific for VI.

In reply to vishnuprasanth:

Why don’t we have our own editors which helps us to write our verification code?

since we move-in in the direction of software, why don’t we have editor which helps us on syntax and formatting.

Letz says, in JAVA developers have editors (which has intelligence), which brings the skeleton of the code and gives suggestions on syntax and highlights the errors when during coding itself.

We are not lesser than software developers. We are writing codes more than designers do.

Even vendors are not concentrating on this.

John

In reply to John Verif:

Mentor has tools that help you write and analyze your verification source code. It understands class inheritance and has template generators to help you write your code (e.g. adds the proper constructors and factory registration to your o/uvm_objects and phase methods to your o/uvm_components). There are a number of tools available from other vendors to help you write your code.

Formatting code for posting in a web forum is a different issue. What I usually do is write the code in an editor that formats the code for me, copy&paste it into the post composing text box, then mark that as a code block using the little <> icon above the text box.