for Digital Students

Embed Size (px)

Citation preview

  • 7/27/2019 for Digital Students

    1/48

    Chapter 1 1

    CS370 Computer Architecture

    Instructor: Tao Xie

    Email address: [email protected]: GMCS 544Office hours: MW 11 am 12 pm (noon)Course website:http://www-rohan.sdsu.edu/~taoxie/cs370/index.htmlPrerequisite: CS237 or equivalent, please show meyour transcript in next class (Monday, Jan. 28).

  • 7/27/2019 for Digital Students

    2/48

    Chapter 1 2

    Grader & Lab Software

    Andres BlancoEmail: [email protected] hours: Wednesday 4 pm - 5 pm,Tuesday&Thursday 1:30 pm- 3:30 pm at GMCS 401

    LogicWorks5 is needed for our lab assignment

  • 7/27/2019 for Digital Students

    3/48

    Chapter 1 3

    Evaluation

    Test1 75-minute close book & in class ...15%

    Test2 75-minute close book & in class ...15%Homework assignment1 ~ 3 ...24% (8% each)Lab1 (6)% ; Lab2-3 (10% each).One 2-hr comprehensive final exam ...20%Weekly exercises* ...0%Please check our class web page regularly.

  • 7/27/2019 for Digital Students

    4/48

    Chapter 1 4

    Class Guidelines

    Prerequisite : The prerequisite for this course is CS237. This prerequisite will be strictlyenforced.There will be NO make-up tests without a verified excuse.I will not sign late drop slips!The final exam is scheduled on Monday (May 13), 13:00-15:00. Failure to appear for thefinal exam will result in a grade of F in the course, unless you make prior arrangementswith me for an Incomplete.Incompletes : To receive a grade of Incomplete (I) in this class, you must meet all of thefollowing criteria:..There will be NO extra credit in any assignments, tests, and final exam.All homeworks are due at the start of class on the indicated due day. No late homework will

    be accepted.All the exams are close-book, close-notes . You can only bring one piece of paper (size A4,one side) as cheating sheet .Any questions about grading must be brought to the attention of the grader or the instructor within one week after the item in question is returned.No cell phones, No Pagers, No speaking in class.Cheating : Any one caught cheating/collaborating on an exam or any assignment will receive

    an F in the course. The incident will be reported to the Office of Judicial Affairs for disciplinary proceedings. Note: If, for instance, you allow your assignment be copied by aclassmate, you are considered as guilty as the copier.

  • 7/27/2019 for Digital Students

    5/48

    Chapter 1 5

    Grading Policy

    100 90 86 82 78 74 70 66 62 58 54 50 0

    | A | A- | B+ | B | B- | C+ | C | C- | D+ | D | D- | F |

  • 7/27/2019 for Digital Students

    6/48Chapter 1 6

    Tips for CS370

    After each class, spend 1 hour to digest lectureslides.After each class, spend another 1 hour to read thetextbook.Each week, spend 1 hour to do Weekly Exercises.On average, spend 4 to 5 hours per week on CS 370.

    Pay close attention on example questions on theslides and make sure you fully understand how to

    solve them.

  • 7/27/2019 for Digital Students

    7/48Chapter 1 7

    Why We Need to Learn Hardware?

    Always ImportantEvery hardware system is differentUnderstanding hardware more efficient algorithms, programs(Microsoft developers say so!)Understanding hardware more effective use of OSUnderstanding hardware more efficient database designTimelyMulticore, hyper-threading, security, . .Opens doors

    Yet another option!You wont know what you need until you need it(and this will probably be after you graduate)

  • 7/27/2019 for Digital Students

    8/48Chapter 1 8

    Software and Hardware

    1-8

    Software

    Hardware

    Application

    Language

    Machine Architecture, ISA (CS572)

    Microarchiture

    Logic and IC (CS370)

    Device

    Algorithm & Data Structure

  • 7/27/2019 for Digital Students

    9/48Chapter 1 92013/1/22 9

    Computer System Design

  • 7/27/2019 for Digital Students

    10/48Chapter 1 10

    System, Component, Logic Circuit, IC, Transistor

    Transistor MOSFET PMOS/NMOS

    CMOS

    Logic Gate NOT/NAND/NOR

    Functional Block ALU FPU

    CPU chip SOC chip

  • 7/27/2019 for Digital Students

    11/48Chapter 1 11

    The Implementation of Computer System

  • 7/27/2019 for Digital Students

    12/48

    Charles Kime & Thomas Kaminski

    2004 Pearson Education, Inc.Terms of Use(Hyperlinks are active in View Show mode)

    Chapter 1 DigitalComputers and Information

    Logic and Computer Design Fundamentals

  • 7/27/2019 for Digital Students

    13/48Chapter 1 13

    Overview

    Digital Systems and Computer SystemsInformation RepresentationNumber Systems [binary, octal andhexadecimal]Arithmetic OperationsBase ConversionDecimal Codes [BCD (binary codeddecimal), parity]

  • 7/27/2019 for Digital Students

    14/48Chapter 1 14

    Digital System

    Takes a set of discrete information inputs and discreteinternal information (system state) and generates a set

    of discrete information outputs.

    System State

    DiscreteInformationProcessingSystem

    DiscreteInputs Discrete

    Outputs

  • 7/27/2019 for Digital Students

    15/48Chapter 1 15

    Types of Digital Systems

    No state present Combinational Logic System

    Output = Function(Input)State present State updated at discrete times

    => Synchronous Sequential System State updated at any time

    => Asynchronous Sequential System State = Function (State, Input) Output = Function (State)

    or Function (State, Input)

  • 7/27/2019 for Digital Students

    16/48Chapter 1 16

    Digital System Example:

    A Digital Counter (e. g., odometer):

    1 30 0 5 6 4Count Up

    Reset

    Inputs: Count Up, ResetOutputs: Visual Display

    State: "Value" of stored digits

  • 7/27/2019 for Digital Students

    17/48Chapter 1 17

    A Digital Computer Example

    Synchronous or

    Asynchronous

    Inputs:Keyboard,

    mouse, modem,microphone

    Outputs: CRT,LCD, modem,speakers

  • 7/27/2019 for Digital Students

    18/48Chapter 1 18

    Signal

    An information variable represented by physicalquantity (e.g., voltages and currents).

    For digital systems, the variable takes on discretevalues.Two level, or binary values are the most prevalentvalues in digital systems.Binary values are represented abstractly by: digits 0 and 1 words (symbols) False (F) and True (T) words (symbols) Low (L) and High (H) and words On and Off.

    Binary values are represented by values or ranges of values of physical quantities (see Figure 1-1)

  • 7/27/2019 for Digital Students

    19/48Chapter 1 19

    Signal Examples Over Time

    Analog

    Asynchronous

    Synchronous

    Time

    Continuous invalue & time

    Discrete invalue &

    continuousin time

    Discrete in

    value & time

    Digital

    Difference between Asy and Syn?

  • 7/27/2019 for Digital Students

    20/48Chapter 1 20

    Signal Example Physical Quantity: Voltage

    ThresholdRegion

  • 7/27/2019 for Digital Students

    21/48Chapter 1 21

    What are other physical quantities

    represent 0 and 1? CPU Voltage

    Disk

    CD Dynamic RAM

    Binary Values: Other Physical Quantities

    Magnetic Field DirectionSurface Pits/Light

    Electrical Charge

  • 7/27/2019 for Digital Students

    22/48

    Chapter 1 22

    Number Systems Representation

    Positive radix, positional number systemsA number with radix r is represented by astring of digits:

    An - 1 An - 2 A1 A0 . A - 1 A - 2 A - m + 1 A - min which 0 A i < r and . is the radix point .The string of digits represents the power series:

    ( ) ( )(Number) r = + j = - m

    j j

    i

    i = 0i r A r A

    (Integer Portion) + (Fraction Portion)

    i = n - 1 j = - 1

  • 7/27/2019 for Digital Students

    23/48

    Chapter 1 23

    Number Systems Examples

    General Decimal Binary

    Radix (Base) r 10 2

    Digits 0 => r - 1 0 => 9 0 => 10123

    Powers of 4Radix 5

    -1-2-3-4

    -5

    r 0

    r 1

    r 2

    r 3

    r 4

    r 5

    r-1

    r -2

    r -3

    r -4

    r -5

    110

    1001000

    10,000100,000

    0.10.01

    0.0010.0001

    0.00001

    1248

    1632

    0.50.25

    0.1250.0625

    0.03125

  • 7/27/2019 for Digital Students

    24/48

    Chapter 1 24

    Special Powers of 2

    210 (1024) is Kilo, denoted "K"

    220 (1,048,576) is Mega, denoted "M"

    230 (1,073, 741,824)is Giga, denoted "G"

  • 7/27/2019 for Digital Students

    25/48

  • 7/27/2019 for Digital Students

    26/48

    Chapter 1 26

    To convert to decimal, use decimal arithmetic

    to form

    (digit respective power of 2).Example:Convert 11010 2 to N 10 :

    Converting Binary to Decimal

  • 7/27/2019 for Digital Students

    27/48

    Chapter 1 27

    Method 1 Subtract the largest power of 2 (see slide 19) that gives

    a positive remainder and record the power. Repeat, subtracting from the prior remainder and

    recording the power, until the remainder is zero. Place 1s in the positions in the binary result

    corresponding to the powers recorded; in all otherpositions place 0s.Example: Convert 625 10 to N 2

    Converting Decimal to Binary

  • 7/27/2019 for Digital Students

    28/48

    Chapter 1 28

    Commonly Occurring Bases

    Name Radix Digits

    Binary 2 0,1Octal 8 0,1,2,3,4,5,6,7

    Decimal 10 0,1,2,3,4,5,6,7,8,9Hexadecimal 16 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F

    The six letters (in addition to the 10integers) in hexadecimal represent: ?

  • 7/27/2019 for Digital Students

    29/48

    Chapter 1 29

    Decimal(Base 10)

    Binary(Base 2)

    Octal(Base 8)

    Hexadecimal(Base 16)

    00 00000 00 0001 00001 01 0102 00010 02 0203 00011 03 0304 00100 04 04

    05 00101 05 0506 00110 06 0607 00111 07 0708 01000 10 0809 01001 11 09

    10 01010 12 0A11 01011 13 0B12 01100 14 0C13 01101 15 0D14 01110 16 0E

    15 01111 17 0F16 10000 20 10

    Good idea to memorize!

    Numbers in Different Bases

  • 7/27/2019 for Digital Students

    30/48

    Chapter 1 30

    Conversion Between Bases

    Method 2

    To convert from one base to another:1) Convert the Integer Part

    2) Convert the Fraction Part

    3) Join the two results with a radix point

  • 7/27/2019 for Digital Students

    31/48

    Chapter 1 31

    Conversion Details

    To Convert the Integral Part:Repeatedly divide the number by the new radix and

    save the remainders. The digits for the new radix arethe remainders in reverse order of their computation .If the new radix is > 10, then convert all remainders >

    10 to digits A, B, To Convert the Fractional Part:

    Repeatedly multiply the fraction by the new radix andsave the integer digits that result. The digits for thenew radix are the integer digits in order of theircomputation. If the new radix is > 10, then convert all

    integers > 10 to digits A, B,

  • 7/27/2019 for Digital Students

    32/48

    Chapter 1 32

    Example: Convert 46.6875 10 To Base 2

    Convert 46 to Base 2

    Convert 0.6875 to Base 2:

    Join the results together with the

    radix point:

  • 7/27/2019 for Digital Students

    33/48

    Chapter 1 33

    Additional Issue - Fractional Part

    Note that in this conversion, the fractional partbecame 0 as a result of the repeated

    multiplications.In general, it may take many bits to get this tohappen or it may never happen.

    Example: Convert 0.65 10 to N 2 0.65 = 0.1010011001001 The fractional part begins repeating every 4 steps

    yielding repeating 1001 forever!Solution: Specify number of bits to right of radix point and round or truncate to this

    number.

  • 7/27/2019 for Digital Students

    34/48

    Chapter 1 34

    Checking the Conversion

    To convert back, sum the digits times theirrespective powers of r.

    From the prior conversion of 46.6875 10101110 2 = 1 32 + 0 16 +1 8 +1 4 + 1 2 +0 1

    = 32 + 8 + 4 + 2= 46

    0.1011 2 = 1/2 + 1/8 + 1/16= 0.5000 + 0.1250 + 0.0625= 0.6875

  • 7/27/2019 for Digital Students

    35/48

    Chapter 1 35

    Binary Numbers and Binary Coding

    Flexibility of representation Within constraints below, can assign any binary

    combination (called a code word) to any data as longas data is uniquely encoded.

    Information Types

    NumericMust represent range of data neededVery desirable to represent data such that simple,straightforward computation for common arithmetic

    operations permittedTight relation to binary numbers

    Non-numericGreater flexibility since arithmetic operations not applied.Not tied to binary numbers

  • 7/27/2019 for Digital Students

    36/48

    Chapter 1 36

    Given n binary digits (called bits), a binary codeis a mapping from a set of represented elements

    to a subset of the 2 n binary numbers.Example: Abinary codefor the sevencolors of therainbowCode 100 isnot used

    Non-numeric Binary Codes

    Binary Number000001010011

    101110111

    ColorRedOrangeYellowGreen

    BlueIndigoViolet

  • 7/27/2019 for Digital Students

    37/48

    Chapter 1 37

    Given M elements to be represented by abinary code, the minimum number of

    bits, n , needed, satisfies the followingrelationships:

    2 n > M > 2 ( n 1)

    n = log 2 M where x , called the ceiling function, is the integer greater than orequal to x .

    Example: How many bits are required torepresent decimal digits with a binarycode?

    Number of Bits Required

  • 7/27/2019 for Digital Students

    38/48

    Chapter 1 38

    Number of Elements Represented

    Given n digits in radix r, there are r ndistinct elements that can be represented.

    But, you can represent m elements, m < r n

    Examples: You can represent 4 elements in radix r = 2with n = 2 digits: (00, 01, 10, 11).

    You can represent 4 elements in radix r = 2with n = 4 digits: (0001, 0010, 0100, 1000). This second code is called a "one hot" code.

  • 7/27/2019 for Digital Students

    39/48

    Chapter 1 39

    Binary Coded Decimal (BCD)

    The BCD code is the 8,4,2,1 code.This code is the simplest, most intuitive binarycode for decimal digits and uses the samepowers of 2 as a binary number, but onlyencodes the first ten values from 0 to 9.Example: 1001 (9) = 1000 (8) + 0001 (1)How many invalid code words are there?

    What are the invalid code words?

  • 7/27/2019 for Digital Students

    40/48

    Chapter 1 40

    Warning: Conversion or Coding?

    Do NOT mix up conversion of a decimalnumber to a binary number with codinga decimal number with a BINARYCODE.

    13 10 = 1101 2 (This is conversion)13 0001|0011 (This is coding)

  • 7/27/2019 for Digital Students

    41/48

    Chapter 1 41

    Binary Arithmetic

    Single Bit Addition with Carry

    Multiple Bit AdditionSingle Bit Subtraction with Borrow

    Multiple Bit SubtractionMultiplication

  • 7/27/2019 for Digital Students

    42/48

    Chapter 1 42

    Single Bit Binary Addition with Carry

    Given two binary digits (X,Y), a carry in (Z) we get thefollowing sum (S) and carry (C):

    Carry in (Z) of 0:

    Carry in (Z) of 1: Z 1 1 1 1

    X 0 0 1 1+ Y + 0 + 1 + 0 + 1

    C S 0 1 1 0 1 0 1 1

    Z 0 0 0 0X 0 0 1 1

    + Y + 0 + 1 + 0 + 1

    C S 0 0 0 1 0 1 1 0

  • 7/27/2019 for Digital Students

    43/48

    Chapter 1 43

    Extending this to two multiple bitexamples:

    Carries 0 0Augend 01100 10110Addend +10001 +10111

    SumNote: The 0 is the default Carry-In to theleast significant bit.

    Multiple Bit Binary Addition

  • 7/27/2019 for Digital Students

    44/48

    Chapter 1 44

    Given two binary digits (X,Y), a borrow in (Z) weget the following difference (S) and borrow (B):

    Borrow in (Z) of 0:

    Borrow in (Z) of 1:

    Single Bit Binary Subtraction with Borrow

    Z 1 1 1 1

    X 0 0 1 1

    - Y -0 -1 -0 -1

    BS 11 1 0 0 0 1 1

    Z 0 0 0 0X 0 0 1 1

    - Y -0 -1 -0 -1

    BS 0 0 1 1 0 1 0 0

  • 7/27/2019 for Digital Students

    45/48

    Chapter 1 45

    Extending this to two multiple bit examples:

    Borrows 0 0Minuend 10110 10110

    Subtrahend - 10010 - 10011Difference

    Notes: The 0 is a Borrow-In to the least significantbit. If the Subtrahend > the Minuend, interchangeand append a to the result.

    Multiple Bit Binary Subtraction

  • 7/27/2019 for Digital Students

    46/48

    Chapter 1 46

    Binary Multiplication

    The binary multiplication table is simple:

    0 0 = 0 | 1 0 = 0 | 0 1 = 0 | 1 1 = 1Extending multiplication to multiple digits :

    Multiplicand 1011Multiplier x 101Partial Products 1011

    0000 -1011 - -

    Product 110111

  • 7/27/2019 for Digital Students

    47/48

    Chapter 1 47

    Weekly Exercise 1-1

    Problems (P31 on text book)1-1; 1-4; 1-7; 1-8; 1-9, 1-12 (a); 1-16 (a)Memorize the table on slide 29

  • 7/27/2019 for Digital Students

    48/48

    Terms of Use

    2004 by Pearson Education,Inc. All rights reserved.The following terms of use apply in addition to the standardPearson Education Legal Notice .

    Permission is given to incorporate these materials into classroompresentations and handouts only to instructors adopting Logic andComputer Design Fundamentals as the course text.Permission is granted to the instructors adopting the book to postthese materials on a protected website or protected ftp site inoriginal or modified form. All other website or ftp postings,including those offering the materials for a fee, are prohibited.

    You may not remove or in any way alter this Terms of Use noticeor any trademark, copyright, or other proprietary notice,including the copyright watermark on each slide.Return to Title Page

    http://www.pearsoned.com/legal/index.htmhttp://www.pearsoned.com/legal/index.htm