SlideShare a Scribd company logo
1 of 12
ENGR. RASHID FARID CHISHTI
LECTURER,DEE, FET, IIUI
CHISHTI@IIU.EDU.PK
WEEK 4
VERILOG PROGRAMMING
FPGA Based System Design
Sunday, May 17, 2015
1
www.iiu.edu.pk
A hardware description language is a computer language
that is used to describe hardware.
Currently, almost all integrated circuits are designed with
using HDL. Two HDLs are widely used
 Verilog HDL
 VHDL (Very High Speed Integrated Circuit Hardware
Description Language)
Schematic design entry can be replaced by writing HDL
code that CAD tools understand.
CAD tools can verify the HDL codes, and create the
circuits automatically from HDL codes.
Hardware Description Language
Sunday, May 17, 2015www.iiu.edu.pk 2
We use Verilog, not VHDL for FPGA programming
 Verilog is more popular in industry than VHDL
 They offer similar features
History of Verilog
 In 1980s, originally developed by Gateway Design Automation.
 In 1990, was put in public domain.
 In 1995, adopted as an IEEE standard 1364-1995
 In 2001, an enhanced version, Verilog 2001
Functions of Verilog
 Design entry, like schematic
 Simulation and verification of your design
 Synthesis
Facts About Verilog
Sunday, May 17, 2015www.iiu.edu.pk 3
Verilog may be used to model circuits and behaviors at
various levels of abstraction:
 Transistor/Switch Level Modeling. LOW LEVEL
 Gate Level Modeling.
 Data Flow Modeling.
 Behavioral or algorithmic Modeling. HIGH LEVEL
For design with FPGA devices, transistor and gate level
modeling is not appropriate.
Register Transfer Level (RTL) is a combination of
behavioral and dataflow Modeling.
Verilog Usage
Sunday, May 17, 2015www.iiu.edu.pk 4
//Define inverter
module my_not(out, in);
output out;
input in;
// declare power
// and ground
supply1 pwr;
supply0 gnd;
//instantiate nmos
// and pmos switches
pmos (out, pwr, in);
nmos (out, gnd, in);
endmodule
Switch Level Modeling
Sunday, May 17, 2015www.iiu.edu.pk 5
// A simple example
module gate1 (a,b,c);
input a,b;
output c;
and (c,a,b);
endmodule
 Modules are the basic building blocks in Verilog.
 A logic circuit  module, Its ports: inputs and outputs
 Begins with module, ends with endmodule
