You are on page 1of 38

Saba institute of higher education

Faculty of Computer Science

Computer
Fundamentals

Khalil Ahmad Faizi

1
Contents
● Functions of a
● Computer CPU
– ALU

– CU
–Registers

● Memory
● Cash Memory
● Simple Program
Memory
● Memory is used to store:

instructions to execute a program, and
● data.
● There are two kinds of computer Memory:

Primary Memory Secondary Memory

(When the computer is doing any job, the data that have to be processed are stored in
the primary memory. This data may come from an input device like keyboard or from a
secondary storage device like a CD ROM or DVD ROM.)
Memory (Primary Memory)
● Primary memory is accessible
directly by the processing unit.
– RAM (Random access memory) is
an example of primary
memory
● As soon as the computer is switched off the contents of RAM
is lost (Volatile).

You can store and retrieve data much faster with primary
memory compared to secondary memory

Primary memory is more expensive than secondary memory.

The size of primary memory is less than that of secondary
memory.

Primary memory is faster than secondary memory.

Also called Read and write memory
Read Only Memory (ROM)
● ROM is non-volatile memory.
● The storage of program and data in the ROM is
permanent.

The ROM stores some standard processing programs
supplied by the manufacturers to operate the computer.

The ROM can only be read by the CPU but it cannot
be changed.
● The basic input/output program is stored in the
ROM that examines and initializes various
equipment attached to the PC when the switch is
made ON.
Programmable read only memory
(PROM)
• PROM is another type of primary memory in
computer, which is called Programmable Read
Only Memory (PROM).
• You know that it is not possible to modify or erase
programs stored in ROM, but it is possible for you to
store your program in PROM chip. Once the
programmes are written it cannot be changed
and remain intact even if power is switched off.
• Programs or instructions written in PROM or
ROM cannot be erased or changed.
Erasable Programmable read only memory
(PROM)
• EPROM: Erasable Programmable Read Only Memory,
which over come the problem of PROM & ROM.

• EPROM chip can be programmed time and again by


erasing the information stored earlier in it.

• When the EPROM is in use information can only be read.


Secondary Memory

● Secondary memory such as floppy disks ,hard


magnetic disk, etc., is located inside and outside the
computer.
Memory...
Cache Memory

Small amount of fast memory

Sits between normal main memory and CPU

May be located on CPU chip or module

The access time is very close to the
processing speed of CPU

3
4
Cache/Main Memory Structure
Cache Read Operation - Flowchart
The memory hierarchy

Cache memory has the fastest access time after registers.
The Bus
• What is a bus?
• It is a simplified way for many devices to
communicate to each other.
• Looks like a “highway” for information.
• Actually, more like a “basket” that they
all share.

CPU Keyboard Display

Bus
The Bus...
The Bus...
• Suppose CPU needs to check to see if the
user typed anything.

CPU Keyboard Display

Bus
The Bus
• CPU puts “Keyboard, did the user type
anything?” (represented in some way) on the Bus.

CPU Keyboard Display

Bus
“Keyboard, did the user type anything?”

17
The Bus
• Each device (except CPU) is a State Machine
that constantly checks to see what’s on the Bus.

CPU Keyboard Display

Bus
“Keyboard, did the user type anything?”

18
The Bus
• Keyboard notices that its name is on the Bus,
and reads info. Other devices ignore the info.

CPU Keyboard Display

Bus
“Keyboard, did the user type anything?”

19
The Bus
• Keyboard then writes “CPU: Yes, user typed ‘a’.”
to the Bus.

CPU Keyboard Display

Bus
“CPU: Yes, user typed ‘a’.”

20
The Bus
• At some point, CPU reads the Bus, and gets
the Keyboard’s response.

CPU Keyboard Display

Bus
“CPU: Yes, user typed ‘a’.”

