SlideShare a Scribd company logo
1 of 31
Vinoth Raj R
Research Scholar - Information Security & VLSI Research Group
Intrusion Detection Laboratory, School of EEE
SASTRA Deemed to be University
Thanjavur
Digital Design using
Verilog HDL
Course Outline
• Introduction
• Types of HDL
• Verilog data types
• Operators
• Levels of abstraction
• Gate level or Structural modelling
• User Defined Primitives
• Data flow modelling
• Behavioural modelling
• File Handling
• Discussion
3/16/2023 2
Kalaivanar NSK college of engineering
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
3/16/2023 3
Kalaivanar NSK college of engineering
Types of HDL
• Verilog
• VHDL (VHSIC)
• System Verilog
• System C
• Bluespec System Verilog
3/16/2023 4
Kalaivanar NSK college of engineering
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)
3/16/2023 5
Kalaivanar NSK college of engineering
Contd...
• Our emphasis will be on the modeling, verification, and
synthesis (both manual and automated) of Verilog models of
circuits having specified behavior
3/16/2023 6
Kalaivanar NSK college of engineering
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
3/16/2023 7
Kalaivanar NSK college of engineering
Value set
Value Definition
0 logic zero or false
1 logic one or true
x unknown logic value
z High impedance
3/16/2023 8
Kalaivanar NSK college of engineering
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
3/16/2023 9
Kalaivanar NSK college of engineering
Nets
1. wire
2. tri
3. wor
4. wand
5. supply0
6. supply1
3/16/2023 10
Kalaivanar NSK college of engineering
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)
3/16/2023 11
Kalaivanar NSK college of engineering
Levels of Abstraction
Behavioral Structural
Physical
Programs
Specifications
Truth Table
Gates
Adders
Registers
Transistors/Layout
Cells
Chips/boards
3/16/2023 12
Kalaivanar NSK college of engineering
Structural or Gate Level Modelling
• 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
3/16/2023 13
Kalaivanar NSK college of engineering
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
3/16/2023 14
Kalaivanar NSK college of engineering
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
3/16/2023 15
Kalaivanar NSK college of engineering
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
3/16/2023 16
Kalaivanar NSK college of engineering
Data Flow Modelling
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
3/16/2023 17
Kalaivanar NSK college of engineering
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
3/16/2023 18
Kalaivanar NSK college of engineering
Behavioral Modelling
• 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
3/16/2023 19
Kalaivanar NSK college of engineering
always block
• always @( )
begin
...elements...
end
always @(posedge clk)
always @(negedge clk)
always @(posedge clk or negedge rst)
always @(*)
Sensitivity list
3/16/2023 20
Kalaivanar NSK college of engineering
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;
3/16/2023 21
Kalaivanar NSK college of engineering
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
3/16/2023 22
Kalaivanar NSK college of engineering
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
3/16/2023 23
Kalaivanar NSK college of engineering
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
3/16/2023 24
Kalaivanar NSK college of engineering
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
3/16/2023 25
Kalaivanar NSK college of engineering
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:
3/16/2023 26
Kalaivanar NSK college of engineering
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
3/16/2023 27
Kalaivanar NSK college of engineering
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]]);
3/16/2023 28
Kalaivanar NSK college of engineering
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
3/16/2023 29
Kalaivanar NSK college of engineering
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
3/16/2023 30
Kalaivanar NSK college of engineering
3/16/2023 Kalaivanar NSK college of engineering 31

More Related Content

Similar to kalaivaanar_NSK_V3.ppt

dokumen.tips_verilog-basic-ppt.pdf
dokumen.tips_verilog-basic-ppt.pdfdokumen.tips_verilog-basic-ppt.pdf
dokumen.tips_verilog-basic-ppt.pdfVelmathi Saravanan
 
Svd filtered temporal usage clustering
Svd filtered temporal usage clusteringSvd filtered temporal usage clustering
Svd filtered temporal usage clusteringLiang Xie, PhD
 
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
 
Implementation of Reversable Logic Based Design using Submicron Technology
Implementation of Reversable Logic Based Design using Submicron TechnologyImplementation of Reversable Logic Based Design using Submicron Technology
Implementation of Reversable Logic Based Design using Submicron TechnologySai Viswanath
 