A Simple Verilog Example
Sunday, May 17, 2015www.iiu.edu.pk 6
comment line
module name
port list
end module
port declarations
a
b
c
gate1
module eg1 (a,b,c,f);
input a,b,c;
output f;
wire g,h,i;
and (g,a,b);
not (h,b);
and (i,h,c);
or (f,g,i);
endmodule
Gate Level Modeling vs Data Flow Modeling
Sunday, May 17, 2015www.iiu.edu.pk 7
// Data Flow Modeling
module ex1 (a,b,c,f);
input a,b,c;
output f;
assign f = (a&b) | (~b&c);
endmodule
// Data Flow Modeling
module ex1 (a,b,c,f);
input a,b,c;
output f;
assign f = (a&b) | (~b&c);
endmodule
a
c
F = AB + B'C
b
fg
ih
Writing Test Bench
Sunday, May 17, 2015www.iiu.edu.pk 8
/* testbench for ex1 block *//* testbench for ex1 block */
modulemodule ex1_tb ;ex1_tb ;
wirewire f1;f1;
regreg a1, b1, c1;a1, b1, c1;
ex1 my_module(a1, b1, c1, f1);ex1 my_module(a1, b1, c1, f1);
initialinitial
beginbegin
$monitor$monitor(($time$time," ", a1, b1,," ", a1, b1,
c1, ," ", f1);c1, ," ", f1);
a1 = 1'ba1 = 1'b00; b1 = 1'b; b1 = 1'b11; c1 = 1'b; c1 = 1'b00;;
#5#5
a1 = 1'ba1 = 1'b11; b1 = 1'b; b1 = 1'b11; c1 = 1'b; c1 = 1'b11;;
#5#5
a1 = 1'ba1 = 1'b11; b1 = 1'b; b1 = 1'b00; c1 = 1'b; c1 = 1'b11;;
#5#5
a1 = 1'ba1 = 1'b11; b1 = 1'b; b1 = 1'b11; c1 = 1'b; c1 = 1'b11;;
#10#10 $finish$finish;;
endend
endmoduleendmodule
/* testbench for ex1 block *//* testbench for ex1 block */
modulemodule ex1_tb ;ex1_tb ;
wirewire f1;f1;
regreg a1, b1, c1;a1, b1, c1;
ex1 my_module(a1, b1, c1, f1);ex1 my_module(a1, b1, c1, f1);
initialinitial
beginbegin
$monitor$monitor(($time$time," ", a1, b1,," ", a1, b1,
c1, ," ", f1);c1, ," ", f1);
a1 = 1'ba1 = 1'b00; b1 = 1'b; b1 = 1'b11; c1 = 1'b; c1 = 1'b00;;
#5#5
a1 = 1'ba1 = 1'b11; b1 = 1'b; b1 = 1'b11; c1 = 1'b; c1 = 1'b11;;
#5#5
a1 = 1'ba1 = 1'b11; b1 = 1'b; b1 = 1'b00; c1 = 1'b; c1 = 1'b11;;
#5#5
a1 = 1'ba1 = 1'b11; b1 = 1'b; b1 = 1'b11; c1 = 1'b; c1 = 1'b11;;
#10#10 $finish$finish;;
endend
endmoduleendmodule
module ex1 (a,b,c,f);
input a,b,c;
output f;
assign f=(a&b)|(!b&c);
endmodule
module ex1 (a,b,c,f);
input a,b,c;
output f;
assign f=(a&b)|(!b&c);
endmodule
Each signal in Verilog belongs
to either a net or a register
A net (wire) represents a
physical wire. Its signal value is
determined by its driver.
If it is not driven by any driver,
its value is high impedance (Z).
A register is like a variable in
programming languages. It keeps
its value until a new value is
assigned to it.
Unlike registers, nets do not
have storage capacity.
Each signal in Verilog belongs
to either a net or a register
A net (wire) represents a
physical wire. Its signal value is
determined by its driver.
If it is not driven by any driver,
its value is high impedance (Z).
A register is like a variable in
programming languages. It keeps
its value until a new value is
assigned to it.
Unlike registers, nets do not
have storage capacity.
print to a console
Verilog supports basic logic gates as predefined primitives.
There are two classes of basic gates: and/or gates and buf/not gates.
And/or gates have one scalar output and multiple scalar inputs
The first terminal in the list of gate terminals is an output and the
other terminals are inputs.
Example 1: Gate Instantiation of And/Or Gates
wire OUT, IN1, IN2;
and a1(OUT, IN1, IN2);
xnor (OUT, IN1, IN2);
// More than two inputs;
// 3 input nand gate
nand (OUT, IN1, IN2, IN3);
Basic Gates
Sunday, May 17, 2015www.iiu.edu.pk 9
Truth Tables for And/Or Gates
Sunday, May 17, 2015www.iiu.edu.pk 10
and 0 1 x z   or 0 1 x z   xor 0 1 x z
0 0 0 0 0   0 0 1 x x   0 0 1 x x
1 0 1 x x   1 1 1 1 1   1 1 0 x x
x 0 x x x   x x 1 x x   x x x x x
z 0 x x x   z x 1 x x   z x x x x
nand 0 1 x z nor 0 1 x z xnor 0 1 x z
0 1 1 1 1 0 1 0 x x 0 1 0 x x
1 1 0 x x 1 0 0 0 0 1 0 1 x x
x 1 x x x x x 0 x x x x x x x
z 1 x x x z x 0 x x z x x x X
1=True , 0=False, X=Unknown, Z=High impedance
Buf/not gates have one scalar input and one or more scalar outputs
The last terminal in the port list is connected to the input. Other
terminals are connected to the outputs
Basic buf/not gate primitives in verilog are buf not
Buf/not gates with additional
control signal are
bufif1, notif1, bufif0, notif0
Buf/Not Gates
Sunday, May 17, 2015www.iiu.edu.pk 11
buf   not
input output   input output
0 0   0 1
1 1   1 0
x x   x x
z x   z x
The L and H symbols have a
special meaning. The L symbol
means the output has 0 or z value.
The H symbol means the output
has 1 or z value.
 Any transition to H or L is treated
as a transition to x.
Examples
//Instantiation of bufif gates.
bufif1 b1 (out, in, ctrl);
bufif0 b0 (out, in, ctrl);
//Instantiation of notif gates
notif1 n1 (out, in, ctrl);
notif0 n0 (out, in, ctrl); x={0,1,z} L={0,z} H={1,z}
bufif1
Ctrl  
notif1
Ctrl
0 1 x z  
0 1 x z
in
0 z 0 L L  
in
0 z 1 H H
1 z 1 H H  
1 z 0 L L
x z x x x  
x z x x x
z z x x x  
z z x x x
bufif0
Ctrl
notif0
Ctrl
0 1 x z 0 1 x z
in
0 0 z L L  
in
0 1 z H H
1 1 z H H  
1 0 z L L
x x z x x  
x x z x x
z x z x x  
z x z x x
Truth Table for bufif/notif Gates
Sunday, May 17, 2015www.iiu.edu.pk 12

More Related Content

What's hot

Modules and ports in Verilog HDL
Modules and ports in Verilog HDLModules and ports in Verilog HDL
Modules and ports in Verilog HDLanand hd
 
