Hardware - PowerPoint PPT Presentation

1 / 57
About This Presentation
Title:

Hardware

Description:

Hardware machines on which to implement algorithms. How computer are constructed? ... Also, the range of voltage changes with advances in hardware technology ... – PowerPoint PPT presentation

Number of Views:116
Avg rating:3.0/5.0
Slides: 58
Provided by: CDTL
Category:
Tags: hardware

less

Transcript and Presenter's Notes

Title: Hardware


1
Hardware
  • Reading Materials
  • Chapter 4-5 of SG
  • Optional Chapter 1-2 of A
  • OUTLINE
  • The Binary Digital Computer
  • Binary Numbers
  • Data Representation
  • Boolean Circuits
  • CPU and Program Execution
  • Peripherals

2
Hardware
  • Educational Goals To learn
  • What are computers?
  • Hardware machines on which to implement
    algorithms
  • How computer are constructed?
  • Computers are devices for computing logical
    functions (AND, OR, NOT, etc)
  • Simple steps in this construction (eg OR)
  • Building complex system from smaller (simpler)
    parts
  • Computer are general purpose machines

3
Hardware Chapter Outline
  • The Binary Digital Computer
  • READING Sect. 4.1 to 4.2 of SG
  • Organization of Digital Computers
  • Why Binary Numbers / Computers
  • Binary Numbers
  • Data Representation
  • Boolean Circuits
  • CPU and Program Execution
  • Peripherals

4
The Binary Digital Computer
  • Organization of a Computer

5
Analog/Digital Computer
  • Up to now, whatever we have discussed could
    equally well be discussed in the context of
    either digital or analog computations
  • We shall concentrate on digital computer
  • Specifically, binary computers
  • BINARY two value (0 and 1) ON/OFF
  • Why binary computers?
  • Physical components transistors, etc
  • Reliability of hardware components

6
Why use Binary Numbers?
  • Reliability
  • Represent only two values (0 and 1), ON/OFF
  • High margin of error
  • Nature of Hardware Devices
  • Many devices are two-state devices
  • Persistence of Digital Data
  • Can store and preserve digital data better

7
Why Binary Computers Reliability
  • Reliability
  • computer store info using electronic devices
  • electronic quantities measured by
  • voltage, current, charge, etc
  • These quantities are not always reliable!
  • esp. for old equipments
  • Also, the range of voltage changes with advances
    in hardware technology
  • What if we want a decimal computer!
  • need 10 different, distinct and STABLE levels
  • (to represent 0, 1, 2, 3, , 9)
  • Eg If voltage is between 0 and 90Volts,

8
Why Binary Computers
  • Suppose we want a decimal computer
  • Need to represent 10 digits (0, 1, 2, , 9)
  • need 10 different, distinct and STABLE levels
  • If voltage is between 0 and 90V (volts),
    then may use 0, 10, 20,,90 as digits
  • Question How to store 37?
  • But, the voltage is NOT reliable,
  • eg Even a 10 drop in voltage can cause a
    6 (60V) to be a 5 (54V)!
  • Binary numbers give better error margin

9
Why Binary Nature of Hardware Devices
  • Many hw devices are two-state devices
  • magnetized / demagnetized
  • diskettes (3.5 floppy, Zip disks,)
  • direction of magnetization (cw / ccw)
  • CORE memory (main memory)
  • charged / discharged capacitor

10
Why Digital (not Analog) More Durable
  • Analog data poses difficulties
  • very hard to store real numbers accurately
  • or persistently (over time)
  • eg old photographs, movie reels, books
  • Solution Store them digitally
  • CD player uses approximation
  • instead of the exact frequency/volume (audio)
  • But, the approx is good enough
  • Our ears not sensitive enough to tell difference
  • Once we have digital data (reliability)
  • also, can use various algorithms (eg
    compression) for easier processing of the data.

