Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

Lecture on Global Informatics

and Electronics Ⅱ
Jubee Tada
Graduate School of Science and Engineering,
Yamagata University
Tel:0238-26-3576
E-mail:jubee@yz.yamagata-u.ac.jp
Introduction

• Contents
– Basis of Computer Architecture
– Methods for Performance Improvement
– Effects of Memory Hierarchy
– Trends of Microprocessors

1
What is a Computer?

• Computer
– A machine that does computations.
• Computation
– Process the input data according to an algorithm,
outputting the results.
• Program
– An algorithm expressed by a combination of
instructions.

• A computer performs computations by executing


a program.
2
What is instructions?

• Instructions
– each process that a computer can execute.
– Arithmetic instructions:+, ×, &, etc.
– Load/Store instructions:read and write data
between a memory and a processor.
– Branch instructions:change the next instruction.

• Any program is realized by a combination of


these three types of instructions.

3
Example of a program

C = A + B;

• Expressed as a combination of instructions


1. Load the value of A.
2. Load the value of B.
3. Add the value of A and B
4. Store the result as the value of C

4
Structure of a Computer (1/3)

• Processor
– A part of processing instructions
• Memory (Main memory)
– All instructions and data are stored in main
memory

Processor Memory
(Main memory)

5
Structure of a Computer (2/3)

• Address:position in a memory
• Register:storage device in a processor
• ALU(Arithmetic Logic Unit)
:device that performs calculations
# Register
Address Address Data
0
1 Variable A
0 Instruction 1
Data 4 Instruction 2


15
Data 100 Variable A
104 Variable B


ALU
6
Instruction processing flow

1. Read an instruction from the main memory.


• Where is the instruction?
2. Decode the instruction.
• What type of the instruction?
3. Prepare the necessary data and execute the
instruction.
• Where is the data?
4. Sore the executed result.
• Where the result should be stored?
5. Move on to processing the next instruction.
• How to process the next instruction?
7
Behavior of a Computer

1.Read the instruction from the address indicated


by the program counter (PC) value.
2.Decode the opcode and decide what to do.
3.Read data from the location specified by the
operands and perform executing.
4.Store the result in the location specified by the
operand.
5.Update the PC value to indicate the location of
the next instruction.

8
Structure of a Computer (3/3)
Address
PC Main Memory
Instruction Address Data
Decoder 0 Instruction1
4 Instruction2
# of Register 8 Instruction3
# register Data 12 Instruction4
0


1 Variable A Data 100 Variable A

104 Variable B
15 108 Variable C
112 Variable D
Data


Address
ALU
9
An Example: Execute C=A+B; (1/5)
Address
PC=0 Main Memory
Instruction Address Data
Decoder 0 Load A to R1
4 Load B to R2
# of Register 8 R3=R1+R2
register Data 12 Store R3 to C
R0


R1 Data 100 A=4
R2 104 B=6
R3 108 C=?
112
Data


Address
ALU
10
An Example: Execution of C=A+B; (2/5)
Address
PC=0 Main Memory
Instruction Address Data
Decoder 0 Load A to R1
4 Load B to R2
# of Register 8 R3=R1+R2
register Data 12 Store R3 to C
R0


R1 4
Data 100 A=4
R2 104 B=6
R3 108 C=?
112
Data


Address
ALU
11
An Example: Execution of C=A+B; (3/5)
Address
PC=4 Main Memory
Instruction Address Data
Decoder 0 Load A to R1
4 Load B to R2
# of Register 8 R3=R1+R2
register Data 12 Store R3 to C
R0


R1 4
Data 100 A=4
R2 6 104 B=6
R3 108 C=?
112
Data


Address
ALU
12
An Example: Execution of C=A+B; (4/5)
Address
PC=8 Main Memory
Instruction Address Data
Decoder 0 Load A to R1
4 Load B to R2
# of Register 8 R3=R1+R2
register Data 12 Store R3 to C
R0


R1 4
Data 100 A=4
R2 6 104 B=6
R3 10 108 C=?
112
Data


