Ece3430 Lecture 01

Embed Size (px)

Citation preview

  • 8/11/2019 Ece3430 Lecture 01

    1/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014

    1

    ECE 3430Introduction to Microcomputer Systems

    University of Colorado at Colorado Springs

    Lecture #1

    Agenda Today:

    1) Microcomputers, Microprocessors, Microcontrollers

    2) Number Systems

  • 8/11/2019 Ece3430 Lecture 01

    2/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014

    2

    Microcomputers and Terminology

    There are lots of confusing terms floating around which dont alwayshave consistent definitions. Get used to it!

    What is a microcomputer?

    Term which evolved intopersonal computer (PC)desktopand

    laptop. Sometimes just referred to as a computer.

    A microcomputer is a computerbut a computer

    is not a microcomputer.

    Other types of computers (not digital in nature): Analog (slide ruler, abacus, mechanical computers)

    Pulse (neural networks)

  • 8/11/2019 Ece3430 Lecture 01

    3/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014

    3

    Microcomputers and Terminology

    Other types of digital computers: Minicomputers (larger than microcomputers)

    Mainframe computers (larger than minicomputers)

    Supercomputers (biggest and fastest)

    Microcomputers have five classic components:

    Input (keyboards, mice, touch-screens, etc.) Output (LCD panels, monitors, printers)

    Memory (ROM, RAM, hard drives)

    Datapath (performs arithmetic and logical operations [ALU])

    Control (state machine in nature, controls the datapath)

    The last two (datapath and control) are usually collectively

    called theprocessoror central processor unit(CPU). Microcomputers are typically computers that are developed

    around a microprocessor.

  • 8/11/2019 Ece3430 Lecture 01

    4/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014 4

    Microprocessors and Microcontrollers

    Microprocessor:

    A CPU packaged in a single integrated circuit.

    Typically employs multiple execution pipelines, data and instruction

    caches, and other complex logic to get very high execution

    throughput (lots of work done in a given unit of time).

    Microcontroller:

    A computer system implemented on a single, very large-scale

    integrated circuit. Generally speaking, a microcontroller contains

    everything in a microprocessor plus on-chip peripheral devices(bells

    and whistles). A microcontroller may contain memories, timer circuits,

    A/D converters, USB interface engines, the kitchen

    sink, et cetera.

  • 8/11/2019 Ece3430 Lecture 01

    5/27

  • 8/11/2019 Ece3430 Lecture 01

    6/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014 6

    Number Systems

    Number Base Notation Used in this Course:

    Decimal, Base 10 or d

    Ex) 11ord11

    Binary, Base 2 0b orb orb

    Ex) 0b1011orb1011or1011b

    Octal, Base 8 q or q

    Ex) q13or13q

    Hexadecimal, Base 16 0x or h or h

    Ex) 0xBDorhBDorBDh

    ASCII or

    Ex) Fred (non-terminated)orBarney (terminated)

    The MSP430 assembler and C/C++ compiler will make use of one of the above. Well

    discuss assembly, the assembler, and higher-level programming languages (C/C++)

    later.

  • 8/11/2019 Ece3430 Lecture 01

    7/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014 7

    Number Systems

    Base ConversionBinary to Decimal Each digit has a weight of 2nthat depends on the position of the

    digit.

    Multiply each digit by its weight.

    Sum the resultant products.

    Ex) Convert b1011 to decimal

    23 22 21 20 (weight)

    % 1 0 1 1

    = 1(23

    ) + 0(22

    ) + 1(21

    ) + 1(20

    )= 1(8) + 0(4) + 1(2) + 1(1)

    = 8 + 0 + 2 + 1= d11

  • 8/11/2019 Ece3430 Lecture 01

    8/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014 8

    Number Systems

    Base ConversionBinary to Decimal with Fractions The weight of the binary digits have negative positions.

    ex) Convert b1011.101 to decimal

    23 22 21 20 2-1 2-2 2-3

    1 0 1 1 . 1 0 1

    = 1(23) + 0(22) + 1(21) + 1(20) + 1(2-1) + 0(2-2) + 1(2-3)

    = 1(8) + 0(4) + 1(2) + 1(1) + 1(0.5)+ 0(0.25)+ 1(0.125)

    = 8 + 0 + 2 + 1 + 0.5 + 0 + 0.125= d11.625

  • 8/11/2019 Ece3430 Lecture 01

    9/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014 9

    Number Systems

    Base ConversionDecimal to Binary- the decimal number is divided by 2, the remainder is recorded- the quotient is then divided by 2, the remainder is recorded

    - the process is repeated until the quotient is zero

    ex) Convert 11 decimal to binary

    Quotient Remainder2 11 5 1 LSB

    2 5 2 1

    2 2 1 0

    2 1 0 1 MSB

    = b1011

  • 8/11/2019 Ece3430 Lecture 01

    10/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014 10

    Number Systems

    Base ConversionDecimal to Binary with Fractions- the fraction is converted to binary separately- the fraction is multiplied by 2, the 0thdigit is recorded

    - the remaining fraction is multiplied by 2, the 0thdigit is recorded

    - the process is repeated until the fractional part is zero

    ex) Convert 0.375 decimal to binary

    Product 0thDigit

    0.3752 0.75 0 MSB

    0.752 1.50 1

    0.52 1.00 1 LSB

    d0.375 = b.011

    finished

  • 8/11/2019 Ece3430 Lecture 01

    11/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014 11

    Number Systems

    Base ConversionHex to Decimal- the same process as binary to decimal except the weights are now BASE 16- NOTE (hA=d10, hB=d11, hC=d12, hD=d13, hE=d14, hF=d15)

    ex) Convert h2BC to decimal

    162 161 160 (weight)

    2 B C

    = 2(162) + B(161) + C(160)

    = 2(256) + 11(16) + 12(1)

    = 512 + 176 + 12= d700

  • 8/11/2019 Ece3430 Lecture 01

    12/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014 12

    Number Systems

    Base ConversionHex to Decimal with Fractions- the fractional digits have negative weights (BASE 16)- NOTE (hA=d10, hB=d11, hC=d12, hD=d13, hE=d14, hF=d15)

    ex) Convert h2BC.F to decimal

    162 161 160 16-1 (weight)

    2 B C . F

    = 2(162) + B(161) + C(160) + F(16-1)

    = 2(256) + 11(16) + 12(1) + 15(0.0625)

    = 512 + 176 + 12 + 0.938= d700.938

  • 8/11/2019 Ece3430 Lecture 01

    13/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014 13

    Number Systems

    Base ConversionDecimal to Hex

    - the same procedure is used as before but with BASE 16 as the divisor/multiplier

    ex) Convert 420.625 decimal to hex

    1st, convert the integer part

    Quotient Remainder

    16 420 26 4 LSB

    16 26 1 10

    16 1 0 1 MSB

    = h1A4

    2nd, convert the fractional part

    Product 0thDigit0.62516 10.00 10 MSB

    = h.A

    d420.625 = h1A4.A

  • 8/11/2019 Ece3430 Lecture 01

    14/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014 14

    Number Systems

    Base ConversionOctal to Decimal / Decimal to Octal

    The same procedure is used as before but with BASE 8as the divisor/multiplier

  • 8/11/2019 Ece3430 Lecture 01

    15/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014 15

    Number Systems (Shortcuts)

    Base ConversionHex to BinaryEach HEX digit is made up of four binary bits which represent 8, 4, 2, and 1

    Ex) Convert hABC to binary

    A B C

    = 1010 1011 1100

    = b1010 1011 1100

    Octal to Binary works the same except using groups of three binary

    bits which represent 4, 2, and 1.

  • 8/11/2019 Ece3430 Lecture 01

    16/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014 16

    Number Systems (Shortcuts)

    Base ConversionBinary to Hex- every 4 binary bits for one HEX digit- begin the groups of four at the LSB

    - if necessary, fill the leading bits with 0s

    ex) Convert b1100101111 to hex

    = 0011 0010 1111

    3 2 F

    = h32F

    Binary to Octal works the same way using groups of 3 binary bits.

  • 8/11/2019 Ece3430 Lecture 01

    17/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014 17

    Number Systems

    Binary Addition- same as BASE 10 addition- need to keep track of the carry bit

    ex) Add b1011 and b1001

    1 1

    1 0 1 11 0 0 1

    +________

    1 0 1 0 0

    Carry Bit

  • 8/11/2019 Ece3430 Lecture 01

    18/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014 18

    Number Systems

    Ways to represent integer signed values: Sign-Magnitude (historical): b1111 1111 = d-127 0 and -0 can be represented.

    8-bit range: -127 to 127

    Number line: 0,1,,127,-0,-1,,-127

    Ones Complement (historical): b1111 1111 = d-0

    0 and -0 can be represented.

    8-bit range: -127 to 127

    Number line: 0,1,,127,-127,-126,,-0

    Twos Complement (used today): b1111 1111 = d-1

    Only one 0 representation.

    Always one more negative value than positive. 8-bit range: -128 to 127

    Number line: 0,1,,127,-128,-127,-1

  • 8/11/2019 Ece3430 Lecture 01

    19/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014 19

    Number Systems

    Twos Complement- this encoding was chosen to represent negative numbers in modern computers- this way we can use adding circuitry to perform subtraction (easily)

    - since the number of bits we have is fixed (i.e., 8), we use the MSB as a signbit

    Positive #s : MSB = 0 (ex: b0000 1111 is positive number)

    Negative #s : MSB = 1 (ex: b1000 1111 is negative number)

    - the range of #s that a twos complement code can represent is:

    (-2n-1) < N < (2n-11) : n = number of bits

    ex) What is the range of #s that an 8-bit twos complement code can represent?

    (-28-1) < N < (28-11)

    (-128) < N < (+127)

  • 8/11/2019 Ece3430 Lecture 01

    20/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014 20

    Number Systems

    Twos Complement Negation- to take the twos complement of a positive number (i.e., find its negative equivalent)

    Nc = 2nN Nc= Twos Complement

    N = Original Positive Number

    ex) Find the 8-bit twos complement representation of 52dec

    N = +52dec

    Nc = 28 52 = 25652 = 204 = b1100 1100

    Note the Sign Bit

  • 8/11/2019 Ece3430 Lecture 01

    21/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014 21

    Number Systems

    Twos Complement Negation (a second method)- to take the twos complement of a positive number (i.e., find its negative equivalent)

    1) Invert all the bits of the original positive number (binary)

    2) Add 1 to the result

    ex) Find the 8-bit twos complement representation of 52dec

    N = +52dec = b0011 0100

    Invert: = 1100 1011

    Add 1 = 1100 1011

    + 1

    --------------------

    b1100 1100 (-52dec)

  • 8/11/2019 Ece3430 Lecture 01

    22/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014 22

    Number Systems

    Twos Complement Negation (a third method)

    1. Begin with the original positive value.

    2. Change all of bits to the left of the right-most 1 to the opposite state. Done.

    ex) Find the 8-bit twos complement representation of 52dec

    N = +52dec = b0011 0100

    right-most 1

    b1100 1100 (-52dec)

  • 8/11/2019 Ece3430 Lecture 01

    23/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014 23

    Number Systems

    Twos Complement Addition

    -Addition of twos complement numbers is performed just like

    standard binary addition.

    - However, the carry bit is ignored.

  • 8/11/2019 Ece3430 Lecture 01

    24/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014 24

    Number Systems

    Twos Complement Subtraction

    - now we have a tool to do subtraction using the addition algorithm

    ex) Subtract d8 from d15

    d15 = b0000 1111

    d8 = b0000 1000 -> twos complement -> invert 1111 0111

    add1 1111 0111

    + 1

    -----------------

    1111 1000 = d-8

    Now Add: 15 + (-8) = 0000 11111111 1000

    +_________

    1 0000 0111 = d7Disregard Carry

  • 8/11/2019 Ece3430 Lecture 01

    25/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014 25

    Number Systems

    Twos Complement Overflow

    - If a twos complement subtraction results in a number that is outside

    the range of representation (i.e., -128 < N < +127), an overflow

    has occurred.

    ex) -100dec100dec- = -200dec (cant represent)

    - There are three cases when overflow occurs

    1) Sum of like signs results in answer with opposite sign

    2) NegativePositive = Positive

    3) PositiveNegative = Negative

    - Boolean logic can be used to detect these situations.

  • 8/11/2019 Ece3430 Lecture 01

    26/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014 26

    Number Systems

    Binary Coded Decimal- Sometimes we wish to represent an individual decimal digit as

    a binary representation (i.e., 7-segment display to eliminate a decoder)

    - We do this by using 4 binary digits.

    Decimal BCD

    0 00001 0001 ex) Represent 17dec2 00103 0011 Binary = 101114 0100 BCD = 0001 01115 01016 01107 01118 10009 1001

  • 8/11/2019 Ece3430 Lecture 01

    27/27

    Lecture #1 ECE 3430Intro to Microcomputer SystemsFall 2014 27

    Number Systems

    ASCII

    American Standard Code for Information Interchange.

    English alphanumeric characters are represented with a 7-bit code.

    ex) A = h41

    a = h61

    There are ASCII tables everywhere. Google it.

    Unicode

    Supports text expressed in most of the worlds writing systems.

    Each character represented by one or more bytes. UTF-8, UTF-16 are most popular today.

    UTF-8 is ubiquitous on the World-Wide Web (avoids complications arising from

    byte-ordering).