Verilog Interview Questions 50
Verilog Interview Questions 50
Interview Questions
1. What do you understand from Verilog?
Answer: Verilog is a hardware description language (HDL) used for modeling and
simulation of digital circuits. It is primarily utilized in designing and verifying digital
systems, including applications in integrated circuits (ICs) and FPGA designs. Verilog
enables engineers to describe hardware behavior at different levels of abstraction—
behavioral, dataflow, and structural modeling.
6. What are the five basic differences between Verilog’s task and function?
Answer:
Answer: In pure combinational circuits, it’s essential to list all input signals in the
sensitivity list because the output directly depends on the inputs. Any change in
inputs must trigger the evaluation of the output.
Behavioral coding and Register Transfer Level (RTL) focus on data transfer between
registers, whereas Gate-level coding describes circuits using logic gates.
Behavioral Coding: This style focuses on describing the system’s behavior without
detailing its structure. It primarily uses constructs like always blocks and procedural
assignments to model functionality, making it easier to conceptualize complex
operations without diving into the specific hardware implementation details.
Register Transfer Level (RTL): RTL coding represents the system’s behavior by
emphasizing the transfer of data between registers. It concentrates on describing
how data moves between registers through combinational logic, capturing the
essence of digital hardware design.
Gate-level Coding: This style describes the system using basic logic gates like AND,
OR, NOT, etc. It is highly detailed, defining the hardware structure explicitly and
using primitive gates or modules to represent the actual physical components of the
circuit.
Tools like Xilinx Vivado, Altera Quartus, Synopsys Design Compiler, and Mentor
Graphics ModelSim are popular for Verilog-based design, simulation, and synthesis.
27. Can you tell me about the datatypes in Verilog?
Verilog consists of a range of data types essential for design representation. These
types serve distinct functions, which are as follows:
Integer: Represents signed 32-bit integer values, utilized for arithmetic operations in
Verilog.
29. What are Verilog full case statements and Verilog parallel case statements?
Verilog’s full case statements cover all potential input conditions, ensuring explicit definition
and execution of associated statements for each match within the case structure. On the other
hand, Verilog’s parallel case statements execute only the first encountered match within the
case structure, optimizing simulation efficiency by stopping further evaluations after finding a
match, although it may not explicitly cover all potential conditions.
Example:
module clk_gen;
reg clk;
always #5 clk = ~clk;
endmodule
35. What is FIFO? What are underflow and overflow conditions in FIFO? Write Verilog code for
the design?
FIFO stands for first in first out which means that the first element enters into the buffer and
comes out first.
Underflow: When an attempt is made to read data from an empty FIFO, it is called an
underflow. The design should have an ‘empty’ flag to avoid getting invalid values
Overflow: When an attempt is made to write data into the already full FIFO, it is called an
overflow. The design should have a ‘full’ flag to avoid losing the data sent from the previous
module.
36. What is infer latch means? How can you avoid it?
Infer latch means creating a feedback loop from the output back to the input due to missing
if-else condition or missing ‘default’ in a ‘case’ statement.
Infer latch indicates that the design might not be implemented as intended and can result in
race conditions and timing issues.
How to avoid it?
Always use all branches in the ‘if’ and ‘case’ statements.
Use default in the ‘case’ statement.
Have a proper code review.
Use lint tools, and logical-equivalence-check tools
Intra statement delay refers to the delay within a single statement. It represents the time
difference between the start of a statement and the execution of a specific operation within
that statement.
Wires are used to connect signals between modules, and can only be driven by a module's
output. They are also used internally to connect different logic gates within a module. Wires
are meant to represent continuous values, such as analog signals, rather than discrete values
like bits.
48. Can I use a Verilog function to define the width of a multi-bit port, wire, or reg type?
No, you cannot use a Verilog function to define the width of a multi-bit port, wire, or reg type.
The width of a Verilog port, wire, or reg declaration must be a constant or a parameter value,
both of which are determined at compile-time.
Functions, on the other hand, are executed at run-time and their return values cannot be used
to dynamically set the widths of Verilog objects. Attempting to use a function to define the
width of a port, wire, or reg will result in a compile-time error. However, you can use function
parameters to define the width of Verilog objects. For example, you can declare a parameter
and use it.
$strobe displays values of selected signals at the end of the current simulation time when all
simulation events have occurred and just before time advances whereas $monitor displays
the value of selected signals whenever its value changes.
50. What are the differences between synchronous and asynchronous state machines?
Synchronous state machines have a clock input that triggers state transitions at specific times.
When the clock signal rises, the state machine updates its output values and transitions to the
next state based on its current state and input values.
Asynchronous state machines do not require a clock signal as they are triggered by input signals
that are not synchronized in time. Each input signal can trigger a state transition at any time,
independent of any clock signal. Asynchronous state machines can be more complex to design
and test due to the possibility of race conditions and glitches, but they can be more efficient and
consume less power compared to synchronous state machines