SlideShare a Scribd company logo
Digital Design Using Verilog
- For Absolute Beginners
LEC 8 :Verilog Blocking & Non-
Blocking Assignments
PROLOGUE
• In the earlier lecture , you have seen the basic
concepts of Verilog Behavioral modelling with
some examples.
• Before going further, let us recapitulate what we
have learnt in the earlier lecture .
• In the behaviour model,which is mainly based on
the Proedural block ,there are aminly two
importanr constructs.
• One is always block and the other is Initial Block.
Procedural assignments
• Always block is used to describe the circuit
functionality using behavioral statements.
• The Initial block is used to initialize behavioral
statements for simulation.
• Each ‘always’ and ‘Initial’ block represents a
separate process.
• These processes run in parallel(concurrently)and
start at time 0.
• Statements inside the process are execute
sequentially.
Always block
• Always block consists of behavioural statements
and keywords begin and end must be used if the
block contains more than one statements.
• Example:
module clk_gen
# (parameter period = 50)
(
output reg clk
)
initial
clk = 1’b0;
contd
23 June 2020 5yayavaram@yahoo.com
• always
# (period/2 ) clk = ~ clk;
initial
# 100 $ finish;
endmodule
Example -2
23 June 2020 6yayavaram@yahoo.com
• module clock _gen (output, reg, clock);//Initialize
clock at time zero
initial
clock = 1'b0;
//Toggle clock every half-cycle (time period = 20)
always
# 10 clock = ~clock;
initial
#1000 $finish;
endmodule
contd
23 June 2020 7yayavaram@yahoo.com
• In this example , the always statement starts at time
0 and executes the statement clock = ~clock at every
10 time units.
• If the initialization of clock is inside the always
block, clock will be initialized every time the
‘always’ is entered.
• Also, the simulation must be halted inside an initial
statement. If there is no $stop or $finish statement to
halt the simulation, the clock generator will run
forever.
Initial Block
23 June 2020 8yayavaram@yahoo.com
• All statements inside an ‘initial’ statement constitute
the initial block. This is executed only once by the
simulator.
• The multiple statements are grouped in a ‘begin ..
end’ structure.
• The statement inside an ‘initial’ block start at time 0.
• If there are multiple blocks all the blocks start
concurrently at time 0 only.
• The initial block is typically used to write test bench
for simulation.
Ex: Initial Block
23 June 2020 9yayavaram@yahoo.com
• module stimulus;
reg x,y, a, b, m;
initial
m = 1'b0; //single statement; need not be grouped
initial
begin
#5 a = 1'b1; //multiple statements ,so grouped
#25 b = 1'b0;
• end
ex contd
23 June 2020 10yayavaram@yahoo.com
initial
begin
#10 x = 1'b0;
#25 y = 1'b1;
end
Initial
#50 $ finish; // no grouping
endmodule
ex contd
23 June 2020 11yayavaram@yahoo.com
• Thus, the execution sequence of the statements
inside the initial blocks will be as follows.
time statement executed
0 m = 1'b0;
5 a = 1'b1;
10 x = 1'b0;
30 b = 1'b0;
35 y = 1'b1;
50 $finish;
• Procedural assignments update values of reg,
integer, real, or time variables.
• The value placed on a variable will remain
unchanged until another procedural assignment
updates the variable with a different value.
• There are two types of procedural assignment
statements .
(i).Blocking assignments &
(ii).Non-Blocking Assignments
23 June 2020 12yayavaram@yahoo.com
Procedural Assignment types
BLOCKING ASSIGNMENT
• It is the most commonly used assignment and
denoted by ‘equal to sign ‘ (=).
• The target of the assignment is gets updated before
the next sequential in the procedural block is
executed.
• That means, a statement using the blocking
assignment blocks the execution of the statements
following it,until it gets completed.
• This type of assignment is normally used for
combinational logic For ex: Y = A & B;
23 June 2020 13yayavaram@yahoo.com
Non-Blocking Assignment(<=)
• This assignment is denoted by ‘less than equal to’
symbol. It is normally used in Sequential logic.
• In this style , the assignment to the target gets
scheduled for the end of the simulation cycle.
• i.e normally occurs at the end of the sequential block
• The statements, subsequent to the instruction under
consideration are not blocked by the assignment.
• This non-blocking assignment uses several reg type
variables synchronously under the control of
common clock.
23 June 2020 14yayavaram@yahoo.com
Example-Blocking
• reg x, y, z;
reg [15:0] reg_a, reg_b;
integer count;
initial begin
x = 0; y = 1; z = 1; // Scalar assignments
count = 0; //Assignment to integer variables
reg_a = 16'b0; reg_b = reg_a; / initialize vectors
#15 reg_a[2] = 1'b1; delay
#10 reg_b[15:13] = {x, y, z}
count = count + 1;
end
23 June 2020 15yayavaram@yahoo.com
Example-Blocking
• reg x, y, z;
• reg [15:0] reg_a, reg_b;
• integer count;
• initial begin
• x = 0; y = 1; z = 1; // Scalar assignments
• count = 0; //Assignment to integer variables
• reg_a = 16'b0; reg_b = reg_a; / initialize vectors
• #15 reg_a[2] = 1'b1; delay
• #10 reg_b[15:13] = {x, y, z}
• count = count + 1;
• end
23 June 2020 16yayavaram@yahoo.com
contd
• All statements x = 0 through reg_b = reg_a are
executed at time 0.
• Statement reg_a[2] = 0 at time = 15
• Statement reg_b[15:13] = {x, y, z} at time = 25
• Statement count = count + 1 at time = 25
• Since there is a delay of 15 and 10 in the preceding
statements, count = count + 1 will be executed at
time = 25 units
23 June 2020 17yayavaram@yahoo.com
Ex: Blocking vs Non-Blocking
Lets take the following example. Assume that initially,
a= 1 and b =2
23 June 2020 18yayavaram@yahoo.com
contd
• After simulation the result is
• a = b = 2 ; a=c=2 --in the blocking assignment
• a = b = 2 ; a=c=1 --in non-blocking assignment
23 June 2020 19yayavaram@yahoo.com
Blocking & Non Blocking Examples
• begin -------//Blocking example
a = 1 ; // at time 0 , the variable a is 1
#10 a = 0; // at time 10 , the variable a = 0
# 5 a = 4; // at time 15 ,the variable a = 4;
end
• begin ………// non-blocking example
a <= 1 ; // at time 0 the variable a = 1.
#10 a <= 0 ; // at time 5 the variable a = 4
# 5 a<= 4 ; // at time 10 the variable a = 0
end
23 June 2020 20yayavaram@yahoo.com
Another example
• module block_nonblock();
reg a,b,c,d,e,f;
initial begin
a =#10 1’b1 ;//the variable a= 1 at time 10
b = #20 1’b0 ;// the variable a= 0 at time 30
c = # 40 1’b 1 ;// the variable a =1 at time 70
end
initial begin
d <= #10 1’b1 ; // the variable a = 1 at time 10
23 June 2020 21yayavaram@yahoo.com
contd
e <= # 20 1’b 0 ; // the variable a = 0 at time 20
f <= # 40 1’b 1 ; // the variable a = 1 at time 40
end
endmodule
23 June 2020 22yayavaram@yahoo.com
(i). always @(posedge clk) (ii).always@(posedge clk)
begin begin
x = next_x ; x <= next_x;
end end
23 June 2020 23yayavaram@yahoo.com
DESIGN EXAMPLES
Different Example
always@(posedge clk) always @(posedge clk)
begin begin
x = next_x ; x<= next_x;
y = x; y <= x;
end end
23 June 2020 24yayavaram@yahoo.com
Ex: fork and join
• fork This fork –join block has the same
a = 1 ; functionality as the block with
# 10 a = 0; non-blocking assignment.
# 5 a = 4;
join
23 June 2020 25yayavaram@yahoo.com
While loop
Initial begin
Count = 0;
While (count <101)
begin
$display (‘count = %d”,count);
count = count +1;
end
end
23 June 2020 26yayavaram@yahoo.com
If –else example
always @ * begin
if(sel1)
q = A:
else if(sel2)
q = B;
else q =C ;
end
23 June 2020 27yayavaram@yahoo.com
23 June 2020 28yayavaram@yahoo.com
THANQ FOR WATCHINIG
GOOD LUCK !!
Ad

