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

Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 

Dernier (20)

Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.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