SlideShare a Scribd company logo
1 of 31
Vinoth Raj R
Assistant Professor
Electronics & Communication Engineering
Velammal Institute of Technology
Digital Logic Design using
Verilog HDL
Course Outline
• Introduction
• Types of HDL
• Verilog data types
• Operators
• Levels of abstraction
• Gate level or Structural modeling
• User Defined Primitives
• Data flow modeling
• Behavioral modeling
• File Handling
• Discussion
5/4/2023 2
velammal Institute of technolgy
Introduction
• A hardware description language (HDL) is a computer-based language that
describes the hardware of digital systems in a textual form
• Similar to computer programming language, such as C, but is specifically
oriented to describing hardware structures and the behavior of logic circuits
• It can be used to represent logic diagrams, truth tables, Boolean
expressions, and complex abstractions of the behavior of a digital system
• It describes a relationship between signals that are the inputs to a circuit
and the signals that are the outputs of the circuit
5/4/2023 3
velammal Institute of technolgy
Types of HDL
• Verilog
• VHDL (VHSIC)
• System Verilog
• System C
• Bluespec System Verilog
5/4/2023 4
velammal Institute of technolgy
Widely used
Verilog Vs. VHDL
Verilog VHDL
Case sensitive Case insensitive
Not a strongly typed Strongly typed
Similar to C language Similar to ADA language
Up to transistor level simulation is possible Only up to gate level simulation
IEEE 1364 standard (Synopys) IEEE 1164 (Department of Defence)
5/4/2023 5
velammal Institute of technolgy
Contd...
• Our emphasis will be on the modeling, verification, and
synthesis (both manual and automated) of Verilog models of
circuits having specified behavior
5/4/2023 6
velammal Institute of technolgy
Operators
Bitwise
& and
| or
~ not
&~ nand
&| nor
^ ex-or
~^ ex-nor
Arithmetic
+ addition
- subratction
* multiplication
/ division
% modulus
Logical
&& and
|| or
! not
Relational
== Equality
!= Inequality
>= Greater than or
equal
<= Less than or equal
=== Case equality
!== Case inequality
others
{} concatenate
?: conditional
shift
>> shift right
<< shift left
5/4/2023 7
velammal Institute of technolgy
Value set
Value Definition
0 logic zero or false
1 logic one or true
x unknown logic value
z High impedance
5/4/2023 8
velammal Institute of technolgy
During the initialization /
simulation: All unconnected nets
are set to ‘Z’ & All register
variables are set to ‘X’.
wire x, y, z; // single bit
wire [7:0] sum; // 7 – MSB, 0 - LSB
reg [31:0] MDR; // 31 – MSB, 0 - LSB
reg [1:10] data; // 1 – MSB, 10 - LSB
wire clock; // single bit with sequence
reg [31:0] IR;
reg [5:0] opcode;
reg [4:0] reg1, reg2, reg3;
reg [10:0] offset;
opcode = IR[31:26];
offset = IR[10:0];
reg1 = IR[25:21]; reg2 = IR[20:16];
reg3 = IR[15:11];
Data Types
1. Nets
• The variables represent the physical connection between structural entities.
• These variables do not store variables
• Value changes is continuously driving to the circuit
2. Registers
• It is used in procedural blocks which stores values from one assignment to
next
• Assignment statement in a procedure act as a trigger that changes the value
of the data storage element
5/4/2023 9
velammal Institute of technolgy
Nets
1. wire
2. tri
3. wor
4. wand
5. supply0
6. supply1
5/4/2023 10
velammal Institute of technolgy
Register Data Type
• In Verilog - Register is a variable that can holds a value
• unlike a “net” that is continuously driven and cannot hold any value
• Combinational circuit can also use register type variables
• register data types
a) reg :most widely used
b) integer :used for loop counting
c) real :used to store floating point numbers
d) time :keeps track of simulation time(not synthesizable)
5/4/2023 11
velammal Institute of technolgy
Levels of Abstraction
Behavioral Structural
Physical
Programs
Specifications
Truth Table
Gates
Adders
Registers
Transistors/Layout
Cells
Chips/boards
5/4/2023 12
velammal Institute of technolgy
Structural or Gate Level Modeling
• When we design a Verilog code entirely using Primitive Logic Gates, it is
called “Gate Level Modelling“. This is Lowest level abstraction
• Likewise in Structural modelling, we model a circuit by using Primitive
gates, and predefined modules
• Inbuilt primitives
• and, or, not, nand, nor, xor, xnor
• cmos,pmos,nmos,supply0,supply1
Synthesizable
Non synthesizable
5/4/2023 13
velammal Institute of technolgy
Module Instantiation
module
myexor(a,b,s);
input a,b;
output s;
xor (s,a,b);
endmodule
module
myand(a,b,c);
input a,b;
output y;
and (c,a,b);
endmodule
module ha(a,b,s,c);
input a,b;
output y;
myxor g1(s,a,b);
myand g2(c,a,b);
endmodule
5/4/2023 14
velammal Institute of technolgy
User Defined Primitives (UDP)
• The user can create additional primitives by defining them in tabular
form
• One way of specifying a digital circuit in tabular form is by means of
a truth table
• UDP descriptions do not use the keyword pair module . . .
endmodule
• Instead, they are declared with the keyword pair primitive . . .
endprimitive
5/4/2023 15
velammal Institute of technolgy
Examples
primitive udp_or(a,b,c);
input a,b;
output c;
table
//a b :c;
? 1 : 1;
1 ? :1;
0 0 : 0;
endtable
endprimitive
module myor_gate(a,b,c);
input a,b;
output c;
udp_or g1(a,b,c);
endmodule
primitive sum(s,a,b);
input a,b;
output s;
table
//a b :s;
0 0 : 0;
0 1 : 1;
1 0 : 1;
1 1 : 0;
endtable
endprimitive
primitive carry(c,a,b);
input a,b;
output c;
table
//a b :c;
0 0 : 0;
0 1 : 0;
1 0 : 0;
1 1 : 1;
endtable
endprimitive
module ha_udp(s,c,a,b);
input a,b;
output s,c;
sum t1(s,a,b);
carry t2(c,a,b);
endmodule
5/4/2023 16
velammal Institute of technolgy
Data Flow Modeling
It is completely done by the logical expression of the digital circuit
• We have arithmetic and logical operators in verilog which we can
use to create a logic expressions of the circuit
• This is medium level abstraction this type of modelling along with
structural modelling in highly recommended in ASIC design
continous assignment
• values are continously assigned to nets
• keyword assign
5/4/2023 17
velammal Institute of technolgy
Examples
module myand(a,b,y);
input a,b;
output y;
assign y = a & b;
endmodule
module ha(a,b,s,c);
input a,b;
output s,c;
assign c = a ^ b;
assign s = a & b;
endmodule
module
mux_2_1(y,s,a,b);
input a,b,s;
output y;
assign y=(~s)&(a)|(s&b);
endmodule
5/4/2023 18
velammal Institute of technolgy
Behavioral Modeling
• It completely depends on the truth table or behaviour of the circuit
• In this modelling we can design without even knowing the
components present in it
• If we know the behaviour of the circuit, we can design it
• This is the highest level abstraction
• This modelling is recommended for FPGA prototyping and other
Reconfigurable devices
5/4/2023 19
velammal Institute of technolgy
always block
• always @( )
begin
...elements...
end
always @(posedge clk)
always @(negedge clk)
always @(posedge clk or negedge rst)
always @(*)
Sensitivity list
5/4/2023 20
velammal Institute of technolgy
Procedural Statements
Blocking statements
•It must be executed before the execution of the statements that followed in a sequential block
ex
a=b;
b=c;
Non blocking statements
•It allow you to schedule assignments without blocking the procedural flow
•whenever you want to make several register assignments within the same time step without
regard to order or dependence upon each other
ex
b<=a;
c<=b;
5/4/2023 21
velammal Institute of technolgy
Conditional Statements
• It is used to make a decision on whether the statement within
the if block should be executed or not
• If there is an else statement and expression is false then
statements within else block will be executed
1. if without else
2. if with else
3. if else if
5/4/2023 22
velammal Institute of technolgy
Examples
module
up_counter(clk,rst,count);
input clk,rst;
output reg[31:0]count;
always@(posedge clk or
negedge rst)
begin
if(!rst)
count =32'b0;
else
count=count+1;
end
endmodule
module mux_2_1(a,b,sel,out);
input a,b, sel;
output reg out;
always@(a or b or sel)
begin
if(sel == 1)
out = a;
else
out = b;
end
endmodule
module d_ff(clk,rst,q,d);
input clk,rst,q;
output reg q;
always@(posedge clk or negedge
rst)
begin
if(rst == 0)
q<=1'b0;
else
q<=d;
end
endmodule
5/4/2023 23
velammal Institute of technolgy
Case Statement
The case statement is a decision instruction that chooses one statement for
execution. The statement chosen is one with a value that matches that of the case
statement
Syntax
case (expression)
expression : statement
expression {, expression} : statement
default : statement
endcase
5/4/2023 24
velammal Institute of technolgy
Examples
module
mux_4_1(i0,i1,i2,i3,sel,y);
input i0,i1,i2,i3;
input [1:0]sel;
output reg y;
always@(i0 or i1 or i2 or i3 or
sel)
begin
case(sel)
2'b00 : y=i0;
2'b01 : y=i1;
2'b10 : y=i2;
2'b11 : y=i3;
endcase
end
endmodule
5/4/2023 25
velammal Institute of technolgy
Looping Statement
forever loop
The forever loop executes continually, the loop never ends. Normally we use forever statements in initial blocks
syntax forever < statement >
while loop
The while loop executes as long as an < expression > evaluates as true. This is the same as in any other programming language
syntax : while (< expression >) < statement >
for loop
The for loop is the same as the for loop used in any other programming language
Executes an < initial assignment > once at the start of the loop
Executes the loop as long as an < expression > evaluates as true
Executes a < step assignment > at the end of each pass through the loop
syntax:
5/4/2023 26
velammal Institute of technolgy
module forever_example ();
reg clk;
initial begin
#1 clk = 0;
forever begin
#5 clk = ! clk;
end
end
initial begin
$monitor ("Time = %d clk = %b",$time, clk);
#100 $finish;
end
endmodule
module while_example();
reg [5:0] loc;
reg [7:0] data;
always @ (data or loc)
begin
loc = 0;
// If Data is 0, then loc is 32 (invalid value)
if (data == 0) begin
loc = 32;
end else begin
while (data[0] == 0) begin
loc = loc + 1;
data = data >> 1;
end
end
$display ("DATA = %b LOCATION = %d",data,loc);
end
initial begin
#1 data = 8'b11;
#1 data = 8'b100;
#1 data = 8'b1000;
#1 data = 8'b1000_0000;
#1 data = 8'b0;
#1 $finish;
end
endmodule
module for_example();
integer i;
reg [7:0] ram [0:255];
initial begin
for (i = 0; i < 256; i = i + 1) begin
#1 $display(" Address = %g Data = %h",i,ram[i]);
ram[i] <= 0; // Initialize the RAM with 0
#1 $display(" Address = %g Data = %h",i,ram[i]);
end
#1 $finish;
end
endmodule
5/4/2023 27
velammal Institute of technolgy
File Handling
• $fopen(file_name);
• $fdisplay(arguments);
• $fmonitor(arguments);
• $fclose(file_name);
• $fwrite(arguments);
• $freadmemb(“file”,memory_identifier[,begin_address[,end_address]]);
• $readmemh(“file”,memory_identifier[,begin_address[,end_address]]);
5/4/2023 28
velammal Institute of technolgy
integer file;
reg a,b,c;
initial
begin
file =$fopen(“results.dat”);
a=b&c;
$fdisplay(file,”Result is:%b”,a);
$fclose(file);
end
reg[3:0]memory[15:0];
initial
begin
$readmemb(“data.bin”,memory);
end
reg[3:0]memory[15:0];
initial
begin
$readmemh(“data.hex”,memory,4,2);
end
loading data in hexadecimal format from file
data.hex into memory starting address 4 and
down to 2
loading data in binary format from the file
data.bin into memory
Result of operation a = b & c will be
put into the file result.dat
5/4/2023 29
velammal Institute of technolgy
References
• NPTEL lecture on “Hardware modelling using verilog” by Prof
Indranil sen gupta, professor, department of CSE ,IIT
Kharagpur.
• “Digital design with an introduction to verilog HDL”, fifth
edition M.Morris Mano and Micheal d Ciletti.
• www.asic-world.com
5/4/2023 30
velammal Institute of technolgy
5/4/2023 velammal Institute of technolgy 31

