SlideShare a Scribd company logo
1 of 21
4/25/2023 Brigette Huang - Autumn 2002 1
Verilog HDL Tutorial
Winter 2003
University of Washington
ACME Lab
Brigette Huang
4/25/2023 Brigette Huang - Autumn 2002 2
Tutorial Outline
• Introduction
• Circuit Modeling
• Gate-level Modeling
• Data-level Modeling
• Behavioral Modeling
• Testing & Simulation
4/25/2023 Brigette Huang - Autumn 2002 3
Introduction
• What is Verilog HDL?
Verilog HDL is a Hardware Description
Language that can be used to model a
digital system at many levels of
abstraction:
–Algorithmic-level
–Gate-level
–Switch-level
4/25/2023 Brigette Huang - Autumn 2002 4
Where can we use Verilog HDL?
• Verilog is designed for circuit verification and
simulation, for timing analysis, for test
analysis (testability analysis and fault
grading) and for logic synthesis.
• For example, before you get to the structural
level of your design, you want to make sure
the logical paths of your design is faultless
and meets the spec.
4/25/2023 Brigette Huang - Autumn 2002 5
Basic Procedure of Using Verilogger
• Preparation – always create a new folder in C drive.
– c:/documents and settings
– your_login_name
– your_project_folder
• Start – all programs –synaptiCAD - Verilogger pro 6.5
• Editor – new HDL file – write your code – save as filename.v
in your project folder
• Project – add HDL files – choose the file you just saved
• Project – save HDL project – save it in the your project
folder too.
We will continue after we finishing the modeling section…..
4/25/2023 Brigette Huang - Autumn 2002 6
Basic Syntax of a Module
Module module_name (port_list);
Declarations:
input, output, wire, parameter…..
System Modeling:
describe the system in gate-level, data-flow, or
behavioral style…
endmodule
4/25/2023 Brigette Huang - Autumn 2002 7
Basic Module Construction
// Compute the logical AND and OR of
inputs A and B.
module AND_OR(andOut, orOut, A, B);
output andOut, orOut;
input A, B;
and TheAndGate (andOut, A, B);
or TheOrGate (orOut, A, B);
endmodule
AND_OR
andOut
orOut
A
B
TheAndGate
TheOrGate
AND_OR
andOut
orOut
A
B
TheAndGate
TheOrGate
4/25/2023 Brigette Huang - Autumn 2002 8
Gate-Level Modeling
Systems structure can be described using Build-in
gates or pre-built modules.
Basic syntax is :
gate-type #delay instance1_name(outputs.., inputs.. ),
:
:
instance6_name(outputs.., inputs.. );
pre-built module module_instance1(output…,inputs..);
4/25/2023 Brigette Huang - Autumn 2002 9
The Built-in Primitive Gates
• Multiple-input gates:
– and, nand, or, nor, xor, xnor
xor xor1(out, inA, inB, inC);
• Multiple-output gates:
– buf, not
not inverter1(fanout1, fanout2, in);
• Tristate gates:
– bufif0, bufif1, notif0, notif1
bufif0 tbuffer1(out, in, control);
4/25/2023 Brigette Huang - Autumn 2002 10
Gate Delays
• Syntax: #(Tplh, Tphl)
• Examples:
nor #10 Tplh =Tphl=10 time units
nor #(3,5) Tplh=3, Tphl=5
nor #(2:3:4, 5) Tplh=(min2,typ3,max4)
4/25/2023 Brigette Huang - Autumn 2002 11
Example: A 4 to1 Multiplexer
D3
D0
D1
D2
S0
S1
Z
T3
T0
T1
T2
4/25/2023 Brigette Huang - Autumn 2002 12
Simple Example
module Mux4_1 (Z, D,S);
output Z;
input [3:0] D;
input [1:0] S;
wire S0b, S1b, T0, T1, T2, T3;
not #5 inv0(S0b, S[0]),
inv1(S1b, S[1]);
and #10 and0(T0, D[0], S1b, S0b),
and1(T1, D[1], S1b, S[0]),
and2(T2, D[2], S[1], S0b),
and3(T3, D[3], S[0], S[1]);
or #10 or1(Z, T0,T1,T2,T3);
endmodule
4/25/2023 Brigette Huang - Autumn 2002 13
Data-flow Modeling
• The basic mechanism used to model a
design in the dataflow style is the
continuous assignment.
• In a continuous assignment, a value is
assigned to a net.
• Syntax:
assign #delay LHS_net = RHS_expression;
4/25/2023 Brigette Huang - Autumn 2002 14
Example: 2 to 4 Decoder
A
B
EN
Z[0]
Z[1]
Z[2]
Z[3]
4/25/2023 Brigette Huang - Autumn 2002 15
Example
module Decoder 2_4(A,B,EN,Z);
Input A,B,EN;
output [0:3] Z;
wire Ab, Bb;
assign #1 Ab=~A;
assign #1 Bb=~B;
assign #2 Z[0]=~(Ab & Bb & EN);
assign #2 Z[1]=~(Ab & B & EN);
assign #2 Z[2]=~(A & Bb & EN);
assign #2 Z[3]=~(A & B & EN);
endmodule
4/25/2023 Brigette Huang - Autumn 2002 16
Behavioral Modeling
• The behavior of a design is described
using procedural constructs. These are:
– Initial statement: This statement executes
only once.
– Always statement: this statement always
executes in a loop forever…..
• Only register data type can be assigned
a value in either of these statements.
4/25/2023 Brigette Huang - Autumn 2002 17
Always Statement
• Syntax: always
#timing_control procedural_statement
• Procedural statement is one of :
– Blocking Procedural_assignment
always
@ (A or B or Cin)
begin
T1=A & B;
T2=B & Cin;
T3=A & Cin;
Cout=T1 | T2 | T3;
end
T1 assignment is occurs first, then T2, then T3….
4/25/2023 Brigette Huang - Autumn 2002 18
Procedural statements
Conditional_statement
always
@(posedge clk or posedge reset)
if ( Sum <60)
begin
Grade = C;
Total_C=Total_C +1;
end
else if (Sum<75)
Grade = B;
else
Grade = A;
4/25/2023 Brigette Huang - Autumn 2002 19
Procedural statements
Case_statement
always
@(Time ==7)
case(Day)
Tue: Pocket-Money = 6;
Mon,
Wed: Pocket_Money = 2;
Fri,
Sat,
Sun: Pocket_Money = 7;
default: Pocket_Money= 0;
endcase
4/25/2023 Brigette Huang - Autumn 2002 20
Let’s look at a file to review what
we have learned today…..
4/25/2023 Brigette Huang - Autumn 2002 21
References
• Couple of good verilog books here:
– A Verilog HDL Primer by J. Bhasker
– Verilog HDL: A Guide to Digital Design and
Synthesis by Samir Palnitkar
• Special thanks to
Professor Peckol and Professor Hauck for
their support and the tutorial documents
they provided…..