11
Hardware Chapter Outline
  • The Digital Computer
  • Binary Numbers
  • Decimal and Binary numbers
  • From Decimal to Binary
  • Adding and Subtracting Binary Numbers
  • Data Representation
  • Boolean Circuits
  • CPU and Program Execution
  • Peripherals

12
2. Binary Numbers (vs Decimal Numbers)
  • Humans use Decimal number system
  • 7809 7?103 8?102 0?101 9?100
  • Each digit is from 0,1,2,3,4,5,6,7,8,9
  • (we happen to have 10 fingers.)
  • Computers use Binary number system
  • (1101)2 1?23 1?22 0?21 1?20 13
  • Each binary digit (bit) is 0,1
  • (IT people have 1 finger/hand)
  • Readings Section 4.2 of SG

13
Converting from Decimal to Binary
  • Example 43
  • Method (repeated divide by 2)
  • 43 / 2 ---- Quotient 21 Remainder 1
  • 21 / 2 ---- Quotient 10 Remainder 1
  • 10 / 2 ---- Quotient 5 Remainder 0
  • 5 / 2 ---- Quotient 2 Remainder 1
  • 2 / 2 ---- Quotient 1 Remainder 0
  • 1 / 2 ---- Quotient 0 Remainder 1
  • (43)10 (101011)2

14
Exercise
  • In the previous worked example on converting
    decimal numbers to binary, at the end of all the
    dividing-by-two, we collect the digits by going
    backwards! Why?
  • Hint Try working this out yourself.
  • Try going forward instead. What is the binary
    number you get. Convert it back to decimal and
    see what you will get. Use 6 and 4 as examples.
  • Given a decimal number n (a positive integer), if
    we convert it to binary, we will need k digits.
    What is k in term of n?
  • Hint Use the above process as a guide. We will
    keep dividing by 2 (and throw away the remainder)
    until we reach 0.

15
Decimal to Binary (2) -- Algorithm
  • Algorithm Decimal-to-Binary(n)
  • Input Decimal number (n)10
  • Output Binary representation
  • (n)10 (bk-1 bj b0)2
  • let j ? 0
  • let num ? n
  • while (num 0) do
  • bj ? num mod 2 // remainder
  • num ? num div 2 // divide by 2
  • j ? j 1
  • endwhile
  • Output B(bk-1 bk-2 b1 b0)

16
Exercise
  • Exercise Algorithm Decimal-to-Binary on the
    following inputs. For each input, what is the
    output binary number and the value of k?
  • (a) 8 (b) 13

17
For the mathematically inclined
  • In General
  • (n)10 (bk-1 bi b1b0)2
  • where each bit bi is given by
  • Number of bits k log2n
  • Why is it log2n bits?

18
Rep using Binary Numbers
  • More on binary number representation
  • with 1 bit, can represent 2 numbers 0,1
  • 2 bits ? 4 numbers, 0..3
  • 00, 01, 10, 11
  • 3 bits ? 8 numbers, 0..7
  • 000, 001, 010, 011, , 110, 111
  • 4 bits ? 16 numbers, 0..15
  • 0000, 0001, 0010, , 1110, 1111
  • With k bits ? 2k numbers, 0 .. 2k-1
  • Typical computers today work with
  • 16 or 32 bit numbers!

19
Add Subtract for Binary Numbers
  • Similar to those for decimal (simpler)
  • Actually, use the same algorithm!
  • For each digit, we have
  • 0 0 0
  • 0 1 1
  • 1 0 1
  • 1 1 0 (with carry 1)
  • Example
  • 101101100
  • 110101010

20
Hardware Chapter Outline
  • The Digital Computer
  • Binary Numbers
  • Data Representation
  • READ Sect. 4.2 of SG or Sect 1.4, 1.5, 1.7 of
    A
  • Representing data numbers, characters
  • Approximation for Real Numbers
  • Analog Data (audio, video)
  • Boolean Circuits
  • CPU and Program Execution
  • Peripherals