More Related Content

Similar to Verilog HDL Digital Logic Design Course Outline

Verilog_Cheat_sheet_1672542963.pdf
Verilog_Cheat_sheet_1672542963.pdfVerilog_Cheat_sheet_1672542963.pdf
Verilog_Cheat_sheet_1672542963.pdfsagar414433
 
Verilog_Cheat_sheet_1672542963.pdf
Verilog_Cheat_sheet_1672542963.pdfVerilog_Cheat_sheet_1672542963.pdf
Verilog_Cheat_sheet_1672542963.pdfsagar414433
 
vlsi design using verilog presentaion 1
vlsi design using verilog   presentaion 1vlsi design using verilog   presentaion 1
vlsi design using verilog presentaion 1MANDHASAIGOUD1
 
Digital System Design-Switchlevel and Behavioural Modeling
Digital System Design-Switchlevel and Behavioural ModelingDigital System Design-Switchlevel and Behavioural Modeling
Digital System Design-Switchlevel and Behavioural ModelingIndira Priyadarshini
 
VerilogTutorial-101702.ppt
VerilogTutorial-101702.pptVerilogTutorial-101702.ppt
VerilogTutorial-101702.pptPavanBhandari6
 
Analogue Behavioral Modelling: An Inconvenient Truth
Analogue Behavioral Modelling: An Inconvenient TruthAnalogue Behavioral Modelling: An Inconvenient Truth
Analogue Behavioral Modelling: An Inconvenient TruthDVClub
 