Digital System Design-Introductio to ASIC
Digital System Design-Introductio to ASICDigital System Design-Introductio to ASIC
Digital System Design-Introductio to ASICIndira Priyadarshini
 
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
 
Implementation and Comparison of Efficient 16-Bit SQRT CSLA Using Parity Pres...
Implementation and Comparison of Efficient 16-Bit SQRT CSLA Using Parity Pres...Implementation and Comparison of Efficient 16-Bit SQRT CSLA Using Parity Pres...
Implementation and Comparison of Efficient 16-Bit SQRT CSLA Using Parity Pres...IJERA Editor
 
Ecad &amp;vlsi lab 18
Ecad &amp;vlsi lab 18Ecad &amp;vlsi lab 18
Ecad &amp;vlsi lab 18Shekar Midde
 
Efficient anomaly detection via matrix sketching
Efficient anomaly detection via matrix sketchingEfficient anomaly detection via matrix sketching
Efficient anomaly detection via matrix sketchingHsing-chuan Hsieh
 
Library Characterization Flow
Library Characterization FlowLibrary Characterization Flow
Library Characterization FlowSatish Grandhi
 
24-02-18 Rejender pratap.pdf
24-02-18 Rejender pratap.pdf24-02-18 Rejender pratap.pdf
24-02-18 Rejender pratap.pdfFrangoCamila
 
Summer training vhdl
Summer training vhdlSummer training vhdl
Summer training vhdlArshit Rai
 
Fpga based low power and high performance address
Fpga based low power and high performance addressFpga based low power and high performance address
Fpga based low power and high performance addresseSAT Publishing House
 
Fpga based low power and high performance address generator for wimax deinter...
Fpga based low power and high performance address generator for wimax deinter...Fpga based low power and high performance address generator for wimax deinter...
Fpga based low power and high performance address generator for wimax deinter...eSAT Journals
 

Similar to kalaivaanar_NSK_V3.ppt (20)

verilog ppt .pdf
verilog ppt .pdfverilog ppt .pdf
verilog ppt .pdf
 
dokumen.tips_verilog-basic-ppt.pdf
dokumen.tips_verilog-basic-ppt.pdfdokumen.tips_verilog-basic-ppt.pdf
dokumen.tips_verilog-basic-ppt.pdf
 
Verilog_ppt.pdf
Verilog_ppt.pdfVerilog_ppt.pdf
Verilog_ppt.pdf
 
Svd filtered temporal usage clustering
Svd filtered temporal usage clusteringSvd filtered temporal usage clustering
Svd filtered temporal usage clustering
 
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
 
Implementation of Reversable Logic Based Design using Submicron Technology
Implementation of Reversable Logic Based Design using Submicron TechnologyImplementation of Reversable Logic Based Design using Submicron Technology
Implementation of Reversable Logic Based Design using Submicron Technology
 
Verilog HDL - 3
Verilog HDL - 3Verilog HDL - 3
Verilog HDL - 3
 
Digital System Design-Introductio to ASIC
Digital System Design-Introductio to ASICDigital System Design-Introductio to ASIC
Digital System Design-Introductio to ASIC
 
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
 
Implementation and Comparison of Efficient 16-Bit SQRT CSLA Using Parity Pres...
Implementation and Comparison of Efficient 16-Bit SQRT CSLA Using Parity Pres...Implementation and Comparison of Efficient 16-Bit SQRT CSLA Using Parity Pres...
Implementation and Comparison of Efficient 16-Bit SQRT CSLA Using Parity Pres...
 
Ecad &amp;vlsi lab 18
Ecad &amp;vlsi lab 18Ecad &amp;vlsi lab 18
Ecad &amp;vlsi lab 18
 
Efficient anomaly detection via matrix sketching
Efficient anomaly detection via matrix sketchingEfficient anomaly detection via matrix sketching
Efficient anomaly detection via matrix sketching
 
1.ppt
1.ppt1.ppt
1.ppt
 
Library Characterization Flow
Library Characterization FlowLibrary Characterization Flow
Library Characterization Flow
 
24-02-18 Rejender pratap.pdf
24-02-18 Rejender pratap.pdf24-02-18 Rejender pratap.pdf
24-02-18 Rejender pratap.pdf
 
Summer training vhdl
Summer training vhdlSummer training vhdl
Summer training vhdl
 