Digital Circuit Verification Hardware Descriptive Language Verilog
Digital Circuit Verification Hardware Descriptive Language VerilogDigital Circuit Verification Hardware Descriptive Language Verilog
Digital Circuit Verification Hardware Descriptive Language VerilogAbhiraj Bohra
 
Verilog Lecture5 hust 2014
Verilog Lecture5 hust 2014Verilog Lecture5 hust 2014
Verilog Lecture5 hust 2014Béo Tú
 
Lecture 2 verilog
Lecture 2   verilogLecture 2   verilog
Lecture 2 verilogvenravi10
 
Verilog overview
Verilog overviewVerilog overview
Verilog overviewposdege
 
VHDL- gate level modelling
VHDL- gate level modellingVHDL- gate level modelling
VHDL- gate level modellingVandanaPagar1
 
Day2 Verilog HDL Basic
Day2 Verilog HDL BasicDay2 Verilog HDL Basic
Day2 Verilog HDL BasicRon Liu
 
Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014Béo Tú
 
Verilog presentation final
Verilog presentation finalVerilog presentation final
Verilog presentation finalAnkur Gupta
 
Basics of digital verilog design(alok singh kanpur)
Basics of digital verilog design(alok singh kanpur)Basics of digital verilog design(alok singh kanpur)
Basics of digital verilog design(alok singh kanpur)Alok Singh
 
Verilog Lecture4 2014
Verilog Lecture4 2014Verilog Lecture4 2014
Verilog Lecture4 2014Béo Tú
 
System Verilog Tutorial - VHDL
System Verilog Tutorial - VHDLSystem Verilog Tutorial - VHDL
System Verilog Tutorial - VHDLE2MATRIX
 
Verilog 語法教學
Verilog 語法教學 Verilog 語法教學
Verilog 語法教學 艾鍗科技
 

What's hot (20)

Coding verilog
Coding verilogCoding verilog
Coding verilog
 
Modules and ports in Verilog HDL
Modules and ports in Verilog HDLModules and ports in Verilog HDL
Modules and ports in Verilog HDL
 
Digital Circuit Verification Hardware Descriptive Language Verilog
Digital Circuit Verification Hardware Descriptive Language VerilogDigital Circuit Verification Hardware Descriptive Language Verilog
Digital Circuit Verification Hardware Descriptive Language Verilog
 
Verilog Lecture5 hust 2014
Verilog Lecture5 hust 2014Verilog Lecture5 hust 2014
Verilog Lecture5 hust 2014
 
Lecture 2 verilog
Lecture 2   verilogLecture 2   verilog
Lecture 2 verilog
 
Verilog overview
Verilog overviewVerilog overview
Verilog overview
 
verilog
verilogverilog
verilog
 
VHDL- gate level modelling
VHDL- gate level modellingVHDL- gate level modelling
VHDL- gate level modelling
 
Day2 Verilog HDL Basic
Day2 Verilog HDL BasicDay2 Verilog HDL Basic
Day2 Verilog HDL Basic
 
Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014
 
Verilog lab manual (ECAD and VLSI Lab)
Verilog lab manual (ECAD and VLSI Lab)Verilog lab manual (ECAD and VLSI Lab)
Verilog lab manual (ECAD and VLSI Lab)
 
Verilog presentation final
Verilog presentation finalVerilog presentation final
Verilog presentation final
 
Basics of digital verilog design(alok singh kanpur)
Basics of digital verilog design(alok singh kanpur)Basics of digital verilog design(alok singh kanpur)
Basics of digital verilog design(alok singh kanpur)
 
Verilog Lecture4 2014
Verilog Lecture4 2014Verilog Lecture4 2014
Verilog Lecture4 2014
 
Verilog hdl
Verilog hdlVerilog hdl
Verilog hdl
 
System Verilog Tutorial - VHDL
System Verilog Tutorial - VHDLSystem Verilog Tutorial - VHDL
System Verilog Tutorial - VHDL
 
Verilog 語法教學
Verilog 語法教學 Verilog 語法教學
Verilog 語法教學
 
Verilog tutorial
Verilog tutorialVerilog tutorial
Verilog tutorial
 
Verilog hdl
Verilog hdlVerilog hdl
Verilog hdl
 
04 sequentialbasics 1
04 sequentialbasics 104 sequentialbasics 1
04 sequentialbasics 1
 

Viewers also liked

Viewers also liked (12)

Verilog HDL
Verilog HDLVerilog HDL
Verilog HDL
 
FPGA
FPGAFPGA
FPGA
 
Fundamentals of FPGA
Fundamentals of FPGAFundamentals of FPGA
Fundamentals of FPGA
 
FPGA Overview
FPGA OverviewFPGA Overview
FPGA Overview
 
Field programable gate array
Field programable gate arrayField programable gate array
Field programable gate array
 
FPGAs : An Overview
FPGAs : An OverviewFPGAs : An Overview
FPGAs : An Overview
 