CombVerilog.pdf
CombVerilog.pdfCombVerilog.pdf
CombVerilog.pdfashwkr07
 
Verilog_Overview.pdf
Verilog_Overview.pdfVerilog_Overview.pdf
Verilog_Overview.pdfQuangHuyDo3
 
Ecad &amp;vlsi lab 18
Ecad &amp;vlsi lab 18Ecad &amp;vlsi lab 18
Ecad &amp;vlsi lab 18Shekar Midde
 
Advanced Digital Design With The Verilog HDL
Advanced Digital Design With The Verilog HDLAdvanced Digital Design With The Verilog HDL
Advanced Digital Design With The Verilog HDLTony Lisko
 
An Overview of SystemVerilog for Design and Verification
An Overview of SystemVerilog  for Design and VerificationAn Overview of SystemVerilog  for Design and Verification
An Overview of SystemVerilog for Design and VerificationKapilRaghunandanTrip
 
Verilog Lecture2 thhts
Verilog Lecture2 thhtsVerilog Lecture2 thhts
Verilog Lecture2 thhtsBéo Tú
 
Fpga 07-port-rules-gate-delay-data-flow-carry-look-ahead-adder
Fpga 07-port-rules-gate-delay-data-flow-carry-look-ahead-adderFpga 07-port-rules-gate-delay-data-flow-carry-look-ahead-adder
Fpga 07-port-rules-gate-delay-data-flow-carry-look-ahead-adderMalik Tauqir Hasan
 