More Related Content

What's hot (20)

Verilog HDL
Verilog HDLVerilog HDL
Verilog HDL
Mantra VLSI
 
Verilog hdl
Verilog hdlVerilog hdl
Verilog hdl
Muhammad Uzair Rasheed
 
faults in digital systems
faults in digital systemsfaults in digital systems
faults in digital systems
dennis gookyi
 
Verilog Tasks & Functions
Verilog Tasks & FunctionsVerilog Tasks & Functions
Verilog Tasks & Functions
anand hd
 
Verilog tutorial
Verilog tutorialVerilog tutorial
Verilog tutorial
Maryala Srinivas
 
Synchronous and asynchronous reset
Synchronous and asynchronous resetSynchronous and asynchronous reset
Synchronous and asynchronous reset
Nallapati Anindra
 
Data types in verilog
Data types in verilogData types in verilog
Data types in verilog
Nallapati Anindra
 
BUilt-In-Self-Test for VLSI Design
BUilt-In-Self-Test for VLSI DesignBUilt-In-Self-Test for VLSI Design
BUilt-In-Self-Test for VLSI Design
Usha Mehta
 
Powerplanning
PowerplanningPowerplanning
Powerplanning
VLSI SYSTEM Design
 
System verilog coverage
System verilog coverageSystem verilog coverage
System verilog coverage
Pushpa Yakkala
 
Static_Timing_Analysis_in_detail.pdf
Static_Timing_Analysis_in_detail.pdfStatic_Timing_Analysis_in_detail.pdf
Static_Timing_Analysis_in_detail.pdf
Usha Mehta
 
Session 2,3 FPGAs
Session 2,3 FPGAsSession 2,3 FPGAs
Session 2,3 FPGAs
Subhash Iyer
 
Synchronous and asynchronous clock
Synchronous and asynchronous clockSynchronous and asynchronous clock
Synchronous and asynchronous clock
Nallapati Anindra
 
Basic synthesis flow and commands in digital VLSI
Basic synthesis flow and commands in digital VLSIBasic synthesis flow and commands in digital VLSI
Basic synthesis flow and commands in digital VLSI
Surya Raj
 
axi protocol
axi protocolaxi protocol
axi protocol
Azad Mishra
 
Clock Distribution
Clock DistributionClock Distribution
Clock Distribution
Abhishek Tiwari
 