FPGA Introduction
FPGA IntroductionFPGA Introduction
FPGA Introduction
 
Introduction to FPGA, VHDL
Introduction to FPGA, VHDL  Introduction to FPGA, VHDL
Introduction to FPGA, VHDL
 
verilog code
verilog codeverilog code
verilog code
 
FPGA
FPGAFPGA
FPGA
 
What is FPGA?
What is FPGA?What is FPGA?
What is FPGA?
 
Connected Car Security
Connected Car SecurityConnected Car Security
Connected Car Security
 

Similar to Fpga 04-verilog-programming

vlsi design using verilog presentaion 1
vlsi design using verilog   presentaion 1vlsi design using verilog   presentaion 1
vlsi design using verilog presentaion 1MANDHASAIGOUD1
 
Gate level design -For beginners
Gate level design -For beginnersGate level design -For beginners
Gate level design -For beginnersDr.YNM
 
Practical file
Practical filePractical file
Practical filerajeevkr35
 
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
 
Digital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECEDigital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECERamesh Naik Bhukya
 
Digital system design practical file
Digital system design practical fileDigital system design practical file
Digital system design practical fileArchita Misra
 
Introduction to VHDL
Introduction to VHDLIntroduction to VHDL
Introduction to VHDLYaser Kalifa
 
Building Hierarchy
Building HierarchyBuilding Hierarchy
Building HierarchyMohamed Samy
 
gate level modeling
gate level modelinggate level modeling
gate level modelingVandanaBR2
 
SKEL 4273 CAD with HDL Topic 2
SKEL 4273 CAD with HDL Topic 2SKEL 4273 CAD with HDL Topic 2
SKEL 4273 CAD with HDL Topic 2alhadi81
 

Similar to Fpga 04-verilog-programming (20)

vlsi design using verilog presentaion 1
vlsi design using verilog   presentaion 1vlsi design using verilog   presentaion 1
vlsi design using verilog presentaion 1
 
Gate level design -For beginners
Gate level design -For beginnersGate level design -For beginners
Gate level design -For beginners
 
e CAD lab manual
e CAD lab manuale CAD lab manual
e CAD lab manual
 
Practical file
Practical filePractical file
Practical file
 
VLSI & E-CAD Lab Manual
VLSI & E-CAD Lab ManualVLSI & E-CAD Lab Manual
VLSI & E-CAD Lab Manual
 
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
 
Digital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECEDigital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECE
 
Digital system design practical file
Digital system design practical fileDigital system design practical file
Digital system design practical file
 
1.ppt
1.ppt1.ppt
1.ppt
 
Introduction to VHDL
Introduction to VHDLIntroduction to VHDL
Introduction to VHDL
 
Building Hierarchy
Building HierarchyBuilding Hierarchy
Building Hierarchy
 
mod-4.pptx
mod-4.pptxmod-4.pptx
mod-4.pptx
 
Session1
Session1Session1
Session1
 
Verilog tutorial
Verilog tutorialVerilog tutorial
Verilog tutorial
 
VHDL Entity
VHDL EntityVHDL Entity
VHDL Entity
 
gate level modeling
gate level modelinggate level modeling
gate level modeling
 
Assic 6th Lecture
Assic 6th LectureAssic 6th Lecture
Assic 6th Lecture
 
ECAD lab manual
ECAD lab manualECAD lab manual
ECAD lab manual
 
Spdas2 vlsibput
Spdas2 vlsibputSpdas2 vlsibput
Spdas2 vlsibput
 
SKEL 4273 CAD with HDL Topic 2
SKEL 4273 CAD with HDL Topic 2SKEL 4273 CAD with HDL Topic 2
SKEL 4273 CAD with HDL Topic 2
 

More from Malik Tauqir Hasan

Fpga 11-sequence-detector-fir-iir-filter
Fpga 11-sequence-detector-fir-iir-filterFpga 11-sequence-detector-fir-iir-filter
Fpga 11-sequence-detector-fir-iir-filterMalik Tauqir Hasan
 
Fpga 10-bcd-to-excess-3-converter-manchester-encoding
Fpga 10-bcd-to-excess-3-converter-manchester-encodingFpga 10-bcd-to-excess-3-converter-manchester-encoding
Fpga 10-bcd-to-excess-3-converter-manchester-encodingMalik Tauqir Hasan
 
Fpga 09-behavioral-modeling-moore-machine
Fpga 09-behavioral-modeling-moore-machineFpga 09-behavioral-modeling-moore-machine
Fpga 09-behavioral-modeling-moore-machineMalik Tauqir Hasan
 
Fpga 08-behavioral-modeling-mealy-machine
Fpga 08-behavioral-modeling-mealy-machineFpga 08-behavioral-modeling-mealy-machine
Fpga 08-behavioral-modeling-mealy-machineMalik Tauqir Hasan
 

More from Malik Tauqir Hasan (9)

