SlideShare une entreprise Scribd logo
1  sur  49
Télécharger pour lire hors ligne
Verilog Fundamentals
Shubham Singh
Junior Undergrad.
Electrical Engineering
VERILOG FUNDAMENTALS
HDLs HISTORY
HOW FPGA & VERILOG ARE
RELATED
CODING IN VERILOG
HDLs HISTORY
HDL – HARDWARE DESCRIPTION LANGUAGE
EARLIER DESIGNERS USED BREADBOARDS
FOR DESIGNING
PRINTED CIRCUIT
BOARD
SOLDERLESS
BREADBOARD
HDLs ENABLED LOGIC LEVEL SIMULATION
AND TESTING
MANUAL
SIMULATE
GATE LEVEL
DESCRIPTION
THEN DESIGNERS BEGAN TO USE HDLs
FOR HIGHER LEVEL DESIGN
MANUAL
MANUAL
MANUAL
SIMUALTE
SIMULATE
SIMULATE
BEHAVIOURAL
ALGORITHM
REGISTER
TRANSFER
LEVEL
GATE LEVEL
HDLs LED TO TOOLS FOR AUTOMATIC
TRANSLATION
AUTOPLACE & ROUTE
GATE LEVEL
REGISTER
TRANSFER LEVEL
LOGIC SYNTHESIS
MANUAL
BEHAVIOURAL
ALGORITHM
SIMULATE
SIMULATE
SIMULATE
THE CURRENT SITUATION
C,C++
BEHAVIOURAL
VERILOG
MATLAB
STRUCTURAL
VERILOG
GATE
LEVEL
COMPILERS ARE NOT
AVAILABLE TO CONVERT
BEHAVIOURAL LEVEL TO
REGISTER TRANSFER
LEVEL
LOGIC SYNTHESIS
MUX 4 : GATE LEVEL DESIGNING
modulemux4(input a,b,c,d, input[1:0] sel, output out);
wire[1:0] sel_b;
not not0( sel_b[0], sel[0] );
not not1( sel_b[1], sel[1] );
wire n0, n1, n2, n3;
and and0( n0, c, sel[1] );
and and1( n1, a, sel_b[1] );
and and2( n2, d, sel[1] );
and and3( n3, b, sel_b[1] );
wirex0, x1;
nor nor0( x0, n0, n1 );
nor nor1( x1, n2, n3 );
wirey0, y1;
or or0( y0, x0, sel[0] );
or or1( y1, x1, sel_b[0] );
nand nand0( out, y0, y1 );
endmodule
MUX 4 : REGISTER TRANSFER LEVEL
Module mux4( input a, b, c, d
input[1:0] sel,
Output out );
wire out, t0, t1;
assign out = ( sel == 0 ) ? a :
( sel == 1 ) ? b :
( sel == 2 ) ? c :
( sel == 3 ) ? d : 1’bx;
endmodule
VERILOG & FPGAs
VERILOG
Verilog is a HARDWARE DESCRIPTION
LANGUAGE.
HDLs are used to describe a digital system
Not a programming language despite the
syntax being similar to C
Synthesized (analogous to compiled for C)
to give the circuit logic diagram
FPGAs
 Field Programmable Gate Array
 A Fully configurable IC
 FPGAs contain programmable logic components called
logic blocks.
 Contain hierarchy of reconfigurable interconnects that
allow the blocks to be wired together.
 Logic Blocks can be configured to any complex circuit.
 FPGA can be made to work as a Xor gate, a Counter or
even bigger- an entire Processor!
An FPGA
Logic Blocks
HOW TO PROGRAM FPGAs
 Configured using a Hardware Description
Language
 Can be configured by any way by the user
 Basic Idea :
