SlideShare a Scribd company logo
1 of 23
Download to read offline
SKEL 4273: CAD with HDL
Ab Al-Hadi Ab Rahman, PhD
Semester 2017/2018-2
Universiti Teknologi Malaysia
Topic 2: Introduction to
Verilog HDL
Outline
• Basic structures in HDL
• Data types, operators, expressions
• Modeling styles: behavioural, dataflow,
structural
Overview
• Verilog was adopted as an official standard as IEEE
Standard 1364-1995 in 1995.
• An enhanced version, called Verilog-2001, was adopted
in 2001 as IEEE Standard 1364-2001.
• Originally intended for simulation, today Verilog is
designed to facilitate digital hardware for both
simulation and synthesis.
• Verilog is a great low level language.
• The syntax is regular and easy to remember. It is the
fastest HDL language to learn and use.
• Verilog has also been extended for implementation and
verification called System Verilog.
Verilog constructs
Verilog constructs (cont.)
Verilog constructs (cont.)
Verilog basics
module module_name ( ports );
{parameter declarations}
input <port list> ; // input/output
declarations:
output <port list> ;
wire <list> ; // nets & variables:
reg (or integer) <list> ;
{assign continuous statement;} //
behaviour statements:
{initial block;}
{always blocks;}
{gate instantiations;}
{module instantiations;}
endmodule
Verilog basics (cont.)
• Verilog describes a digital circuit or system as a set of
modules.
• The entity used in Verilog description of hardware
components is a module
• Following the module header is a declarative part, where
module ports, nets and variables are declared.
• A port in Verilog may be input, output, or inout. Ports
provide the module with a means to connect to other
modules.
• Nets are typically declared by the keyword wire, connection
between hardware elements.
• A port is automatically declared as wire if it is defined as
input, output, or inout.
Verilog constructs (cont.)
• Variables, declared as reg, are used for behavioural
descriptions, and are very much like variables in
software languages.
• Usually each line of Verilog text must terminate with a
semicolon, one exception of which is the terminating
endmodule keyword.
• Verilog is case-sensitive. It allows letters, numbers and
special character “_” to be used for names.
• Names (or identifiers) are used for modules,
parameters, ports, variables, and instances of modules,
and must begin with letters.
• Keywords cannot be used for names.
Verilog constructs (cont.)
module circuitA ( Cin, x, y, X, Y, Cout, s,
Bus, S );
input Cin, x, y;
input [3:0] X, Y;
output Cout, s;
output [3:0] S;
inout [7:0] Bus;
wire d;
reg e;
…
endmodule
Verilog constructs
module circuitA1995 ( a, b, c, x, y, z );
input a, b, c;
output x, y, z;
reg z; //z is an output of a register
…
endmodule
module circuitA2001 (
input a, b, c, output x, y,
output reg z);
…
endmodule
Verilog 1995 Verilog 2001
Representation of numbers
• Verilog uses a 4-value logic, that is, 0, 1, z, and x.
• Numbers can be given as binary (b), octal (o), hex
(h), or decimal (d).
• <size-in-bits> ’ <radix-identifier> <significant-
digits>
• E.g., 2217 can be represented as
12’b100010101001, 12’h8A9, or 8’d2217.
• Unsigned numbers are given without specifying
the size, e.g. ‘b1000100110 or ‘h116 or ‘d2217
Representation of numbers
• Negative numbers, e.g. if -5 is specified as
-4’b101, it will be interpreted as a four-bit 2’s
complement of 5, which is 1011.
• The number 12’b100010101001 may be
written as 12’b1000_1010_1001 to improve
readability in the code.
• A constant used in Verilog may be given as
8’hz3, which is the same as 8’bzzzz0011.
• 8’hx denotes an unknown 8-bit number.
Operators in Verilog
Operators in Verilog
• The bitwise operator produces the same number of
bits as the operands. E.g, A = a1a0, B = b1b0, C = c1c0,
then A|B results in c1=a1|b1 and c0 = a0|b0.
• The logical operator generates a one-bit result. Used in
conditional statements.
• C = A||B results in 1 unless both A and B are zeros.
• C = A && B will produce a result of 1 if both A and B are
nonzeros.
• !A gives a 1 if all its bits are 0, otherwise it results in a
1. ~A flips all the bits in A.
Operators in Verilog
• The “&” in &A is called the reduction AND, where the result
is one bit AND of all the bits in A.
• The relational operator outputs a 1 or 0 based on the
(specified) comparison of A and B.
• The shift operators perform logical shifts to the right or left,
with zeros shifted in. A >> B right-shifts A by B bits.
• Arithmetic shifts can be performed using the “>>>” or
“<<<” operators, where the MSB and the LSB values
respectively are shifted in.
• In the case of the conditional operator, the operation A?B:C
produce a result that is equal to B if A evaluates to 1,
otherwise the result is C.
• The precedence of Verilog operators is similar to that found
in arithmetic and Boolean algebra.
HDL Modeling of Digital Circuits
• Different circuit complexities (e.g., simple
modules to complete systems) require
different kinds of specification or levels of
abstraction.
• Three modelling styles in HDL-based design of
digital systems
– Structural modelling
– Dataflow modelling
– Behavioural modelling
HDL Modeling of Digital Circuits
• Structural modelling – using primitives and lower-level
module instantiation. This modelling allows for the
hierarchical modular design approach in design. It is used
to describe a schematic or logic diagram. The functionality
of the design is hidden inside the components.
• Dataflow modelling – output signals are specified in terms
of input signal transformation. This style is similar to
Boolean equations. This model-ling style allows a digital
system to be designed in terms of its function.
• Behavioural modelling – describes the function or expected
behaviour of the design in an algorithmic manner. This style
is the closest to a natural language description of the circuit
functionality.
Dataflow Modeling
module func2 (x1, x2, x3, f) ;
input x1, x2, x3;
output f ;
assign f = ( ~x1 & ~x2 & x3)
| (x1 & ~x2 & ~x3)
| (x1 & ~x2 & x3)
| (x1 & x2 & ~x3) ;
endmodule
module fulladder (Cin, x, y, S, Cout) ;
input Cin, x, y;
output S, Cout ;
assign S = ( x ^ y ^ Cin ) ;
assign Cout = (x & y) | (Cin & x) |
(Cin & y);
endmodule
• In Verilog, concurrent assignment statements
are called continuous assignment statements.
• They are executed concurrently, and the line
order is not important.
Structural Modeling
module FA (cin, a, b, sum, cout) ;
input cin, a, b;
output sum, cout ;
wire s1, s2, s3;
HA u1 (a, b, s1, s2);
HA u2 (s1, cin, sum, s3);
assign cout = s2 | s3;
endmodule
module HA (a, b, s, c) ;
input a, b;
output s, c ;
assign s = a ^ b ;
assign c = a & b ;
endmodule
• In Verilog structural modelling, module
instantiation is used.
• The instantiation statement associates
the signals in the instantiated module
(HA, in this case) with the ports of the
design unit (FA in this case).
• Here, positional association is applied,
where each signal in the instantiation
statement is mapped by position to the
corresponding signal in the module.
Behavioural Modeling
• Behavioural modelling in Verilog uses constructs similar to
C language constructs.
• Sequential statements, like if-else and case statements, are
called procedural statements.
• Procedural statements be contained inside a construct
called an always block
• An always block executes sequentially in the order they are
listed in the source code.
• The @ symbol is called the event control operator. The part
after the @ symbol, is the event control expression, also
referred to as the sensitivity list.
• This variable holds its value until the next time an event
occurs on inputs in the sensitivity list.
Behavioural Modeling
module Vcircuit (A, B, z) ;
input [3:0] A, B;
output z ;
reg z;
always @ (A or B)
begin
z = 0 ;
if (A == B) z = 1;
end
endmodule
• Verilog syntax requires any signal
assigned a value inside an always block
has to be a variable of type reg; hence z
is declared as reg.
• Since z depends on A and B, these
signals are included in the sensitivity
list.
• Blocking assignments, denoted by “=”
symbol is used. The assignment
completes and updates its LHS before
the next statement is evaluated.
• We will cover non-blocking
assignment, denoted by <= symbol later
on.
Behavioural Modeling
module Vcircuit (A, B, z) ;
input [3:0] A, B;
output z ;
reg z;
always @ (A or B)
begin
z = 0 ;
if (A == B) z = 1;
end
endmodule
Verilog 2001
• always @ (A, B)
• always @ (*)  for combinational logic

