Please format your code with markdown or <code> </code> tags

See Formatting in Posts

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

class packet;
   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] 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 markdown your code between ``` tags 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
```

Markdown automatically detects which programming language your code is written in and highlights the syntax. You can force the language selection by putting the language name wight after the ```

```verilog
```vhdl
```text

Note that Verilog is also used for SystemVerilog.

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.