SlideShare a Scribd company logo
1 of 6
Download to read offline
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

More Related Content

What's hot

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
 

What's hot (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
 

Similar to 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
 

Similar to 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
 

Recently uploaded

Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIShubhangi Sonawane
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 

Recently uploaded (20)

Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 

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