More Related Content

What's hot

Variables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detailVariables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detailgourav kottawar
 
Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01Iffat Anjum
 
Algorithm and pseudocode conventions
Algorithm and pseudocode conventionsAlgorithm and pseudocode conventions
Algorithm and pseudocode conventionssaranyatdr
 
Unit iv-syntax-directed-translation
Unit iv-syntax-directed-translationUnit iv-syntax-directed-translation
Unit iv-syntax-directed-translationAjith kumar M P
 
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
 
Introduction To Algorithm [2]
Introduction To Algorithm [2]Introduction To Algorithm [2]
Introduction To Algorithm [2]ecko_disasterz
 
Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2Iffat Anjum
 
Operator Precedence and Associativity
Operator Precedence and AssociativityOperator Precedence and Associativity
Operator Precedence and AssociativityNicole Ynne Estabillo
 
Commutative Short Circuit Operators
Commutative Short Circuit OperatorsCommutative Short Circuit Operators
Commutative Short Circuit OperatorsEdward Willink
 
Database Management System-session 3-4-5
Database Management System-session 3-4-5Database Management System-session 3-4-5
Database Management System-session 3-4-5Infinity Tech Solutions
 
Numerical analysis using Scilab: Numerical stability and conditioning
Numerical analysis using Scilab: Numerical stability and conditioningNumerical analysis using Scilab: Numerical stability and conditioning
Numerical analysis using Scilab: Numerical stability and conditioningScilab
 