More Related Content

Similar to VerilogTutorial-101702.ppt

Verilog tutorial
Verilog tutorialVerilog tutorial
Verilog tutorial
Abhiraj Bohra
 
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
Nirav Desai
 
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
loyad20119
 
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
Malik Tauqir Hasan
 

Similar to VerilogTutorial-101702.ppt (20)

Vhdl new
Vhdl newVhdl new
Vhdl new
 
Verilog hdl
Verilog hdlVerilog hdl
Verilog hdl
 
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 tutorial
Verilog tutorialVerilog tutorial
Verilog tutorial
 
Verilog tutorial
Verilog tutorialVerilog tutorial
Verilog tutorial
 
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
 
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
 
An Overview of SystemVerilog for Design and Verification
An Overview of SystemVerilog  for Design and VerificationAn Overview of SystemVerilog  for Design and Verification
An Overview of SystemVerilog for Design and Verification
 
Verilog_ppt.pdf
Verilog_ppt.pdfVerilog_ppt.pdf
Verilog_ppt.pdf
 
Ver1-iitkgp.ppt
Ver1-iitkgp.pptVer1-iitkgp.ppt
Ver1-iitkgp.ppt
 
Session 02 _rtl_design_with_vhdl 101
Session 02 _rtl_design_with_vhdl 101Session 02 _rtl_design_with_vhdl 101
Session 02 _rtl_design_with_vhdl 101
 