BEHAVIOURAL DESCRIPTION
OF REQUIRED CIRCUIT
A COMPLETE CIRCUIT
DIAGRAM
VERILOG
SYNTHESISER
Synthesis of VERILOG :
CODING IN VERILOG
• BREAKING CIRCUITS INTO VARIOUS
BUILDING BLOCKS CALLED “MODULE”
• DEFINING MODULE
• CONNECTING VARIOUS MODULES
CODING IN VERILOG
Communication between a module and its
environment is achieved by using Ports
Ports are of three types: input, output,
inout
AN EXAMPLE : 4029 COUNTER
• Name: 4029
• Input Ports: One
• Output Ports: Four
• Size
• Driver type
• Internal Logic: At every rising edge of the
clock, increment the output by one
MODULE
A “Black Box” in Verilog with inputs,
outputs and internal logic working.
So, a module can be used to implement a
counter.
A module is defined as
module <specific type>(<port list>);
DEFINING 4029 MODULE
 Way 1:
module 4029(clk,out,reset,enable);
 Way 2:
module 4029(clk, a, b, c, d, reset, enable);
 Input and Output Ports in each of the above?
 EVERY PORT MUST HAVE A DIRECTION AND BITWIDTH
 Every module ends with the statement
endmodule
DECLARING PORTS
Way 1:
input clk;
input reset;
input enable;
output a,b,c,d;
Way 2:
input clk;
input reset;
input enable;
output [3:0] out;
DRIVERS IN VERILOG
 We need drivers for this module in order to interact with
the ports and describe its logical working.
 Two types of drivers:
• Can store a value (for example, flip-flop) : REG
• Cannot store a value, but connects two points (for
example, a wire) : WIRE
DRIVERS IN 4029
 Ports defined as wires?
• clk
• reset
• enable
We do not need to stores the values of these ports in our
logical block.
 Ports defined as reg?
• a,b,c,d
• out
We need to store them so that we could modify their values
when
required.
DEFINING DRIVERS FOR 4029
 Way 1:
wire clk;
wire reset;
wire enable;
reg a,b.c,d;
 Way 2:
wire clk;
wire reset;
wire enable;
reg [3:0] out;
Defining Internal Logic
OPERATORS AND CONDITIONAL
OPERATORS
All the arithmetic as well as logical
operators in Verilog are similar to C, except
++ and -- which are not available in Verilog.
Conditional statements are also similar to C
with following modifications:
• { is replaced by begin.
• } is replaced by end.
COMBINATIONAL CIRCUITS
Combinational circuits are acyclic
interconnections of gates.
And, Or, Not, Xor, Nand, Nor ……
Multiplexers, Decoders, Encoders ….
OUTPUT IS A FUNCTION OF PRESENT
INPUT ONLY
How are these gates, muxs etc. abstracted
in Verilog?
Gates, Add, Multiply … : by simple operators
like in C
Multiplexers … : by control statements like if-
else, case, etc
Gate level implementation of above high
level operators done by Verilog synthesizer.
SEQUENTIAL CIRCUITS
Circuits containing state elements are
called sequential circuits
OUTPUT DEPENDS ON THE PRESENT INPUT
AS WELL AS ON ITS PRESENT STATE.
How do you implement such an element in
Verilog?
always block
 Syntax
always @(condition)
begin
//Code
end
 Blocks starting with keyword always run
simultaneously.
 @ symbol is used to specify the condition which
should be satisfied for the execution of this block.
Usage of always block
 always
The code in this block will keep on executing.
 always @(a)
The code in this block will be executed every time
the value of a changes.
 always @(posedge clk)
This block is executed at every positive edge of
clk.
always @ BLOCK
It is an abstraction provided in Verilog to
mainly implement sequential circuits.
Also used for combinational circuits.
BLOCKING AND NON-BLOCKING
ASSIGNMENTS
 Non-blocking assignments happen in parallel.