STA vs DTA.pptx
STA vs DTA.pptxSTA vs DTA.pptx
STA vs DTA.pptx
Payal Dwivedi
 
Overview of digital design with Verilog HDL
Overview of digital design with Verilog HDLOverview of digital design with Verilog HDL
Overview of digital design with Verilog HDL
anand hd
 
VLSI routing
VLSI routingVLSI routing
VLSI routing
Naveen Kumar
 
Altera flex
Altera flexAltera flex
Altera flex
Sharmil Nila
 
faults in digital systems
faults in digital systemsfaults in digital systems
faults in digital systems
dennis gookyi
 
Verilog Tasks & Functions
Verilog Tasks & FunctionsVerilog Tasks & Functions
Verilog Tasks & Functions
anand hd
 
Synchronous and asynchronous reset
Synchronous and asynchronous resetSynchronous and asynchronous reset
Synchronous and asynchronous reset
Nallapati Anindra
 
BUilt-In-Self-Test for VLSI Design
BUilt-In-Self-Test for VLSI DesignBUilt-In-Self-Test for VLSI Design
BUilt-In-Self-Test for VLSI Design
Usha Mehta
 
System verilog coverage
System verilog coverageSystem verilog coverage
System verilog coverage
Pushpa Yakkala
 
Static_Timing_Analysis_in_detail.pdf
Static_Timing_Analysis_in_detail.pdfStatic_Timing_Analysis_in_detail.pdf
Static_Timing_Analysis_in_detail.pdf
Usha Mehta
 
Synchronous and asynchronous clock
Synchronous and asynchronous clockSynchronous and asynchronous clock
Synchronous and asynchronous clock
Nallapati Anindra
 
Basic synthesis flow and commands in digital VLSI
Basic synthesis flow and commands in digital VLSIBasic synthesis flow and commands in digital VLSI
Basic synthesis flow and commands in digital VLSI
Surya Raj
 
Overview of digital design with Verilog HDL
Overview of digital design with Verilog HDLOverview of digital design with Verilog HDL
Overview of digital design with Verilog HDL
anand hd
 

Similar to VERILOG HDL :: Blocking & NON- Blocking assignments (20)

Fpga 08-behavioral-modeling-mealy-machine
Fpga 08-behavioral-modeling-mealy-machineFpga 08-behavioral-modeling-mealy-machine
Fpga 08-behavioral-modeling-mealy-machine
Malik Tauqir Hasan
 
Lect 7: Verilog Behavioral model for Absolute Beginners
Lect 7: Verilog Behavioral model for Absolute BeginnersLect 7: Verilog Behavioral model for Absolute Beginners
Lect 7: Verilog Behavioral model for Absolute Beginners
Dr.YNM
 
verilog modelling and types of modellings
verilog modelling and types of modellingsverilog modelling and types of modellings
verilog modelling and types of modellings
ReguMohanraj
 
Verilog Lecture4 2014
Verilog Lecture4 2014Verilog Lecture4 2014
Verilog Lecture4 2014
Béo Tú
 
Verilog TASKS & FUNCTIONS
Verilog TASKS & FUNCTIONSVerilog TASKS & FUNCTIONS
Verilog TASKS & FUNCTIONS
Dr.YNM
 
Core Java Programming Language (JSE) : Chapter IV - Expressions and Flow Cont...
Core Java Programming Language (JSE) : Chapter IV - Expressions and Flow Cont...Core Java Programming Language (JSE) : Chapter IV - Expressions and Flow Cont...
Core Java Programming Language (JSE) : Chapter IV - Expressions and Flow Cont...
WebStackAcademy
 
Introduction to C ++.pptx
Introduction to C ++.pptxIntroduction to C ++.pptx
Introduction to C ++.pptx
VAIBHAVKADAGANCHI
 
Digital System Design-Switchlevel and Behavioural Modeling
Digital System Design-Switchlevel and Behavioural ModelingDigital System Design-Switchlevel and Behavioural Modeling
Digital System Design-Switchlevel and Behavioural Modeling
Indira Priyadarshini
 
Verilog Test Bench
Verilog Test BenchVerilog Test Bench
Verilog Test Bench
Dr.YNM
 
module 2-1 Design Analysis & Investigation of combinational logic in HDL.pptx
module 2-1 Design Analysis & Investigation of combinational logic in HDL.pptxmodule 2-1 Design Analysis & Investigation of combinational logic in HDL.pptx
module 2-1 Design Analysis & Investigation of combinational logic in HDL.pptx
Maaz609108
 
Sequential_Modelling Design Explainations
Sequential_Modelling Design ExplainationsSequential_Modelling Design Explainations
Sequential_Modelling Design Explainations
GoobeDGreat1
 
Lecture11(Repetition-Part 2) computers.pdf
Lecture11(Repetition-Part 2) computers.pdfLecture11(Repetition-Part 2) computers.pdf
Lecture11(Repetition-Part 2) computers.pdf
jayyusimagdaong24
 
Operating System
Operating SystemOperating System
Operating System
Subhasis Dash
 
Lecture1
Lecture1Lecture1
Lecture1
Amisha Dalal
 
Python unit 3 part 1
Python unit 3 part 1Python unit 3 part 1
Python unit 3 part 1
Vikram Nandini
 
