Now that we have understood what System Verilog is used for, let's dive into more details. I am making a modest assumption that you are familiar with verilog

// This is a one-line comment
/* This is a multiple line comment. 
As you can see, since this line is within the block comment symbols, it is a comment.
/* Another multiple line comment
// A nested one-line comment inside a block comment is fine.
But a block comment cannot be nested in another block comment.

Following are the four states that an element/net can hold

0 Logic state 0 - element/net is at 0 volts
1 Logic state 1 - element/net is at some value > 0.7 volts
x or X Logic state X - element/net has either 0/1 - we just don't know
z or Z Logic state Z - net has high impedence - maybe the wire is not connected and is floating

A variable can be assigned values in the following ways

'0, '1, 'X, 'x, 'Z, 'z      // sets all bits to this value
reg      flag;
reg [3:0]    errorValue;
flag      = 'X;           // sets to value "x"
errorValue   = '1;           // sets to value "1111" since there are 4 bits
Sets fixed point format. eg 2.8 or exponent format (eg 7.2e6)
real    pi   = 3.145;      // sets to 3.145
real   mega = 1e6;        // sets to 1000000.0
0.3ns, 20ps // time is written followed without a space by a time unit (fs ps ns us ms s)
$display ("New York is an awesome place.\
So much of energy and vibrancy.");
// New York is an awesome place.So much of energy and vibrancy.
$display ("New York is an awesome place.\n\
So much of energy and vibrancy.");
// New York is an awesome place.
// So much of energy and vibrancy.
// To store a string literal in an integral type, each character will require 8 bits
byte     myLetter   = "D";         
bit [7:0]   myNewLine   = "\n";
// Need space for 17 characters, each character will occupy 8-bits
bit [8*17:1] myMessage  = "Hello ChipVerify\n";   
\n Newline - whatever is printed next will be on a new line
\t Tab - jumps a predefined number of spaces to the right
\\ \ character
\" " character
// format [q, q, q] 
//        [q, q, q] 
int a[1:2][1:3] = '{'{0,1,2}, '{3{4}}};
typedef struct {
  int   coins;
  real   dollars;
} s_money;
s_money wallet;
wallet = '{5, 19.75};                       // assign direct values to a structure variable
wallet = '{coins:5, dollars:19.75};         // assign values using member names
wallet = '{default:0};                      // assign all elements of structure to 0
wallet = s_money'{int:1, dollars:2};        // assign default values to all members of that type
struct {
  int  A, B, C;
} ABC = '{3{1}};               // A = B = C = 1
// Assigning an array of structures
s_money purse [1:0] = '{'{2, 4.25}, '{7,1.5}};
Continue to Data Types

Was this article helpful ?