ece 331 – digital system design single-bit adder circuits and adder circuits in vhdl (lecture #11)...

26
ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials accompanying Fundamentals of Logic Design, 6 th Edition, by Roth and Kinney, and were used with permission from Cengage Learning.

Upload: homer-banks

Post on 14-Dec-2015

227 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

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.

Page 2: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

Fall 2010 ECE 331 - Digital System Design 2

The Half Adder (HA)

Page 3: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

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

Page 4: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

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

Page 5: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

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.

Page 6: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

Fall 2010 ECE 331 - Digital System Design 6

The Full Adder (FA)

Page 7: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

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

Page 8: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

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

Page 9: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

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.

Page 10: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

Fall 2010 ECE 331 - Digital System Design 10

The Full Adder

Exercise:

Design a Full Adder using

2 Half Adders1 OR gate

Page 11: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

Fall 2010 ECE 331 - Digital System Design 11

The Full Adder

Half Adder

Half Adder

A

B

CinSum

Cout

Page 12: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

Fall 2010 ECE 331 - Digital System Design 12

More VHDL Fundamentals

Page 13: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

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.

Page 14: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

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

Page 15: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

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.

Page 16: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

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 ;

Page 17: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

Fall 2010 ECE 331 - Digital System Design 17

Adder Circuits in VHDL

Page 18: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

Fall 2010 ECE 331 - Digital System Design 18

The Half Adder in VHDL

Page 19: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

Fall 2010 ECE 331 - Digital System Design 19

The Half Adder in VHDL

Page 20: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

Fall 2010 ECE 331 - Digital System Design 20

The Full Adder in VHDL

Page 21: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

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

Page 22: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

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

Page 23: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

Fall 2010 ECE 331 - Digital System Design 23

The Full Adder in VHDL

Page 24: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

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 ;

Page 25: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

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 ;

Page 26: ECE 331 – Digital System Design Single-bit Adder Circuits and Adder Circuits in VHDL (Lecture #11) The slides included herein were taken from the materials

Fall 2010 ECE 331 - Digital System Design 26

Questions?