Programming.pptVBVBBMCGHFGFDFDHGDFKJKJKKJ;J
Programming.pptVBVBBMCGHFGFDFDHGDFKJKJKKJ;JProgramming.pptVBVBBMCGHFGFDFDHGDFKJKJKKJ;J
Programming.pptVBVBBMCGHFGFDFDHGDFKJKJKKJ;J
AlthimeseAnderson
 
Pro Java Fx – Developing Enterprise Applications
Pro Java Fx – Developing Enterprise ApplicationsPro Java Fx – Developing Enterprise Applications
Pro Java Fx – Developing Enterprise Applications
Stephen Chin
 
Data flow model -Lecture-4
Data flow model -Lecture-4Data flow model -Lecture-4
Data flow model -Lecture-4
Dr.YNM
 
Synchronization in os.pptx
Synchronization in os.pptxSynchronization in os.pptx
Synchronization in os.pptx
AbdullahBhatti53
 
Test driven development
Test driven developmentTest driven development
Test driven development
christoforosnalmpantis
 
Fpga 08-behavioral-modeling-mealy-machine
Fpga 08-behavioral-modeling-mealy-machineFpga 08-behavioral-modeling-mealy-machine
Fpga 08-behavioral-modeling-mealy-machine
Malik Tauqir Hasan
 
Lect 7: Verilog Behavioral model for Absolute Beginners
Lect 7: Verilog Behavioral model for Absolute BeginnersLect 7: Verilog Behavioral model for Absolute Beginners
Lect 7: Verilog Behavioral model for Absolute Beginners
Dr.YNM
 
verilog modelling and types of modellings
verilog modelling and types of modellingsverilog modelling and types of modellings
verilog modelling and types of modellings
ReguMohanraj
 
Verilog Lecture4 2014
Verilog Lecture4 2014Verilog Lecture4 2014
Verilog Lecture4 2014
Béo Tú
 
Verilog TASKS & FUNCTIONS
Verilog TASKS & FUNCTIONSVerilog TASKS & FUNCTIONS
Verilog TASKS & FUNCTIONS
Dr.YNM
 
Core Java Programming Language (JSE) : Chapter IV - Expressions and Flow Cont...
Core Java Programming Language (JSE) : Chapter IV - Expressions and Flow Cont...Core Java Programming Language (JSE) : Chapter IV - Expressions and Flow Cont...
Core Java Programming Language (JSE) : Chapter IV - Expressions and Flow Cont...
WebStackAcademy
 
Digital System Design-Switchlevel and Behavioural Modeling
Digital System Design-Switchlevel and Behavioural ModelingDigital System Design-Switchlevel and Behavioural Modeling
Digital System Design-Switchlevel and Behavioural Modeling
Indira Priyadarshini
 
Verilog Test Bench
Verilog Test BenchVerilog Test Bench
Verilog Test Bench
Dr.YNM
 
module 2-1 Design Analysis & Investigation of combinational logic in HDL.pptx
module 2-1 Design Analysis & Investigation of combinational logic in HDL.pptxmodule 2-1 Design Analysis & Investigation of combinational logic in HDL.pptx
module 2-1 Design Analysis & Investigation of combinational logic in HDL.pptx
Maaz609108
 
Sequential_Modelling Design Explainations
Sequential_Modelling Design ExplainationsSequential_Modelling Design Explainations
Sequential_Modelling Design Explainations
GoobeDGreat1
 
Lecture11(Repetition-Part 2) computers.pdf
Lecture11(Repetition-Part 2) computers.pdfLecture11(Repetition-Part 2) computers.pdf
Lecture11(Repetition-Part 2) computers.pdf
jayyusimagdaong24
 
Programming.pptVBVBBMCGHFGFDFDHGDFKJKJKKJ;J
Programming.pptVBVBBMCGHFGFDFDHGDFKJKJKKJ;JProgramming.pptVBVBBMCGHFGFDFDHGDFKJKJKKJ;J
Programming.pptVBVBBMCGHFGFDFDHGDFKJKJKKJ;J
AlthimeseAnderson
 
Pro Java Fx – Developing Enterprise Applications
Pro Java Fx – Developing Enterprise ApplicationsPro Java Fx – Developing Enterprise Applications
Pro Java Fx – Developing Enterprise Applications
Stephen Chin
 
Data flow model -Lecture-4
Data flow model -Lecture-4Data flow model -Lecture-4
Data flow model -Lecture-4
Dr.YNM
 
Synchronization in os.pptx
Synchronization in os.pptxSynchronization in os.pptx
Synchronization in os.pptx
AbdullahBhatti53
 
Ad

More from Dr.YNM (20)

Introduction to DSP.ppt
Introduction to DSP.pptIntroduction to DSP.ppt
Introduction to DSP.ppt
Dr.YNM
 
Atmel.ppt
Atmel.pptAtmel.ppt
Atmel.ppt
Dr.YNM
 
PIC Microcontrollers.ppt
PIC Microcontrollers.pptPIC Microcontrollers.ppt
PIC Microcontrollers.ppt
Dr.YNM
 
Crystalstructure-.ppt
Crystalstructure-.pptCrystalstructure-.ppt
Crystalstructure-.ppt
Dr.YNM
 
Basics of OS & RTOS.ppt
Basics of OS & RTOS.pptBasics of OS & RTOS.ppt
Basics of OS & RTOS.ppt
Dr.YNM
 
Introducion to MSP430 Microcontroller.pptx
Introducion to MSP430 Microcontroller.pptxIntroducion to MSP430 Microcontroller.pptx
Introducion to MSP430 Microcontroller.pptx
Dr.YNM
 
