30
Data Manipulation Chih-Wei Tang (唐之 之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan

Data Manipulation - 140.115.154.40140.115.154.40/vclab/teacher/2014CS/Data Manipulation.pdf · Data Manipulation Chih-Wei Tang ... Data Transfer Copy data between CPU and main memory

Embed Size (px)

Citation preview

Data Manipulation

Chih-Wei Tang (唐唐唐唐 之之之之 瑋瑋瑋瑋)

Department of Communication Engineering

National Central University

JhongLi, Taiwan

C.E., NCU, Taiwan 2

Outline

� Computer Architecture

� Machine Language

� Program Execution

� Arithmetic/Logic Instructions

� Communicating with Other Devices

C.E., NCU, Taiwan 3

Computer Architecture

� Central Processing Unit (CPU) or processor� arithmetic/Logic Unit (ALU): perform data manipulation

� control Unit: coordinate the machine’s activities

� registers: temporary storage of information

� general purpose registers

� a temporary holding places for data being manipulated by the CPU

� Inputs to the ALU circuitry

� Results produced by ALU circuitry

� special-purpose registers

� cache Memory

� Bus

� Motherboard

C.E., NCU, Taiwan 4

Cache Memory

� Cache memory

� keep a copy of that portion of main

memory that is of current interest

� register ��cache memory

� CPU can execute more rapidly

� update main memory if data change

� Main memory: data that will be needed in

the near future

� Mass storage: data that will likely not be

needed in the near future

C.E., NCU, Taiwan 5

CPU & Main Memory

C.E., NCU, Taiwan 6

Adding Values Stored in Memory

C.E., NCU, Taiwan 7

Outline

� Computer Architecture

� Machine Language

� Program Execution

� Arithmetic/Logic Instructions

� Communicating with Other Devices

C.E., NCU, Taiwan 8

Machine Language

� Machine instruction = an instruction coded as a bit pattern directly recognizable by the CPU

� Machine language = the set of all instructions recognized by a machine

� Reduced Instruction Set Computing (RISC)� CPU executes minimal set of machine instructions

� few, simple, efficient, and fast instructions

� example: PowerPC from Apple/IBM/Motorola

� Complex Instruction Set Computing (CISC)� CPU executes a large number of complex instructions, even though man of them are technically redundant

� the more complex CPU is easier to program

� example: Pentium from Intel

C.E., NCU, Taiwan 9

Machine Instruction Types –

Data Transfer

� Copy data between CPU and main memory

� LOAD : fill a general-purpose register with the contents of a memory cell

� STORE : transfer the contents of a register to a memory cell

� I/O instructions : communicating with devices outside the CPU-main memory context (printers,

keyboards, monitors, disk drives, etc.)

C.E., NCU, Taiwan 10

Machine Instruction Types –

Arithmetic/Logic

� Use existing data values to compute a new

data value

� Tell the control unit to request an activity

within the arithmetic/logic unit

� AND, OR, and XOR

� SHIFT : the bits that fall off the end of the register are discarded

� ROTATE : fill the holes left at the other end

C.E., NCU, Taiwan 11

Machine Instruction Types – Control

� Direct the execution

of the program rather

than the

manipulation of data

� JUMP

� unconditional jumps

� conditional jumps

Dividing Values Stored in Memory

C.E., NCU, Taiwan 12

A Machine Instruction

� Op-code: specifies which machine operation to

execute

� one per instruction

� Operand: more detailed information about this

operation

� number of operands varies depending on op-code

C.E., NCU, Taiwan 13

Decoding The Instruction 35A7

C.E., NCU, Taiwan 14

Outline

� Computer Architecture

� Machine Language

� Program Execution

� Arithmetic/Logic Instructions

� Communicating with Other Devices

C.E., NCU, Taiwan 15

Program Execution

� Controlled by two special-purpose registers

within CPU

� program counter : address of next instruction

� instruction register : current instruction

� Machine cycle: 3 steps performed by control

unit

� fetch

� decode

� execute

C.E., NCU, Taiwan 16

A Machine Cycle

C.E., NCU, Taiwan 17

Special Case –

Decoding the Instruction B258

C.E., NCU, Taiwan 18

Stored Program Concept

� A program is just a special type of data!

� a program can be encoded and stored in main

memory

� the control unit extracts the program from

memory, decode the instructions, and execute

them

� The machine alone don’t know what is data

and what is program

� The computer just executes according to the

program counter

C.E., NCU, Taiwan 19

The Program Stored in Main Memory

Ready for Execution

C.E., NCU, Taiwan 20

Performing the Fetch Step of the

Machine Cycle (1/2)

C.E., NCU, Taiwan 21

Performing the Fetch Step of the

Machine Cycle (2/2)

C.E., NCU, Taiwan 22

Outline

� Computer Architecture

� Machine Language

� Program Execution

� Arithmetic/Logic Instructions

� Communicating with Other Devices

C.E., NCU, Taiwan 23

Arithmetic/Logic Operations

� Logic: AND, OR, XOR

� Rotate and Shift

� circular shift

� logical shift : discard the bit that falls off the edge

and always fill the hole with a 0

� arithmetic shift : leave the sign bit unchanged

� Arithmetic: add, subtract, multiply, divide

� separate instructions for different types of data

C.E., NCU, Taiwan 24

Outline

� Computer Architecture

� Machine Language

� Program Execution

� Arithmetic/Logic Instructions

� Communicating with Other Devices

C.E., NCU, Taiwan 25

Controllers Attached to a Machine’s

Bus

C.E., NCU, Taiwan 26

Controller

� Intermediary device : it handles communication

between the computer and a device

� Physical form of a circuit board : it plugs into a slot

on the computer’s motherboard

� Format conversion : between a computer and a

particular type of peripheral device

� Port = set of addresses assigned to a controller

� memory-mapped I/O : computer’s I/O devices

appear to be in various memory locations

� buses contain a signal : indicates whether the

message is for a controller or memory

C.E., NCU, Taiwan 27

A Conceptual Representation of

Memory-Mapped I/O

C.E., NCU, Taiwan 28

Communicating with Other Devices

� Direct memory access (DMA)� a controller accesses main memory over the bus

� CPU is not using the bus

� CPU continues with other tasks while the controller performs read/write

� Von Neumann bottleneck: the CPU and the controllers compete for bus access� von Neumann architecture: a computer design model that uses a single storage structure to hold both instructions and data

� coordination of these activities is a major design issue

� Handshaking� 2-way dialogue

� the computer and the peripheral device exchange device’s status and coordinate their activities

C.E., NCU, Taiwan 29

Data Communication Rates

� Measurement units� bps = bits per second

� Kbps = kilo-bps, or 1,000 bps

� Mbps = mega-bps, or 1,000,000 bps

� Gbps = giga-bps, or 1,000,000,000 bps

� Bandwidth = maximum available rate� depends on the type of communication path

and the technology used in its implementation

C.E., NCU, Taiwan 30

Data Communication Path Types

� Parallel communication� several lines transfer different bits simultaneously

� rapid

� complex communication path

� example: CPU �� peripheral devices (e.g., printers)

� rates: > Mbps

� Serial communication� one line transfers one bit at a time

� slower

� communication between different computers

� example : telephone line

� modem : bit patterns (source) � audible tones � bit patterns (destination) (D/A � A/D)