SlideShare une entreprise Scribd logo
1  sur  6
Télécharger pour lire hors ligne
1|Page

Notes: Verilog Part 4
7 CHAPTER 7:
7.1 STRUCTURED PROCEDURES:
7.1.1

initial statement








7.1.2

An initial block starts at time 0 and executes only once.
If there are more than one initial blocks, they all begin at the
same time (“0”). Each block independently finishes its
execution. They must be grouped between begin and end.
They are mainly used for initialization, monitoring waveforms
and other processes that do not require simulation for more
than one time.
There are various short hand syntaxes.
For example, when variables are declared they can be initialized.
The combined port/data declaration can also be combined with
an initialization.
They can be initialized while declaring them in the port
declaration of the module statement.
INITIAL

always statement





For programming level always works as infinite loop, but for
hardware designers this can be used as continuous activity from
the power on.
This can be used to generate the clock generator.
ALWAYS

7.2 PROCEDURAL ASSIGNMENTS


The Syntax for the procedural assignment is as follows

assignment ::= variable_lvalue = [ delay_or_event_control ]
expression




7.2.1

The difference between the assignment here and that in
dataflow is that in dataflow, the value of LHS operand changes
immediately with the change in the RHS value, whereas in this
case, the value of the LHS operand does not change until
another procedural assignment is observed.

Blocking assignments are executed in the order in which they
are assigned. They follow sequential flow.
The ‘=’ operator indicates sequential blocking.

Blocking Assignment



Notes: Verilog Part 4

Prepared By: Jay Baxi
2|Page




7.2.2

Non-Blocking Assignment:








In the Blocking Assignment Example following things are to be
noted.
All statements x = 0 through reg_b = reg_a are executed
sequentially at time = 0.
The statements reg_a[2] = 0 at time = 15.
The statement reg_b[15:13] = {x,y,z} at time = 25.
Statement count = count + 1 at time = 25 is executed last
because of delays of 15 and 10 time units in the preceding
statements .
Note that if the RHS as more bits as compared to the LHS, the
RHS is truncated to match the width of the LHS, the MSBs are
truncated and LSBs are kept as it is. However, if they have RHS
has fewer bits, zeroes are filled in the vacant places.

Nonblocking assignments allow scheduling of assignments
without blocking the execution of the statements in the
sequential block.
‘<=’ operator indicated Nonblocking assignment
In the nonblocking assignment example, following things should
be noted.
All statements x = 0 through reg_b = reg_a are executed
sequentially at time = 0.
The statements reg_a[2] = 0 at time = 15.
The statement reg_b[15:13] = {x,y,z} at time = 10.
Statement count = count + 1 at time = 0 (without any delay) is
executed last despite of delays of 15 and 10 time units in the
preceding statements.
The nonblocking assingments are used to eliminate the race
condition and in order to understand that, we illustrate the
example of SWAP.

7.3 TIMING CONTROLS
7.3.1

Delay Based Timing Control.
 It is an expression that specifies the time duration between
when the statement is encountered and executed. There are
three different types of Delay based timing control.
 1.) Regular Delay Control
 2.) Intra-Assignment Delay Control
 3.) Zero Delay Control

7.3.2

Event-Based Timing Control
 An event is the change in the value of a register or a net. Events
can be used to trigger the execution of a statement or a block of
statements. There are four types of event based timing control
 1.) Regular Event Control

Notes: Verilog Part 4

Prepared By: Jay Baxi
3|Page





2.) Named Event Control: Verilog provides the capability to
declare an event and recognize the occurrence of the event.
The event cannot hold any data.
A named event can be declared using the keyword event.
The event is triggered by the symbol -> and recognized by ‘@’
3.) Event OR Control (Use of @(*) Operator)
4.) Level-Sensitive Timing Control:
Verilog provides ability to wait for certain condition to be true in
order for a block of statement to be executed.
The keyword used is wait.
always
wait (count_enable) #20 count = count + 1;
In the above example, the value of count_enable is continuously
monitored. If it is 0, the statement is not entered. If it is logical
1, the value of count is incremented after 20 time units.

7.4 CONDITIONAL STATEMENTS:


The conditional statements are nothing but same as if..else as
observed in the C language.
//Type 1:
if (condition) true_statement;
//Type 2:
if(condition) true_statement; else false_statement;
//Type 3:
if(condition1) true_statement1;
else if (condition2) true_statement2;
else if (conditionN) true_statementN;
else false_statement;

7.5 MULTIWAY BRANCHING:






Notes: Verilog Part 4

The nested if-else-if becomes cumbersome if there are too
many alternatives. Hence, case comes to the rescue.
case, default and endcase are the commonly used keywords for
the case syntax.
case(condition)
alternative1: statement1;
alternative2: statement2;
alternative3: statement3;
alternativeN: statementN;
default: default_statement;
endcase
The case syntax is self-explanatory.
It compares 0,1,x or z values in the expression bit by bit.

Prepared By: Jay Baxi
4|Page
7.5.1

casex, casez keywords




casez treats all the z valyes in the case alternatives as don’t
cares. All bit positions with z can also be represented by ? in that
postion.
casex treats all x and z values in the case as don’t cares.

7.6 LOOPS
7.6.1

For and While Loops




7.6.2

Repeat Loop





7.6.3

The use of while and for loop in Verilog is same as that in C
language.
The while loop continues until the condition in the while
statement is not true.
For loops provides a more compact loops structure, the
initialization and increment assignment is included in the for
loop.
While Loop
For Loop

The keyword repeat is used in a repeat loop.
This loop iterates a statement for a fixed number of times. It
cannot be used to iterate a general logical expression.
A repeat construct must contain a number, which can be a
variable, constant or a value. However, if the number is a
constant or a signal value, it is evaluated only when the loop
starts and not during the loop execution.
Repeat Loop

Forever Loop








The keyword forever is used to express this loop.
The loops does not contain any expression and executes forever
until $finish is encountered.
This loop is equivalent to a while loop which always has a true
condition.
The loop can be disables by the use of disable statement.
This is generally used in conjunction with timing constructs, if
they are not the loop runs for infinite amount of time and no
further simulation will happen.
Forever Loop

7.7 SEQUENTIAL BLOCK AND PARALLEL BLOCKS
7.7.1
7.7.1.1

Types of Blocks
Sequential Blocks


Notes: Verilog Part 4

They keywords begin and end are used to group sentences into
sequential block.
Prepared By: Jay Baxi
5|Page







7.7.1.2

They are processed in the order they are specified.
If a delay or event control is specified, it is relative to the
simulation time when the previous statement in the block
completed the execution.

They are specified by keywords fork and join.
The statements are processed concurrently.
Ordering of the statements is controlled by delay or event
control assigned to each statement.
If delay or even control is assigned it is relative to time the block
was entered.
RACE CONDITION:
Race condition comes into picture when two statements that
use same variables are executed at the same time.
In simulation time, all fork-join statements are executed at once.
Different simulators execute statements in different order. Thus
the race condition is a limitation in today’s simulators.

Parallel Blocks




7.7.2

Features





NESTING: A sequential and parallel blocks can be nested in the
same program.
NAMED BLOCKS: Blocks can be given names
local variables can be declared for the named block.
Named blocks are a part of design hierarchy.
They can be disabled.
DISABLING NAMED BLOCKS: The disable keyword is used to
terminate the execution of a named block.
It is used to handle error conditions, get out of the loop or
control execution of the pieces of code, based on control signal.
It is similar to break in C. The difference is break just comes out
of the loop, whereas disable can disable the entire block.

7.8 GENERATE





Notes: Verilog Part 4

Generate statements allow Verilog code to be generated
dynamically before the simulation time begins.
This is particularly useful when same operation is to be
performed for multiple bits of vector.
All the instructions are coded within generate – endgenerate
keywords.
Generated instantiations are one or more of the following types
Modules
User Defined Primitives
Verilog Gate Primitives
Continuous Assignments
initial and always blocks.

Prepared By: Jay Baxi
6|Page






7.8.1

Generate Loop









7.8.2

Various data types allowed in a generate statement to support
interconnections between structural elements and/or
procedural blocks.
net, reg
integer, real, time, realtime,
event
Tasks and Functions are allowed within a Generate Scope, but
not in a generate loop.
Some module declarations and module items are not permitted
in a generate statement are
parameter, local parameter
input, output and inout declarations
specify blocks.
There are three methods to create generate statements:

A generate loop allows one or more of the aforementioned to
be instantiated multiple times using a FOR loop.
Generate Loop.
In the above example, before the actual simulation, the code is
elaborated to create a flat representation without the generate
block. The elaborated code is simulated.
Thus generate blocks are a simply a convenient way of replacing
multiple repetitive Verilog blocks.
genvar is a keyword to declare a variable that is used only to
evaluate the generate block.
Its value can be defined only by the generate loop.
Two generate loops can be nested, provided they have different
genvars.

Generate Conditional





7.8.3

A generate conditional is just like an if-else-if.
Parameterized Multiplier.

A generate case is just like a case statement
N-bit Adder

Generate Case

7.9 EXAMPLES:
 4-Bit Counter
 Traffic Signal Controller

Notes: Verilog Part 4

Prepared By: Jay Baxi

Contenu connexe

Tendances

Functions and tasks in verilog
Functions and tasks in verilogFunctions and tasks in verilog
Functions and tasks in verilogNallapati Anindra
 
Delays in verilog
Delays in verilogDelays in verilog
Delays in verilogJITU MISTRY
 
System Verilog Tutorial - VHDL
System Verilog Tutorial - VHDLSystem Verilog Tutorial - VHDL
System Verilog Tutorial - VHDLE2MATRIX
 
Verilog Lecture2 thhts
Verilog Lecture2 thhtsVerilog Lecture2 thhts
Verilog Lecture2 thhtsBéo Tú
 
System verilog assertions
System verilog assertionsSystem verilog assertions
System verilog assertionsHARINATH REDDY
 
Critical section problem in operating system.
Critical section problem in operating system.Critical section problem in operating system.
Critical section problem in operating system.MOHIT DADU
 
FPGA training session generic package and funtions of VHDL by Digitronix Nepal
FPGA training session generic package and funtions of VHDL by Digitronix NepalFPGA training session generic package and funtions of VHDL by Digitronix Nepal
FPGA training session generic package and funtions of VHDL by Digitronix NepalKrishna Gaihre
 
Symbolic Execution (introduction and hands-on)
Symbolic Execution (introduction and hands-on)Symbolic Execution (introduction and hands-on)
Symbolic Execution (introduction and hands-on)Emilio Coppa
 
Ch10 Program Organization
Ch10 Program OrganizationCh10 Program Organization
Ch10 Program OrganizationSzeChingChen
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programmingTejaswiB4
 
VHDL- gate level modelling
VHDL- gate level modellingVHDL- gate level modelling
VHDL- gate level modellingVandanaPagar1
 
Introduction to System verilog
Introduction to System verilog Introduction to System verilog
Introduction to System verilog Pushpa Yakkala
 
Critical Section Problem - Ramakrishna Reddy Bijjam
Critical Section Problem - Ramakrishna Reddy BijjamCritical Section Problem - Ramakrishna Reddy Bijjam
Critical Section Problem - Ramakrishna Reddy BijjamRamakrishna Reddy Bijjam
 

Tendances (20)

Functions and tasks in verilog
Functions and tasks in verilogFunctions and tasks in verilog
Functions and tasks in verilog
 
Delays in verilog
Delays in verilogDelays in verilog
Delays in verilog
 
System Verilog Tutorial - VHDL
System Verilog Tutorial - VHDLSystem Verilog Tutorial - VHDL
System Verilog Tutorial - VHDL
 
Verilog Lecture2 thhts
Verilog Lecture2 thhtsVerilog Lecture2 thhts
Verilog Lecture2 thhts
 
System verilog assertions
System verilog assertionsSystem verilog assertions
System verilog assertions
 
Operating system critical section
Operating system   critical sectionOperating system   critical section
Operating system critical section
 
Critical section problem in operating system.
Critical section problem in operating system.Critical section problem in operating system.
Critical section problem in operating system.
 
Coding verilog
Coding verilogCoding verilog
Coding verilog
 
FPGA training session generic package and funtions of VHDL by Digitronix Nepal
FPGA training session generic package and funtions of VHDL by Digitronix NepalFPGA training session generic package and funtions of VHDL by Digitronix Nepal
FPGA training session generic package and funtions of VHDL by Digitronix Nepal
 