Type Conversion, Precedence and Associativity
Type Conversion, Precedence and AssociativityType Conversion, Precedence and Associativity
Type Conversion, Precedence and AssociativityAakash Singh
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programmingsavitamhaske
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translationAkshaya Arunan
 
Numerical analysis using Scilab: Error analysis and propagation
Numerical analysis using Scilab: Error analysis and propagationNumerical analysis using Scilab: Error analysis and propagation
Numerical analysis using Scilab: Error analysis and propagationScilab
 
Expression and Operartor In C Programming
Expression and Operartor In C Programming Expression and Operartor In C Programming
Expression and Operartor In C Programming Kamal Acharya
 

What's hot (20)

Variables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detailVariables, Data Types, Operator & Expression in c in detail
Variables, Data Types, Operator & Expression in c in detail
 
Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01Lecture 10 semantic analysis 01
Lecture 10 semantic analysis 01
 
Algorithm and pseudocode conventions
Algorithm and pseudocode conventionsAlgorithm and pseudocode conventions
Algorithm and pseudocode conventions
 
Unit iv-syntax-directed-translation
Unit iv-syntax-directed-translationUnit iv-syntax-directed-translation
Unit iv-syntax-directed-translation
 
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
 
Introduction To Algorithm [2]
Introduction To Algorithm [2]Introduction To Algorithm [2]
Introduction To Algorithm [2]
 
Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2Lecture 11 semantic analysis 2
Lecture 11 semantic analysis 2
 
Operator Precedence and Associativity
Operator Precedence and AssociativityOperator Precedence and Associativity
Operator Precedence and Associativity
 
Commutative Short Circuit Operators
Commutative Short Circuit OperatorsCommutative Short Circuit Operators
Commutative Short Circuit Operators
 
Chapter 6 Intermediate Code Generation
Chapter 6   Intermediate Code GenerationChapter 6   Intermediate Code Generation
Chapter 6 Intermediate Code Generation
 
Database Management System-session 3-4-5
Database Management System-session 3-4-5Database Management System-session 3-4-5
Database Management System-session 3-4-5
 