Fpga 13-task-and-functions
Fpga 13-task-and-functionsFpga 13-task-and-functions
Fpga 13-task-and-functions
 
Fpga 12-event-control
Fpga 12-event-controlFpga 12-event-control
Fpga 12-event-control
 
Fpga 11-sequence-detector-fir-iir-filter
Fpga 11-sequence-detector-fir-iir-filterFpga 11-sequence-detector-fir-iir-filter
Fpga 11-sequence-detector-fir-iir-filter
 
Fpga 10-bcd-to-excess-3-converter-manchester-encoding
Fpga 10-bcd-to-excess-3-converter-manchester-encodingFpga 10-bcd-to-excess-3-converter-manchester-encoding
Fpga 10-bcd-to-excess-3-converter-manchester-encoding
 
Fpga 09-behavioral-modeling-moore-machine
Fpga 09-behavioral-modeling-moore-machineFpga 09-behavioral-modeling-moore-machine
Fpga 09-behavioral-modeling-moore-machine
 
Fpga 08-behavioral-modeling-mealy-machine
Fpga 08-behavioral-modeling-mealy-machineFpga 08-behavioral-modeling-mealy-machine
Fpga 08-behavioral-modeling-mealy-machine
 
Fpga 03-cpld-and-fpga
Fpga 03-cpld-and-fpgaFpga 03-cpld-and-fpga
Fpga 03-cpld-and-fpga
 
Fpga 02-memory-and-pl ds
Fpga 02-memory-and-pl dsFpga 02-memory-and-pl ds
Fpga 02-memory-and-pl ds
 
Fpga 01-digital-logic-design
Fpga 01-digital-logic-designFpga 01-digital-logic-design
Fpga 01-digital-logic-design
 

Recently uploaded

定制(Salford学位证)索尔福德大学毕业证成绩单原版一比一
定制(Salford学位证)索尔福德大学毕业证成绩单原版一比一定制(Salford学位证)索尔福德大学毕业证成绩单原版一比一
定制(Salford学位证)索尔福德大学毕业证成绩单原版一比一ss ss
 
Papular No 1 Online Istikhara Amil Baba Pakistan Amil Baba In Karachi Amil B...
Papular No 1 Online Istikhara Amil Baba Pakistan  Amil Baba In Karachi Amil B...Papular No 1 Online Istikhara Amil Baba Pakistan  Amil Baba In Karachi Amil B...
Papular No 1 Online Istikhara Amil Baba Pakistan Amil Baba In Karachi Amil B...Authentic No 1 Amil Baba In Pakistan
 
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
定制(USF学位证)旧金山大学毕业证成绩单原版一比一
定制(USF学位证)旧金山大学毕业证成绩单原版一比一定制(USF学位证)旧金山大学毕业证成绩单原版一比一
定制(USF学位证)旧金山大学毕业证成绩单原版一比一ss ss
 
Alambagh Call Girl 9548273370 , Call Girls Service Lucknow
Alambagh Call Girl 9548273370 , Call Girls Service LucknowAlambagh Call Girl 9548273370 , Call Girls Service Lucknow
Alambagh Call Girl 9548273370 , Call Girls Service Lucknowmakika9823
 
NO1 Qualified Best Black Magic Specialist Near Me Spiritual Healer Powerful L...
NO1 Qualified Best Black Magic Specialist Near Me Spiritual Healer Powerful L...NO1 Qualified Best Black Magic Specialist Near Me Spiritual Healer Powerful L...
NO1 Qualified Best Black Magic Specialist Near Me Spiritual Healer Powerful L...Amil baba
 