Symbolic Execution (introduction and hands-on)
Symbolic Execution (introduction and hands-on)Symbolic Execution (introduction and hands-on)
Symbolic Execution (introduction and hands-on)
 
Verilog hdl
Verilog hdlVerilog hdl
Verilog hdl
 
Ch10 Program Organization
Ch10 Program OrganizationCh10 Program Organization
Ch10 Program Organization
 
Mutual exclusion
Mutual exclusionMutual exclusion
Mutual exclusion
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
 
Hd6
Hd6Hd6
Hd6
 
Ch4 Expressions
Ch4 ExpressionsCh4 Expressions
Ch4 Expressions
 
VHDL- gate level modelling
VHDL- gate level modellingVHDL- gate level modelling
VHDL- gate level modelling
 
Introduction to System verilog
Introduction to System verilog Introduction to System verilog
Introduction to System verilog
 
Critical Section Problem - Ramakrishna Reddy Bijjam
Critical Section Problem - Ramakrishna Reddy BijjamCritical Section Problem - Ramakrishna Reddy Bijjam
Critical Section Problem - Ramakrishna Reddy Bijjam
 
Ch6 Loops
Ch6 LoopsCh6 Loops
Ch6 Loops
 

Similaire à Notes: Verilog Part 4- Behavioural Modelling

Fpga 08-behavioral-modeling-mealy-machine
Fpga 08-behavioral-modeling-mealy-machineFpga 08-behavioral-modeling-mealy-machine
Fpga 08-behavioral-modeling-mealy-machineMalik Tauqir Hasan
 
RTL Coding Basics in verilog hardware language
RTL Coding Basics in verilog hardware languageRTL Coding Basics in verilog hardware language
RTL Coding Basics in verilog hardware languageMohammedAbdulAzeem51
 
behavioralmodeling and Timing Control - P04.pptx
behavioralmodeling and Timing Control - P04.pptxbehavioralmodeling and Timing Control - P04.pptx
behavioralmodeling and Timing Control - P04.pptxMPrasannakumarM
 
Operating Systems - "Chapter 5 Process Synchronization"
Operating Systems - "Chapter 5 Process Synchronization"Operating Systems - "Chapter 5 Process Synchronization"
Operating Systems - "Chapter 5 Process Synchronization"Ra'Fat Al-Msie'deen
 
Android Application Development - Level 3
Android Application Development - Level 3Android Application Development - Level 3
Android Application Development - Level 3Isham Rashik
 
Something for Nothing
Something for NothingSomething for Nothing
Something for NothingKevlin Henney
 
INTERVIEW QUESTIONS_Verilog_PART-3-5 (1).pdf
INTERVIEW QUESTIONS_Verilog_PART-3-5 (1).pdfINTERVIEW QUESTIONS_Verilog_PART-3-5 (1).pdf
INTERVIEW QUESTIONS_Verilog_PART-3-5 (1).pdfDrViswanathKalannaga1
 
Notes about concurrent and distributed systems & x86 virtualization
Notes about concurrent and distributed systems & x86 virtualizationNotes about concurrent and distributed systems & x86 virtualization
Notes about concurrent and distributed systems & x86 virtualizationAlessio Villardita
 
Concurrency: Mutual Exclusion and Synchronization
Concurrency: Mutual Exclusion and SynchronizationConcurrency: Mutual Exclusion and Synchronization
Concurrency: Mutual Exclusion and SynchronizationAnas Ebrahim
 
Spin Locks and Contention : The Art of Multiprocessor Programming : Notes
Spin Locks and Contention : The Art of Multiprocessor Programming : NotesSpin Locks and Contention : The Art of Multiprocessor Programming : Notes
Spin Locks and Contention : The Art of Multiprocessor Programming : NotesSubhajit Sahu
 
Process Synchronization -1.ppt
Process Synchronization -1.pptProcess Synchronization -1.ppt
Process Synchronization -1.pptjayverma27
 
Control statements
Control statementsControl statements
Control statementsCutyChhaya
 
Do While Repetition Structure
Do While Repetition StructureDo While Repetition Structure
Do While Repetition StructureShahzu2
 
Monitor(karthika)
Monitor(karthika)Monitor(karthika)
Monitor(karthika)Nagarajan
 
