SlideShare a Scribd company logo
1 of 65
Download to read offline
Tutorial on Verilog HDL
HDL
Hardware Description Languages
Widely used in logic design
Verilog and VHDL
Describe hardware using code
Document logic functions
Simulate logic before building
Synthesize code into gates and layout
Requires a library of standard cells
Verilog
Verilog is one of the two major Hardware
Description Languages(HDL) used by hardware
designers in industry and academia.
VHDL is another one
Verilog is easier to learn and use than VHDL
Verilog HDL allows a hardware designer to
describer designs at a high level of abstraction
such as at the architectural or behavioral level as
well as the lower implementation levels (i.e.,
gate and switch levels).
Why use Verilog HDL
Digital system are highly complex.
Verilog language provides the digital designer
a software platform.
Verilog allows user to express their design
with behavioral constructs.
A program tool can convert the Verilog
program to a description that was used to
make chip, like VLSI.
Module portsModule name
Verilog keywords
Taste of Verilog
module Add_half ( sum, c_out, a, b );
input a, b;
output sum, c_out;
wire c_out_bar;
xor (sum, a, b);
// xor G1(sum, a, b);
nand (c_out_bar, a, b);
not (c_out, c_out_bar);
endmodule
DeclarationDeclaration of port
modes
DeclarationDeclaration of internal
signal
InstantiationInstantiation of primitive
gates
c_out
a
b sum
c_out_bar
G1G1
Lexical Convention
Lexical convention are close to C++.
Comment
// to the end of the line.
/* to */ across several lines
. Keywords are lower case letter.
the language is case sensitive
Lexical Convention
Numbers are specified in the traditional form
or below .
<size><base format><number>
Size: contains decimal digitals that specify the
size of the constant in the number of bits.
Base format: is the single character ‘ followed
by one of the following characters
b(binary),d(decimal),o(octal),h(hex).
Number: legal digital.
Lexical Convention
Example :
347 // decimal number
4’b101 // 4- bit binary number 0101
2’o12 // 2-bit octal number
5’h87f7 // 5-bit hex number h87f7
2’d83 // 2-bit decimal number
String in double quotes
“ this is a introduction”
Lexical Convention
Operator are one, two, or three characters
and are used in the expressions.
just like C++.
Identifier: specified by a letter or underscore
followed by more letter or digits, or signs.
Program structure
Structure
module <module name> (< port list>);
< declares>
<module items>
endmodule
. Module name
an identifier that uniquely names the module.
. Port list
a list of input, inout and output ports which are
referenced in other modules.
Program structure
. Declares
section specifies data objects as registers,
memories and wires as well as procedural constructs
such as functions and tasks.
. Module items
initial constructs
always constructs
assignment
……………….
Test Module structure
module <test module name> ;
// Data type declaration.// Data type declaration. Inputs declared asInputs declared as regreg andand
outputs declared asoutputs declared as wirewire
// Instantiate module ( call the module that is// Instantiate module ( call the module that is goinggoing
to be tested)to be tested)
// Apply the stimulus// Apply the stimulus
// Display results// Display results
endmodule
Three Modeling Styles in Verilog
Structural modeling (Gate-level)
Use predefined or user-defined
primitive gates.
Dataflow modeling
Use assignment statements (assign)
Behavioral modeling
Use procedural assignment
statements (always)
Structural model
//structural model of a NAND gate
// program nand2.v
module my_NAND(A, B, F);
input A, B;
output F;
nand G(F, A, B); // first parameter must be output.
endmodule
Example of gate NAND
module test_my_nand;
// Test bench to test nand
reg A, B; wire F;
my_NAND test_my_nand(A, B, F); // instantiate my_NAND.
initial
begin // apply the stimulus, test data
A = 1'b0; B = 1'b0;
#100 A = 1'b1; // delay one simulation cycle, then change A=>1.
#100 B = 1'b1;
#100 A = 1'b0;
end
initial #500 $finish;
begin // setup monitoring
//$monitor("Time=%0d a=%b b=%b out1=%b", $time, A, B, F);
//#500 $finish;
end
endmodule
Test bench module test_nand for the nand1.v
//Gate-level description of a 2-to-4-line decoder
//Figure 4-19
module decoder_gl (input A,B,E, output [0:3] D);
wire Anot, Bnot, Enot;
not
n1 (Anot, A),
n2 (Bnot, B),
n3 (Enot, E);
nand
n4 (D[0], Anot, Bnot, Enot),
n5 (D[1], Anot,B, Enot),
n6 (D[2], A, Bnot, Enot),
n7 (D[3], A, B, Enot);
endmodule
Structural Modeling
//Gate-level hierarchical description of 4-bit adder
// Description of half adder (see Fig 4-5b)
//module halfadder (S,C,x,y);
// input x,y;
// output S,C;
module halfadder (output S,C, input x,y);
//Instantiate primitive gates
xor (S,x,y);
and (C,x,y);
endmodule
//Description of full adder (see Fig 4-8)
module fulladder (output S,C, input x,y,z);
wire S1,C1,C2; //Outputs of first XOR and two AND gates
halfadder HA1 (S1,C1,x,y), HA2 (S,C2,S1,z); //Instantiate the halfadder
or g1(C,C2,C1);
endmodule
//Description of 4-bit adder (see Fig 4-9)
module ripple_carry_4bit_adder (output [3:0] S, output C4, input [3:0] A,B, input C0)
// input [3:0] A,B;
//input C0;
//output [3:0] S;
//output C4;
wire C1,C2,C3; //Intermediate carries
//Instantiate the fulladder
fulladder FA0 (S[0], C1, A[0], B[0], C0),
FA1 (S[1], C2, A[1], B[1], C1),
FA2 (S[2], C3, A[2], B[2], C2),
FA3 (S[3], C4, A[3], B[3], C3);
endmodule
The names are required!
Dataflow Modeling
//HDL Example 4-3
//----------------------------------------------
//Dataflow description of a 2-to-4-line decoder
//See Fig.4-19
module decoder_df (output [0:3] D, input A, B,
enable);
assign D[0] = ~(~A & ~B & ~ enable),
D[1] = ~(~A & B & ~ enable),
D[2] = ~(A & ~B & ~ enable),
D[3] = ~(A & B & ~ enable);
endmodule
Dataflow Modeling
//HDL Example 4-4
//----------------------------------------
//Dataflow description of 4-bit adder
module binary_adder (A, B, Cin, SUM, Cout);
input [3:0] A,B;
input Cin;
output [3:0] SUM;
output Cout;
assign {Cout, SUM} = A + B + Cin;
endmodule
concatenation Binary addition
Dataflow Modeling
//HDL Example 4-5
//-----------------------------------
//Dataflow description of a 4-bit comparator.
module magcomp (A,B,ALTB,AGTB,AEQB);
input [3:0] A,B;
output ALTB,AGTB,AEQB;
assign ALTB = (A < B),
AGTB = (A > B),
AEQB = (A == B);
endmodule
Dataflow Modeling
//HDL Example 4-6
//----------------------------------------
//Dataflow description of 2-to-1-line multiplexer
module mux2x1_df (A, B, select, OUT);
input A,B,select;
output OUT;
assign OUT = select ? A : B;
endmodule
Behavioral Description
module Add_half ( sum, c_out, a, b );
input a, b;
output sum, c_out;
reg sum, c_out;
always @ ( a or b )
begin
sum = a ^ b; // Exclusive or
c_out = a & b; // And
end
endmodule
a
b
Add_half
sum
c_out
Event control
expression
Procedure
assignment
statements
Must be of the
‘reg’ type
Example of Flip-flop
module Flip_flop ( q, data_in, clk, rst );
input data_in, clk, rst;
output q;
reg q;
always @ ( posedge clk )
begin
if ( rst == 1) q = 0;
else q = data_in;
end
endmodule
data_in q
rst
clk
Declaration of synchronous behavior
Procedural statement
Using Verilogger Pro
Evaluation Version.
enter the window of Verilogger
Start Program SynaptiCad Verilogg
er Pro..
How to build a new project
Click Menu [ Project]Project] [New[New Project]Project] enter
the conversation window.
Enter the Project Name.
default: untitled.hpj. *.hpj
Enter the Project Directory
C:SynaptiCADproject
Or others.
.Click the [Finish] to close the window.
Other menus of [Project]
[Open Project][Open Project]
[Close Project][Close Project]
[Save Project][Save Project]
[Save Project as][Save Project as]
[Add User Source Files][Add User Source Files]
all the user source used by thisall the user source used by this
project.project.
Project settingProject setting
Print Project HierarchyPrint Project Hierarchy
Verilogger Editor
Use the Verilogger Editor to build a
program.
In the Verilogger Window:
click [Editor] [New HDL file] pop
up a editor window for you.
. Others Menu in the [Editor] same as
Menu[Project]
Example of gate NAND
Save the HDL files as nand1.v in menu
[Editor] [Save HDL File As] and
save another HDL file as test-nand1.v
Attach these two HDL files to a new
project test.hpj in [project window]
Run the simulation program
run/resume simulation button or in the
[simulate].
How to build a new project?
How to create a HDL file?
How to save the HDL file?
How to add a source HDL file
to a Project(project1)
Now, Ready to run the
program!
The Report Window of
Verilogger.(all the simulation
information is in this window)
Example of gate NAND
Simulation report from Verilog-Report
window.
Running...
Time=0 a=0 b=0 out1=1
Time=1 a=1 b=0 out1=1
Time=2 a=1 b=1 out1=0
Time=3 a=0 b=1 out1=1
0 Errors, 0 Warnings
Compile time = 0.00000, Load time = 0.00000,
Execution time = 0.06000
Normal exit
Diagram window of Simulation
result
How to copy the diagram to
Microsoft Word!
Example of gate NAND
Wave from Verilog diagram.
Verilog windows
Activate the the diagram windows
Method 1: [File] -> [Print Diagram] -> Print to: [WMF
Metafile[MS Word];
Method 2: [edit] [copy to clipboard] select “wave
form, name and time line” select “ok”
then you can paste the diagram to anywhere you
want.
You can paste the diagram
here!

More Related Content

What's hot

What's hot (20)

verilog code for logic gates
verilog code for logic gatesverilog code for logic gates
verilog code for logic gates
 
vhdl
vhdlvhdl
vhdl
 
Lecture 2 verilog
Lecture 2   verilogLecture 2   verilog
Lecture 2 verilog
 
Verilog hdl
Verilog hdlVerilog hdl
Verilog hdl
 
Day2 Verilog HDL Basic
Day2 Verilog HDL BasicDay2 Verilog HDL Basic
Day2 Verilog HDL Basic
 
VHDL - Part 2
VHDL - Part 2VHDL - Part 2
VHDL - Part 2
 
Verilog Lecture1
Verilog Lecture1Verilog Lecture1
Verilog Lecture1
 
An Introductory course on Verilog HDL-Verilog hdl ppr
An Introductory course on Verilog HDL-Verilog hdl pprAn Introductory course on Verilog HDL-Verilog hdl ppr
An Introductory course on Verilog HDL-Verilog hdl ppr
 
Verilog presentation final
Verilog presentation finalVerilog presentation final
Verilog presentation final
 
Verilog tutorial
Verilog tutorialVerilog tutorial
Verilog tutorial
 
Data Flow Modeling
Data Flow ModelingData Flow Modeling
Data Flow Modeling
 
VLSI & E-CAD Lab Manual
VLSI & E-CAD Lab ManualVLSI & E-CAD Lab Manual
VLSI & E-CAD Lab Manual
 
Automatic Test Pattern Generation (Testing of VLSI Design)
Automatic Test Pattern Generation (Testing of VLSI Design)Automatic Test Pattern Generation (Testing of VLSI Design)
Automatic Test Pattern Generation (Testing of VLSI Design)
 
VLSI Lab manual PDF
VLSI Lab manual PDFVLSI Lab manual PDF
VLSI Lab manual PDF
 
Crash course in verilog
Crash course in verilogCrash course in verilog
Crash course in verilog
 
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 Test Bench
Verilog Test BenchVerilog Test Bench
Verilog Test Bench
 
verilog
verilogverilog
verilog
 
Study of vlsi design methodologies and limitations using cad tools for cmos t...
Study of vlsi design methodologies and limitations using cad tools for cmos t...Study of vlsi design methodologies and limitations using cad tools for cmos t...
Study of vlsi design methodologies and limitations using cad tools for cmos t...
 
Verilog coding of mux 8 x1
Verilog coding of mux  8 x1Verilog coding of mux  8 x1
Verilog coding of mux 8 x1
 

Viewers also liked

Experiment write-vhdl-code-for-realize-all-logic-gates
Experiment write-vhdl-code-for-realize-all-logic-gatesExperiment write-vhdl-code-for-realize-all-logic-gates
Experiment write-vhdl-code-for-realize-all-logic-gatesRicardo Castro
 
Overview of verilog
Overview of verilogOverview of verilog
Overview of verilogRaghu Veer
 
Verilog code all
Verilog code allVerilog code all
Verilog code allMNIT jaipur
 
System Verilog Tutorial - VHDL
System Verilog Tutorial - VHDLSystem Verilog Tutorial - VHDL
System Verilog Tutorial - VHDLE2MATRIX
 
Verilog codes and testbench codes for basic digital electronic circuits.
Verilog codes and testbench codes for basic digital electronic circuits. Verilog codes and testbench codes for basic digital electronic circuits.
Verilog codes and testbench codes for basic digital electronic circuits. shobhan pujari
 
たぶんできる!Verilog hdl
たぶんできる!Verilog hdlたぶんできる!Verilog hdl
たぶんできる!Verilog hdlcahara_mitsu
 

Viewers also liked (9)

Experiment write-vhdl-code-for-realize-all-logic-gates
Experiment write-vhdl-code-for-realize-all-logic-gatesExperiment write-vhdl-code-for-realize-all-logic-gates
Experiment write-vhdl-code-for-realize-all-logic-gates
 
Overview of verilog
Overview of verilogOverview of verilog
Overview of verilog
 
Verilog code all
Verilog code allVerilog code all
Verilog code all
 
07 sequential verilog
07 sequential verilog07 sequential verilog
07 sequential verilog
 
Switch level modeling
Switch level modelingSwitch level modeling
Switch level modeling
 
System Verilog Tutorial - VHDL
System Verilog Tutorial - VHDLSystem Verilog Tutorial - VHDL
System Verilog Tutorial - VHDL
 
Verilog codes and testbench codes for basic digital electronic circuits.
Verilog codes and testbench codes for basic digital electronic circuits. Verilog codes and testbench codes for basic digital electronic circuits.
Verilog codes and testbench codes for basic digital electronic circuits.
 
VERILOG CODE
VERILOG CODEVERILOG CODE
VERILOG CODE
 
たぶんできる!Verilog hdl
たぶんできる!Verilog hdlたぶんできる!Verilog hdl
たぶんできる!Verilog hdl
 

Similar to Verilog tutorial

Similar to Verilog tutorial (20)

vlsi design using verilog presentaion 1
vlsi design using verilog   presentaion 1vlsi design using verilog   presentaion 1
vlsi design using verilog presentaion 1
 
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)
 
