Quick Verilog Guide
Quick Verilog Guide
Binary operator:
It consists of single operator and two operands
Ex: a&b;
Ternary operator:
It consists of multiple operators and multiple operands
Ex: a+b+c+d+e;
6. Strings :
It stores the ASCII values inside it. String is represented in between
double quotes ("")
Ex: "a=%b,b=%b,c=%b"
7. white space:
Used to create new line, space etc
Data types in Verilog
Net data types
Variable data types
Constant:
It stores the constant values which can never be changed
Integer:
It will store integer values. It is a 32 bit general purpose register. It is
declared by int keyword
Ex: int count;
Time:
It stores the time of the data
Arrays:
Array is a data structure that allows multiple data elements of the same
data type into a single collection.
Compiler directives and system tasks
Compiler directives:
Used to specify certain information and asks compiler to process it.
'define – used to define text macros
'include – used to include all the files into existing Verilog file
'ifdef, 'endif, 'else, 'endif – conditional compiler directives
which behaves as conditions
statements
'timescale – to specify time units
System tasks in Verilog:
The system tasks in Verilog performs the operations like terminating
simulation, displaying messages, generating numbers etc.,
$display:
It is used to display the statement during the simulation.
$monitor:
It is used to monitor the variables and display the statement whenever
the variables changes the values.
$strobe:
$strobe is similar to $monitor but only active for the time duration
specified.
$time:
Returns the current simulation time.
$finish:
Terminates the simulation.
$stop:
Stops the simulation until manually resumed.
Levels of Abstraction
In Verilog, there are 5 levels of abstraction
• Data flow modeling
• Gate level modeling
• Structural modeling
• Behavioral modeling
• Switch level modeling
Data flow modeling
• In data flow modeling, the code will be written by using the output expression of the
circuit.
• "assign" keyword is used in data flow modeling
Replication operator:
Replication operator is used to replicate the value n number of
times. It is represented by "{{}}"
Arithmetic operator:
It performs arithmetic operations such as addition, subtraction,
multiplication etc.,
Relational operator:
Symbol Operation
35
Equality operator:
Symbol Operation
= Equal to
!= Not equal to
Negation operator:
In Verilog, the negation operator is represented by the
unary operator !. This operator is used to perform logical
negation on a single bit or a logical expression
Unary reduction operator:
Operator Description
& and
| or
^ xor
~& nand
~| nor
~^ or ^~ xnor
Shift operators:
>> -logical right shift
<< - logical left shift
>>> - arithmetic right shift
>>> - arithmetic left shift
Bitwise operator:
Operator Description
& and
| or
^ xor
~& nand
~| nor
~^ or ^~ xnor
Behavioral modeling
The sensitive list is the one that tells the always block when to execute
the block of code.
Verilog regions:
The Verilog regions are,
• Active region
• Inactive region
• NBA(non-blocking assignments)
• Postponed region
Active region:
The active region is used to hold current events being evaluated and
can be processed in any order.
Inactive region:
The inactive region holds the events to be evaluated after all the
active events are processed. An explicit zero delay (#0) requires that
the process be suspended and an event scheduled into the inactive
region of the current time slot so that the process can be resumed in
the next inactive to active iteration.
NBA:
Non-blocking Assignment Events region (NBA)The principal function
of this region is to execute the updates to the Left-Hand-Side (LHS)
variables that were scheduled in the Active region for all currently
executing nonblocking assignments.
Postponed region:
Also known as monitor region.
Verilog Display Tasks. $monitor prints out variable or expression
values whenever the variable or expression in its argument list
changes. So, at S0 state, nothing changes so you won't get it printed
unless you change code.