Similar to Verilog HDL Digital Logic Design Course Outline (20)

Verilog Cheat sheet-2 (1).pdf
Verilog Cheat sheet-2 (1).pdfVerilog Cheat sheet-2 (1).pdf
Verilog Cheat sheet-2 (1).pdf
 
Verilog_Cheat_sheet_1672542963.pdf
Verilog_Cheat_sheet_1672542963.pdfVerilog_Cheat_sheet_1672542963.pdf
Verilog_Cheat_sheet_1672542963.pdf
 
Verilog_Cheat_sheet_1672542963.pdf
Verilog_Cheat_sheet_1672542963.pdfVerilog_Cheat_sheet_1672542963.pdf
Verilog_Cheat_sheet_1672542963.pdf
 
vlsi design using verilog presentaion 1
vlsi design using verilog   presentaion 1vlsi design using verilog   presentaion 1
vlsi design using verilog presentaion 1
 
Verilog_ppt.pdf
Verilog_ppt.pdfVerilog_ppt.pdf
Verilog_ppt.pdf
 
Digital System Design-Switchlevel and Behavioural Modeling
Digital System Design-Switchlevel and Behavioural ModelingDigital System Design-Switchlevel and Behavioural Modeling
Digital System Design-Switchlevel and Behavioural Modeling
 
