ece 331 – digital system design single-bit adder circuits and adder circuits in vhdl (lecture #11)...
TRANSCRIPT
ECE 331 – Digital System Design
Single-bit Adder Circuitsand
Adder Circuits in VHDL
(Lecture #11)
The slides included herein were taken from the materials accompanying Fundamentals of Logic Design, 6th Edition, by Roth and Kinney,
and were used with permission from Cengage Learning.
Fall 2010 ECE 331 - Digital System Design 2
The Half Adder (HA)
Fall 2010 ECE 331 - Digital System Design 3
The Half Adder
0 0 1 1+ 0 + 1 + 0 + 1 0 1 1 10
Sum Carry Sum
Fall 2010 ECE 331 - Digital System Design 4
The Half Adder
A B Sum Carry
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
Truth Table
Fall 2010 ECE 331 - Digital System Design 5
The Half Adder
Exercise:
1. Derive the Boolean expressions for the sum and the carry outputs.2. Draw the associated combinational logic
circuit diagrams.
Fall 2010 ECE 331 - Digital System Design 6
The Full Adder (FA)
Fall 2010 ECE 331 - Digital System Design 7
The Full Adder
0 0 0 00 0 1 1
+ 0 + 1 + 0 + 1 0 1 1 10
Carry-out Sum
1 1 1 10 0 1 1
+ 0 + 1 + 0 + 1 1 10 10 11
Carry-in
Fall 2010 ECE 331 - Digital System Design 8
The Full Adder
A B Cin Sum Cout0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
Truth Table
Fall 2010 ECE 331 - Digital System Design 9
The Full Adder
Exercise:
1. Derive the Boolean expressions for the sum and the carry outputs.2. Draw the associated combinational logic
circuit diagrams.
Fall 2010 ECE 331 - Digital System Design 10
The Full Adder
Exercise:
Design a Full Adder using
2 Half Adders1 OR gate
Fall 2010 ECE 331 - Digital System Design 11
The Full Adder
Half Adder
Half Adder
A
B
CinSum
Cout
Fall 2010 ECE 331 - Digital System Design 12
More VHDL Fundamentals
Fall 2010 ECE 331 - Digital System Design 13
VHDL: Components Specify the logical sub-circuits (i.e. components) that
will be used in a hierarchical design. Define the interface to the sub-circuit.
Uses the same format as the Entity Statement.
Sub-circuits are interconnected using “wires”. This is known as Structural VHDL.
The architecture statement for the sub-circuit may be included in the same file as the upper level design or in a separate file.
If included in a separate file, it must be compiled prior to compilation of the upper level design.
Fall 2010 ECE 331 - Digital System Design 14
VHDL: Components
COMPONENT <component name> PORT ( <interface signals> : mode
type ) ;END COMPONENT ;
Component Statement
Component Instantiation<instance name> : <component name> PORT MAP ( <component port names> => <signal names> ) ;
<instance name> : <component name> PORT MAP ( <signal names> ) ;
named association
positional association
Fall 2010 ECE 331 - Digital System Design 15
VHDL: Packages
Packages (and libraries) allow frequently used functions and components to be “centrally” located.
Component declarations are included in package files rather than in the VHDL code for the hierarchical design.
The associated VHDL models for the components are included in separate files.
The compiled VHDL models are typically included in the same library.
When the package file is compiled, the package is created and stored in the working directory.
Fall 2010 ECE 331 - Digital System Design 16
VHDL: Packages
Package DeclarationLIBRARY ieee ;USE ieee.std_logic_1164.all ;
PACKAGE <package name> IS<package declarations> ;
END <package name> ;
Package InstantiationLIBRARY work ;USE work.<package name>.all ;
Fall 2010 ECE 331 - Digital System Design 17
Adder Circuits in VHDL
Fall 2010 ECE 331 - Digital System Design 18
The Half Adder in VHDL
Fall 2010 ECE 331 - Digital System Design 19
The Half Adder in VHDL
Fall 2010 ECE 331 - Digital System Design 20
The Full Adder in VHDL
Fall 2010 ECE 331 - Digital System Design 21
The Full Adder in VHDL
Construct Full Adder from two Half Adders Use Structural VHDL Realize using hierarchical design
Design half adder Interconnect half adders Include any additional logic
Fall 2010 ECE 331 - Digital System Design 22
The Full Adder in VHDL
(Using the structural model)
Half Adder (ha1)
Half Adder (ha2)
A
B
CinSum
Cout
inputports
Entity
outputports
Architecturesignals
s1
c1
c2
Fall 2010 ECE 331 - Digital System Design 23
The Full Adder in VHDL
Fall 2010 ECE 331 - Digital System Design 24
The Full Adder in VHDL(The Package File)
LIBRARY ieee ;USE ieee.std_logic_1164.all ;
PACKAGE halfadd_package ISCOMPONENT halfadd
PORT ( A, B: IN STD_LOGIC ; Sum, Cout: OUT
STD_LOGIC ) ;END COMPONENT ;
END halfadd_package ;
Fall 2010 ECE 331 - Digital System Design 25
The Full Adder in VHDL(The Design File)
LIBRARY ieee ;USE ieee.std_logic_1164.all ;USE work.halfadd_package.all ;
ENTITY fulladd ISPORT ( Cin, A, B : IN STD_LOGIC ; Sum, Cout : OUT STD_LOGIC ) ;
END fulladd ;
ARCHITECTURE Structure OF fulladd IS SIGNAL s1, c1, c2: STD_LOGIC ;BEGIN ha1 : halfadd PORT MAP ( A => A, B => B, Sum => s1, Cout => c1 ) ; ha2 : halfadd PORT MAP ( s1, Cin, Sum, c2 ); Cout <= c1 OR c2 ;END Structure ;
Fall 2010 ECE 331 - Digital System Design 26
Questions?