always @ ( #sensitivity list # ) begin
B <= A ;
C <= B ; (A,B) = (1,2) -> (B,C) = (1,2)
end
 Blocking assignments happen sequentially.
always @ ( #sensitivity list # ) begin
B = A ;
C = B ; (A,B) = (1,2) -> (B,C) = (1,1)
end
POINTS TO NOTE
Use always@(*) block with blocking
assignments for combinational circuits
Use always@( posedge CLK) block with non-
blocking assignments for sequential
circuits.
Do not mix blocking and non-blocking
assignments.
A COMPLETE 4029 MODULE
module 4029 ( input wire clk,
input wire reset,
input wire enable,
output [3:0] reg out);
//You can declare direction as well as data type
//in the module definition.
always @(posedge clk)
begin
if (reset == 0 && enable == 0)
begin
out <= out +1;
end
end
always @(reset or enable)
begin
if (reset == 1’b1)
begin
out <= 0;
end
end
endmodule
AN EXAMPLE
ANOTHER EXAMPLE
WRONG SOLUTION
ANOTHER WAY : MULTIPLE always BLOCK
WRONG SOLUTION
Connecting Various Modules
Various modules are interconnected to
make a larger circuit (or module).
Each sub-module has a separate
Verilog file.
A sub-module may have another sub-
module in its circuit.
One needs to indicate the top level
module before synthesis.
EXAMPLE
module 4029(input wire clk, output
[3:0]reg out);
module 7447(input [3:0] reg in, output
[6:0] reg bcd);
module TOP(input wire clk, output
[6:0] reg bcd);
INSTANTIATION
 USED TO INTERCONNECT VARIOUS MODULES
 In the above example, we need to instantiate the
two sub-modules in the top level module
 THIS IS DONE AS FOLLOWS:
wire [3:0] c;
4029 counter (.clk(clk), .out(c) );
7447 decoder (.in(c), .bcd(bcd));
Problem Statement
 Level 1 : Theoretical Questions on basic syntax of
Verilog
 Level 2 : Design a digital system using Verilog .
(weightage will be given to how much modular
your circuit is )

Contenu connexe

Similaire à Verilog_ppt.pdf

Session 8 assertion_based_verification_and_interfaces
Session 8 assertion_based_verification_and_interfacesSession 8 assertion_based_verification_and_interfaces
Session 8 assertion_based_verification_and_interfacesNirav Desai
 
System design using HDL - Module 3
System design using HDL - Module 3System design using HDL - Module 3
System design using HDL - Module 3Aravinda Koithyar
 
Gate level design -For beginners
Gate level design -For beginnersGate level design -For beginners
Gate level design -For beginnersDr.YNM
 
Programmable Logic Array
Programmable Logic Array Programmable Logic Array
Programmable Logic Array Sharun Rajeev
 
ADC and DAC interfacing.pdf
ADC and DAC interfacing.pdfADC and DAC interfacing.pdf
ADC and DAC interfacing.pdfVikasMahor3
 
tau 2015 spyrou fpga timing
tau 2015 spyrou fpga timingtau 2015 spyrou fpga timing
tau 2015 spyrou fpga timingTom Spyrou
 
L6_Slides_vhdl coures temporary hair dye for dark hair
L6_Slides_vhdl coures temporary hair dye for dark hairL6_Slides_vhdl coures temporary hair dye for dark hair
L6_Slides_vhdl coures temporary hair dye for dark hairloyad20119
 
Digital system design practical file
Digital system design practical fileDigital system design practical file
Digital system design practical fileArchita Misra
 
Seminar on field programmable gate array
Seminar on field programmable gate arraySeminar on field programmable gate array
Seminar on field programmable gate arraySaransh Choudhary
 
vlsi design using verilog presentaion 1
vlsi design using verilog   presentaion 1vlsi design using verilog   presentaion 1
vlsi design using verilog presentaion 1MANDHASAIGOUD1
 
Galil ioc7007 catalog
Galil ioc7007 catalogGalil ioc7007 catalog
Galil ioc7007 catalogElectromate
 

Similaire à Verilog_ppt.pdf (20)

VLSI & E-CAD Lab Manual
VLSI & E-CAD Lab ManualVLSI & E-CAD Lab Manual
VLSI & E-CAD Lab Manual
 
10617568.ppt
10617568.ppt10617568.ppt
10617568.ppt
 
Plc
PlcPlc
Plc
 
Session 8 assertion_based_verification_and_interfaces
Session 8 assertion_based_verification_and_interfacesSession 8 assertion_based_verification_and_interfaces
Session 8 assertion_based_verification_and_interfaces
 
e CAD lab manual
e CAD lab manuale CAD lab manual
e CAD lab manual
 
System design using HDL - Module 3
System design using HDL - Module 3System design using HDL - Module 3
System design using HDL - Module 3
 
Gate level design -For beginners
Gate level design -For beginnersGate level design -For beginners
Gate level design -For beginners
 
EMBEDDED SYSTEM BASICS
EMBEDDED SYSTEM BASICSEMBEDDED SYSTEM BASICS
EMBEDDED SYSTEM BASICS
 
Programmable Logic Array
Programmable Logic Array Programmable Logic Array
Programmable Logic Array
 
CPLD & FPGA
CPLD & FPGACPLD & FPGA
CPLD & FPGA
 
ADC and DAC interfacing.pdf
ADC and DAC interfacing.pdfADC and DAC interfacing.pdf
ADC and DAC interfacing.pdf
 
tau 2015 spyrou fpga timing
tau 2015 spyrou fpga timingtau 2015 spyrou fpga timing
tau 2015 spyrou fpga timing
 
L6_Slides_vhdl coures temporary hair dye for dark hair
L6_Slides_vhdl coures temporary hair dye for dark hairL6_Slides_vhdl coures temporary hair dye for dark hair
L6_Slides_vhdl coures temporary hair dye for dark hair
 
Digital system design practical file
Digital system design practical fileDigital system design practical file
Digital system design practical file
 
ECAD lab manual
ECAD lab manualECAD lab manual
ECAD lab manual
 
Seminar on field programmable gate array
Seminar on field programmable gate arraySeminar on field programmable gate array
Seminar on field programmable gate array
 
Shishupal plc
Shishupal plcShishupal plc
Shishupal plc
 
vlsi design using verilog presentaion 1
vlsi design using verilog   presentaion 1vlsi design using verilog   presentaion 1
vlsi design using verilog presentaion 1
 
Galil ioc7007 catalog
Galil ioc7007 catalogGalil ioc7007 catalog
Galil ioc7007 catalog
 
PLC Architecture
PLC ArchitecturePLC Architecture
PLC Architecture
 

Dernier

SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
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
 
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
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
(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
 
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
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
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
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
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
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
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
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...ranjana rawat
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 

Dernier (20)

SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
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
 
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
 
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
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
(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...
 
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
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
★ 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
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
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...
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
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
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 

Verilog_ppt.pdf

  • 1. Verilog Fundamentals Shubham Singh Junior Undergrad. Electrical Engineering
  • 2. VERILOG FUNDAMENTALS HDLs HISTORY HOW FPGA & VERILOG ARE RELATED CODING IN VERILOG
  • 3. HDLs HISTORY HDL – HARDWARE DESCRIPTION LANGUAGE
  • 4. EARLIER DESIGNERS USED BREADBOARDS FOR DESIGNING PRINTED CIRCUIT BOARD SOLDERLESS BREADBOARD
  • 5. HDLs ENABLED LOGIC LEVEL SIMULATION AND TESTING MANUAL SIMULATE GATE LEVEL DESCRIPTION
  • 6. THEN DESIGNERS BEGAN TO USE HDLs FOR HIGHER LEVEL DESIGN MANUAL MANUAL MANUAL SIMUALTE SIMULATE SIMULATE BEHAVIOURAL ALGORITHM REGISTER TRANSFER LEVEL GATE LEVEL
  • 7. HDLs LED TO TOOLS FOR AUTOMATIC TRANSLATION AUTOPLACE & ROUTE GATE LEVEL REGISTER TRANSFER LEVEL LOGIC SYNTHESIS MANUAL BEHAVIOURAL ALGORITHM SIMULATE SIMULATE SIMULATE
  • 8. THE CURRENT SITUATION C,C++ BEHAVIOURAL VERILOG MATLAB STRUCTURAL VERILOG GATE LEVEL COMPILERS ARE NOT AVAILABLE TO CONVERT BEHAVIOURAL LEVEL TO REGISTER TRANSFER LEVEL LOGIC SYNTHESIS
  • 9. MUX 4 : GATE LEVEL DESIGNING modulemux4(input a,b,c,d, input[1:0] sel, output out); wire[1:0] sel_b; not not0( sel_b[0], sel[0] ); not not1( sel_b[1], sel[1] ); wire n0, n1, n2, n3; and and0( n0, c, sel[1] ); and and1( n1, a, sel_b[1] ); and and2( n2, d, sel[1] ); and and3( n3, b, sel_b[1] ); wirex0, x1; nor nor0( x0, n0, n1 ); nor nor1( x1, n2, n3 ); wirey0, y1; or or0( y0, x0, sel[0] ); or or1( y1, x1, sel_b[0] ); nand nand0( out, y0, y1 ); endmodule
  • 10. MUX 4 : REGISTER TRANSFER LEVEL Module mux4( input a, b, c, d input[1:0] sel, Output out ); wire out, t0, t1; assign out = ( sel == 0 ) ? a : ( sel == 1 ) ? b : ( sel == 2 ) ? c : ( sel == 3 ) ? d : 1’bx; endmodule
  • 12. VERILOG Verilog is a HARDWARE DESCRIPTION LANGUAGE. HDLs are used to describe a digital system Not a programming language despite the syntax being similar to C Synthesized (analogous to compiled for C) to give the circuit logic diagram
  • 13. FPGAs  Field Programmable Gate Array  A Fully configurable IC  FPGAs contain programmable logic components called logic blocks.  Contain hierarchy of reconfigurable interconnects that allow the blocks to be wired together.  Logic Blocks can be configured to any complex circuit.  FPGA can be made to work as a Xor gate, a Counter or even bigger- an entire Processor!
  • 16. HOW TO PROGRAM FPGAs  Configured using a Hardware Description Language  Can be configured by any way by the user  Basic Idea : BEHAVIOURAL DESCRIPTION OF REQUIRED CIRCUIT A COMPLETE CIRCUIT DIAGRAM VERILOG SYNTHESISER
  • 18. CODING IN VERILOG • BREAKING CIRCUITS INTO VARIOUS BUILDING BLOCKS CALLED “MODULE” • DEFINING MODULE • CONNECTING VARIOUS MODULES
  • 19. CODING IN VERILOG Communication between a module and its environment is achieved by using Ports Ports are of three types: input, output, inout
  • 20. AN EXAMPLE : 4029 COUNTER • Name: 4029 • Input Ports: One • Output Ports: Four • Size • Driver type • Internal Logic: At every rising edge of the clock, increment the output by one
  • 21. MODULE A “Black Box” in Verilog with inputs, outputs and internal logic working. So, a module can be used to implement a counter. A module is defined as module <specific type>(<port list>);
  • 22. DEFINING 4029 MODULE  Way 1: module 4029(clk,out,reset,enable);  Way 2: module 4029(clk, a, b, c, d, reset, enable);  Input and Output Ports in each of the above?  EVERY PORT MUST HAVE A DIRECTION AND BITWIDTH  Every module ends with the statement endmodule
  • 23. DECLARING PORTS Way 1: input clk; input reset; input enable; output a,b,c,d; Way 2: input clk; input reset; input enable; output [3:0] out;
  • 24. DRIVERS IN VERILOG  We need drivers for this module in order to interact with the ports and describe its logical working.  Two types of drivers: • Can store a value (for example, flip-flop) : REG • Cannot store a value, but connects two points (for example, a wire) : WIRE
  • 25. DRIVERS IN 4029  Ports defined as wires? • clk • reset • enable We do not need to stores the values of these ports in our logical block.  Ports defined as reg? • a,b,c,d • out We need to store them so that we could modify their values when required.
  • 26. DEFINING DRIVERS FOR 4029  Way 1: wire clk; wire reset; wire enable; reg a,b.c,d;  Way 2: wire clk; wire reset; wire enable; reg [3:0] out;
  • 28. OPERATORS AND CONDITIONAL OPERATORS All the arithmetic as well as logical operators in Verilog are similar to C, except ++ and -- which are not available in Verilog. Conditional statements are also similar to C with following modifications: • { is replaced by begin. • } is replaced by end.
  • 29. COMBINATIONAL CIRCUITS Combinational circuits are acyclic interconnections of gates. And, Or, Not, Xor, Nand, Nor …… Multiplexers, Decoders, Encoders …. OUTPUT IS A FUNCTION OF PRESENT INPUT ONLY
  • 30. How are these gates, muxs etc. abstracted in Verilog? Gates, Add, Multiply … : by simple operators like in C Multiplexers … : by control statements like if- else, case, etc Gate level implementation of above high level operators done by Verilog synthesizer.
  • 31. SEQUENTIAL CIRCUITS Circuits containing state elements are called sequential circuits OUTPUT DEPENDS ON THE PRESENT INPUT AS WELL AS ON ITS PRESENT STATE. How do you implement such an element in Verilog?
  • 32. always block  Syntax always @(condition) begin //Code end  Blocks starting with keyword always run simultaneously.  @ symbol is used to specify the condition which should be satisfied for the execution of this block.
  • 33. Usage of always block  always The code in this block will keep on executing.  always @(a) The code in this block will be executed every time the value of a changes.  always @(posedge clk) This block is executed at every positive edge of clk.
  • 34. always @ BLOCK It is an abstraction provided in Verilog to mainly implement sequential circuits. Also used for combinational circuits.
  • 35. BLOCKING AND NON-BLOCKING ASSIGNMENTS  Non-blocking assignments happen in parallel. always @ ( #sensitivity list # ) begin B <= A ; C <= B ; (A,B) = (1,2) -> (B,C) = (1,2) end  Blocking assignments happen sequentially. always @ ( #sensitivity list # ) begin B = A ; C = B ; (A,B) = (1,2) -> (B,C) = (1,1) end
  • 36. POINTS TO NOTE Use always@(*) block with blocking assignments for combinational circuits Use always@( posedge CLK) block with non- blocking assignments for sequential circuits. Do not mix blocking and non-blocking assignments.
  • 37. A COMPLETE 4029 MODULE module 4029 ( input wire clk, input wire reset, input wire enable, output [3:0] reg out); //You can declare direction as well as data type //in the module definition.
  • 38. always @(posedge clk) begin if (reset == 0 && enable == 0) begin out <= out +1; end end
  • 39. always @(reset or enable) begin if (reset == 1’b1) begin out <= 0; end end endmodule
  • 43. ANOTHER WAY : MULTIPLE always BLOCK
  • 46. Various modules are interconnected to make a larger circuit (or module). Each sub-module has a separate Verilog file. A sub-module may have another sub- module in its circuit. One needs to indicate the top level module before synthesis.
  • 47. EXAMPLE module 4029(input wire clk, output [3:0]reg out); module 7447(input [3:0] reg in, output [6:0] reg bcd); module TOP(input wire clk, output [6:0] reg bcd);
  • 48. INSTANTIATION  USED TO INTERCONNECT VARIOUS MODULES  In the above example, we need to instantiate the two sub-modules in the top level module  THIS IS DONE AS FOLLOWS: wire [3:0] c; 4029 counter (.clk(clk), .out(c) ); 7447 decoder (.in(c), .bcd(bcd));
  • 49. Problem Statement  Level 1 : Theoretical Questions on basic syntax of Verilog  Level 2 : Design a digital system using Verilog . (weightage will be given to how much modular your circuit is )