Chapter 3 - Flow of Control Part II.pdf
Chapter 3  - Flow of Control Part II.pdfChapter 3  - Flow of Control Part II.pdf
Chapter 3 - Flow of Control Part II.pdfKirubelWondwoson1
 
FPGA Coding Guidelines
FPGA Coding GuidelinesFPGA Coding Guidelines
FPGA Coding GuidelinesChethan Kumar
 
control statements
control statementscontrol statements
control statementsAzeem Sultan
 

Similaire à Notes: Verilog Part 4- Behavioural Modelling (20)

Fpga 08-behavioral-modeling-mealy-machine
Fpga 08-behavioral-modeling-mealy-machineFpga 08-behavioral-modeling-mealy-machine
Fpga 08-behavioral-modeling-mealy-machine
 
RTL Coding Basics in verilog hardware language
RTL Coding Basics in verilog hardware languageRTL Coding Basics in verilog hardware language
RTL Coding Basics in verilog hardware language
 
behavioralmodeling and Timing Control - P04.pptx
behavioralmodeling and Timing Control - P04.pptxbehavioralmodeling and Timing Control - P04.pptx
behavioralmodeling and Timing Control - P04.pptx
 
Operating Systems - "Chapter 5 Process Synchronization"
Operating Systems - "Chapter 5 Process Synchronization"Operating Systems - "Chapter 5 Process Synchronization"
Operating Systems - "Chapter 5 Process Synchronization"
 
Android Application Development - Level 3
Android Application Development - Level 3Android Application Development - Level 3
Android Application Development - Level 3
 
Something for Nothing
Something for NothingSomething for Nothing
Something for Nothing
 
INTERVIEW QUESTIONS_Verilog_PART-3-5 (1).pdf
INTERVIEW QUESTIONS_Verilog_PART-3-5 (1).pdfINTERVIEW QUESTIONS_Verilog_PART-3-5 (1).pdf
INTERVIEW QUESTIONS_Verilog_PART-3-5 (1).pdf
 
Notes about concurrent and distributed systems & x86 virtualization
Notes about concurrent and distributed systems & x86 virtualizationNotes about concurrent and distributed systems & x86 virtualization
Notes about concurrent and distributed systems & x86 virtualization
 
Concurrency: Mutual Exclusion and Synchronization
Concurrency: Mutual Exclusion and SynchronizationConcurrency: Mutual Exclusion and Synchronization
Concurrency: Mutual Exclusion and Synchronization
 
Switch case and looping jam
Switch case and looping jamSwitch case and looping jam
Switch case and looping jam
 
CH05.pdf
CH05.pdfCH05.pdf
CH05.pdf
 
Spin Locks and Contention : The Art of Multiprocessor Programming : Notes
Spin Locks and Contention : The Art of Multiprocessor Programming : NotesSpin Locks and Contention : The Art of Multiprocessor Programming : Notes
Spin Locks and Contention : The Art of Multiprocessor Programming : Notes
 
Process Synchronization -1.ppt
Process Synchronization -1.pptProcess Synchronization -1.ppt
Process Synchronization -1.ppt
 
Control statements
Control statementsControl statements
Control statements
 
Final requirement
Final requirementFinal requirement
Final requirement
 
Do While Repetition Structure
Do While Repetition StructureDo While Repetition Structure
Do While Repetition Structure
 
Monitor(karthika)
Monitor(karthika)Monitor(karthika)
Monitor(karthika)
 
Chapter 3 - Flow of Control Part II.pdf
Chapter 3  - Flow of Control Part II.pdfChapter 3  - Flow of Control Part II.pdf
Chapter 3 - Flow of Control Part II.pdf
 
FPGA Coding Guidelines
FPGA Coding GuidelinesFPGA Coding Guidelines
FPGA Coding Guidelines
 
control statements
control statementscontrol statements
control statements
 

Dernier

ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Dust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEDust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEaurabinda banchhor
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxElton John Embodo
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 

Dernier (20)

YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Dust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEDust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSE
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docx
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 

