Spring - 2025 - Tutorial 06 PDF
Spring - 2025 - Tutorial 06 PDF
Introduction to Verilog
Verilog is a hardware description language (HDL) used to model electronic systems. It allows
designers to describe the structure and behavior of electronic circuits, which can then be
synthesized into actual hardware.
Design Complex Systems: Verilog is used to design everything from simple logic
gates to complex processors.
Industry Standard: Widely used in the industry for FPGA and ASIC design.
Simulation: Before physical implementation, designs can be simulated to ensure
correctness.
Verilog HDL is commonly used for design of both Field programmable gate arrays(FPGA)
and Application-specific Integrated Circuits(ASIC). There are mainly three levels of abstraction
for writing in Verilog:
Here in this level of abstraction we make use of the functions that define the working of the
circuit instead of it's gate structure. This abstraction level mainly focuses on the flow of data
through the circuit logic gates or functional expressions.
Behavioral Modeling
This is the highest level of abstraction in Verilog. At this level the designers describe the
functionality of the circuit without specifying the functionality and structure of the digital circuit.
This modeling will be helpful because it focuses on what the circuit should do rather than how it
should be implemented.
Dataflow Level: Uses expressions to describe how data flows through the circuit.
module and_gate_dataflow (
input A,
input B,
output Y
);
assign Y = A & B; // Dataflow description of AND operation
endmodule
Switch-level: Represents the circuit using transistors, offering the lowest level of
abstraction.
module and_gate_switchlevel (
input A,
input B,
output Y
);
wire nA, nB, nY;
Data Types
● wire: Represents a connection between hardware elements.
● reg: Stores data (used in procedural blocks).
● integer: For calculations in testbenches.
wire myWire;
reg myReg;
integer myInt;
Operators
● Arithmetic: +, -, *, /
● Logical: &&, ||, !
● Bitwise: &, |, ^, ~
● Relational: ==, !=, >, <
Procedural Blocks
● always: Executes statements whenever a specified event occurs.
● initial: Executes statements once at the beginning of the simulation.
Control Structures
● if / else: Conditional execution.
● case: Multi-way branching.
task displayValues;
input a, b;
begin
$display("A: %d, B: %d", a, b);
end
endtask