Microcontroller-8051.ppt
Microcontroller-8051.pptMicrocontroller-8051.ppt
Microcontroller-8051.ppt
Dr.YNM
 
Introduction to ASICs.pptx
Introduction to ASICs.pptxIntroduction to ASICs.pptx
Introduction to ASICs.pptx
Dr.YNM
 
VHDL-PRESENTATION.ppt
VHDL-PRESENTATION.pptVHDL-PRESENTATION.ppt
VHDL-PRESENTATION.ppt
Dr.YNM
 
Basics of data communications.pptx
Basics of data communications.pptxBasics of data communications.pptx
Basics of data communications.pptx
Dr.YNM
 
CPLD & FPGA Architectures and applictionsplications.pptx
CPLD & FPGA Architectures and applictionsplications.pptxCPLD & FPGA Architectures and applictionsplications.pptx
CPLD & FPGA Architectures and applictionsplications.pptx
Dr.YNM
 
Transient response of RC , RL circuits with step input
Transient response of RC , RL circuits  with step inputTransient response of RC , RL circuits  with step input
Transient response of RC , RL circuits with step input
Dr.YNM
 
CISC & RISC ARCHITECTURES
CISC & RISC ARCHITECTURESCISC & RISC ARCHITECTURES
CISC & RISC ARCHITECTURES
Dr.YNM
 
Lect 4 ARM PROCESSOR ARCHITECTURE
Lect 4 ARM PROCESSOR ARCHITECTURELect 4 ARM PROCESSOR ARCHITECTURE
Lect 4 ARM PROCESSOR ARCHITECTURE
Dr.YNM
 
Lect 3 ARM PROCESSOR ARCHITECTURE
Lect 3  ARM PROCESSOR ARCHITECTURE Lect 3  ARM PROCESSOR ARCHITECTURE
Lect 3 ARM PROCESSOR ARCHITECTURE
Dr.YNM
 
Microprocessor Architecture 4
Microprocessor Architecture  4Microprocessor Architecture  4
Microprocessor Architecture 4
Dr.YNM
 
Lect 2 ARM processor architecture
Lect 2 ARM processor architectureLect 2 ARM processor architecture
Lect 2 ARM processor architecture
Dr.YNM
 
Microprocessor Architecture-III
Microprocessor Architecture-IIIMicroprocessor Architecture-III
Microprocessor Architecture-III
Dr.YNM
 
LECT 1: ARM PROCESSORS
LECT 1: ARM PROCESSORSLECT 1: ARM PROCESSORS
LECT 1: ARM PROCESSORS
Dr.YNM
 
Microprocessor architecture II
Microprocessor architecture   IIMicroprocessor architecture   II
Microprocessor architecture II
Dr.YNM
 
Introduction to DSP.ppt
Introduction to DSP.pptIntroduction to DSP.ppt
Introduction to DSP.ppt
Dr.YNM
 
Atmel.ppt
Atmel.pptAtmel.ppt
Atmel.ppt
Dr.YNM
 
PIC Microcontrollers.ppt
PIC Microcontrollers.pptPIC Microcontrollers.ppt
PIC Microcontrollers.ppt
Dr.YNM
 
Crystalstructure-.ppt
Crystalstructure-.pptCrystalstructure-.ppt
Crystalstructure-.ppt
Dr.YNM
 
Basics of OS & RTOS.ppt
Basics of OS & RTOS.pptBasics of OS & RTOS.ppt
Basics of OS & RTOS.ppt
Dr.YNM
 
Introducion to MSP430 Microcontroller.pptx
Introducion to MSP430 Microcontroller.pptxIntroducion to MSP430 Microcontroller.pptx
Introducion to MSP430 Microcontroller.pptx
Dr.YNM
 
Microcontroller-8051.ppt
Microcontroller-8051.pptMicrocontroller-8051.ppt
Microcontroller-8051.ppt
Dr.YNM
 
Introduction to ASICs.pptx
Introduction to ASICs.pptxIntroduction to ASICs.pptx
Introduction to ASICs.pptx
Dr.YNM
 
VHDL-PRESENTATION.ppt
VHDL-PRESENTATION.pptVHDL-PRESENTATION.ppt
VHDL-PRESENTATION.ppt
Dr.YNM
 
Basics of data communications.pptx
Basics of data communications.pptxBasics of data communications.pptx
Basics of data communications.pptx
Dr.YNM
 
CPLD & FPGA Architectures and applictionsplications.pptx
CPLD & FPGA Architectures and applictionsplications.pptxCPLD & FPGA Architectures and applictionsplications.pptx
CPLD & FPGA Architectures and applictionsplications.pptx
Dr.YNM
 
Transient response of RC , RL circuits with step input
Transient response of RC , RL circuits  with step inputTransient response of RC , RL circuits  with step input
Transient response of RC , RL circuits with step input
Dr.YNM
 
CISC & RISC ARCHITECTURES
CISC & RISC ARCHITECTURESCISC & RISC ARCHITECTURES
CISC & RISC ARCHITECTURES
Dr.YNM
 
Lect 4 ARM PROCESSOR ARCHITECTURE
Lect 4 ARM PROCESSOR ARCHITECTURELect 4 ARM PROCESSOR ARCHITECTURE
Lect 4 ARM PROCESSOR ARCHITECTURE
Dr.YNM
 