21
3. Representation of Data
  • Computers process numbersbut also much more..
  • non numeric data and text
  • 0 1 9 a b z . (
  • special control characters eg CR, tabs
  • ASCII (American Standard Code for Information
    Interchange) as-kee
  • uses 7 bit code for each character
  • Usually, a 0 is added in front
  • A is 01000001
  • a is 01100001

22
Data Representation (2)
  • Using ASCII codes, we can represent
  • numbers, letters (as characters)
  • Names of people, sentences
  • as sequences of characters
  • Hello World!
  • Question how many chars in above msg?
  • Represent instructions (eg ADD, SUB)
  • we first assign them codes
  • ADD 00
  • SUB 01
  • and then represent the codes..

23
Data Representation Analog Data?
  • What about analog data?
  • Why is analog data problematic?
  • How to represent (2.1)10 in binary?
  • (10.1)2 (2.5)10
  • (10.01)2 (2.25)10
  • (10.001)2 (2.125)10
  • (10.0001)2 (2.0625)10
  • (10.00011)2 (2.09375)10
  • (10.000111)2 (2.109375)10
  • CANNOT represent (2.1)10 exactly in binary!!
  • We can only give an approximation.
  • Accuracy depends on the number of bits

24
Data Representation..
  • Analog data (eg video, audio data)
  • can be represented as digital data
  • using approximation
  • via a digitization process
  • Accuracy depends on number of bits!
  • the more bits, the more accurate

25
Number Representations
  • Read up on
  • Signed magnitude numbers
  • floating point representation of real numbers
  • Mantissa, exponent
  • Readings Section 4.? of SG

26
Hardware Chapter Outline
  • The Binary Digital Computer
  • Binary Numbers
  • Data Representation
  • Boolean Circuits
  • READING Sect. 4.3 to 4.5 of SG Notes
  • Basic Gates, Truth Tables
  • Combinatorial Circuits
  • Sequential Circuits
  • CPU and Program Execution
  • Peripherals

27
4. Boolean Circuits
  • Computer operations based on logic circuits
  • Logic based on Boolean Algebra
  • Logic circuits have
  • inputs (each with value 0 or 1) T/F
  • outputs
  • state
  • Type of Logic Circuits
  • Combinational circuits output depends only on
    input
  • Sequential circuits output depends also on past
    history (get sequence of output)
  • GATES Basic Building Blocks for Circuits

28
Basic Logic Gates (and Truth Tables)
  • AND Gate
  • OR Gate
  • NOT Gate

29
Whats inside a Gate?
  • Gate made of physical components
  • called transistors
  • A transistor is formed by sandwiching a p-type
    silicon between two n-type silicon or vice versa.
  • In this course, we do not need to deal with the
    details of whats inside a Gate.

30
Combinational Circuits
  • Built using a combination of logic gates
  • output depends only on the input
  • can also be represented by its truth table
  • Examples
  • C (A B)
  • D AB (A B)
  • G A (B C)

31
Combinational Circuits
Logic Circuit
Truth Table
32
Logic Circuits An aside
  • Possible Interpretation of G
  • Sound the buzzer if
  • temperature of engine exceeds 200F, or
  • car is in gear and drivers seat-belt is not
    buckled
  • We define
  • G Sound buzzer
  • A Temperature of engine exceeds 200F
  • B Car is in gear
  • C drivers seat-belt is buckled
  • G A (B C)
  • HW Give other interpretations

33
Manipulation with Logical Expressions
  • Can manipulate logical expression
  • subject to Algebraic Laws (Boolean algebra)
  • Examples
  • Commutative Laws
  • (A B) (B A)
  • A B B A (Note Shorthand A B as AB)
  • Associative Laws
  • A (B C) (A B) C
  • A (B C) (A B) C
  • Distributive Laws
  • A (B C) (A B) (A C)
  • A (B C) (AB) (AC)

34
Can Prove Laws using Truth Tables
  • Can use the truth tables to prove laws
  • (AB) (A) (B) DeMorgans Law

35
HW Prove the following laws
  • Using Truth tables or otherwise
  • (A B) A B DeMorgans Law
  • (AB) (AC) A B C Distributive Law
  • A A 1 A A 0
  • A 1 A A 1 1
  • A A B A Absorption Law
  • A (A B) A Absorption Law

36
From Truth Table ? Logic Circuits
Output function X A(B)C AB(C)
ABC
  • Each row in the table is a logical term
  • X A(B)C AB(C) ABC A(B)C AB(C
    C) A(B)C AB

37
More Basic Logic Gates
  • XOR Gate
  • NAND Gate

38
Logical Completeness
  • , , is logically complete
  • , is logically complete
  • (p q) ( (p) (q) )
  • , is logically complete
  • , is NOT logically complete
  • NAND is logically complete
  • (p NAND p) (p)
  • (p NAND q) (p q)

39
Design of a One-Bit Adder
  • Add two 1-bit numbers
  • A B S (with carry-bit C)
  • Logic Circuits
  • S A ? B C A B

40
Design of an n-bit Full-Adder
  • A full n-bit Adder consists of
  • consists of n half-adders in stages
  • eg A 3-bit Full-Adder
  • consists of 3 half-adder
  • (An example of design decomposition)

41
Design of A Half-Adder
  • Half adder circuit
  • Input Ai, Bi, Ci
  • Output Si, Ci1
  • Design HW problem

42
Sequential Circuits
  • Circuits that can store information
  • Built using a combination of logic gates
  • output depends on the input, and
  • the past history (state of the circuit)
  • can also be represented by its truth table
  • Example
  • Initially, SetReset0
  • Set1 ? State1
  • Reset1 ? State0

43
Basic Sequential Circuit
  • Flip Flop (Logical View)
  • Memory Element
  • State 0 or 1
  • Change of state controlled byinput signal at
    each TIME STEP
  • Flip Flop
  • Initially, Set Reset 0
  • If we momentarily let Set1, then Output1
  • The value of Output 1 will persist
  • even if the value of Set goes back to 0
  • If we momentarily let Reset1, Output0
  • Value persist even if Reset goes back to 0
  • THEREFORE, can use Flip-Flop as Memory Unit
  • Stores 1-bit info (State 0 or 1)

44
Hardware Chapter Outline
  • The Binary Digital Computer
  • Binary Numbers
  • Data Representation
  • Boolean Circuits
  • CPU and Program Execution
  • READING Sect. 5.1 and 5.2 of SG
  • Memory Unit
  • CPU and its Components
  • Execution of Stored Program
  • Peripherals

45
The Binary Digital Computer
  • Organization of a Computer

46
Memory
  • the functional unit that stores
  • instructions (programs) and
  • data
  • Primary Memory Types
  • RAM (Random Access Memory)
  • Read/Write, Volatile
  • ROM (Read Only Memory)
  • Read only, permanent

47
Memory Unit Organization
  • Bit, Byte implemented by flip-flops
  • Each flip-flop is a one-bit memory (can be 0 or
    1)
  • one Byte is a series of 8 flip-flops (8-bits)
  • Memory made up of
  • A large array of fixed size cells
  • Each cell consists of 8 bits (called bytes)
  • Each cell has an address
  • Address are represented as bit-strings
  • Eg 10-bits can address 210 1K memory cells
  • while 20-bit address can rep. 220 1MB memory
  • (Recall, k bits can address 2k memory cells)
  • Memory and Registers
  • registers are similar memory cells
  • but built into the CPU (faster access)

48
Memory Unit -- Operations
  • Data Transfers
  • Need Registers
  • MAR (Memory Address Register) for the address
    of the memory being accessed
  • MDR (Memory Data Register) for data to be
    written to memory or read from the memory
  • Need Instructions
  • FETCH instr to read content of a memory
    location
  • (fetch some data from memory)
  • STORE instr to write a value to a memory
    location
  • (store some data into memory)
  • implemented via digital circuitry

49
Recap
  • Have seen how
  • logic gates and flip-flops can be used to form
    combinational and sequential circuits
  • Any logic/arithmetic functions (operations) can
    be implemented this way
  • But, then the functions will be hard-wired.
  • Need a different computer for each new job!!
  • Instead, we want a general purpose computer
  • computer runs a STORED program
  • function of the computer varies according to
    the different STORED program
  • the stored program is arbitrary ? general purpose
    computer
  • Basic Architecture Von-Neumann Architecture

50
CPU (Central Processing Unit)
  • Components of a CPU
  • Control Unit the brain of the CPU.
  • decoding which operation is to be performed, and
  • deciding the next operation to perform
  • ALU (Arithmetic Logic Unit)
  • consists of logic circuits for addition,
    multiplication, and all other operations
  • Buses wire connecting
  • wires connecting up different parts of CPU, and
    the CPU to other components
  • Each component is built using logic circuits

51
CPU Execution Example W X Y
  • To add two numbers stored in X and Y and store
    the result in W
  • CPU performs the following steps
  • Place address of first number (X) in MAR
  • Issue a FETCH command to Memory Unit
  • Transfer content of MDR to Register R1
  • Place address of second number (Y) in MAR
  • Issue a FETCH command to Memory Unit
  • Transfer contents of MDR to Register R2
  • Issue a ADD command to ALU to perform addition
    of numbers in registers R1 R2 and place result
    in register R3
  • Transfer contents of R3 to MDR
  • Place address of result (W) in MAR
  • Issue a STORE instruction to Memory Unit

52
Functioning of a CPU
  • The steps above illustrates
  • basic technique for CPU to execute simple
    instructions
  • similar technique is used for all other
    instructions
  • ANALOGY If we have buttons for the CPU
    functions, then a human can press the appropriate
    button to execute the above step
  • In real computers, the
  • role of human is performed by the Control Unit,
  • role of buttons by using control signals
  • Control Unit is also responsible for
  • decoding the instruction,
  • figuring out the next instruction, etc

53
CPU Instruction Execution
  • The CPU repeatedly execution the following
    instruction cycle
  • CPU Instruction Execution Cycle
  • Fetch instruction from Memory
  • Decode the instruction
  • Execute the instruction (including determining
    the next instruction to be executed)

54
CPU Instruction Execution (2)
  • Fetch instruction from Memory
  • Decode the instruction
  • PC (Program Counter) contains the address of the
    next instruction
  • Place the address on MAR
  • Send FETCH command to Memory Unit
  • Get the instruction from MDR
  • Transfer to Instruction Register (IR)
  • Generate list of micro-instructions to be
    executed (see example of ADDING two numbers)

55
CPU Instruction Execution (3)
  • Execute the instruction
  • including setting up for the next instruction to
    be executed
  • The sequencer keeps track of which
    micro-instruction is to be executed in which
    order
  • Set up the next instruction to be executed
  • Normally, PC ? PC 1
  • May be different when if-then-else or
    for/while are used

56
Peripheral Devices
  • Other Devices that augments the CPUmemory
  • I/O Keyboard, mouse, monitor, printers,
    speakers,
  • Storage Cache, Disk drives, CD-drive, Zip-drive,
    tapes
  • Communication Network cards, modems,
  • Devices communicate with CPU via controllers
  • usually some kind of circuit board (eg sound
    cards)
  • Also,
  • I/O devices vary greatly
  • Can Dynamically added/removed devices
  • Flexible Design needed to allow easy addition /
    removal / upgrading
  • Design may be sub-optimal.
  • Flexibility often more important than optimality.

57
  • If you are new to all these
  • read the textbook
  • do the exercises in the book
  • The End
Write a Comment
User Comments (0)
About PowerShow.com