Verilog
Verilog
1) What is Verilog?
Verilog is a Hardware Description Language (HDL) used for describing a digital system
such as a network switch, a microprocessor, a memory, or a flip-flop. Verilog is mainly
used to verify analog circuits, mixed-signal circuits, and the design of genetic circuits. It
is also used in the design and verification of digital circuits at the register-transfer level
of abstraction.
○ Behavioral level
○ Register-transfer level
○ Gate level
Verilog was introduced by Prabhu Goel, Phil Moorby, Chi-Lai Huang, and Douglas
Warmke between late 1983 and early 1984.
VHDL is an acronym that stands for Very high-speed integrated circuit Hardware
Description Language. It is a programming language used to describe circuits in digital
systems and model the digital system by using dataflow, behavioral and structural style
of modeling.
VHDL is defined by IEEE standards and has mainly two common variants:
○ VHDL-1987
○ VHDL-1993
○ It is mainly used to design hardware and create test entities to verify the behavior
of that hardware.
○ It is used as a design entry format by various EDA tools, such as synthesis tools,
simulation tools, and formal verification tools.
Verilog and VHDL are not identical. They are different, and the main difference between
Verilog and VHDL is that Verilog is based on C language while VHDL is based on Ada
and Pascal languages.
Although both Verilog and VHDL are Hardware Description Languages (HDL) used to
describe digital system hardware such as microprocessors and flip-flops. These
languages are different from common programming languages. Let's compare them to
see the main differences between them:
Verilog VHDL
that is used to model electronic describe digital and mixed-signal systems such as
circuits.
in 1984. 1980.
language.
language.
hardware modeling but has a deterministic and more verbose than Verilog.
verbose as VHDL.
Verilog is more compact than In VHDL, you have to write more lines of code.
VHDL.
Verilog is weakly typed and VHDL is self-documenting and often catches
HDL simulators are software packages that are used to simulate expressions written in
one of the Hardware Description Languages, such as Verilog, VHDL, SystemVerilog.
There are two types of procedural assignment statements in Verilog known as blocking
and non-blocking. You can identify them as they use different assignment operators
represented by the symbols = and <=.
The Verilog full case statements are statements in which binary patterns of every
potential case expression can match either a case item or default. If your considered
case statement does not involve a case default and is likely to discover a binary case
expression that does not match any of the defined case items, the case statement
would not be considered full.
A parallel case statement is a statement where it matches a case expression, just one
case item. If you can find a case expression that would fit more than one case item, the
matching case items are called 'overlapping case items,' and the case statement would
be not parallel."
11) What are the main differences between Task and Function in
Verilog?
Functions Tasks
In Verilog, a function cannot enable a task; In Verilog, tasks can enable a function
functions. tasks.
A function cannot contain any event, delay, A task can contain any event, delay, or
statements.
A function can carry out its required duty in Tasks also run with a zero simulation.
zero simulation time because the program But if required, they can also be
routine. time.
At the time of the invocation of a function, it A task is allowed to use zero or more
Functions only return a single value and A task cannot return a value but can
cannot use either output or input pass multiple values via the output
The sensitivity list is used to specify that when you make changes in any one of the
elements in the list change, begin end statement inside that always will get executed.
14) What is the difference between == and === in Verilog?
== ===
In Verilog, the main difference between == and === On the other hand, the output
If you compare two numbers using == and if one or If you are comparing two
both the figures have one or more bits as X, then the numbers using ===, the output
== can only be used to compare 1s and 0s since it === can also be used to
The $monitor, $display, and $strobe are commands with similar syntax and show text
on the screen while running a simulation. These commands are typically less
convenient to use than waveform tools, such as cwaves. The $display and $strobe
command appear once each time you execute them, but the $monitor command is
used to display each time you change one of the parameters.
The main difference between the $display and the $strobe command is that the $strobe
command is used to display the parameters after the current simulation time unit. On
the other hand, the $display command displays the parameters when you execute it. In
these commands, the format sequence is similar to C/C++ and sometimes contains
format characters. The most commonly-used format characters are "%d" for decimal,
"%h" for hexadecimal, "%b" for binary, "%c" for character, "%s" for string, "%t" for time, and
"%m" for hierarchy level.
16) What is the difference between $monitor and $display?
The $monitor and $display are system functions or command and are used to see the
test bench results. Following is a list of some key differences between $monitor and
$display.
$monitor $display
The monitor is used to make changes in the value of the It is used to display the
The monitor command can be invoked only once. The display command can
once.
17) What are the main differences between Wire and Reg?
Wire Reg
Wire requires drivers to get output Reg does not need a driver to get output.
values.
The wire elements can only be used The reg elements can also be used for
We can use wire at the left-hand side We cannot use reg on the left-hand side of an
○ Evaluate the right-hand side of all non-blocking statements at the start of the
time step.
○ Update the left-hand side of all non-blocking statements after the time step.
A continuous assignment is used to drive values to the net. The left-hand side can be
scalar, vector net, or concatenation of both, while the right-hand side can be scalar or
vector net or register or concatenation of both.
20) What are the full case and parallel case statements?
Full case statement: The full case is a case statement in which all possible case
expressions can be matched with case items or case default.
Transport delay: Transport delay is a type of delay caused by the wires that connect to
the gates. Due to the wire's resistance and inductance, it delays the signal.
Inertial delay: The inertial delay is the time it takes for a gate to change its output.
○ Using the first method where all input decoders, present state, and output
decoder are combined in one process.
○ Using the second method where all combinational circuits and sequential circuits
are separated in a different process.
○ Using the third method, where input decoder and present state are combined, and
output decoder are separated in other processes.
○ Using the fourth method, all three input decoders, present state, and output
decoder are separated into three processes.
Yes. In a pure combinational circuit, it is necessary to mention all the inputs in the
sensitivity disk; otherwise, you will get a pre and post-synthesis mismatch in the result.
24) Which will be updated first between variable and signal?
The freeze, deposit, drive, and force are commands used in Verilog that can be defined
in the following way:
○ Freeze: The freeze command is used to put a value on the signal. This value
remains the same throughout the simulation and cannot be overwritten by
simulation.
○ Deposit: The deposit command is also used to value the signal, but it will hold
until it is overwritten. For example, if you deposit 0 to a flip flop, it will remain a '0'
until the simulation updates it to a new value. It is like giving an initial value to a
signal.
○ Drive: The drive command is used to put a value to a signal, and if it is updated
by simulation, it will then 'resolve' to a new value. For example, if you drive a
signal to '1', and the simulation value is '0', the signal will go 'X.'
○ Force: The force is a powerful Verilog command which you can use to drive
signals at any timestamp of your simulation.
The timescale directive is a compiler directive used to measure simulation time or delay
time. The timescale / reference_time_unit specifies the unit of measurement for times
and delays. The time_precision specifies the precision to which the delays are rounded
off.
In Verilog, the $setup and $hold are used to monitor the setup and hold time constraints
for sequential logic. The setup time is the minimum time in which the data must arrive
before the active edge of a clock signal. The hold time is the minimum time in which the
data cannot change after the active edge of a clock signal.
In Verilog, the easiest and efficient way to generate sine waves is using CORDIC
Algorithm.
The casex and casez are the types of case statements in Verilog. Here, casez treats all z
values in the case alternatives or the case expression as don't cares. All bit positions
with z can also be represented by ? in that position. casex treats all x and z values in the
case item or the case expression as don't cares. Don't cares are not allowed in the case
statement so, we have to use casex and casez.