Address
ALU
13
An Example: Execution of C=A+B; (5/5)
Address
PC=12 Main Memory
Instruction Address Data
Decoder 0 Load A to R1
4 Load B to R2
# of Register 8 R3=R1+R2
register Data 12 Store R3 to C
R0


R1 4
Data 100 A=4
R2 6 104 B=6
R3 10 108 C=10
112
Data


Address
ALU
14
Instruction processing flow and five stages

1.Read the instruction from the address indicated by


the program counter (PC) value.
2.Decode the opcode and decide what to do.
3.Read data from the location specified by the
operands and perform executing.
4.Store the result in the location specified by the
operand.
Instruction
Instruction Decode/ Execution Read/Write Register
Fetch Register on ALU Memory Write
Read

1 2 4

3
15
Components required to execute instructions

• Reading instructions IF
– instruction fetch(IF: Instruction Fetch)
• Reading the instruction decode register ID
– instruction decoding(ID: Instruction Decode)
• ALU operation
– Calculation execution(EX: EXecute) EX

• reading and writing memory


– Memory access (MEM: MEMory access) MEM
• Write to register
– Write back (WB: Write Back) WB
16
Each component and behavior (1/4)

• Instruction fetch (IF)


– corresponding hardware:memory
• The address stored in the program counter is
sent to memory and an instruction is read out.
• von Neumann architecture: shared memory is
used to store instructions and data.
• harvard architecture: instruction memory which
only stores instructions is used.

17
Each component and behavior (2/4)

• Instruction decode (ID)・Write back (WB)


– corresponding hardware:register
• ID: one or two values are read out from the
register; the register number is specified by the
operands. The values are sent to ALU.
• WB: the output of ALU is sent to the register,
and that is stored in the register number
specified by the operand.

18
Each component and behavior (3/4)

• Execute calculation (EX)


– corresponding hardware:ALU(Arithmetic Logic
Unit)
• operation instructions: execute the specified
operation on the sent value
• load/store instructions: calculate the memory
address (add)
• branch instructions: determine branch
conditions (subtract)

19
Each component and behavior (4/4)

• Memory access (MEM)


– corresponding hardware: memory
– load instruction: read data from the address
calculated by ALU.
– store instructions: write data to the address
calculated by ALU.

20
Components used when executing each instruction(1/2)

• Arithmetic instructions: IF・ID・EX・WB


– Read the instruction, decode it, read the register,
execute the operation and write the result to a register.
• Branch instruction: IF・ID・EX
– Read the instruction, decode it, read the register,
execute the operation and update the program counter
according to the result of operation.

21
Components used when executing each instruction(2/2)

• Store instructions:IF・ID・EX・MEM
– Read the instruction, decode it, read the register,
execute the operation (calculate the address) and
write the data to memory
• Load instruction:IF・ID・EX・MEM・WB
– Read the instruction, decode it, read the register,
Perform the operation (calculate the address), read the
data from memory, and write it to the register.

22
total time for each instruction type

Instruction instruction register ALU memory register total


type reading reading operation access write time

load
200ps 100ps 200ps 200ps 100ps 800ps
(lw)

store
200ps 100ps 200ps 200ps 700ps
(sw)
arithmetic
(add, sub, 200ps 100ps 200ps 100ps 600ps
etc.)
branch
200ps 100ps 200ps 500ps
(beq, etc.)

ps = picosecond (10-12)

23
Single clock cycle method

• Execute all steps in one clock cycle.


– Clock cycle time: inverse of clock frequency
– 1 n(10-9)sec → 1G(109)Hz
• Clock cycle time is determined by the longest
time among the execution times of each
instruction.
– Load(800ps)・Store(700ps)
– Arithmetic(600ps)・Branch(500ps)
→800ps

24
The processing time for instructions in single clock method

time 200 400 600 800 1000 1200 1400 1600 1800

execution order

lw IF ID EX MEM WB
$s1,100($0)
lw 800ps
IF ID EX MEM WB
$s2,200($0)
lw 800ps
IF
$s3,300($0)
800ps

• The time required to execute 3 instructions:


800ps×3=2400ps

25

You might also like