CombVerilog.pdf
CombVerilog.pdfCombVerilog.pdf
CombVerilog.pdf
 
Verilog
VerilogVerilog
Verilog
 
Hardware Description Language
Hardware Description Language Hardware Description Language
Hardware Description Language
 
slide8.ppt
slide8.pptslide8.ppt
slide8.ppt
 
Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)
 
Qe Reference
Qe ReferenceQe Reference
Qe Reference
 
Introduction to HDLs
Introduction to HDLsIntroduction to HDLs
Introduction to HDLs
 
Digital System Design-Gatelevel and Dataflow Modeling
Digital System Design-Gatelevel and Dataflow ModelingDigital System Design-Gatelevel and Dataflow Modeling
Digital System Design-Gatelevel and Dataflow Modeling
 
Verilog Final Probe'22.pptx
Verilog Final Probe'22.pptxVerilog Final Probe'22.pptx
Verilog Final Probe'22.pptx
 
C++ Overview PPT
C++ Overview PPTC++ Overview PPT
C++ Overview PPT
 
C++
C++C++
C++
 
Vhdl new
Vhdl newVhdl new
Vhdl new
 
Verilogspk1
Verilogspk1Verilogspk1
Verilogspk1
 
Vhdl
VhdlVhdl
Vhdl
 
