Review: computer system - the memory

At the start of the course, we have studied the computer memory:

  • Computer memory consists of (a massive amount of) electronical switches

  • Each switch has 2 states: 0 or 1

  • Consequently:

    • Computer memory can only store binary numbers

  • Information are stored in the computer memory using some coding method

  • When a computer program is running, the computer memory will contain:

      • The instructions (statements) of the program

      • The variables (data) of the program
        The data uses a code to represent information       

We will now study the other component of the computer system:  the Central Processing Unit

The function of the CPU
 

Recall:

  • The function of the Central Processing Unit (CPU) is:

      • Fetch (= obtain) and execute the next computer instruction

        Recall that all instructions are stored in the computer memory !!!

 

 

In order to perform these functions, the CPU contains circuitry (= discussed in CS355) that enable the CPU to perform its function

In CS255, we will only study the logical structure of the CPU (i.e.: discuss the CPU abstractly)

Logical structure of the CPU in a computer system

Logically, the CPU consists of these functional components:

 
 

(1) A number of general purpose registers
(2) A number of special purpose registers (IR, PC, PSR)
(3) An Arithmetic and logic unit
(4) Wires that interconnect the various components

Registers

What are registers:

 
 

A register is a memory device on the CPU that can store a binary number (typically 32/64 bits long)

General purpose registers

What are general purpose registers:

 
 

General purpuse registers are used to store:

  1. the input values used in a computation and

  2. the output value of a computation

Comment:   I used decimal numbers in the figure - they are actually binary numbers

And you know how to convert a decimal number into a binary number...

The Arithmetic and Logic Unit (ALU)

What is the Arithmetic and Logic Unit (ALU):

 
 

The ALU contains digital circuitry that can perform:

  1. arithmetic operations (e.g.: +, −, ×, %, /) and

  2. logic operations (e.g.: AND, OR, NOT, exclusive OR, etc)

DEMO: /home/cs255001/demo/355/add-circuit
DEMO: /home/cs255001/demo/355/multiply-circuit

The Arithmetic and Logic Unit (ALU)

How does the Arithmetic and Logic Unit know what operation that it needs to perform ???

 
 

The operation performed by the ALU is determined by:

  • the control signals send out by the Instruction Register (IR) (discussed later)

In CS355, we will build a simple ALU circuit using a digital simulator
DEMO: /home/cs255001/demo/355/ALU-circuit

Special purpose registers

What are special purpose registers:

 

Special purpuse registers are:

  • registers that are used to store (binary) numbers that have a specific purpose/usage

I.e.: the (binary) number in a special purpose register has a pre-assigned meaning !

The Program Counter (PC) special purpose register

What is the Program Counter (PC) special purpose register used for:

 

The program counter (PC) contains:

  • the address (= location in memory) of the next instruction that the CPU must execute

Recall that all instructions are stored in the memory !!

The Program Counter (PC) special purpose registers

How is the program counter (PC) used:

 

The program pointer (PC) is pointing at the memory location where the CPU can obtain the next (computer) instruction !!!

The Instruction Register (IR) special purpose register

What is the Instruction Register (IR) special purpose register used for:

 
 

The Instruction Register (IR) contains:

  • the instruction that the CPU is currently executing

Note:   the IR is "empty" when the CPU has finished executing an instruction and has not yet fetched the next one

The Instruction Register (IR) special purpose registers

How is the Instruction Register (IR) used:

 
 

The Binary number in the Instruction register is used to:

  • Send out specific control signals to registers and the ALU to execute the instruction

For more datails: take CS355...

The Processor Status Register (PSR) special purpose register

What is the Processor Status Register (PSR) special purpose register:

 
 

The Processor Status Register (PSR) contains:

  • A number of status code bits that represent the state of the CPU

Some of these status code bits contains the status information on the outcome of a machine instruction

The Processor Status Register (PSR) special purpose registers

How is the Processor Status Register (PSR) used:

 
 

Some instructions will update the Processor Status Register (PSR)

E.g.: if the instruction compares 4 against 7, the status bits in the PSR will indicate that 4 < 7.

The Processor Status Register (PSR) special purpose registers

How is the Processor Status Register (PSR) used:

 
 

The next instruction executed will usually be a conditional instruction !!

The execution of a conditional instruction will depend on the current settings of the status bits in the PSR

We will study these conditional instructions soon in the Assembler Programming part of CS255