Advanced Digital Design With The Verilog HDL
Advanced Digital Design With The Verilog HDLAdvanced Digital Design With The Verilog HDL
Advanced Digital Design With The Verilog HDL
 
Verilog
VerilogVerilog
Verilog
 
Verilog
VerilogVerilog
Verilog
 
Session1
Session1Session1
Session1
 
Dica ii chapter slides
Dica ii chapter slidesDica ii chapter slides
Dica ii chapter slides
 
Lecture-07 Modelling techniques.pdf
Lecture-07 Modelling techniques.pdfLecture-07 Modelling techniques.pdf
Lecture-07 Modelling techniques.pdf
 
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
 
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
 
Vhdl basic unit-2
Vhdl basic unit-2Vhdl basic unit-2
Vhdl basic unit-2
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 

VerilogTutorial-101702.ppt

  • 1. 4/25/2023 Brigette Huang - Autumn 2002 1 Verilog HDL Tutorial Winter 2003 University of Washington ACME Lab Brigette Huang
  • 2. 4/25/2023 Brigette Huang - Autumn 2002 2 Tutorial Outline • Introduction • Circuit Modeling • Gate-level Modeling • Data-level Modeling • Behavioral Modeling • Testing & Simulation
  • 3. 4/25/2023 Brigette Huang - Autumn 2002 3 Introduction • What is Verilog HDL? Verilog HDL is a Hardware Description Language that can be used to model a digital system at many levels of abstraction: –Algorithmic-level –Gate-level –Switch-level
  • 4. 4/25/2023 Brigette Huang - Autumn 2002 4 Where can we use Verilog HDL? • Verilog is designed for circuit verification and simulation, for timing analysis, for test analysis (testability analysis and fault grading) and for logic synthesis. • For example, before you get to the structural level of your design, you want to make sure the logical paths of your design is faultless and meets the spec.
  • 5. 4/25/2023 Brigette Huang - Autumn 2002 5 Basic Procedure of Using Verilogger • Preparation – always create a new folder in C drive. – c:/documents and settings – your_login_name – your_project_folder • Start – all programs –synaptiCAD - Verilogger pro 6.5 • Editor – new HDL file – write your code – save as filename.v in your project folder • Project – add HDL files – choose the file you just saved • Project – save HDL project – save it in the your project folder too. We will continue after we finishing the modeling section…..
  • 6. 4/25/2023 Brigette Huang - Autumn 2002 6 Basic Syntax of a Module Module module_name (port_list); Declarations: input, output, wire, parameter….. System Modeling: describe the system in gate-level, data-flow, or behavioral style… endmodule
  • 7. 4/25/2023 Brigette Huang - Autumn 2002 7 Basic Module Construction // Compute the logical AND and OR of inputs A and B. module AND_OR(andOut, orOut, A, B); output andOut, orOut; input A, B; and TheAndGate (andOut, A, B); or TheOrGate (orOut, A, B); endmodule AND_OR andOut orOut A B TheAndGate TheOrGate AND_OR andOut orOut A B TheAndGate TheOrGate
  • 8. 4/25/2023 Brigette Huang - Autumn 2002 8 Gate-Level Modeling Systems structure can be described using Build-in gates or pre-built modules. Basic syntax is : gate-type #delay instance1_name(outputs.., inputs.. ), : : instance6_name(outputs.., inputs.. ); pre-built module module_instance1(output…,inputs..);
  • 9. 4/25/2023 Brigette Huang - Autumn 2002 9 The Built-in Primitive Gates • Multiple-input gates: – and, nand, or, nor, xor, xnor xor xor1(out, inA, inB, inC); • Multiple-output gates: – buf, not not inverter1(fanout1, fanout2, in); • Tristate gates: – bufif0, bufif1, notif0, notif1 bufif0 tbuffer1(out, in, control);
  • 10. 4/25/2023 Brigette Huang - Autumn 2002 10 Gate Delays • Syntax: #(Tplh, Tphl) • Examples: nor #10 Tplh =Tphl=10 time units nor #(3,5) Tplh=3, Tphl=5 nor #(2:3:4, 5) Tplh=(min2,typ3,max4)
  • 11. 4/25/2023 Brigette Huang - Autumn 2002 11 Example: A 4 to1 Multiplexer D3 D0 D1 D2 S0 S1 Z T3 T0 T1 T2
  • 12. 4/25/2023 Brigette Huang - Autumn 2002 12 Simple Example module Mux4_1 (Z, D,S); output Z; input [3:0] D; input [1:0] S; wire S0b, S1b, T0, T1, T2, T3; not #5 inv0(S0b, S[0]), inv1(S1b, S[1]); and #10 and0(T0, D[0], S1b, S0b), and1(T1, D[1], S1b, S[0]), and2(T2, D[2], S[1], S0b), and3(T3, D[3], S[0], S[1]); or #10 or1(Z, T0,T1,T2,T3); endmodule
  • 13. 4/25/2023 Brigette Huang - Autumn 2002 13 Data-flow Modeling • The basic mechanism used to model a design in the dataflow style is the continuous assignment. • In a continuous assignment, a value is assigned to a net. • Syntax: assign #delay LHS_net = RHS_expression;
  • 14. 4/25/2023 Brigette Huang - Autumn 2002 14 Example: 2 to 4 Decoder A B EN Z[0] Z[1] Z[2] Z[3]
  • 15. 4/25/2023 Brigette Huang - Autumn 2002 15 Example module Decoder 2_4(A,B,EN,Z); Input A,B,EN; output [0:3] Z; wire Ab, Bb; assign #1 Ab=~A; assign #1 Bb=~B; assign #2 Z[0]=~(Ab & Bb & EN); assign #2 Z[1]=~(Ab & B & EN); assign #2 Z[2]=~(A & Bb & EN); assign #2 Z[3]=~(A & B & EN); endmodule
  • 16. 4/25/2023 Brigette Huang - Autumn 2002 16 Behavioral Modeling • The behavior of a design is described using procedural constructs. These are: – Initial statement: This statement executes only once. – Always statement: this statement always executes in a loop forever….. • Only register data type can be assigned a value in either of these statements.
  • 17. 4/25/2023 Brigette Huang - Autumn 2002 17 Always Statement • Syntax: always #timing_control procedural_statement • Procedural statement is one of : – Blocking Procedural_assignment always @ (A or B or Cin) begin T1=A & B; T2=B & Cin; T3=A & Cin; Cout=T1 | T2 | T3; end T1 assignment is occurs first, then T2, then T3….
  • 18. 4/25/2023 Brigette Huang - Autumn 2002 18 Procedural statements Conditional_statement always @(posedge clk or posedge reset) if ( Sum <60) begin Grade = C; Total_C=Total_C +1; end else if (Sum<75) Grade = B; else Grade = A;
  • 19. 4/25/2023 Brigette Huang - Autumn 2002 19 Procedural statements Case_statement always @(Time ==7) case(Day) Tue: Pocket-Money = 6; Mon, Wed: Pocket_Money = 2; Fri, Sat, Sun: Pocket_Money = 7; default: Pocket_Money= 0; endcase
  • 20. 4/25/2023 Brigette Huang - Autumn 2002 20 Let’s look at a file to review what we have learned today…..
  • 21. 4/25/2023 Brigette Huang - Autumn 2002 21 References • Couple of good verilog books here: – A Verilog HDL Primer by J. Bhasker – Verilog HDL: A Guide to Digital Design and Synthesis by Samir Palnitkar • Special thanks to Professor Peckol and Professor Hauck for their support and the tutorial documents they provided…..