Lect 3 ARM PROCESSOR ARCHITECTURE
Lect 3  ARM PROCESSOR ARCHITECTURE Lect 3  ARM PROCESSOR ARCHITECTURE
Lect 3 ARM PROCESSOR ARCHITECTURE
Dr.YNM
 
Microprocessor Architecture 4
Microprocessor Architecture  4Microprocessor Architecture  4
Microprocessor Architecture 4
Dr.YNM
 
Lect 2 ARM processor architecture
Lect 2 ARM processor architectureLect 2 ARM processor architecture
Lect 2 ARM processor architecture
Dr.YNM
 
Microprocessor Architecture-III
Microprocessor Architecture-IIIMicroprocessor Architecture-III
Microprocessor Architecture-III
Dr.YNM
 
LECT 1: ARM PROCESSORS
LECT 1: ARM PROCESSORSLECT 1: ARM PROCESSORS
LECT 1: ARM PROCESSORS
Dr.YNM
 
Microprocessor architecture II
Microprocessor architecture   IIMicroprocessor architecture   II
Microprocessor architecture II
Dr.YNM
 
Ad

Recently uploaded (20)

SICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introductionSICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introduction
fabienklr
 
Artificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptxArtificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptx
rakshanatarajan005
 
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdfSmart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
PawachMetharattanara
 
Construction-Chemicals-For-Waterproofing.ppt
Construction-Chemicals-For-Waterproofing.pptConstruction-Chemicals-For-Waterproofing.ppt
Construction-Chemicals-For-Waterproofing.ppt
ssuser2ffcbc
 
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdfLittle Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
gori42199
 
Design of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdfDesign of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdf
Kamel Farid
 
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software ApplicationsJacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia
 
Slide share PPT of NOx control technologies.pptx
Slide share PPT of  NOx control technologies.pptxSlide share PPT of  NOx control technologies.pptx
Slide share PPT of NOx control technologies.pptx
vvsasane
 
vtc2018fall_otfs_tutorial_presentation_1.pdf
vtc2018fall_otfs_tutorial_presentation_1.pdfvtc2018fall_otfs_tutorial_presentation_1.pdf
vtc2018fall_otfs_tutorial_presentation_1.pdf
RaghavaGD1
 
How to Build a Desktop Weather Station Using ESP32 and E-ink Display
How to Build a Desktop Weather Station Using ESP32 and E-ink DisplayHow to Build a Desktop Weather Station Using ESP32 and E-ink Display
How to Build a Desktop Weather Station Using ESP32 and E-ink Display
CircuitDigest
 
Lecture - 7 Canals of the topic of the civil engineering
Lecture - 7  Canals of the topic of the civil engineeringLecture - 7  Canals of the topic of the civil engineering
Lecture - 7 Canals of the topic of the civil engineering
MJawadkhan1
 
AI Chatbots & Software Development Teams
AI Chatbots & Software Development TeamsAI Chatbots & Software Development Teams
AI Chatbots & Software Development Teams
Joe Krall
 
Physical and Physic-Chemical Based Optimization Methods: A Review
Physical and Physic-Chemical Based Optimization Methods: A ReviewPhysical and Physic-Chemical Based Optimization Methods: A Review
Physical and Physic-Chemical Based Optimization Methods: A Review
Journal of Soft Computing in Civil Engineering
 
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdfML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
rameshwarchintamani
 
twin tower attack 2001 new york city
twin  tower  attack  2001 new  york citytwin  tower  attack  2001 new  york city
twin tower attack 2001 new york city
harishreemavs
 
Frontend Architecture Diagram/Guide For Frontend Engineers
Frontend Architecture Diagram/Guide For Frontend EngineersFrontend Architecture Diagram/Guide For Frontend Engineers
Frontend Architecture Diagram/Guide For Frontend Engineers
Michael Hertzberg
 
Automatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and BeyondAutomatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and Beyond
NU_I_TODALAB
 
Optimizing Reinforced Concrete Cantilever Retaining Walls Using Gases Brownia...
Optimizing Reinforced Concrete Cantilever Retaining Walls Using Gases Brownia...Optimizing Reinforced Concrete Cantilever Retaining Walls Using Gases Brownia...
Optimizing Reinforced Concrete Cantilever Retaining Walls Using Gases Brownia...
Journal of Soft Computing in Civil Engineering
 
IBAAS 2023 Series_Lecture 8- Dr. Nandi.pdf
IBAAS 2023 Series_Lecture 8- Dr. Nandi.pdfIBAAS 2023 Series_Lecture 8- Dr. Nandi.pdf
IBAAS 2023 Series_Lecture 8- Dr. Nandi.pdf
VigneshPalaniappanM
 
David Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry - Specializes In AWS, Microservices And Python.pdfDavid Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry
 
SICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introductionSICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introduction
fabienklr
 
Artificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptxArtificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptx
rakshanatarajan005
 
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdfSmart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
PawachMetharattanara
 
Construction-Chemicals-For-Waterproofing.ppt
Construction-Chemicals-For-Waterproofing.pptConstruction-Chemicals-For-Waterproofing.ppt
Construction-Chemicals-For-Waterproofing.ppt
ssuser2ffcbc
 
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdfLittle Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
gori42199
 
Design of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdfDesign of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdf
Kamel Farid
 
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software ApplicationsJacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia
 