(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service
(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service
(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Call Girls In Munirka>༒9599632723 Incall_OutCall Available
Call Girls In Munirka>༒9599632723 Incall_OutCall AvailableCall Girls In Munirka>༒9599632723 Incall_OutCall Available
Call Girls In Munirka>༒9599632723 Incall_OutCall AvailableCall Girls in Delhi
 
Call Girls Service Kolkata Aishwarya 🤌 8250192130 🚀 Vip Call Girls Kolkata
Call Girls Service Kolkata Aishwarya 🤌  8250192130 🚀 Vip Call Girls KolkataCall Girls Service Kolkata Aishwarya 🤌  8250192130 🚀 Vip Call Girls Kolkata
Call Girls Service Kolkata Aishwarya 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
办理(CSU毕业证书)澳洲查理斯特大学毕业证成绩单原版一比一
办理(CSU毕业证书)澳洲查理斯特大学毕业证成绩单原版一比一办理(CSU毕业证书)澳洲查理斯特大学毕业证成绩单原版一比一
办理(CSU毕业证书)澳洲查理斯特大学毕业证成绩单原版一比一diploma 1
 
定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一
定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一
定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一ss ss
 
(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...
《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...
《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...ur8mqw8e
 
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...nagunakhan
 
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up NumberCall Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up NumberMs Riya
 
Hifi Babe North Delhi Call Girl Service Fun Tonight
Hifi Babe North Delhi Call Girl Service Fun TonightHifi Babe North Delhi Call Girl Service Fun Tonight
Hifi Babe North Delhi Call Girl Service Fun TonightKomal Khan
 
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一ga6c6bdl
 
vip Model Basti Call Girls 9999965857 Call or WhatsApp Now Book
vip Model Basti Call Girls 9999965857 Call or WhatsApp Now Bookvip Model Basti Call Girls 9999965857 Call or WhatsApp Now Book
vip Model Basti Call Girls 9999965857 Call or WhatsApp Now Bookmanojkuma9823
 

Recently uploaded (20)

9953330565 Low Rate Call Girls In Jahangirpuri Delhi NCR
9953330565 Low Rate Call Girls In Jahangirpuri  Delhi NCR9953330565 Low Rate Call Girls In Jahangirpuri  Delhi NCR
9953330565 Low Rate Call Girls In Jahangirpuri Delhi NCR
 
定制(Salford学位证)索尔福德大学毕业证成绩单原版一比一
定制(Salford学位证)索尔福德大学毕业证成绩单原版一比一定制(Salford学位证)索尔福德大学毕业证成绩单原版一比一
定制(Salford学位证)索尔福德大学毕业证成绩单原版一比一
 
Papular No 1 Online Istikhara Amil Baba Pakistan Amil Baba In Karachi Amil B...
Papular No 1 Online Istikhara Amil Baba Pakistan  Amil Baba In Karachi Amil B...Papular No 1 Online Istikhara Amil Baba Pakistan  Amil Baba In Karachi Amil B...
Papular No 1 Online Istikhara Amil Baba Pakistan Amil Baba In Karachi Amil B...
 
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
 
定制(USF学位证)旧金山大学毕业证成绩单原版一比一
定制(USF学位证)旧金山大学毕业证成绩单原版一比一定制(USF学位证)旧金山大学毕业证成绩单原版一比一
定制(USF学位证)旧金山大学毕业证成绩单原版一比一
 
Alambagh Call Girl 9548273370 , Call Girls Service Lucknow
Alambagh Call Girl 9548273370 , Call Girls Service LucknowAlambagh Call Girl 9548273370 , Call Girls Service Lucknow
Alambagh Call Girl 9548273370 , Call Girls Service Lucknow
 
NO1 Qualified Best Black Magic Specialist Near Me Spiritual Healer Powerful L...
NO1 Qualified Best Black Magic Specialist Near Me Spiritual Healer Powerful L...NO1 Qualified Best Black Magic Specialist Near Me Spiritual Healer Powerful L...
NO1 Qualified Best Black Magic Specialist Near Me Spiritual Healer Powerful L...
 
(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service
(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service
(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service
 
CIVIL ENGINEERING
CIVIL ENGINEERINGCIVIL ENGINEERING
CIVIL ENGINEERING
 
Call Girls In Munirka>༒9599632723 Incall_OutCall Available
Call Girls In Munirka>༒9599632723 Incall_OutCall AvailableCall Girls In Munirka>༒9599632723 Incall_OutCall Available
Call Girls In Munirka>༒9599632723 Incall_OutCall Available
 
Call Girls Service Kolkata Aishwarya 🤌 8250192130 🚀 Vip Call Girls Kolkata
Call Girls Service Kolkata Aishwarya 🤌  8250192130 🚀 Vip Call Girls KolkataCall Girls Service Kolkata Aishwarya 🤌  8250192130 🚀 Vip Call Girls Kolkata
Call Girls Service Kolkata Aishwarya 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
办理(CSU毕业证书)澳洲查理斯特大学毕业证成绩单原版一比一
办理(CSU毕业证书)澳洲查理斯特大学毕业证成绩单原版一比一办理(CSU毕业证书)澳洲查理斯特大学毕业证成绩单原版一比一
办理(CSU毕业证书)澳洲查理斯特大学毕业证成绩单原版一比一
 
定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一
定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一
定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一
 
(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(ANIKA) Wanwadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...
《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...
《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...
 
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
 
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up NumberCall Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
 
Hifi Babe North Delhi Call Girl Service Fun Tonight
Hifi Babe North Delhi Call Girl Service Fun TonightHifi Babe North Delhi Call Girl Service Fun Tonight
Hifi Babe North Delhi Call Girl Service Fun Tonight
 
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一
 
vip Model Basti Call Girls 9999965857 Call or WhatsApp Now Book
vip Model Basti Call Girls 9999965857 Call or WhatsApp Now Bookvip Model Basti Call Girls 9999965857 Call or WhatsApp Now Book
vip Model Basti Call Girls 9999965857 Call or WhatsApp Now Book
 

Fpga 04-verilog-programming

  • 1. ENGR. RASHID FARID CHISHTI LECTURER,DEE, FET, IIUI CHISHTI@IIU.EDU.PK WEEK 4 VERILOG PROGRAMMING FPGA Based System Design Sunday, May 17, 2015 1 www.iiu.edu.pk
  • 2. A hardware description language is a computer language that is used to describe hardware. Currently, almost all integrated circuits are designed with using HDL. Two HDLs are widely used  Verilog HDL  VHDL (Very High Speed Integrated Circuit Hardware Description Language) Schematic design entry can be replaced by writing HDL code that CAD tools understand. CAD tools can verify the HDL codes, and create the circuits automatically from HDL codes. Hardware Description Language Sunday, May 17, 2015www.iiu.edu.pk 2
  • 3. We use Verilog, not VHDL for FPGA programming  Verilog is more popular in industry than VHDL  They offer similar features History of Verilog  In 1980s, originally developed by Gateway Design Automation.  In 1990, was put in public domain.  In 1995, adopted as an IEEE standard 1364-1995  In 2001, an enhanced version, Verilog 2001 Functions of Verilog  Design entry, like schematic  Simulation and verification of your design  Synthesis Facts About Verilog Sunday, May 17, 2015www.iiu.edu.pk 3
  • 4. Verilog may be used to model circuits and behaviors at various levels of abstraction:  Transistor/Switch Level Modeling. LOW LEVEL  Gate Level Modeling.  Data Flow Modeling.  Behavioral or algorithmic Modeling. HIGH LEVEL For design with FPGA devices, transistor and gate level modeling is not appropriate. Register Transfer Level (RTL) is a combination of behavioral and dataflow Modeling. Verilog Usage Sunday, May 17, 2015www.iiu.edu.pk 4
  • 5. //Define inverter module my_not(out, in); output out; input in; // declare power // and ground supply1 pwr; supply0 gnd; //instantiate nmos // and pmos switches pmos (out, pwr, in); nmos (out, gnd, in); endmodule Switch Level Modeling Sunday, May 17, 2015www.iiu.edu.pk 5
  • 6. // A simple example module gate1 (a,b,c); input a,b; output c; and (c,a,b); endmodule  Modules are the basic building blocks in Verilog.  A logic circuit  module, Its ports: inputs and outputs  Begins with module, ends with endmodule A Simple Verilog Example Sunday, May 17, 2015www.iiu.edu.pk 6 comment line module name port list end module port declarations a b c gate1
  • 7. module eg1 (a,b,c,f); input a,b,c; output f; wire g,h,i; and (g,a,b); not (h,b); and (i,h,c); or (f,g,i); endmodule Gate Level Modeling vs Data Flow Modeling Sunday, May 17, 2015www.iiu.edu.pk 7 // Data Flow Modeling module ex1 (a,b,c,f); input a,b,c; output f; assign f = (a&b) | (~b&c); endmodule // Data Flow Modeling module ex1 (a,b,c,f); input a,b,c; output f; assign f = (a&b) | (~b&c); endmodule a c F = AB + B'C b fg ih
  • 8. Writing Test Bench Sunday, May 17, 2015www.iiu.edu.pk 8 /* testbench for ex1 block *//* testbench for ex1 block */ modulemodule ex1_tb ;ex1_tb ; wirewire f1;f1; regreg a1, b1, c1;a1, b1, c1; ex1 my_module(a1, b1, c1, f1);ex1 my_module(a1, b1, c1, f1); initialinitial beginbegin $monitor$monitor(($time$time," ", a1, b1,," ", a1, b1, c1, ," ", f1);c1, ," ", f1); a1 = 1'ba1 = 1'b00; b1 = 1'b; b1 = 1'b11; c1 = 1'b; c1 = 1'b00;; #5#5 a1 = 1'ba1 = 1'b11; b1 = 1'b; b1 = 1'b11; c1 = 1'b; c1 = 1'b11;; #5#5 a1 = 1'ba1 = 1'b11; b1 = 1'b; b1 = 1'b00; c1 = 1'b; c1 = 1'b11;; #5#5 a1 = 1'ba1 = 1'b11; b1 = 1'b; b1 = 1'b11; c1 = 1'b; c1 = 1'b11;; #10#10 $finish$finish;; endend endmoduleendmodule /* testbench for ex1 block *//* testbench for ex1 block */ modulemodule ex1_tb ;ex1_tb ; wirewire f1;f1; regreg a1, b1, c1;a1, b1, c1; ex1 my_module(a1, b1, c1, f1);ex1 my_module(a1, b1, c1, f1); initialinitial beginbegin $monitor$monitor(($time$time," ", a1, b1,," ", a1, b1, c1, ," ", f1);c1, ," ", f1); a1 = 1'ba1 = 1'b00; b1 = 1'b; b1 = 1'b11; c1 = 1'b; c1 = 1'b00;; #5#5 a1 = 1'ba1 = 1'b11; b1 = 1'b; b1 = 1'b11; c1 = 1'b; c1 = 1'b11;; #5#5 a1 = 1'ba1 = 1'b11; b1 = 1'b; b1 = 1'b00; c1 = 1'b; c1 = 1'b11;; #5#5 a1 = 1'ba1 = 1'b11; b1 = 1'b; b1 = 1'b11; c1 = 1'b; c1 = 1'b11;; #10#10 $finish$finish;; endend endmoduleendmodule module ex1 (a,b,c,f); input a,b,c; output f; assign f=(a&b)|(!b&c); endmodule module ex1 (a,b,c,f); input a,b,c; output f; assign f=(a&b)|(!b&c); endmodule Each signal in Verilog belongs to either a net or a register A net (wire) represents a physical wire. Its signal value is determined by its driver. If it is not driven by any driver, its value is high impedance (Z). A register is like a variable in programming languages. It keeps its value until a new value is assigned to it. Unlike registers, nets do not have storage capacity. Each signal in Verilog belongs to either a net or a register A net (wire) represents a physical wire. Its signal value is determined by its driver. If it is not driven by any driver, its value is high impedance (Z). A register is like a variable in programming languages. It keeps its value until a new value is assigned to it. Unlike registers, nets do not have storage capacity. print to a console
  • 9. Verilog supports basic logic gates as predefined primitives. There are two classes of basic gates: and/or gates and buf/not gates. And/or gates have one scalar output and multiple scalar inputs The first terminal in the list of gate terminals is an output and the other terminals are inputs. Example 1: Gate Instantiation of And/Or Gates wire OUT, IN1, IN2; and a1(OUT, IN1, IN2); xnor (OUT, IN1, IN2); // More than two inputs; // 3 input nand gate nand (OUT, IN1, IN2, IN3); Basic Gates Sunday, May 17, 2015www.iiu.edu.pk 9
  • 10. Truth Tables for And/Or Gates Sunday, May 17, 2015www.iiu.edu.pk 10 and 0 1 x z   or 0 1 x z   xor 0 1 x z 0 0 0 0 0   0 0 1 x x   0 0 1 x x 1 0 1 x x   1 1 1 1 1   1 1 0 x x x 0 x x x   x x 1 x x   x x x x x z 0 x x x   z x 1 x x   z x x x x nand 0 1 x z nor 0 1 x z xnor 0 1 x z 0 1 1 1 1 0 1 0 x x 0 1 0 x x 1 1 0 x x 1 0 0 0 0 1 0 1 x x x 1 x x x x x 0 x x x x x x x z 1 x x x z x 0 x x z x x x X 1=True , 0=False, X=Unknown, Z=High impedance
  • 11. Buf/not gates have one scalar input and one or more scalar outputs The last terminal in the port list is connected to the input. Other terminals are connected to the outputs Basic buf/not gate primitives in verilog are buf not Buf/not gates with additional control signal are bufif1, notif1, bufif0, notif0 Buf/Not Gates Sunday, May 17, 2015www.iiu.edu.pk 11 buf   not input output   input output 0 0   0 1 1 1   1 0 x x   x x z x   z x
  • 12. The L and H symbols have a special meaning. The L symbol means the output has 0 or z value. The H symbol means the output has 1 or z value.  Any transition to H or L is treated as a transition to x. Examples //Instantiation of bufif gates. bufif1 b1 (out, in, ctrl); bufif0 b0 (out, in, ctrl); //Instantiation of notif gates notif1 n1 (out, in, ctrl); notif0 n0 (out, in, ctrl); x={0,1,z} L={0,z} H={1,z} bufif1 Ctrl   notif1 Ctrl 0 1 x z   0 1 x z in 0 z 0 L L   in 0 z 1 H H 1 z 1 H H   1 z 0 L L x z x x x   x z x x x z z x x x   z z x x x bufif0 Ctrl notif0 Ctrl 0 1 x z 0 1 x z in 0 0 z L L   in 0 1 z H H 1 1 z H H   1 0 z L L x x z x x   x x z x x z x z x x   z x z x x Truth Table for bufif/notif Gates Sunday, May 17, 2015www.iiu.edu.pk 12

Editor's Notes

  1. Behavioral or algorithmic level This is the highest level of abstraction provided by Verilog HDL. A module can be implemented in terms of the desired design algorithm without concern for the hardware implementation details. Designing at this level is very similar to C programming. Dataflow level At this level, the module is designed by specifying the data flow. The designer is aware of how data flows between hardware registers and how the data is processed in the design. Gate level The module is implemented in terms of logic gates and interconnections between these gates. Design at this level is similar to describing a design in terms of a gate-level logic diagram. Switch level This is the lowest level of abstraction provided by Verilog. A module can be implemented in terms of switches, storage nodes, and the interconnections between them. Design at this level requires knowledge of switch-level implementation details. Verilog allows the designer to mix and match all four levels of abstractions in a design. In the digital design community, the term register transfer level (RTL) is frequently used for a Verilog description that uses a combination of behavioral and dataflow constructs and is acceptable to logic synthesis tools.