Numerical analysis using Scilab: Numerical stability and conditioning
Numerical analysis using Scilab: Numerical stability and conditioningNumerical analysis using Scilab: Numerical stability and conditioning
Numerical analysis using Scilab: Numerical stability and conditioning
 
Type Conversion, Precedence and Associativity
Type Conversion, Precedence and AssociativityType Conversion, Precedence and Associativity
Type Conversion, Precedence and Associativity
 
Programming with matlab session 4
Programming with matlab session 4Programming with matlab session 4
Programming with matlab session 4
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programming
 
Ch5a
Ch5aCh5a
Ch5a
 
COM1407: C Operators
COM1407: C OperatorsCOM1407: C Operators
COM1407: C Operators
 
Syntax directed translation
Syntax directed translationSyntax directed translation
Syntax directed translation
 
Numerical analysis using Scilab: Error analysis and propagation
Numerical analysis using Scilab: Error analysis and propagationNumerical analysis using Scilab: Error analysis and propagation
Numerical analysis using Scilab: Error analysis and propagation
 
Expression and Operartor In C Programming
Expression and Operartor In C Programming Expression and Operartor In C Programming
Expression and Operartor In C Programming
 

Similar to CAD with HDL: Introduction to Verilog HDL

Similar to CAD with HDL: Introduction to Verilog HDL (20)

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
 
VIT_Workshop.ppt
VIT_Workshop.pptVIT_Workshop.ppt
VIT_Workshop.ppt
 
Verilog
VerilogVerilog
Verilog
 
vlsi design using verilog presentaion 1
vlsi design using verilog   presentaion 1vlsi design using verilog   presentaion 1
vlsi design using verilog presentaion 1
 
Verilog Final Probe'22.pptx
Verilog Final Probe'22.pptxVerilog Final Probe'22.pptx
Verilog Final Probe'22.pptx
 
Verilog_ppt.pdf
Verilog_ppt.pdfVerilog_ppt.pdf
Verilog_ppt.pdf
 
Verilog_Overview.pdf
Verilog_Overview.pdfVerilog_Overview.pdf
Verilog_Overview.pdf
 
verilog
verilogverilog
verilog
 
Hardware Description Language
Hardware Description Language Hardware Description Language
Hardware Description Language
 
CombVerilog.pdf
CombVerilog.pdfCombVerilog.pdf
CombVerilog.pdf
 
Verilog
VerilogVerilog
Verilog
 
slide8.ppt
slide8.pptslide8.ppt
slide8.ppt
 
Lecture-07 Modelling techniques.pdf
Lecture-07 Modelling techniques.pdfLecture-07 Modelling techniques.pdf
Lecture-07 Modelling techniques.pdf
 
Verilog presentation final
Verilog presentation finalVerilog presentation final
Verilog presentation final
 
Day2 Verilog HDL Basic
Day2 Verilog HDL BasicDay2 Verilog HDL Basic
Day2 Verilog HDL Basic
 
Verilog hdl
Verilog hdlVerilog hdl
Verilog hdl
 
Ver1-iitkgp.ppt
Ver1-iitkgp.pptVer1-iitkgp.ppt
Ver1-iitkgp.ppt
 
Vhdl new
Vhdl newVhdl new
Vhdl new
 
dokumen.tips_verilog-basic-ppt.pdf
dokumen.tips_verilog-basic-ppt.pdfdokumen.tips_verilog-basic-ppt.pdf
dokumen.tips_verilog-basic-ppt.pdf
 
kalaivaanar_NSK_V3.ppt
kalaivaanar_NSK_V3.pptkalaivaanar_NSK_V3.ppt
kalaivaanar_NSK_V3.ppt
 