21
Inside the CPU (cont.)
Memory Registers Temporary Memory.
Register 0 Computer “Loads” data
from RAM to
Register 1 registers,
performs operations on
Register 2 data in registers, and
“stores” results from
Register 3 registers back to
RAM

Remember our initial example: “read value of A from memory; read


value of B from memory; add values of A and B; put result in memory
in variable C.” The reads are done to registers, the addition is done in
registers, and the result is written to memory from a register.

22
Inside the CPU (cont.)
Memory Registers
Register 0 Arithmetic
Register 1 / Logic
Unit
Register 2
Register 3
To hold the
Instruction Register address of the
current instruction
Instr. Pointer (IP)
in RAM
23
Inside the CPU (cont.)
Memory Registers
Register 0 Arithmetic
Register 1 / Logic
Unit
Register 2
Register 3
Control Unit
Instruction Register (State Machine)

Instr. Pointer (IP)

24
A Simple
Program
• Want to add values of variables a and b
(assumed to be in memory), and put the
result in variable c in memory, I.e. c
a+b
• Instructions in program
– Load a into register r1
– Load b into register r3
– r2 =r1 + r3
– Store r2 in c
Running the
Program
2 a

1 c

3 b
r1 2
r2

Logic Memory
r3
Load a into 2005
IR
r4 Load a into r1 r1
Load b into 2006
IP 2005 r3
r2 =r1 + r3 2007
Store r2 into c 2008
CPU
26
Running the
Program
2 a

1 c

3 b
r1 2
r2
r3 3
Logic Memory
r4
Load a into 2005
IR Load b into r3 r1
Load b into 2006
IP 2006
r3 r2 r1 2007
Store
+ r3 r2 into c 2008
CPU
27
Running the
Program
2 a

1 c

3 b
r1 2
r2 5

r3 3
Logic Memory
r4
Load a into r1 2005
IR r2 r1 + r3
Load b into r3 2006
IP 2007
r2 r1 + r3 2007
Store r2 into c 2008
CPU 5
Running the
Program
2 a

1 c

3 b
r1 2
r2 5

r3 3
Logic Memory

r4 Load a into r1 2005


Load b into r3 2006
IR 2008
r2 r1 + r3 2007
Sto Store r2 into c 2008
re CPU 5
r2
Running the
Program
2 a

5 c

3 b
r1 2
r2 5

r3 3
Logic Memory
r4
Load a into r1 2005
IR Store r2 into c Load b into r3 2006
IP 2008
r2 r1 + r3 2007
Store r2 into c 2008
CPU 5
Conclusion
• Computer has many parts, connected by a Bus:

CPU Keyboard Display

Bus

Hard
CD-ROM
RAM
Disk
Conclusion ...
• The RAM is the computer’s main memory.
• This is where programs and data are
stored.
Keyboard Display
CPU

Bus

Hard CD-ROM
RAM
Disk
Conclusion ...
• The CPU goes in a never-ending cycle,
reading instructions from RAM and executing
them.
CPU Keyboard Display

Bus

Hard
CD-ROM
RAM Disk
Conclusion ...
• This cycle is orchestrated by the Control Unit
in the CPU.
Memory Registers
Register 0 Arithmetic
Register 1 / Logic
Unit
Register 2
Register 3
Instruction Register
Control Unit
(State Machine)
Inst. Pointer (IP) 61
Conclusion ...

It simply looks at where IP is pointing, reads
the instruction there from RAM, and executes
it.
Memory Registers
Register 0 Arithmetic
Register 1 / Logic
Unit
Register 2
Register 3
Instruction Register
Control Unit
(State Machine)
Inst. Pointer (IP) 62
Conclusion ...

To execute an instruction, the Control Unit uses the
ALU plus Memory and/or the Registers..
Memory Registers
Register 0 Arithmetic
Register 1 / Logic
Unit
Register 2
Register 3
Instruction Register
Control Unit
(State Machine)
Inst. Pointer (IP) 63
Simple Machine Organization
Thank You for your attention!

38

You might also like