VerilogTutorial-101702.ppt
VerilogTutorial-101702.pptVerilogTutorial-101702.ppt
VerilogTutorial-101702.ppt
 
Analogue Behavioral Modelling: An Inconvenient Truth
Analogue Behavioral Modelling: An Inconvenient TruthAnalogue Behavioral Modelling: An Inconvenient Truth
Analogue Behavioral Modelling: An Inconvenient Truth
 
Verilog tutorial
Verilog tutorialVerilog tutorial
Verilog tutorial
 
CombVerilog.pdf
CombVerilog.pdfCombVerilog.pdf
CombVerilog.pdf
 
Verilog_Overview.pdf
Verilog_Overview.pdfVerilog_Overview.pdf
Verilog_Overview.pdf
 
Ecad &amp;vlsi lab 18
Ecad &amp;vlsi lab 18Ecad &amp;vlsi lab 18
Ecad &amp;vlsi lab 18
 
Verilog
VerilogVerilog
Verilog
 
Advanced Digital Design With The Verilog HDL
Advanced Digital Design With The Verilog HDLAdvanced Digital Design With The Verilog HDL
Advanced Digital Design With The Verilog HDL
 
An Overview of SystemVerilog for Design and Verification
An Overview of SystemVerilog  for Design and VerificationAn Overview of SystemVerilog  for Design and Verification
An Overview of SystemVerilog for Design and Verification
 
Verilog hdl
Verilog hdlVerilog hdl
Verilog hdl
 
Vhdl new
Vhdl newVhdl new
Vhdl new
 
verilog
verilogverilog
verilog
 
Verilog Lecture2 thhts
Verilog Lecture2 thhtsVerilog Lecture2 thhts
Verilog Lecture2 thhts
 
Fpga 07-port-rules-gate-delay-data-flow-carry-look-ahead-adder
Fpga 07-port-rules-gate-delay-data-flow-carry-look-ahead-adderFpga 07-port-rules-gate-delay-data-flow-carry-look-ahead-adder
Fpga 07-port-rules-gate-delay-data-flow-carry-look-ahead-adder
 

Recently uploaded