Recently uploaded

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
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
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
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
(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
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
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
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
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
 
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
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 

Recently uploaded (20)

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
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
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
 
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
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
🔝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...
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
(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...
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
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
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
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...
 
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
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 

CAD with HDL: Introduction to Verilog HDL

  • 1. SKEL 4273: CAD with HDL Ab Al-Hadi Ab Rahman, PhD Semester 2017/2018-2 Universiti Teknologi Malaysia Topic 2: Introduction to Verilog HDL
  • 2. Outline • Basic structures in HDL • Data types, operators, expressions • Modeling styles: behavioural, dataflow, structural
  • 3. Overview • Verilog was adopted as an official standard as IEEE Standard 1364-1995 in 1995. • An enhanced version, called Verilog-2001, was adopted in 2001 as IEEE Standard 1364-2001. • Originally intended for simulation, today Verilog is designed to facilitate digital hardware for both simulation and synthesis. • Verilog is a great low level language. • The syntax is regular and easy to remember. It is the fastest HDL language to learn and use. • Verilog has also been extended for implementation and verification called System Verilog.
  • 7. Verilog basics module module_name ( ports ); {parameter declarations} input <port list> ; // input/output declarations: output <port list> ; wire <list> ; // nets & variables: reg (or integer) <list> ; {assign continuous statement;} // behaviour statements: {initial block;} {always blocks;} {gate instantiations;} {module instantiations;} endmodule
  • 8. Verilog basics (cont.) • Verilog describes a digital circuit or system as a set of modules. • The entity used in Verilog description of hardware components is a module • Following the module header is a declarative part, where module ports, nets and variables are declared. • A port in Verilog may be input, output, or inout. Ports provide the module with a means to connect to other modules. • Nets are typically declared by the keyword wire, connection between hardware elements. • A port is automatically declared as wire if it is defined as input, output, or inout.
  • 9. Verilog constructs (cont.) • Variables, declared as reg, are used for behavioural descriptions, and are very much like variables in software languages. • Usually each line of Verilog text must terminate with a semicolon, one exception of which is the terminating endmodule keyword. • Verilog is case-sensitive. It allows letters, numbers and special character “_” to be used for names. • Names (or identifiers) are used for modules, parameters, ports, variables, and instances of modules, and must begin with letters. • Keywords cannot be used for names.
  • 10. Verilog constructs (cont.) module circuitA ( Cin, x, y, X, Y, Cout, s, Bus, S ); input Cin, x, y; input [3:0] X, Y; output Cout, s; output [3:0] S; inout [7:0] Bus; wire d; reg e; … endmodule
  • 11. Verilog constructs module circuitA1995 ( a, b, c, x, y, z ); input a, b, c; output x, y, z; reg z; //z is an output of a register … endmodule module circuitA2001 ( input a, b, c, output x, y, output reg z); … endmodule Verilog 1995 Verilog 2001
  • 12. Representation of numbers • Verilog uses a 4-value logic, that is, 0, 1, z, and x. • Numbers can be given as binary (b), octal (o), hex (h), or decimal (d). • <size-in-bits> ’ <radix-identifier> <significant- digits> • E.g., 2217 can be represented as 12’b100010101001, 12’h8A9, or 8’d2217. • Unsigned numbers are given without specifying the size, e.g. ‘b1000100110 or ‘h116 or ‘d2217
  • 13. Representation of numbers • Negative numbers, e.g. if -5 is specified as -4’b101, it will be interpreted as a four-bit 2’s complement of 5, which is 1011. • The number 12’b100010101001 may be written as 12’b1000_1010_1001 to improve readability in the code. • A constant used in Verilog may be given as 8’hz3, which is the same as 8’bzzzz0011. • 8’hx denotes an unknown 8-bit number.
  • 15. Operators in Verilog • The bitwise operator produces the same number of bits as the operands. E.g, A = a1a0, B = b1b0, C = c1c0, then A|B results in c1=a1|b1 and c0 = a0|b0. • The logical operator generates a one-bit result. Used in conditional statements. • C = A||B results in 1 unless both A and B are zeros. • C = A && B will produce a result of 1 if both A and B are nonzeros. • !A gives a 1 if all its bits are 0, otherwise it results in a 1. ~A flips all the bits in A.
  • 16. Operators in Verilog • The “&” in &A is called the reduction AND, where the result is one bit AND of all the bits in A. • The relational operator outputs a 1 or 0 based on the (specified) comparison of A and B. • The shift operators perform logical shifts to the right or left, with zeros shifted in. A >> B right-shifts A by B bits. • Arithmetic shifts can be performed using the “>>>” or “<<<” operators, where the MSB and the LSB values respectively are shifted in. • In the case of the conditional operator, the operation A?B:C produce a result that is equal to B if A evaluates to 1, otherwise the result is C. • The precedence of Verilog operators is similar to that found in arithmetic and Boolean algebra.
  • 17. HDL Modeling of Digital Circuits • Different circuit complexities (e.g., simple modules to complete systems) require different kinds of specification or levels of abstraction. • Three modelling styles in HDL-based design of digital systems – Structural modelling – Dataflow modelling – Behavioural modelling
  • 18. HDL Modeling of Digital Circuits • Structural modelling – using primitives and lower-level module instantiation. This modelling allows for the hierarchical modular design approach in design. It is used to describe a schematic or logic diagram. The functionality of the design is hidden inside the components. • Dataflow modelling – output signals are specified in terms of input signal transformation. This style is similar to Boolean equations. This model-ling style allows a digital system to be designed in terms of its function. • Behavioural modelling – describes the function or expected behaviour of the design in an algorithmic manner. This style is the closest to a natural language description of the circuit functionality.
  • 19. Dataflow Modeling module func2 (x1, x2, x3, f) ; input x1, x2, x3; output f ; assign f = ( ~x1 & ~x2 & x3) | (x1 & ~x2 & ~x3) | (x1 & ~x2 & x3) | (x1 & x2 & ~x3) ; endmodule module fulladder (Cin, x, y, S, Cout) ; input Cin, x, y; output S, Cout ; assign S = ( x ^ y ^ Cin ) ; assign Cout = (x & y) | (Cin & x) | (Cin & y); endmodule • In Verilog, concurrent assignment statements are called continuous assignment statements. • They are executed concurrently, and the line order is not important.
  • 20. Structural Modeling module FA (cin, a, b, sum, cout) ; input cin, a, b; output sum, cout ; wire s1, s2, s3; HA u1 (a, b, s1, s2); HA u2 (s1, cin, sum, s3); assign cout = s2 | s3; endmodule module HA (a, b, s, c) ; input a, b; output s, c ; assign s = a ^ b ; assign c = a & b ; endmodule • In Verilog structural modelling, module instantiation is used. • The instantiation statement associates the signals in the instantiated module (HA, in this case) with the ports of the design unit (FA in this case). • Here, positional association is applied, where each signal in the instantiation statement is mapped by position to the corresponding signal in the module.
  • 21. Behavioural Modeling • Behavioural modelling in Verilog uses constructs similar to C language constructs. • Sequential statements, like if-else and case statements, are called procedural statements. • Procedural statements be contained inside a construct called an always block • An always block executes sequentially in the order they are listed in the source code. • The @ symbol is called the event control operator. The part after the @ symbol, is the event control expression, also referred to as the sensitivity list. • This variable holds its value until the next time an event occurs on inputs in the sensitivity list.
  • 22. Behavioural Modeling module Vcircuit (A, B, z) ; input [3:0] A, B; output z ; reg z; always @ (A or B) begin z = 0 ; if (A == B) z = 1; end endmodule • Verilog syntax requires any signal assigned a value inside an always block has to be a variable of type reg; hence z is declared as reg. • Since z depends on A and B, these signals are included in the sensitivity list. • Blocking assignments, denoted by “=” symbol is used. The assignment completes and updates its LHS before the next statement is evaluated. • We will cover non-blocking assignment, denoted by <= symbol later on.
  • 23. Behavioural Modeling module Vcircuit (A, B, z) ; input [3:0] A, B; output z ; reg z; always @ (A or B) begin z = 0 ; if (A == B) z = 1; end endmodule Verilog 2001 • always @ (A, B) • always @ (*)  for combinational logic