Notes: Verilog Part 4- Behavioural Modelling

  • 1. 1|Page Notes: Verilog Part 4 7 CHAPTER 7: 7.1 STRUCTURED PROCEDURES: 7.1.1 initial statement      7.1.2 An initial block starts at time 0 and executes only once. If there are more than one initial blocks, they all begin at the same time (“0”). Each block independently finishes its execution. They must be grouped between begin and end. They are mainly used for initialization, monitoring waveforms and other processes that do not require simulation for more than one time. There are various short hand syntaxes. For example, when variables are declared they can be initialized. The combined port/data declaration can also be combined with an initialization. They can be initialized while declaring them in the port declaration of the module statement. INITIAL always statement    For programming level always works as infinite loop, but for hardware designers this can be used as continuous activity from the power on. This can be used to generate the clock generator. ALWAYS 7.2 PROCEDURAL ASSIGNMENTS  The Syntax for the procedural assignment is as follows assignment ::= variable_lvalue = [ delay_or_event_control ] expression   7.2.1 The difference between the assignment here and that in dataflow is that in dataflow, the value of LHS operand changes immediately with the change in the RHS value, whereas in this case, the value of the LHS operand does not change until another procedural assignment is observed. Blocking assignments are executed in the order in which they are assigned. They follow sequential flow. The ‘=’ operator indicates sequential blocking. Blocking Assignment  Notes: Verilog Part 4 Prepared By: Jay Baxi
  • 2. 2|Page   7.2.2 Non-Blocking Assignment:      In the Blocking Assignment Example following things are to be noted. All statements x = 0 through reg_b = reg_a are executed sequentially at time = 0. The statements reg_a[2] = 0 at time = 15. The statement reg_b[15:13] = {x,y,z} at time = 25. Statement count = count + 1 at time = 25 is executed last because of delays of 15 and 10 time units in the preceding statements . Note that if the RHS as more bits as compared to the LHS, the RHS is truncated to match the width of the LHS, the MSBs are truncated and LSBs are kept as it is. However, if they have RHS has fewer bits, zeroes are filled in the vacant places. Nonblocking assignments allow scheduling of assignments without blocking the execution of the statements in the sequential block. ‘<=’ operator indicated Nonblocking assignment In the nonblocking assignment example, following things should be noted. All statements x = 0 through reg_b = reg_a are executed sequentially at time = 0. The statements reg_a[2] = 0 at time = 15. The statement reg_b[15:13] = {x,y,z} at time = 10. Statement count = count + 1 at time = 0 (without any delay) is executed last despite of delays of 15 and 10 time units in the preceding statements. The nonblocking assingments are used to eliminate the race condition and in order to understand that, we illustrate the example of SWAP. 7.3 TIMING CONTROLS 7.3.1 Delay Based Timing Control.  It is an expression that specifies the time duration between when the statement is encountered and executed. There are three different types of Delay based timing control.  1.) Regular Delay Control  2.) Intra-Assignment Delay Control  3.) Zero Delay Control 7.3.2 Event-Based Timing Control  An event is the change in the value of a register or a net. Events can be used to trigger the execution of a statement or a block of statements. There are four types of event based timing control  1.) Regular Event Control Notes: Verilog Part 4 Prepared By: Jay Baxi
  • 3. 3|Page    2.) Named Event Control: Verilog provides the capability to declare an event and recognize the occurrence of the event. The event cannot hold any data. A named event can be declared using the keyword event. The event is triggered by the symbol -> and recognized by ‘@’ 3.) Event OR Control (Use of @(*) Operator) 4.) Level-Sensitive Timing Control: Verilog provides ability to wait for certain condition to be true in order for a block of statement to be executed. The keyword used is wait. always wait (count_enable) #20 count = count + 1; In the above example, the value of count_enable is continuously monitored. If it is 0, the statement is not entered. If it is logical 1, the value of count is incremented after 20 time units. 7.4 CONDITIONAL STATEMENTS:  The conditional statements are nothing but same as if..else as observed in the C language. //Type 1: if (condition) true_statement; //Type 2: if(condition) true_statement; else false_statement; //Type 3: if(condition1) true_statement1; else if (condition2) true_statement2; else if (conditionN) true_statementN; else false_statement; 7.5 MULTIWAY BRANCHING:     Notes: Verilog Part 4 The nested if-else-if becomes cumbersome if there are too many alternatives. Hence, case comes to the rescue. case, default and endcase are the commonly used keywords for the case syntax. case(condition) alternative1: statement1; alternative2: statement2; alternative3: statement3; alternativeN: statementN; default: default_statement; endcase The case syntax is self-explanatory. It compares 0,1,x or z values in the expression bit by bit. Prepared By: Jay Baxi
  • 4. 4|Page 7.5.1 casex, casez keywords   casez treats all the z valyes in the case alternatives as don’t cares. All bit positions with z can also be represented by ? in that postion. casex treats all x and z values in the case as don’t cares. 7.6 LOOPS 7.6.1 For and While Loops    7.6.2 Repeat Loop     7.6.3 The use of while and for loop in Verilog is same as that in C language. The while loop continues until the condition in the while statement is not true. For loops provides a more compact loops structure, the initialization and increment assignment is included in the for loop. While Loop For Loop The keyword repeat is used in a repeat loop. This loop iterates a statement for a fixed number of times. It cannot be used to iterate a general logical expression. A repeat construct must contain a number, which can be a variable, constant or a value. However, if the number is a constant or a signal value, it is evaluated only when the loop starts and not during the loop execution. Repeat Loop Forever Loop       The keyword forever is used to express this loop. The loops does not contain any expression and executes forever until $finish is encountered. This loop is equivalent to a while loop which always has a true condition. The loop can be disables by the use of disable statement. This is generally used in conjunction with timing constructs, if they are not the loop runs for infinite amount of time and no further simulation will happen. Forever Loop 7.7 SEQUENTIAL BLOCK AND PARALLEL BLOCKS 7.7.1 7.7.1.1 Types of Blocks Sequential Blocks  Notes: Verilog Part 4 They keywords begin and end are used to group sentences into sequential block. Prepared By: Jay Baxi
  • 5. 5|Page      7.7.1.2 They are processed in the order they are specified. If a delay or event control is specified, it is relative to the simulation time when the previous statement in the block completed the execution. They are specified by keywords fork and join. The statements are processed concurrently. Ordering of the statements is controlled by delay or event control assigned to each statement. If delay or even control is assigned it is relative to time the block was entered. RACE CONDITION: Race condition comes into picture when two statements that use same variables are executed at the same time. In simulation time, all fork-join statements are executed at once. Different simulators execute statements in different order. Thus the race condition is a limitation in today’s simulators. Parallel Blocks   7.7.2 Features    NESTING: A sequential and parallel blocks can be nested in the same program. NAMED BLOCKS: Blocks can be given names local variables can be declared for the named block. Named blocks are a part of design hierarchy. They can be disabled. DISABLING NAMED BLOCKS: The disable keyword is used to terminate the execution of a named block. It is used to handle error conditions, get out of the loop or control execution of the pieces of code, based on control signal. It is similar to break in C. The difference is break just comes out of the loop, whereas disable can disable the entire block. 7.8 GENERATE     Notes: Verilog Part 4 Generate statements allow Verilog code to be generated dynamically before the simulation time begins. This is particularly useful when same operation is to be performed for multiple bits of vector. All the instructions are coded within generate – endgenerate keywords. Generated instantiations are one or more of the following types Modules User Defined Primitives Verilog Gate Primitives Continuous Assignments initial and always blocks. Prepared By: Jay Baxi
  • 6. 6|Page     7.8.1 Generate Loop        7.8.2 Various data types allowed in a generate statement to support interconnections between structural elements and/or procedural blocks. net, reg integer, real, time, realtime, event Tasks and Functions are allowed within a Generate Scope, but not in a generate loop. Some module declarations and module items are not permitted in a generate statement are parameter, local parameter input, output and inout declarations specify blocks. There are three methods to create generate statements: A generate loop allows one or more of the aforementioned to be instantiated multiple times using a FOR loop. Generate Loop. In the above example, before the actual simulation, the code is elaborated to create a flat representation without the generate block. The elaborated code is simulated. Thus generate blocks are a simply a convenient way of replacing multiple repetitive Verilog blocks. genvar is a keyword to declare a variable that is used only to evaluate the generate block. Its value can be defined only by the generate loop. Two generate loops can be nested, provided they have different genvars. Generate Conditional     7.8.3 A generate conditional is just like an if-else-if. Parameterized Multiplier. A generate case is just like a case statement N-bit Adder Generate Case 7.9 EXAMPLES:  4-Bit Counter  Traffic Signal Controller Notes: Verilog Part 4 Prepared By: Jay Baxi