Lecture 2 - Combinational and Sequential Logic

Embed Size (px)

Citation preview

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    1/27

    1Digital Electronics EEE3017WR. Verrinder (2008)

    Announcements

    Laboratories and Tutorials will be held at the following times:

    Monday (15h00 17h00)

    Tuesday (15h00 17h00)

    Venue Change: Laboratory 1 will be held in the White Lab

    Tutorials will be handed out during the tut session and must be

    completed and handed in by your next lecture (Thursday Lectures)

    It is a DP requirement to attend at least 50% of all labs and tutorials

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    2/27

    2Digital Electronics EEE3017WR. Verrinder (2008)

    Textbooks

    There is no set textbook for this course, however, these

    books maybe useful for certain sections of work:

    Logic and Computer Fundamentals (Mano & Kine)

    The Art of Electronics (Horowitz & Hill)

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    3/27

    3Digital Electronics EEE3017WR. Verrinder (2008)

    Digital Circuits

    There are two main

    classes of digital

    circuits:

    Combinational Circuits

    Sequential Circuits

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    4/27

    4Digital Electronics EEE3017WR. Verrinder (2008)

    Combinational Circuits

    Have no memory

    Output only depends on the inputs

    To reverse engineer the circuit:

    Cycle through all the inputs and note the outputs for

    each input

    INPUT OUTPUT1 2 3

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    5/27

    5Digital Electronics EEE3017WR. Verrinder (2008)

    Sequential Circuits

    Have memory

    Output is a function of inputs and the state of

    the circuit

    Cannot just use inputs and outputs to determinethe circuits construction

    OUTPUTINPUT

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    6/27

    6Digital Electronics EEE3017WR. Verrinder (2008)

    Off the Shelf Digital Chips

    Some digital functions

    are so useful that they

    have dedicated chips

    This include: Multiplexers

    Decoders

    Adders

    Flip-flops

    Counters etc.

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    7/27

    7Digital Electronics EEE3017WR. Verrinder (2008)

    Multiplexers

    Are selector devices Take multiple inputs and

    output one signal based on

    the value of the select

    signals

    Have:

    n inputs

    1 output log2n selection lines

    Examples: 74HC157; 74HC153;

    74HC356

    Sel1 Sel2 Output

    0 0 In0

    0 1 In1

    1 0 In2

    1 1 In3

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    8/27

    8Digital Electronics EEE3017WR. Verrinder (2008)

    Multiplexers cont.

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    9/27

    9Digital Electronics EEE3017WR. Verrinder (2008)

    Encoder

    Converts a signal into

    a specific code

    Used for:

    Encrypting data

    Data compression

    Translating one code

    to another

    In3 In2 In1 In0 Out1 Out0

    0 0 0 1 0 00 0 1 0 0 1

    0 1 0 0 1 0

    1 0 0 0 1 1

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    10/27

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    11/27

    11Digital Electronics EEE3017WR. Verrinder (2008)

    Addition Circuits Half Adder

    Adds 2 bits together

    A

    + BSum

    Sum: AB Carry: A.B

    Problem!

    0

    001

    0

    1

    1

    1Carry1

    1

    0

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    12/27

    12Digital Electronics EEE3017WR. Verrinder (2008)

    Problem!

    Adds two bits together but cant handle an

    input carry bit

    This is why it is called a half adder

    SolutionFULL ADDER

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    13/27

    13Digital Electronics EEE3017WR. Verrinder (2008)

    Addition Circuits Full Adder

    Has 3 inputs:

    Input A

    Input B

    Carry In

    2 outputs

    Sum

    Carry Out

    Made by combining 2 half

    adders and an OR gate

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    14/27

    14Digital Electronics EEE3017WR. Verrinder (2008)

    Multi-bit Wide Adder

    To make multi-bit wide adders:

    Cascade a number of full adders

    The carry out bits are fed into the carry in bits

    etc.

    Problems with this approach:

    Cascading circuits leads to poor overall circuit

    performance

    Chips not infinitely fast

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    15/27

    15Digital Electronics EEE3017WR. Verrinder (2008)

    RS Flip-flops

    Have memory

    Made by cross-coupling

    two:

    NAND gates

    NOR gates

    Pull LOW and Q goes

    HIGH and stays HIGH

    until pulled LOW

    S

    R

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    16/27

    16Digital Electronics EEE3017WR. Verrinder (2008)

    D-type Flip-Flops

    Have following inputs: D Clock (CLK)

    S

    R

    Have following outputs Q Q

    On clock edge, the value

    on D is transferred to Qand stays there

    R and S are used to putdevice into known state

    D CLK Next State of Q

    X 0 No Change

    0 h 01 h 1

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    17/27

    17Digital Electronics EEE3017WR. Verrinder (2008)

    JK Flip-flops

    Operation similar to D-type except has twoinputs J and K

    When J is HIGH, flip-flopis SET

    When K is HIGH, flip-flopis RESET

    If both J and K are high,output simply TOGGLES

    J K Next State of Q

    0 0 No change

    0 1 0

    1 0 1

    1 1 Toggle

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    18/27

    18Digital Electronics EEE3017WR. Verrinder (2008)

    Counters

    Go through a set sequence of states when pulsesare applied to the input

    Different types:

    Ripple counters

    Synchronous counters

    Johnson counters

    Decade counters.

    Up-down counters Ring counters

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    19/27

    19Digital Electronics EEE3017WR. Verrinder (2008)

    Ripple Counter

    Made using flip-flops which can complement their

    outputs

    2nd flip-flop only toggles when first flip-flop has changed

    state

    Outputs do not all change at the same time

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    20/27

    20Digital Electronics EEE3017WR. Verrinder (2008)

    Shift Registers

    Data is put in load input

    For every clock pulse, data is shifted 1 bit to the right

    Used to implement: Parallel to serial conversion

    Used often in microprocessors

    Serial to parallel conversion

    101

    10 0 01 1

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    21/27

    21Digital Electronics EEE3017WR. Verrinder (2008)

    Design of Sequential Circuits

    using D-type Flip-flops D-type flip-flops used to hold systems current state

    Use combinational logic to make system move from

    state to state

    Flip flops holdCURRENT

    state

    Combinational

    circuit calculates

    NEXTstate

    Combinational

    logic calculates

    OUTPUTS for

    each state

    D inputs

    System

    Inputs

    Q

    Outputs SystemOutputs

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    22/27

    22Digital Electronics EEE3017WR. Verrinder (2008)

    How to Design the

    Combinational Circuit

    Draw a present state

    next state diagram

    Show:

    Inputs

    Present States

    Next States

    Enter values in next

    state column given

    inputs and current state

    Simplify using standard

    logic reduction tools

    Input

    Present

    1

    (Q1)

    Present

    0

    (Q0)

    Next

    1

    (D1)

    Next

    0

    (D0)

    0 0 0

    0 0 1

    0 1 0

    0 1 1

    1 0 0

    1 0 1

    1 1 0

    1 1 1

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    23/27

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    24/27

    24Digital Electronics EEE3017WR. Verrinder (2008)

    Example 1 - Solution

    Firstly there are no external inputs

    Use two D-type flip flops as

    This gives us 4 possible states. This is fine as we just use dont care

    conditions for the unwanted state

    To create the combinational logic use aPresent state Next State Diagram

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    25/27

    25Digital Electronics EEE3017WR. Verrinder (2008)

    Example 1 Solution cont.

    Present Next

    (Q1) (Q0) (D1) (D0)

    0 0

    0 1

    1 0

    1 1

    D1 = Q0 Need to use a

    Karnaugh Map to

    find D00 0

    0 1

    01

    X X

    Count Sequence:

    0-1-2-repeat

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    26/27

    26Digital Electronics EEE3017WR. Verrinder (2008)

    Example 1 Solution cont.

    )QQ(

    QQD

    10

    100

    0 1

    0

    1

    Q0

    Q1

    1

    X

  • 7/28/2019 Lecture 2 - Combinational and Sequential Logic

    27/27