Slide share PPT of NOx control technologies.pptx
Slide share PPT of  NOx control technologies.pptxSlide share PPT of  NOx control technologies.pptx
Slide share PPT of NOx control technologies.pptx
vvsasane
 
vtc2018fall_otfs_tutorial_presentation_1.pdf
vtc2018fall_otfs_tutorial_presentation_1.pdfvtc2018fall_otfs_tutorial_presentation_1.pdf
vtc2018fall_otfs_tutorial_presentation_1.pdf
RaghavaGD1
 
How to Build a Desktop Weather Station Using ESP32 and E-ink Display
How to Build a Desktop Weather Station Using ESP32 and E-ink DisplayHow to Build a Desktop Weather Station Using ESP32 and E-ink Display
How to Build a Desktop Weather Station Using ESP32 and E-ink Display
CircuitDigest
 
Lecture - 7 Canals of the topic of the civil engineering
Lecture - 7  Canals of the topic of the civil engineeringLecture - 7  Canals of the topic of the civil engineering
Lecture - 7 Canals of the topic of the civil engineering
MJawadkhan1
 
AI Chatbots & Software Development Teams
AI Chatbots & Software Development TeamsAI Chatbots & Software Development Teams
AI Chatbots & Software Development Teams
Joe Krall
 
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdfML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
rameshwarchintamani
 
twin tower attack 2001 new york city
twin  tower  attack  2001 new  york citytwin  tower  attack  2001 new  york city
twin tower attack 2001 new york city
harishreemavs
 
Frontend Architecture Diagram/Guide For Frontend Engineers
Frontend Architecture Diagram/Guide For Frontend EngineersFrontend Architecture Diagram/Guide For Frontend Engineers
Frontend Architecture Diagram/Guide For Frontend Engineers
Michael Hertzberg
 
Automatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and BeyondAutomatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and Beyond
NU_I_TODALAB
 
IBAAS 2023 Series_Lecture 8- Dr. Nandi.pdf
IBAAS 2023 Series_Lecture 8- Dr. Nandi.pdfIBAAS 2023 Series_Lecture 8- Dr. Nandi.pdf
IBAAS 2023 Series_Lecture 8- Dr. Nandi.pdf
VigneshPalaniappanM
 
David Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry - Specializes In AWS, Microservices And Python.pdfDavid Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry - Specializes In AWS, Microservices And Python.pdf
David Boutry
 