(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 

Recently uploaded (20)

DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 

Verilog HDL Digital Logic Design Course Outline

  • 1. Vinoth Raj R Assistant Professor Electronics & Communication Engineering Velammal Institute of Technology Digital Logic Design using Verilog HDL
  • 2. Course Outline • Introduction • Types of HDL • Verilog data types • Operators • Levels of abstraction • Gate level or Structural modeling • User Defined Primitives • Data flow modeling • Behavioral modeling • File Handling • Discussion 5/4/2023 2 velammal Institute of technolgy
  • 3. Introduction • A hardware description language (HDL) is a computer-based language that describes the hardware of digital systems in a textual form • Similar to computer programming language, such as C, but is specifically oriented to describing hardware structures and the behavior of logic circuits • It can be used to represent logic diagrams, truth tables, Boolean expressions, and complex abstractions of the behavior of a digital system • It describes a relationship between signals that are the inputs to a circuit and the signals that are the outputs of the circuit 5/4/2023 3 velammal Institute of technolgy
  • 4. Types of HDL • Verilog • VHDL (VHSIC) • System Verilog • System C • Bluespec System Verilog 5/4/2023 4 velammal Institute of technolgy Widely used
  • 5. Verilog Vs. VHDL Verilog VHDL Case sensitive Case insensitive Not a strongly typed Strongly typed Similar to C language Similar to ADA language Up to transistor level simulation is possible Only up to gate level simulation IEEE 1364 standard (Synopys) IEEE 1164 (Department of Defence) 5/4/2023 5 velammal Institute of technolgy
  • 6. Contd... • Our emphasis will be on the modeling, verification, and synthesis (both manual and automated) of Verilog models of circuits having specified behavior 5/4/2023 6 velammal Institute of technolgy
  • 7. Operators Bitwise & and | or ~ not &~ nand &| nor ^ ex-or ~^ ex-nor Arithmetic + addition - subratction * multiplication / division % modulus Logical && and || or ! not Relational == Equality != Inequality >= Greater than or equal <= Less than or equal === Case equality !== Case inequality others {} concatenate ?: conditional shift >> shift right << shift left 5/4/2023 7 velammal Institute of technolgy
  • 8. Value set Value Definition 0 logic zero or false 1 logic one or true x unknown logic value z High impedance 5/4/2023 8 velammal Institute of technolgy During the initialization / simulation: All unconnected nets are set to ‘Z’ & All register variables are set to ‘X’. wire x, y, z; // single bit wire [7:0] sum; // 7 – MSB, 0 - LSB reg [31:0] MDR; // 31 – MSB, 0 - LSB reg [1:10] data; // 1 – MSB, 10 - LSB wire clock; // single bit with sequence reg [31:0] IR; reg [5:0] opcode; reg [4:0] reg1, reg2, reg3; reg [10:0] offset; opcode = IR[31:26]; offset = IR[10:0]; reg1 = IR[25:21]; reg2 = IR[20:16]; reg3 = IR[15:11];
  • 9. Data Types 1. Nets • The variables represent the physical connection between structural entities. • These variables do not store variables • Value changes is continuously driving to the circuit 2. Registers • It is used in procedural blocks which stores values from one assignment to next • Assignment statement in a procedure act as a trigger that changes the value of the data storage element 5/4/2023 9 velammal Institute of technolgy
  • 10. Nets 1. wire 2. tri 3. wor 4. wand 5. supply0 6. supply1 5/4/2023 10 velammal Institute of technolgy
  • 11. Register Data Type • In Verilog - Register is a variable that can holds a value • unlike a “net” that is continuously driven and cannot hold any value • Combinational circuit can also use register type variables • register data types a) reg :most widely used b) integer :used for loop counting c) real :used to store floating point numbers d) time :keeps track of simulation time(not synthesizable) 5/4/2023 11 velammal Institute of technolgy
  • 12. Levels of Abstraction Behavioral Structural Physical Programs Specifications Truth Table Gates Adders Registers Transistors/Layout Cells Chips/boards 5/4/2023 12 velammal Institute of technolgy
  • 13. Structural or Gate Level Modeling • When we design a Verilog code entirely using Primitive Logic Gates, it is called “Gate Level Modelling“. This is Lowest level abstraction • Likewise in Structural modelling, we model a circuit by using Primitive gates, and predefined modules • Inbuilt primitives • and, or, not, nand, nor, xor, xnor • cmos,pmos,nmos,supply0,supply1 Synthesizable Non synthesizable 5/4/2023 13 velammal Institute of technolgy
  • 14. Module Instantiation module myexor(a,b,s); input a,b; output s; xor (s,a,b); endmodule module myand(a,b,c); input a,b; output y; and (c,a,b); endmodule module ha(a,b,s,c); input a,b; output y; myxor g1(s,a,b); myand g2(c,a,b); endmodule 5/4/2023 14 velammal Institute of technolgy
  • 15. User Defined Primitives (UDP) • The user can create additional primitives by defining them in tabular form • One way of specifying a digital circuit in tabular form is by means of a truth table • UDP descriptions do not use the keyword pair module . . . endmodule • Instead, they are declared with the keyword pair primitive . . . endprimitive 5/4/2023 15 velammal Institute of technolgy
  • 16. Examples primitive udp_or(a,b,c); input a,b; output c; table //a b :c; ? 1 : 1; 1 ? :1; 0 0 : 0; endtable endprimitive module myor_gate(a,b,c); input a,b; output c; udp_or g1(a,b,c); endmodule primitive sum(s,a,b); input a,b; output s; table //a b :s; 0 0 : 0; 0 1 : 1; 1 0 : 1; 1 1 : 0; endtable endprimitive primitive carry(c,a,b); input a,b; output c; table //a b :c; 0 0 : 0; 0 1 : 0; 1 0 : 0; 1 1 : 1; endtable endprimitive module ha_udp(s,c,a,b); input a,b; output s,c; sum t1(s,a,b); carry t2(c,a,b); endmodule 5/4/2023 16 velammal Institute of technolgy
  • 17. Data Flow Modeling It is completely done by the logical expression of the digital circuit • We have arithmetic and logical operators in verilog which we can use to create a logic expressions of the circuit • This is medium level abstraction this type of modelling along with structural modelling in highly recommended in ASIC design continous assignment • values are continously assigned to nets • keyword assign 5/4/2023 17 velammal Institute of technolgy
  • 18. Examples module myand(a,b,y); input a,b; output y; assign y = a & b; endmodule module ha(a,b,s,c); input a,b; output s,c; assign c = a ^ b; assign s = a & b; endmodule module mux_2_1(y,s,a,b); input a,b,s; output y; assign y=(~s)&(a)|(s&b); endmodule 5/4/2023 18 velammal Institute of technolgy
  • 19. Behavioral Modeling • It completely depends on the truth table or behaviour of the circuit • In this modelling we can design without even knowing the components present in it • If we know the behaviour of the circuit, we can design it • This is the highest level abstraction • This modelling is recommended for FPGA prototyping and other Reconfigurable devices 5/4/2023 19 velammal Institute of technolgy
  • 20. always block • always @( ) begin ...elements... end always @(posedge clk) always @(negedge clk) always @(posedge clk or negedge rst) always @(*) Sensitivity list 5/4/2023 20 velammal Institute of technolgy
  • 21. Procedural Statements Blocking statements •It must be executed before the execution of the statements that followed in a sequential block ex a=b; b=c; Non blocking statements •It allow you to schedule assignments without blocking the procedural flow •whenever you want to make several register assignments within the same time step without regard to order or dependence upon each other ex b<=a; c<=b; 5/4/2023 21 velammal Institute of technolgy
  • 22. Conditional Statements • It is used to make a decision on whether the statement within the if block should be executed or not • If there is an else statement and expression is false then statements within else block will be executed 1. if without else 2. if with else 3. if else if 5/4/2023 22 velammal Institute of technolgy
  • 23. Examples module up_counter(clk,rst,count); input clk,rst; output reg[31:0]count; always@(posedge clk or negedge rst) begin if(!rst) count =32'b0; else count=count+1; end endmodule module mux_2_1(a,b,sel,out); input a,b, sel; output reg out; always@(a or b or sel) begin if(sel == 1) out = a; else out = b; end endmodule module d_ff(clk,rst,q,d); input clk,rst,q; output reg q; always@(posedge clk or negedge rst) begin if(rst == 0) q<=1'b0; else q<=d; end endmodule 5/4/2023 23 velammal Institute of technolgy
  • 24. Case Statement The case statement is a decision instruction that chooses one statement for execution. The statement chosen is one with a value that matches that of the case statement Syntax case (expression) expression : statement expression {, expression} : statement default : statement endcase 5/4/2023 24 velammal Institute of technolgy
  • 25. Examples module mux_4_1(i0,i1,i2,i3,sel,y); input i0,i1,i2,i3; input [1:0]sel; output reg y; always@(i0 or i1 or i2 or i3 or sel) begin case(sel) 2'b00 : y=i0; 2'b01 : y=i1; 2'b10 : y=i2; 2'b11 : y=i3; endcase end endmodule 5/4/2023 25 velammal Institute of technolgy
  • 26. Looping Statement forever loop The forever loop executes continually, the loop never ends. Normally we use forever statements in initial blocks syntax forever < statement > while loop The while loop executes as long as an < expression > evaluates as true. This is the same as in any other programming language syntax : while (< expression >) < statement > for loop The for loop is the same as the for loop used in any other programming language Executes an < initial assignment > once at the start of the loop Executes the loop as long as an < expression > evaluates as true Executes a < step assignment > at the end of each pass through the loop syntax: 5/4/2023 26 velammal Institute of technolgy
  • 27. module forever_example (); reg clk; initial begin #1 clk = 0; forever begin #5 clk = ! clk; end end initial begin $monitor ("Time = %d clk = %b",$time, clk); #100 $finish; end endmodule module while_example(); reg [5:0] loc; reg [7:0] data; always @ (data or loc) begin loc = 0; // If Data is 0, then loc is 32 (invalid value) if (data == 0) begin loc = 32; end else begin while (data[0] == 0) begin loc = loc + 1; data = data >> 1; end end $display ("DATA = %b LOCATION = %d",data,loc); end initial begin #1 data = 8'b11; #1 data = 8'b100; #1 data = 8'b1000; #1 data = 8'b1000_0000; #1 data = 8'b0; #1 $finish; end endmodule module for_example(); integer i; reg [7:0] ram [0:255]; initial begin for (i = 0; i < 256; i = i + 1) begin #1 $display(" Address = %g Data = %h",i,ram[i]); ram[i] <= 0; // Initialize the RAM with 0 #1 $display(" Address = %g Data = %h",i,ram[i]); end #1 $finish; end endmodule 5/4/2023 27 velammal Institute of technolgy
  • 28. File Handling • $fopen(file_name); • $fdisplay(arguments); • $fmonitor(arguments); • $fclose(file_name); • $fwrite(arguments); • $freadmemb(“file”,memory_identifier[,begin_address[,end_address]]); • $readmemh(“file”,memory_identifier[,begin_address[,end_address]]); 5/4/2023 28 velammal Institute of technolgy
  • 29. integer file; reg a,b,c; initial begin file =$fopen(“results.dat”); a=b&c; $fdisplay(file,”Result is:%b”,a); $fclose(file); end reg[3:0]memory[15:0]; initial begin $readmemb(“data.bin”,memory); end reg[3:0]memory[15:0]; initial begin $readmemh(“data.hex”,memory,4,2); end loading data in hexadecimal format from file data.hex into memory starting address 4 and down to 2 loading data in binary format from the file data.bin into memory Result of operation a = b & c will be put into the file result.dat 5/4/2023 29 velammal Institute of technolgy
  • 30. References • NPTEL lecture on “Hardware modelling using verilog” by Prof Indranil sen gupta, professor, department of CSE ,IIT Kharagpur. • “Digital design with an introduction to verilog HDL”, fifth edition M.Morris Mano and Micheal d Ciletti. • www.asic-world.com 5/4/2023 30 velammal Institute of technolgy
  • 31. 5/4/2023 velammal Institute of technolgy 31