Fpga based low power and high performance address
Fpga based low power and high performance addressFpga based low power and high performance address
Fpga based low power and high performance address
 
Fpga based low power and high performance address generator for wimax deinter...
Fpga based low power and high performance address generator for wimax deinter...Fpga based low power and high performance address generator for wimax deinter...
Fpga based low power and high performance address generator for wimax deinter...
 

Recently uploaded

HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxSCMS School of Architecture
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Call Girls Mumbai
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadhamedmustafa094
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwaitjaanualu31
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...soginsider
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxmaisarahman1
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersMairaAshraf6
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARKOUSTAV SARKAR
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...HenryBriggs2
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 

Recently uploaded (20)

HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 

kalaivaanar_NSK_V3.ppt

  • 1. Vinoth Raj R Research Scholar - Information Security & VLSI Research Group Intrusion Detection Laboratory, School of EEE SASTRA Deemed to be University Thanjavur Digital Design using Verilog HDL
  • 2. Course Outline • Introduction • Types of HDL • Verilog data types • Operators • Levels of abstraction • Gate level or Structural modelling • User Defined Primitives • Data flow modelling • Behavioural modelling • File Handling • Discussion 3/16/2023 2 Kalaivanar NSK college of engineering
  • 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 3/16/2023 3 Kalaivanar NSK college of engineering
  • 4. Types of HDL • Verilog • VHDL (VHSIC) • System Verilog • System C • Bluespec System Verilog 3/16/2023 4 Kalaivanar NSK college of engineering 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) 3/16/2023 5 Kalaivanar NSK college of engineering
  • 6. Contd... • Our emphasis will be on the modeling, verification, and synthesis (both manual and automated) of Verilog models of circuits having specified behavior 3/16/2023 6 Kalaivanar NSK college of engineering
  • 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 3/16/2023 7 Kalaivanar NSK college of engineering
  • 8. Value set Value Definition 0 logic zero or false 1 logic one or true x unknown logic value z High impedance 3/16/2023 8 Kalaivanar NSK college of engineering 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 3/16/2023 9 Kalaivanar NSK college of engineering
  • 10. Nets 1. wire 2. tri 3. wor 4. wand 5. supply0 6. supply1 3/16/2023 10 Kalaivanar NSK college of engineering
  • 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) 3/16/2023 11 Kalaivanar NSK college of engineering
  • 12. Levels of Abstraction Behavioral Structural Physical Programs Specifications Truth Table Gates Adders Registers Transistors/Layout Cells Chips/boards 3/16/2023 12 Kalaivanar NSK college of engineering
  • 13. Structural or Gate Level Modelling • 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 3/16/2023 13 Kalaivanar NSK college of engineering
  • 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 3/16/2023 14 Kalaivanar NSK college of engineering
  • 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 3/16/2023 15 Kalaivanar NSK college of engineering
  • 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 3/16/2023 16 Kalaivanar NSK college of engineering
  • 17. Data Flow Modelling 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 3/16/2023 17 Kalaivanar NSK college of engineering
  • 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 3/16/2023 18 Kalaivanar NSK college of engineering
  • 19. Behavioral Modelling • 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 3/16/2023 19 Kalaivanar NSK college of engineering
  • 20. always block • always @( ) begin ...elements... end always @(posedge clk) always @(negedge clk) always @(posedge clk or negedge rst) always @(*) Sensitivity list 3/16/2023 20 Kalaivanar NSK college of engineering
  • 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; 3/16/2023 21 Kalaivanar NSK college of engineering
  • 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 3/16/2023 22 Kalaivanar NSK college of engineering
  • 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 3/16/2023 23 Kalaivanar NSK college of engineering
  • 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 3/16/2023 24 Kalaivanar NSK college of engineering
  • 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 3/16/2023 25 Kalaivanar NSK college of engineering
  • 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: 3/16/2023 26 Kalaivanar NSK college of engineering
  • 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 3/16/2023 27 Kalaivanar NSK college of engineering
  • 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]]); 3/16/2023 28 Kalaivanar NSK college of engineering
  • 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 3/16/2023 29 Kalaivanar NSK college of engineering
  • 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 3/16/2023 30 Kalaivanar NSK college of engineering
  • 31. 3/16/2023 Kalaivanar NSK college of engineering 31