VERILOG HDL :: Blocking & NON- Blocking assignments

  • 1. Digital Design Using Verilog - For Absolute Beginners LEC 8 :Verilog Blocking & Non- Blocking Assignments
  • 2. PROLOGUE • In the earlier lecture , you have seen the basic concepts of Verilog Behavioral modelling with some examples. • Before going further, let us recapitulate what we have learnt in the earlier lecture . • In the behaviour model,which is mainly based on the Proedural block ,there are aminly two importanr constructs. • One is always block and the other is Initial Block.
  • 3. Procedural assignments • Always block is used to describe the circuit functionality using behavioral statements. • The Initial block is used to initialize behavioral statements for simulation. • Each ‘always’ and ‘Initial’ block represents a separate process. • These processes run in parallel(concurrently)and start at time 0. • Statements inside the process are execute sequentially.
  • 4. Always block • Always block consists of behavioural statements and keywords begin and end must be used if the block contains more than one statements. • Example: module clk_gen # (parameter period = 50) ( output reg clk ) initial clk = 1’b0;
  • 5. contd 23 June 2020 5yayavaram@yahoo.com • always # (period/2 ) clk = ~ clk; initial # 100 $ finish; endmodule
  • 6. Example -2 23 June 2020 6yayavaram@yahoo.com • module clock _gen (output, reg, clock);//Initialize clock at time zero initial clock = 1'b0; //Toggle clock every half-cycle (time period = 20) always # 10 clock = ~clock; initial #1000 $finish; endmodule
  • 7. contd 23 June 2020 7yayavaram@yahoo.com • In this example , the always statement starts at time 0 and executes the statement clock = ~clock at every 10 time units. • If the initialization of clock is inside the always block, clock will be initialized every time the ‘always’ is entered. • Also, the simulation must be halted inside an initial statement. If there is no $stop or $finish statement to halt the simulation, the clock generator will run forever.
  • 8. Initial Block 23 June 2020 8yayavaram@yahoo.com • All statements inside an ‘initial’ statement constitute the initial block. This is executed only once by the simulator. • The multiple statements are grouped in a ‘begin .. end’ structure. • The statement inside an ‘initial’ block start at time 0. • If there are multiple blocks all the blocks start concurrently at time 0 only. • The initial block is typically used to write test bench for simulation.
  • 9. Ex: Initial Block 23 June 2020 9yayavaram@yahoo.com • module stimulus; reg x,y, a, b, m; initial m = 1'b0; //single statement; need not be grouped initial begin #5 a = 1'b1; //multiple statements ,so grouped #25 b = 1'b0; • end
  • 10. ex contd 23 June 2020 10yayavaram@yahoo.com initial begin #10 x = 1'b0; #25 y = 1'b1; end Initial #50 $ finish; // no grouping endmodule
  • 11. ex contd 23 June 2020 11yayavaram@yahoo.com • Thus, the execution sequence of the statements inside the initial blocks will be as follows. time statement executed 0 m = 1'b0; 5 a = 1'b1; 10 x = 1'b0; 30 b = 1'b0; 35 y = 1'b1; 50 $finish;
  • 12. • Procedural assignments update values of reg, integer, real, or time variables. • The value placed on a variable will remain unchanged until another procedural assignment updates the variable with a different value. • There are two types of procedural assignment statements . (i).Blocking assignments & (ii).Non-Blocking Assignments 23 June 2020 12yayavaram@yahoo.com Procedural Assignment types
  • 13. BLOCKING ASSIGNMENT • It is the most commonly used assignment and denoted by ‘equal to sign ‘ (=). • The target of the assignment is gets updated before the next sequential in the procedural block is executed. • That means, a statement using the blocking assignment blocks the execution of the statements following it,until it gets completed. • This type of assignment is normally used for combinational logic For ex: Y = A & B; 23 June 2020 13yayavaram@yahoo.com
  • 14. Non-Blocking Assignment(<=) • This assignment is denoted by ‘less than equal to’ symbol. It is normally used in Sequential logic. • In this style , the assignment to the target gets scheduled for the end of the simulation cycle. • i.e normally occurs at the end of the sequential block • The statements, subsequent to the instruction under consideration are not blocked by the assignment. • This non-blocking assignment uses several reg type variables synchronously under the control of common clock. 23 June 2020 14yayavaram@yahoo.com
  • 15. Example-Blocking • reg x, y, z; reg [15:0] reg_a, reg_b; integer count; initial begin x = 0; y = 1; z = 1; // Scalar assignments count = 0; //Assignment to integer variables reg_a = 16'b0; reg_b = reg_a; / initialize vectors #15 reg_a[2] = 1'b1; delay #10 reg_b[15:13] = {x, y, z} count = count + 1; end 23 June 2020 15yayavaram@yahoo.com
  • 16. Example-Blocking • reg x, y, z; • reg [15:0] reg_a, reg_b; • integer count; • initial begin • x = 0; y = 1; z = 1; // Scalar assignments • count = 0; //Assignment to integer variables • reg_a = 16'b0; reg_b = reg_a; / initialize vectors • #15 reg_a[2] = 1'b1; delay • #10 reg_b[15:13] = {x, y, z} • count = count + 1; • end 23 June 2020 16yayavaram@yahoo.com
  • 17. contd • All statements x = 0 through reg_b = reg_a are executed at time 0. • Statement reg_a[2] = 0 at time = 15 • Statement reg_b[15:13] = {x, y, z} at time = 25 • Statement count = count + 1 at time = 25 • Since there is a delay of 15 and 10 in the preceding statements, count = count + 1 will be executed at time = 25 units 23 June 2020 17yayavaram@yahoo.com
  • 18. Ex: Blocking vs Non-Blocking Lets take the following example. Assume that initially, a= 1 and b =2 23 June 2020 18yayavaram@yahoo.com
  • 19. contd • After simulation the result is • a = b = 2 ; a=c=2 --in the blocking assignment • a = b = 2 ; a=c=1 --in non-blocking assignment 23 June 2020 19yayavaram@yahoo.com
  • 20. Blocking & Non Blocking Examples • begin -------//Blocking example a = 1 ; // at time 0 , the variable a is 1 #10 a = 0; // at time 10 , the variable a = 0 # 5 a = 4; // at time 15 ,the variable a = 4; end • begin ………// non-blocking example a <= 1 ; // at time 0 the variable a = 1. #10 a <= 0 ; // at time 5 the variable a = 4 # 5 a<= 4 ; // at time 10 the variable a = 0 end 23 June 2020 20yayavaram@yahoo.com
  • 21. Another example • module block_nonblock(); reg a,b,c,d,e,f; initial begin a =#10 1’b1 ;//the variable a= 1 at time 10 b = #20 1’b0 ;// the variable a= 0 at time 30 c = # 40 1’b 1 ;// the variable a =1 at time 70 end initial begin d <= #10 1’b1 ; // the variable a = 1 at time 10 23 June 2020 21yayavaram@yahoo.com
  • 22. contd e <= # 20 1’b 0 ; // the variable a = 0 at time 20 f <= # 40 1’b 1 ; // the variable a = 1 at time 40 end endmodule 23 June 2020 22yayavaram@yahoo.com
  • 23. (i). always @(posedge clk) (ii).always@(posedge clk) begin begin x = next_x ; x <= next_x; end end 23 June 2020 23yayavaram@yahoo.com DESIGN EXAMPLES
  • 24. Different Example always@(posedge clk) always @(posedge clk) begin begin x = next_x ; x<= next_x; y = x; y <= x; end end 23 June 2020 24yayavaram@yahoo.com
  • 25. Ex: fork and join • fork This fork –join block has the same a = 1 ; functionality as the block with # 10 a = 0; non-blocking assignment. # 5 a = 4; join 23 June 2020 25yayavaram@yahoo.com
  • 26. While loop Initial begin Count = 0; While (count <101) begin $display (‘count = %d”,count); count = count +1; end end 23 June 2020 26yayavaram@yahoo.com
  • 27. If –else example always @ * begin if(sel1) q = A: else if(sel2) q = B; else q =C ; end 23 June 2020 27yayavaram@yahoo.com
  • 28. 23 June 2020 28yayavaram@yahoo.com THANQ FOR WATCHINIG GOOD LUCK !!

Editor's Notes

  • #29: If the value of S is 1 ,then Y= B other wise Y= A
  翻译: