You are on page 1of 22

Operations with Memory

Two operations can be performed with memory


Read Write

To perform these operations, 3 type of information is required:


Data Control (Read/Write) Address
1

RAM and CPU


Address Bus RAM

CPU R W 0 . . . . . . . . . . . . . . . .

Memory Address Register

15 .. . . .. . . .. . . . . . . .
. . .

. . .

C O N T R O L B U S
2

Memory Buffer Register

Data Bus

Address
The Address at which the operation is to be performed, is generated by the CPU This address is passed on the Address bus And is temporarily stored in Memory Address Register Memory Address Register selects one and only 1 Address at a time.
3

Address
Address Bus 3 RAM

3 CPU R W 0 . . . . . . . . . . . . . . . .

Memory Address Register

15 .. . . .. . . .. . . . . . . .
. . .

. . .

C O N T R O L B U S
4

Memory Buffer Register

Data Bus

Control Signal
The CPU generates 2 control signals for memory operations
Read Write Read 0 0 1 1 Write 0 Neither Reading nor Writing Memory 1 Write into Memory 0 Read from Memory 1 Illegal operation (not-defined)
5

Control Signal R= 1
Address Bus 3 RAM

3 CPU R W 0 . . . . . . . . . . . . . . . . 1

Memory Address Register

15 .. . . .. . . .. . . . . . . .
. . .

. . .

C O N T R O L B U S
6

Memory Buffer Register

Data Bus

Data
The Direction of data flow depends on the control signal generated by the CPU. Read = 1 and Write = 0
The Data will move from RAM to CPU

Read = 0 and Write = 1


The Data will move from CPU to RAM

Read = 1 and Write = 0


The Data from the selected row will be copied to the Memory Buffer Register From the MBR, itll be copied to the CPU via the Data Bus

Read = 1 and Write = 0


Address Bus 3 RAM

3 CPU R W 0 . . . . . . 0. . . . . . . . . . 0
9

Memory Address Register

15 .. .. .. 1 . 1 . . . .

. . . . . . . . . 1 0 0

C O N T R O L B U S

. 1 . 1. 0. 1

Memory Buffer Register

Data Bus

Read = 0 and Write = 1


The Data from the CPU will be copied to the Memory Buffer Register From the MBR, itll be copied to the selected row of the RAM

10

Read = 0 and Write = 1


Address Bus 3 RAM

3 CPU R W 1C O N T R O L

Memory Address Register

15 .. .. .. 1 . 1 . . . .

. . . . . . . . . 1 0 0

0 . . . . . . 0. . . . . . . . . . 1

. 0 . 1. 1. 1 1

B U S
11

Memory Buffer Register

Data Bus

Read = 0 and Write = 1


Address Bus 3 RAM

3 CPU R W 1C O N T R O L

Memory Address Register

15 .. .. .. 1 . 0 . . . .

. . . . . . . . . 1 1 1

0 . . . . . . 1. . . . . . . . . . 1

. 0 . 1. 1. 1 1

B U S
12

Memory Buffer Register

Data Bus

The CPU
The CPU is the brain of the computer.

It is the part that actually executes the instructions.


Lets take a look inside.

13

The CPU (cont.)


Memory Registers
Register 0 Register 1 Register 2 Register 3 Temporary Memory, Variables Fetched from memory are stored here

14

The CPU (cont.)


Memory Registers
Register 0 Register 1 Register 2 Register 3 For doing basic Arithmetic / Logic Operations on Values stored in the Registers
15

Arithmetic / Logic Unit

The CPU (cont.)


Memory Registers
Register 0 Register 1 Register 2 Register 3 Instruction Register

Arithmetic / Logic Unit

To hold the current instruction

16

The CPU (cont.)


Memory Registers
Register 0 Register 1 Register 2 Register 3 Instruction Register Instr. Pointer (IP)

Arithmetic / Logic Unit

To hold the address of the current instruction in RAM


17

The CPU (cont.)


Memory Registers
Register 0 Register 1 Register 2 Register 3 Instruction Register Instr. Pointer (IP)
18

Arithmetic / Logic Unit

Control Unit (State Machine)

What does the CPU do???


All that a CPU do, as long as the power is on, is:

Decode

Fetch

Execute

19

The Control Unit


Control Unit State Machine has very simple structure: 1) Fetch:
Ask the RAM for the instruction whose address is stored in IP. And Add 1 to the address stored in IP

2) Decode:
Decode the bit pattern in the instruction register.

3) Execute:
Perform the action requested by the instruction in the instruction register.
20

Instruction Register
Fetched instruction is placed in the instruction register Types of instructions
Processor-memory
transfer data between processor and memory Read Register2, OxAA2

Processor-I/O
data transferred to or from a peripheral device cin, cout

Data processing
arithmetic or logic operation on data Add Register2,Register3,Register1

Control
alter sequence of execution Jump 0xFF3
21

Example of Program Execution

22

You might also like