SlideShare a Scribd company logo
Digital Design Using Verilog -For Absolute Beginners
LECTURE4 :DATA FLOW MODELLING
Introduction-Data Flow Modelling
•For simple circuits, the gate-level modeling
approach works fine because the number of gates is
limited and the designer can instantiate and connect
every gate individually.
•Also, the gate-level modeling is very intuitive to a
designer with a basic knowledge of digital logic
design.
•But , in complex designs where the number of gates
is very large it is not the case. (that easy)
•So, for efficient designing, the designers prefer a
higher level of abstraction than gate level .
contd
• An important point here is, as the designer is aware of
how data flows between hard ware components
(Registers) and how data is being processed in the
design, this model is more convenient to the
designers.
• Another reason for importance of Data flow modelling
is the unprecedented growth in the gate density on a
chip which made the Gate level modelling very
complicated.
• Also, presently automated tools are readily available,
to create a gate level circuit from data flow design
description easily.(This process is called Synthesis).
contd..
• This Data Flow model is also known as
Continuous Assignment model.
• This type of modelling or style is more suitable for
combinational logic circuits where clock is not
involved as any control signal .
• As the output of a logic gate is continuously driving
the input of another gate ,it is popularly known as
Continuous assignment model.
• The Assignment statement starts with the keyword
“assign”
17 June 2020 4yayavaram@yahoo.com
Continuous Assignments
• A continuous assignment is the most basic
statement in dataflow modeling, used to drive a
value onto a net.
• This assignment replaces gates in the description of
the circuit and describes the circuit at a higher level
of abstraction.
• The assignment statement starts with the keyword
assign.
• For ex: assign A = B | C ( B OR C).
• Similarly A = B & C
• Here the assignment is continuously active.
17 June 2020 5yayavaram@yahoo.com
Contd
• The assign keyword creates a static binding
between RHS and LHS of the above expressions.
• So, w.r.t simulation, the output is continuously
active. i.e Continuous assignments are always
active.
• The assignment expression is evaluated as soon as
one of the right-hand-side operands changes .
• The operands on the right-hand side can be registers
or nets or function calls. Registers or nets can be
scalars or vectors.
17 June 2020 6yayavaram@yahoo.com
contd
• The left hand side of an assignment must always be
a scalar or vector net or a concatenation of scalar
and vector nets. It cannot be a scalar or vector
register.
• Here net and Reg are a kind of data types.
• In a simple terminology Nets represent connection
between components. Ex: wire B;
• Nets must be continuously driven and are used
model connections between continuous assignments
& instantiations.
17 June 2020 7yayavaram@yahoo.com
contd
• Where as the Reg(Register) retains the last value
assigned to it until another assignment statement
changes their value.
• Its often used to represent storage elements.
• Net and Register data types can be declared as
vectors (multiple bit width).
• For ex: wire [3:0] a;
• wire[31:0]b;
• reg[7:0] c;
• reg[31:0] d;
17 June 2020 8yayavaram@yahoo.com
Ex 1: HALF ADDER
• module Half_ adder(s,c,a,b);
input a , b; // Declare input Ports
output s, c; // Declare out ports
assign s = a ^ b; // assign statement for x-or
assign c= a & b; // assign statement for logical and
endmodule.
17 June 2020 9yayavaram@yahoo.com
Ex 2: Multiplexer
• The block diagram of Mux is shown below.
17 June 2020 10yayavaram@yahoo.com
contd
• The out put of Mux is
here S is the select line and A,B are inputs.
• Here two logical ‘and’ operations, one NOT
operation and one OR operations are involved.
• Using the assign statements the Verilog can be
written .
17 June 2020 11yayavaram@yahoo.com
Verilog code-Mux
module mymux2_1(A,B,S,Y);
output y;
input A,B,S;
assign Y= (A &(~S) | (B &S));
endmodule
In the above code, & denotes logical ‘and’, ~ Denotes
not , | denotes logical or operations.
17 June 2020 12yayavaram@yahoo.com
Verilog code-Mux(Aliter)
The same code can also be written by another simple
method shown below.
module mymux2_1(A,B,S,Y);
output Y;
input A,B,S;
assign Y= S ? B:A;
endmodule
Note: here ? is the conditional Operator. Y = B when
S=1 else Y=A. (This is a ternary operator)
17 June 2020 13yayavaram@yahoo.com
Conditional operator (?)
• ? Is a conditional operator which is a very useful
ternary operator.
• The conditional operator(? :) takes three operands.
• Usage is ”condition-expr ? true-expr : false-expr ;”
• The condition expression (condition-expr ) is first
evaluated.
• If the result is true (logical 1), then the true-expr is
evaluated. If the result is false (logical 0), then the
false-expression is evaluated.
17 June 2020 14yayavaram@yahoo.com
Ex 3: Full Adder
• Full adder has three input bits and two output bits
sum and carry-out as shown in the diagram below.
• In the diagram A, B, Cin are inputs and Sum &
Cout are outputs.
17 June 2020 15yayavaram@yahoo.com
Verilog code-Full Adder
module myFA1(S,Cout,A,B,Cin);
//Port declaration
output S,Cout;
input A,B,Cin;
assign S= (A^B^Cin); //x-or operation
assign Cout = (A&B | B & Cin | Cin & A);
endmodule
17 June 2020 16yayavaram@yahoo.com
Full Adder -16 bit
module myHA_16(S,Cout,A,B,Cin);
output [15:0]S;
output Cout ;
input [15:0]A ; //here A,B ,S are defined as wire
input [15:0] B;
input Cin ;
assign S[15:0] = A[15:0]^B[15:0]^Cin ;
assign Cout = A[15:0]&B[15:0] | B[15:0]&Cin | Cin
& A[15:0];
endmodule17 June 2020 17yayavaram@yahoo.com
2-4 Decoder with Enable
• Decoder is a combinational circuit that has ‘n’ input
lines and maximum of 2n output lines.
• The diagram shows a 2 to 4 Decoder with two
inputs A & B , an enable pin E and four outputs
D3,D2,D1,D0 .
17 June 2020 18yayavaram@yahoo.com
contd
• The working of the decoder can be under stood from
the truth table shown below.
17 June 2020 19yayavaram@yahoo.com
Ex: 2 to 4 Line Decoder
• module decoder2_4 (A,B,E,D);
input A,B,E;
output [3:0]D;
assign D[3] =~(~A & ~B & ~E);
assign D[2] =~(~A & B & ~E);
assign D[1] =~( A & ~B & ~E);
assign D[0] =~( A & B & ~E);
endmodule
17 June 2020 20yayavaram@yahoo.com
Ex: Half Subtractor
• The diagram below shows the Half Subtractor.It has
two inputs .A & B and two outputs Difference (D)
and borrow(B).
• Difference is given by = A ^ B
• Borrow is given by Bo =
17 June 2020 21yayavaram@yahoo.com
Verilog Code
• module half_sub(D,Bo,A,B);
input A;
input B;
output D, Bo;
assign D = A ^ B ;
• assign borrow=(~A)&B;
• endmodule
17 June 2020 22yayavaram@yahoo.com
Full Subtractor
• Similar to Full adder, Full subtractor has three input
bits and two output bits, Difference and Borrow.
• The logic diagram is shown below.
17 June 2020 23yayavaram@yahoo.com
contd
• In the diagram A,B,C are inputs ;and D and Bo are
outputs.
• The Difference of the Full subtractor is given by
• D = A^(B^C)
• Bo =(B&C)|(A&(B^C)’)
17 June 2020 24yayavaram@yahoo.com
Verilog Code
• module full_sub (D,Bo,A,B,C);
input A,B,C;
output D, Bo;
assign X = B^C;
• assign D = A ^ X;
• assign N =~ C;
• assign Y=B & N;
• assign N1 =~ X;
• assign z = A & N1;
• assign Bo = Y | z;
• endmodule
17 June 2020 25yayavaram@yahoo.com
Verilog Code(Another way)
From the Block Diagram the assignment model is
• module full_sub (D,Bo,A,B,C);
input A,B,C;
output D, Bo;
assign D = A ^ (B^C);
assign Bo = B & C| (A&(B^C)’);
• endmodule
17 June 2020 26yayavaram@yahoo.com
THANQ FOR WATCHING
PATIENTLY
17 June 2020 27yayavaram@yahoo.com

More Related Content

PPT
Marketing Environment Marketing
DOCX
Lambda design rule
PPT
Verilog tutorial
PPTX
Layout & Stick Diagram Design Rules
PPTX
DRONE PPT .1234.pptx
PPTX
Interrupts in 8051
PDF
Power system-analysis-psr murthy
Marketing Environment Marketing
Lambda design rule
Verilog tutorial
Layout & Stick Diagram Design Rules
DRONE PPT .1234.pptx
Interrupts in 8051
Power system-analysis-psr murthy

What's hot (20)

PPTX
Lect 7: Verilog Behavioral model for Absolute Beginners
PPT
PPTX
Verilog
PPTX
gate level modeling
PDF
Verilog Tasks & Functions
PPTX
Programmable logic devices
PPTX
Verilog HDL
PPTX
Verilog Test Bench
PPTX
Verilog presentation final
PPTX
Verilog Tutorial - Verilog HDL Tutorial with Examples
PPTX
Finite state machines
PDF
Concepts of Behavioral modelling in Verilog HDL
PDF
Delays in verilog
PPTX
Introduction to FPGAs
PPT
VHDL-PRESENTATION.ppt
PPT
Switch level modeling
PPT
Verilog Tasks and functions
PDF
Synchronous and asynchronous clock
PPT
8085-microprocessor
PPT
decoder and encoder
Lect 7: Verilog Behavioral model for Absolute Beginners
Verilog
gate level modeling
Verilog Tasks & Functions
Programmable logic devices
Verilog HDL
Verilog Test Bench
Verilog presentation final
Verilog Tutorial - Verilog HDL Tutorial with Examples
Finite state machines
Concepts of Behavioral modelling in Verilog HDL
Delays in verilog
Introduction to FPGAs
VHDL-PRESENTATION.ppt
Switch level modeling
Verilog Tasks and functions
Synchronous and asynchronous clock
8085-microprocessor
decoder and encoder
Ad

Similar to Data flow model -Lecture-4 (20)

PDF
ADDERS IN DIGITAL ELECTRONICS (DE) BY RIZWAN
PPTX
Combinational circuit
PPTX
module 2-1 Design Analysis & Investigation of combinational logic in HDL.pptx
PPTX
Unit-3 PPT_Updated COA.pptx (1).pptx coa
PDF
Combinational and sequential logic
PDF
1. Combinational Logic Circutis with examples (1).pdf
PDF
1. Combinational Logic Circutis with examples (1).pdf
PPTX
18CSC203J_COA_Unit 2 final.pptx
PDF
LMmanual.pdf
PPTX
C sharp part 001
PDF
Lec 05 - Combinational Logic
PPTX
Chapter 4: Combinational Logic
PPTX
Digital Logic Design presentation Combinational Circuits.pptx
PPT
Digital Logic Design
PPTX
Final Video PPT V_05 Final UNIT 3_DL and COA Programming.pptx
PDF
PPTX
Computer Architechture and microprocesssors
PDF
C Programming and Industry 4.0, 5.0.pdf
PDF
IJETT-V9P226
PPSX
2-bit comparator
ADDERS IN DIGITAL ELECTRONICS (DE) BY RIZWAN
Combinational circuit
module 2-1 Design Analysis & Investigation of combinational logic in HDL.pptx
Unit-3 PPT_Updated COA.pptx (1).pptx coa
Combinational and sequential logic
1. Combinational Logic Circutis with examples (1).pdf
1. Combinational Logic Circutis with examples (1).pdf
18CSC203J_COA_Unit 2 final.pptx
LMmanual.pdf
C sharp part 001
Lec 05 - Combinational Logic
Chapter 4: Combinational Logic
Digital Logic Design presentation Combinational Circuits.pptx
Digital Logic Design
Final Video PPT V_05 Final UNIT 3_DL and COA Programming.pptx
Computer Architechture and microprocesssors
C Programming and Industry 4.0, 5.0.pdf
IJETT-V9P226
2-bit comparator
Ad

More from Dr.YNM (20)

PPT
Introduction to DSP.ppt
PPT
Atmel.ppt
PPT
PIC Microcontrollers.ppt
PPT
Crystalstructure-.ppt
PPT
Basics of OS & RTOS.ppt
PPTX
Introducion to MSP430 Microcontroller.pptx
PPT
Microcontroller-8051.ppt
PPTX
Introduction to ASICs.pptx
PPTX
Basics of data communications.pptx
PPTX
CPLD & FPGA Architectures and applictionsplications.pptx
PDF
Transient response of RC , RL circuits with step input
PPSX
CISC & RISC ARCHITECTURES
PPSX
Lect 4 ARM PROCESSOR ARCHITECTURE
PPSX
Lect 3 ARM PROCESSOR ARCHITECTURE
PPSX
Microprocessor Architecture 4
PPSX
Lect 2 ARM processor architecture
PPSX
Microprocessor Architecture-III
PPSX
LECT 1: ARM PROCESSORS
PPSX
Microprocessor architecture II
PPTX
Microprocessor architecture-I
Introduction to DSP.ppt
Atmel.ppt
PIC Microcontrollers.ppt
Crystalstructure-.ppt
Basics of OS & RTOS.ppt
Introducion to MSP430 Microcontroller.pptx
Microcontroller-8051.ppt
Introduction to ASICs.pptx
Basics of data communications.pptx
CPLD & FPGA Architectures and applictionsplications.pptx
Transient response of RC , RL circuits with step input
CISC & RISC ARCHITECTURES
Lect 4 ARM PROCESSOR ARCHITECTURE
Lect 3 ARM PROCESSOR ARCHITECTURE
Microprocessor Architecture 4
Lect 2 ARM processor architecture
Microprocessor Architecture-III
LECT 1: ARM PROCESSORS
Microprocessor architecture II
Microprocessor architecture-I

Recently uploaded (20)

PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PDF
Well-logging-methods_new................
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
Geodesy 1.pptx...............................................
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
Welding lecture in detail for understanding
PDF
Digital Logic Computer Design lecture notes
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
Internet of Things (IOT) - A guide to understanding
Arduino robotics embedded978-1-4302-3184-4.pdf
Well-logging-methods_new................
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Geodesy 1.pptx...............................................
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Model Code of Practice - Construction Work - 21102022 .pdf
CH1 Production IntroductoryConcepts.pptx
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Foundation to blockchain - A guide to Blockchain Tech
Welding lecture in detail for understanding
Digital Logic Computer Design lecture notes
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Lecture Notes Electrical Wiring System Components
UNIT 4 Total Quality Management .pptx
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Operating System & Kernel Study Guide-1 - converted.pdf
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
bas. eng. economics group 4 presentation 1.pptx
Internet of Things (IOT) - A guide to understanding

Data flow model -Lecture-4

  • 1. Digital Design Using Verilog -For Absolute Beginners LECTURE4 :DATA FLOW MODELLING
  • 2. Introduction-Data Flow Modelling •For simple circuits, the gate-level modeling approach works fine because the number of gates is limited and the designer can instantiate and connect every gate individually. •Also, the gate-level modeling is very intuitive to a designer with a basic knowledge of digital logic design. •But , in complex designs where the number of gates is very large it is not the case. (that easy) •So, for efficient designing, the designers prefer a higher level of abstraction than gate level .
  • 3. contd • An important point here is, as the designer is aware of how data flows between hard ware components (Registers) and how data is being processed in the design, this model is more convenient to the designers. • Another reason for importance of Data flow modelling is the unprecedented growth in the gate density on a chip which made the Gate level modelling very complicated. • Also, presently automated tools are readily available, to create a gate level circuit from data flow design description easily.(This process is called Synthesis).
  • 4. contd.. • This Data Flow model is also known as Continuous Assignment model. • This type of modelling or style is more suitable for combinational logic circuits where clock is not involved as any control signal . • As the output of a logic gate is continuously driving the input of another gate ,it is popularly known as Continuous assignment model. • The Assignment statement starts with the keyword “assign” 17 June 2020 4yayavaram@yahoo.com
  • 5. Continuous Assignments • A continuous assignment is the most basic statement in dataflow modeling, used to drive a value onto a net. • This assignment replaces gates in the description of the circuit and describes the circuit at a higher level of abstraction. • The assignment statement starts with the keyword assign. • For ex: assign A = B | C ( B OR C). • Similarly A = B & C • Here the assignment is continuously active. 17 June 2020 5yayavaram@yahoo.com
  • 6. Contd • The assign keyword creates a static binding between RHS and LHS of the above expressions. • So, w.r.t simulation, the output is continuously active. i.e Continuous assignments are always active. • The assignment expression is evaluated as soon as one of the right-hand-side operands changes . • The operands on the right-hand side can be registers or nets or function calls. Registers or nets can be scalars or vectors. 17 June 2020 6yayavaram@yahoo.com
  • 7. contd • The left hand side of an assignment must always be a scalar or vector net or a concatenation of scalar and vector nets. It cannot be a scalar or vector register. • Here net and Reg are a kind of data types. • In a simple terminology Nets represent connection between components. Ex: wire B; • Nets must be continuously driven and are used model connections between continuous assignments & instantiations. 17 June 2020 7yayavaram@yahoo.com
  • 8. contd • Where as the Reg(Register) retains the last value assigned to it until another assignment statement changes their value. • Its often used to represent storage elements. • Net and Register data types can be declared as vectors (multiple bit width). • For ex: wire [3:0] a; • wire[31:0]b; • reg[7:0] c; • reg[31:0] d; 17 June 2020 8yayavaram@yahoo.com
  • 9. Ex 1: HALF ADDER • module Half_ adder(s,c,a,b); input a , b; // Declare input Ports output s, c; // Declare out ports assign s = a ^ b; // assign statement for x-or assign c= a & b; // assign statement for logical and endmodule. 17 June 2020 9yayavaram@yahoo.com
  • 10. Ex 2: Multiplexer • The block diagram of Mux is shown below. 17 June 2020 10yayavaram@yahoo.com
  • 11. contd • The out put of Mux is here S is the select line and A,B are inputs. • Here two logical ‘and’ operations, one NOT operation and one OR operations are involved. • Using the assign statements the Verilog can be written . 17 June 2020 11yayavaram@yahoo.com
  • 12. Verilog code-Mux module mymux2_1(A,B,S,Y); output y; input A,B,S; assign Y= (A &(~S) | (B &S)); endmodule In the above code, & denotes logical ‘and’, ~ Denotes not , | denotes logical or operations. 17 June 2020 12yayavaram@yahoo.com
  • 13. Verilog code-Mux(Aliter) The same code can also be written by another simple method shown below. module mymux2_1(A,B,S,Y); output Y; input A,B,S; assign Y= S ? B:A; endmodule Note: here ? is the conditional Operator. Y = B when S=1 else Y=A. (This is a ternary operator) 17 June 2020 13yayavaram@yahoo.com
  • 14. Conditional operator (?) • ? Is a conditional operator which is a very useful ternary operator. • The conditional operator(? :) takes three operands. • Usage is ”condition-expr ? true-expr : false-expr ;” • The condition expression (condition-expr ) is first evaluated. • If the result is true (logical 1), then the true-expr is evaluated. If the result is false (logical 0), then the false-expression is evaluated. 17 June 2020 14yayavaram@yahoo.com
  • 15. Ex 3: Full Adder • Full adder has three input bits and two output bits sum and carry-out as shown in the diagram below. • In the diagram A, B, Cin are inputs and Sum & Cout are outputs. 17 June 2020 15yayavaram@yahoo.com
  • 16. Verilog code-Full Adder module myFA1(S,Cout,A,B,Cin); //Port declaration output S,Cout; input A,B,Cin; assign S= (A^B^Cin); //x-or operation assign Cout = (A&B | B & Cin | Cin & A); endmodule 17 June 2020 16yayavaram@yahoo.com
  • 17. Full Adder -16 bit module myHA_16(S,Cout,A,B,Cin); output [15:0]S; output Cout ; input [15:0]A ; //here A,B ,S are defined as wire input [15:0] B; input Cin ; assign S[15:0] = A[15:0]^B[15:0]^Cin ; assign Cout = A[15:0]&B[15:0] | B[15:0]&Cin | Cin & A[15:0]; endmodule17 June 2020 17yayavaram@yahoo.com
  • 18. 2-4 Decoder with Enable • Decoder is a combinational circuit that has ‘n’ input lines and maximum of 2n output lines. • The diagram shows a 2 to 4 Decoder with two inputs A & B , an enable pin E and four outputs D3,D2,D1,D0 . 17 June 2020 18yayavaram@yahoo.com
  • 19. contd • The working of the decoder can be under stood from the truth table shown below. 17 June 2020 19yayavaram@yahoo.com
  • 20. Ex: 2 to 4 Line Decoder • module decoder2_4 (A,B,E,D); input A,B,E; output [3:0]D; assign D[3] =~(~A & ~B & ~E); assign D[2] =~(~A & B & ~E); assign D[1] =~( A & ~B & ~E); assign D[0] =~( A & B & ~E); endmodule 17 June 2020 20yayavaram@yahoo.com
  • 21. Ex: Half Subtractor • The diagram below shows the Half Subtractor.It has two inputs .A & B and two outputs Difference (D) and borrow(B). • Difference is given by = A ^ B • Borrow is given by Bo = 17 June 2020 21yayavaram@yahoo.com
  • 22. Verilog Code • module half_sub(D,Bo,A,B); input A; input B; output D, Bo; assign D = A ^ B ; • assign borrow=(~A)&B; • endmodule 17 June 2020 22yayavaram@yahoo.com
  • 23. Full Subtractor • Similar to Full adder, Full subtractor has three input bits and two output bits, Difference and Borrow. • The logic diagram is shown below. 17 June 2020 23yayavaram@yahoo.com
  • 24. contd • In the diagram A,B,C are inputs ;and D and Bo are outputs. • The Difference of the Full subtractor is given by • D = A^(B^C) • Bo =(B&C)|(A&(B^C)’) 17 June 2020 24yayavaram@yahoo.com
  • 25. Verilog Code • module full_sub (D,Bo,A,B,C); input A,B,C; output D, Bo; assign X = B^C; • assign D = A ^ X; • assign N =~ C; • assign Y=B & N; • assign N1 =~ X; • assign z = A & N1; • assign Bo = Y | z; • endmodule 17 June 2020 25yayavaram@yahoo.com
  • 26. Verilog Code(Another way) From the Block Diagram the assignment model is • module full_sub (D,Bo,A,B,C); input A,B,C; output D, Bo; assign D = A ^ (B^C); assign Bo = B & C| (A&(B^C)’); • endmodule 17 June 2020 26yayavaram@yahoo.com
  • 27. THANQ FOR WATCHING PATIENTLY 17 June 2020 27yayavaram@yahoo.com