ee1a2 2011 parta 1 intro and numbers

Upload: tarottaurus549254

Post on 07-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/6/2019 Ee1a2 2011 Parta 1 Intro and Numbers

    1/21

    EE1A2Microprocessor Systems and Digital Logic

    Introduction and Numbers

    Originally written by Dr. Tim Collins

    Edited and presented by Dr Sandra I. Woolley

    "Whether you believe you can, or you can't, you are right

    Henry Ford

  • 8/6/2019 Ee1a2 2011 Parta 1 Intro and Numbers

    2/21

    22

    Content

    Binary Arithmetic

    Addition and subtraction.

    Arithmetic circuits.

    Arithmetic Logic Units (ALUs)

    Microcontrollers

    Microcontroller architecture.

    Essential building blocks of a computer.

    Programming

  • 8/6/2019 Ee1a2 2011 Parta 1 Intro and Numbers

    3/21

    33

    Binary Arithmetic

    Number Systems

    Decimal

    Binary

    Hexadecimal

    Addition

    Long addition

    Full adder circuits

    Parallel adders

    Carry-look-ahead circuitry

    Subtraction

    Twos complement

    Subtraction using a parallel adder

  • 8/6/2019 Ee1a2 2011 Parta 1 Intro and Numbers

    4/21

    44

    Arithmetic Logic Units (ALUs)

    Adder-Subtraction Circuit

    Combining addition and subtraction in a single controllablecircuit

    Arithmetic Logic Units

    General-purpose arithmetic and logic calculation units

    Registers

    How memory circuits can simplify the connections to an ALU

  • 8/6/2019 Ee1a2 2011 Parta 1 Intro and Numbers

    5/21

    55

    The Anatomy of a Microcontroller

    Tri-State Ports and Busses

    How a bus can interconnect many different registers withouthuge wiring difficulties.

    Connecting an ALU to a Bus

    The Building Blocks of a Computer

    ALU

    Registers

    I/O Ports

    Program Memory

    Programs

  • 8/6/2019 Ee1a2 2011 Parta 1 Intro and Numbers

    6/21

    66

    Number Systems Decimal

    Base 10

    Ten digits, 0-9

    Columns represent (from right to left) units, tens, hundreds etc.

    123

    1v102 + 2v101 + 3v100

    or

    1 hundred, 2 tens and 3units

  • 8/6/2019 Ee1a2 2011 Parta 1 Intro and Numbers

    7/21

    77

    Bases

    When counting upwards in base-10, we increase the units digit until

    we get to 10 when we reset the units to zero and increase the tensdigit.

    So, in base-n, we increase the units until we get to n when we reset

    the units to zero and increase the ns digit.

    Consider hours-minutes-seconds as an example of a base-60

    number system:

    Eg. 12:58:43+00:03:20 = 13:02:03

    NB. The base of a number is often indicated by a subscript. E.g.(123)

    10indicates the base-10 number123.

  • 8/6/2019 Ee1a2 2011 Parta 1 Intro and Numbers

    8/21

    88

    Binary

    Base-2

    Two digits, 0 & 1

    Columns represent (from right to left) units, twos, fours, eights

    etc.

    1111011

    1v26 + 1v25 + 1v24 + 1v23 + 0v22 + 1v21 + 1v20

    = 1v64 + 1v32 + 1v16 + 1v8 + 0v4 + 1v2 + 1v1

    = 123

  • 8/6/2019 Ee1a2 2011 Parta 1 Intro and Numbers

    9/21

    9

    Binary Numbers Terminology

    Each digit in a binary

    number is known as abit.

    A group of eight bits

    makes a binary number

    known as a byte. A group of more than

    eight bits is known as a

    word.

    Typical word lengths are12, 16, 32, 64.

    http://www.thinkgeek.com/tshirts/frustrations/5aa9/

  • 8/6/2019 Ee1a2 2011 Parta 1 Intro and Numbers

    10/21

    1010

    Decimal to Binary Conversion

    123z 2 = 61 remainder1

    61z 2 = 30 remainder1

    30z 2 = 15 remainder0

    15z 2 = 7 remainder17z 2 = 3 remainder1

    3z 2 = 1 remainder1

    1z 2 = 0 remainder1

    Least significant bit (rightmost)

    Most significant bit (leftmost)

    Answer: (123)10

    = (1111011)2

    Example Converting (123)10 into binary

  • 8/6/2019 Ee1a2 2011 Parta 1 Intro and Numbers

    11/21

    1111

    Twos Complement

    One byte (eight bits) can be used to represent the decimal number

    range0 to 255 (unsigned) or

    -128 to 127 (signed)

    i.e.,

    Unsigned: 0 1 2 3 ... 126 127 128 129 130 ... 253 254 255

    or

    Signed : 0 1 2 3 ... 126 127 -128 -127 -126 ... -3 -2 -1

    Negative binary numbers are formed by subtracting from a number

    one greater than the maximum possible (i.e. 2

    n

    or 256 for a byte) For example,

    (123)10

    = (01111011)2

    (-123)10

    = (10000101)2

    = (133)10

    = (256-123)10

  • 8/6/2019 Ee1a2 2011 Parta 1 Intro and Numbers

    12/21

    1212

    Frequently Asked Question

    So how can you tell the difference between:

    (-123)10

    = (10000101)2

    and

    (133)10 = (10000101)2

    The answer is you cant unless you know whether youre using

    signed or unsigned arithmetic:

    127128Signed

    2550Unsigned

    ee

    ee

    x

    x

  • 8/6/2019 Ee1a2 2011 Parta 1 Intro and Numbers

    13/21

    1313

    Hexadecimal

    Base-16

    Sixteen digits, 0-9 and A-F (ten to fifteen)

    Columns represent (from right to left) units, 16s, 256s, 4096s

    etc.

    7B

    7v161 + 11v160 = 123

  • 8/6/2019 Ee1a2 2011 Parta 1 Intro and Numbers

    14/21

    14

    Decimal to HexConversion

    123z

    16 = 7 remainder 11 (orB

    )7 z 16 = 0 remainder 7

    Answer : (123)10 = (7B)16

    Converting (123)10 into hex

  • 8/6/2019 Ee1a2 2011 Parta 1 Intro and Numbers

    15/21

    1515

    Binary to Hex/Hex to Binary

    Each group of four binary bits maps on to a single hex digit.

    Even very long numbers can be converted easily, treating each hexdigit independently.

    0111 1011

    7 B

    1011 1001 0110 1111 1010

    B 9 6 F A

    E.g.

  • 8/6/2019 Ee1a2 2011 Parta 1 Intro and Numbers

    16/21

    1616

    Binary Arithmetic - Addition

    Binary long addition works just like decimal long addition.

    1 0 0 1 1 10 0 1 1 1 0

    0

    1

    0

    1

    1

    0

    1

    1

    1

    0

    0

    1

    +

    Carried digits

    Result

    When we work on

    paper we usually

    leave less space for

    the carried digits.

  • 8/6/2019 Ee1a2 2011 Parta 1 Intro and Numbers

    17/21

    1717

    Full Adder

    Each column of the sum has three inputs

    Digits from the two numbers to add (A and B)

    Carry bit from previous column

    It also has two outputs

    SUM Result bit

    COUT Carry bit to next column

    These are the logical operations performed by a full adder circuit.

    ABBCACC

    CBASUM

    ININOUT

    IN

    !

    !

    Full Adder

    B A CIN

    COUT SUM

  • 8/6/2019 Ee1a2 2011 Parta 1 Intro and Numbers

    18/21

    1818

    Parallel Adder

    To add two n-bit numbers together, n full-adders should be

    cascaded. Each full-adder represents a column in the long addition.

    ull dder

    B A CI

    COUT

    SUM

    Full r

    B A CI

    COUT

    SUM

    Full r

    B A CI

    COUT

    SUM

    B A B A B A

    CI

    Q Q Q

  • 8/6/2019 Ee1a2 2011 Parta 1 Intro and Numbers

    19/21

    1919

    Summary

    In digital electronics, numbers are represented using base-2

    (binary). Base-16 (hex) is often used by human programmers because

    binary to hex conversion is very easy.

    Binary numbers may be unsigned or signed (twos complement).

    Binary addition works in a similar way to decimal long addition.

  • 8/6/2019 Ee1a2 2011 Parta 1 Intro and Numbers

    20/21

    2020

    Recommended Private Study

    Practice binary and hexadecimal conversions.

    Use the binary values of A and B from our binary long additionexample and check the answers using the Cout and SUM formulae.

  • 8/6/2019 Ee1a2 2011 Parta 1 Intro and Numbers

    21/21

    Thank You