unit 5-ERTS.pptx
unit 5-ERTS.pptxunit 5-ERTS.pptx
unit 5-ERTS.pptx
 
Vhdl introduction
Vhdl introductionVhdl introduction
Vhdl introduction
 
Objective c beginner's guide
Objective c beginner's guideObjective c beginner's guide
Objective c beginner's guide
 
Programming with c language practical manual
Programming with c language practical manualProgramming with c language practical manual
Programming with c language practical manual
 

Recently uploaded

HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 

Recently uploaded (20)

HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- 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
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 

Verilog tutorial

  • 2. HDL Hardware Description Languages Widely used in logic design Verilog and VHDL Describe hardware using code Document logic functions Simulate logic before building Synthesize code into gates and layout Requires a library of standard cells
  • 3. Verilog Verilog is one of the two major Hardware Description Languages(HDL) used by hardware designers in industry and academia. VHDL is another one Verilog is easier to learn and use than VHDL Verilog HDL allows a hardware designer to describer designs at a high level of abstraction such as at the architectural or behavioral level as well as the lower implementation levels (i.e., gate and switch levels).
  • 4. Why use Verilog HDL Digital system are highly complex. Verilog language provides the digital designer a software platform. Verilog allows user to express their design with behavioral constructs. A program tool can convert the Verilog program to a description that was used to make chip, like VLSI.
  • 5. Module portsModule name Verilog keywords Taste of Verilog module Add_half ( sum, c_out, a, b ); input a, b; output sum, c_out; wire c_out_bar; xor (sum, a, b); // xor G1(sum, a, b); nand (c_out_bar, a, b); not (c_out, c_out_bar); endmodule DeclarationDeclaration of port modes DeclarationDeclaration of internal signal InstantiationInstantiation of primitive gates c_out a b sum c_out_bar G1G1
  • 6. Lexical Convention Lexical convention are close to C++. Comment // to the end of the line. /* to */ across several lines . Keywords are lower case letter. the language is case sensitive
  • 7. Lexical Convention Numbers are specified in the traditional form or below . <size><base format><number> Size: contains decimal digitals that specify the size of the constant in the number of bits. Base format: is the single character ‘ followed by one of the following characters b(binary),d(decimal),o(octal),h(hex). Number: legal digital.
  • 8. Lexical Convention Example : 347 // decimal number 4’b101 // 4- bit binary number 0101 2’o12 // 2-bit octal number 5’h87f7 // 5-bit hex number h87f7 2’d83 // 2-bit decimal number String in double quotes “ this is a introduction”
  • 9. Lexical Convention Operator are one, two, or three characters and are used in the expressions. just like C++. Identifier: specified by a letter or underscore followed by more letter or digits, or signs.
  • 10. Program structure Structure module <module name> (< port list>); < declares> <module items> endmodule . Module name an identifier that uniquely names the module. . Port list a list of input, inout and output ports which are referenced in other modules.
  • 11. Program structure . Declares section specifies data objects as registers, memories and wires as well as procedural constructs such as functions and tasks. . Module items initial constructs always constructs assignment ……………….
  • 12. Test Module structure module <test module name> ; // Data type declaration.// Data type declaration. Inputs declared asInputs declared as regreg andand outputs declared asoutputs declared as wirewire // Instantiate module ( call the module that is// Instantiate module ( call the module that is goinggoing to be tested)to be tested) // Apply the stimulus// Apply the stimulus // Display results// Display results endmodule
  • 13. Three Modeling Styles in Verilog Structural modeling (Gate-level) Use predefined or user-defined primitive gates. Dataflow modeling Use assignment statements (assign) Behavioral modeling Use procedural assignment statements (always)
  • 14. Structural model //structural model of a NAND gate // program nand2.v module my_NAND(A, B, F); input A, B; output F; nand G(F, A, B); // first parameter must be output. endmodule
  • 15. Example of gate NAND module test_my_nand; // Test bench to test nand reg A, B; wire F; my_NAND test_my_nand(A, B, F); // instantiate my_NAND. initial begin // apply the stimulus, test data A = 1'b0; B = 1'b0; #100 A = 1'b1; // delay one simulation cycle, then change A=>1. #100 B = 1'b1; #100 A = 1'b0; end initial #500 $finish; begin // setup monitoring //$monitor("Time=%0d a=%b b=%b out1=%b", $time, A, B, F); //#500 $finish; end endmodule Test bench module test_nand for the nand1.v
  • 16. //Gate-level description of a 2-to-4-line decoder //Figure 4-19 module decoder_gl (input A,B,E, output [0:3] D); wire Anot, Bnot, Enot; not n1 (Anot, A), n2 (Bnot, B), n3 (Enot, E); nand n4 (D[0], Anot, Bnot, Enot), n5 (D[1], Anot,B, Enot), n6 (D[2], A, Bnot, Enot), n7 (D[3], A, B, Enot); endmodule Structural Modeling
  • 17. //Gate-level hierarchical description of 4-bit adder // Description of half adder (see Fig 4-5b) //module halfadder (S,C,x,y); // input x,y; // output S,C; module halfadder (output S,C, input x,y); //Instantiate primitive gates xor (S,x,y); and (C,x,y); endmodule //Description of full adder (see Fig 4-8) module fulladder (output S,C, input x,y,z); wire S1,C1,C2; //Outputs of first XOR and two AND gates halfadder HA1 (S1,C1,x,y), HA2 (S,C2,S1,z); //Instantiate the halfadder or g1(C,C2,C1); endmodule
  • 18. //Description of 4-bit adder (see Fig 4-9) module ripple_carry_4bit_adder (output [3:0] S, output C4, input [3:0] A,B, input C0) // input [3:0] A,B; //input C0; //output [3:0] S; //output C4; wire C1,C2,C3; //Intermediate carries //Instantiate the fulladder fulladder FA0 (S[0], C1, A[0], B[0], C0), FA1 (S[1], C2, A[1], B[1], C1), FA2 (S[2], C3, A[2], B[2], C2), FA3 (S[3], C4, A[3], B[3], C3); endmodule The names are required!
  • 19. Dataflow Modeling //HDL Example 4-3 //---------------------------------------------- //Dataflow description of a 2-to-4-line decoder //See Fig.4-19 module decoder_df (output [0:3] D, input A, B, enable); assign D[0] = ~(~A & ~B & ~ enable), D[1] = ~(~A & B & ~ enable), D[2] = ~(A & ~B & ~ enable), D[3] = ~(A & B & ~ enable); endmodule
  • 20. Dataflow Modeling //HDL Example 4-4 //---------------------------------------- //Dataflow description of 4-bit adder module binary_adder (A, B, Cin, SUM, Cout); input [3:0] A,B; input Cin; output [3:0] SUM; output Cout; assign {Cout, SUM} = A + B + Cin; endmodule concatenation Binary addition
  • 21. Dataflow Modeling //HDL Example 4-5 //----------------------------------- //Dataflow description of a 4-bit comparator. module magcomp (A,B,ALTB,AGTB,AEQB); input [3:0] A,B; output ALTB,AGTB,AEQB; assign ALTB = (A < B), AGTB = (A > B), AEQB = (A == B); endmodule
  • 22. Dataflow Modeling //HDL Example 4-6 //---------------------------------------- //Dataflow description of 2-to-1-line multiplexer module mux2x1_df (A, B, select, OUT); input A,B,select; output OUT; assign OUT = select ? A : B; endmodule
  • 23. Behavioral Description module Add_half ( sum, c_out, a, b ); input a, b; output sum, c_out; reg sum, c_out; always @ ( a or b ) begin sum = a ^ b; // Exclusive or c_out = a & b; // And end endmodule a b Add_half sum c_out Event control expression Procedure assignment statements Must be of the ‘reg’ type
  • 24. Example of Flip-flop module Flip_flop ( q, data_in, clk, rst ); input data_in, clk, rst; output q; reg q; always @ ( posedge clk ) begin if ( rst == 1) q = 0; else q = data_in; end endmodule data_in q rst clk Declaration of synchronous behavior Procedural statement
  • 25. Using Verilogger Pro Evaluation Version. enter the window of Verilogger Start Program SynaptiCad Verilogg er Pro..
  • 26. How to build a new project Click Menu [ Project]Project] [New[New Project]Project] enter the conversation window. Enter the Project Name. default: untitled.hpj. *.hpj Enter the Project Directory C:SynaptiCADproject Or others. .Click the [Finish] to close the window.
  • 27. Other menus of [Project] [Open Project][Open Project] [Close Project][Close Project] [Save Project][Save Project] [Save Project as][Save Project as] [Add User Source Files][Add User Source Files] all the user source used by thisall the user source used by this project.project. Project settingProject setting Print Project HierarchyPrint Project Hierarchy
  • 28. Verilogger Editor Use the Verilogger Editor to build a program. In the Verilogger Window: click [Editor] [New HDL file] pop up a editor window for you. . Others Menu in the [Editor] same as Menu[Project]
  • 29. Example of gate NAND Save the HDL files as nand1.v in menu [Editor] [Save HDL File As] and save another HDL file as test-nand1.v Attach these two HDL files to a new project test.hpj in [project window] Run the simulation program run/resume simulation button or in the [simulate].
  • 30. How to build a new project?
  • 31.
  • 32.
  • 33.
  • 34.
  • 35. How to create a HDL file?
  • 36.
  • 37.
  • 38.
  • 39. How to save the HDL file?
  • 40.
  • 41.
  • 42.
  • 43.
  • 44. How to add a source HDL file to a Project(project1)
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50. Now, Ready to run the program!
  • 51.
  • 52.
  • 53. The Report Window of Verilogger.(all the simulation information is in this window)
  • 54.
  • 55. Example of gate NAND Simulation report from Verilog-Report window. Running... Time=0 a=0 b=0 out1=1 Time=1 a=1 b=0 out1=1 Time=2 a=1 b=1 out1=0 Time=3 a=0 b=1 out1=1 0 Errors, 0 Warnings Compile time = 0.00000, Load time = 0.00000, Execution time = 0.06000 Normal exit
  • 56. Diagram window of Simulation result
  • 57.
  • 58.
  • 59.
  • 60. How to copy the diagram to Microsoft Word!
  • 61. Example of gate NAND Wave from Verilog diagram. Verilog windows Activate the the diagram windows Method 1: [File] -> [Print Diagram] -> Print to: [WMF Metafile[MS Word]; Method 2: [edit] [copy to clipboard] select “wave form, name and time line” select “ok” then you can paste the diagram to anywhere you want.
  • 62.
  • 63.
  • 64.
  • 65. You can paste the diagram here!