1 of 34

Essential Computer Design Concepts

Chapter X

Sections: X, 1.3

Prof. Iyad Jafar

https://sites.google.com/view/iyadjafar

iyad.jafar@ju.edu.jo

2 of 34

Outline

  • A Word on Binary
  • Logic Design Conventions
  • Abstract View of Memory
  • Program Execution
  • The Computer Language
  • Instruction Set Architecture

2

Prof. Iyad Jafar

3 of 34

A Word on Binary

3

Prof. Iyad Jafar

4 of 34

Introduction

  • Computers are digital devices that encode everything in binary; 0 and 1.
  • A binary string could represent:
    • signed number, unsigned number, character, floating number …
  • A single binary digit is called a bit
    • 4 bits : nibble
    • 8 bits : byte
    • 16 bits : half word
    • 32 bits : word
    • 64 bits : double-word
  • Given N bits, the maximum number of elements that can be represented/encoded is 2N.

4

Prof. Iyad Jafar

5 of 34

Unsigned Numbers

  •  

5

Decimal

Binary

0

000

1

001

2

010

3

011

4

100

5

101

6

110

7

111

Prof. Iyad Jafar

6 of 34

Exercise

  • What is the decimal value of unsigned numbers

    • (10110)2

    • (100111)2

6

Prof. Iyad Jafar

7 of 34

Signed Numbers

  •  

7

Decimal

Binary

-4

100

-3

101

-2

110

-1

111

0

000

1

001

2

010

3

011

Prof. Iyad Jafar

8 of 34

The 2s Complement

  • How to represent positive numbers in 2s complement?
    • Sign bit is 0 and remaining bits are for magnitude
    • (+6) using 4 bits is 0110
  • How to represent negative numbers in 2s complement?
    • Always start from the positive representation
    • Method 1: complement individual bits then add 1

(-6) 🡪 0110 🡪 1001🡪 1010

    • Method 2: scan the bits from right to left and keep the bits until the first 1, then complement the remaining bits

(-3) 🡪 0011 🡪 1101

  • Taking the 2s complement of a number changes its sign.

8

Prof. Iyad Jafar

9 of 34

Exercise

  • Represent the following decimal numbers in signed 2s complement using 8 bits.

9

+17

- 45

- 128

Prof. Iyad Jafar

10 of 34

Hexadecimal System

  • Writing and reading binary patterns is not easy.
  • Use numbering systems with higher bases such as octal and hexadecimal.

  • Conversion from binary to hexadecimal
    • Group bits in groups of 4 bits starting from the base point
    • (0110 1100 1001 1010)2 🡪 (6C9A)16 🡪 0x6C9A

  • Conversion from hexadecimal to binary
    • Expand each hex digit into four bits
    • 0xFDB2 🡪 (1111 1101 1011 0010)2

10

Deccimal

Binary

Hex

0

0000

0

1

0001

1

2

0010

2

3

0011

3

4

0100

4

5

0101

5

6

0110

6

7

0111

7

8

1000

8

9

1001

9

10

1010

A

11

1011

B

12

1100

C

13

1101

D

14

1110

E

15

1111

F

Prof. Iyad Jafar

11 of 34

Number Width Expansion – Zero Filling

  • Given an M-bit number, we might need to make it an N-bit number such that N > M

  • Zero filling 🡪 add N-M zeros to the left
  • Used with unsigned numbers

11

1

1

0

1

1

1

0

1

0

0

0

0

13

13

Prof. Iyad Jafar

12 of 34

Number Width Expansion – Sign Extension

  • Given an M-bit number, we might need to make it an N-bit number such that N>M

  • Sign extension 🡪 Replicate the sign bit N-M times
  • Used with signed numbers

12

1

0

1

1

1

0

1

1

1

1

1

1

0

0

1

1

0

0

1

1

0

0

0

0

-5

-5

+3

+3

Prof. Iyad Jafar

13 of 34

Logic Design Conventions

13

Prof. Iyad Jafar

14 of 34

Logic Design Conventions

  • Digital systems contain two types of elements:
    • Combinational
      • Output is function of input only.
      • Elements that operate on data values such as gates, adders, ALU and multiplexors

    • Sequential
      • Elements that contain state such as flip-flops, memory, file register, PC, IR.
      • Output depend on stored value and input.
      • Stored value is allowed to change at the clock edge.

14

A

B

Y

A

B

Y

+

I0

I1

Y

M�u�x

S

A

B

Y

ALU

F

D

Clk

Q

Prof. Iyad Jafar

15 of 34

Sequential Elements

  • A state element allows the stored value to change on every cycle.

  • What if the state element is to hold the stored values over multiple cycles?

15

Prof. Iyad Jafar

16 of 34

Sequential Elements

  • Add a control input to specify at which edge to update the value.

  • How?

16

Prof. Iyad Jafar

17 of 34

Registers

  • A register is basically a group of binary storage elements.

17

4-bit Register

4-bit Register with load control

(clock gating)

4-bit Register with load control

Prof. Iyad Jafar

18 of 34

Abstract View of Memory

18

Prof. Iyad Jafar

19 of 34

The Computer Memory

  •  

19

0

 

0

1

2

M-1

Bn-1

B1

B0

Address

(Log2 M bits)

Control

Data

(n bits)

Address

Bn-1

B1

B0

Bn-1

B1

B0

Bn-1

B1

B0

Prof. Iyad Jafar

20 of 34

Commanding Computers

20

Prof. Iyad Jafar

21 of 34

The Machine Language

  • Commanding computers requires speaking their language;
    • Binary electric signals at the hardware level
    • Machine Language

  • Suppose you want to command the computer to add two variables X and Y and store the result in Z, then you may need to write something like:

00001 0011 0001 0010

  • Imagine writing a program with thousands of commands!
    • Tedious, time consuming, error-prone, knowledge about processor architecture

21

Prof. Iyad Jafar

22 of 34

The Assembly Language

  • Represent binary instruction by words that humans can understand, then convert words to binary manually or using special programs called Assemblers.

  • Suppose you want to command the computer to add two variables X and Y and store the result in Z, then you may need to write something like:

ADD Z, X, Y

  • However;
    • Tedious, time consuming, error-prone, knowledge about processor architecture
    • One line corresponds to one instruction!!

22

00001 0011 0001 0010

Assembler

Prof. Iyad Jafar

23 of 34

High-Level Language

  • Make expressing instructions closer to the way humans express operations.
  • Conversion to machine language is done automatically using special programs called Compilers.
  • Suppose you want to command the computer to add two variables X and Y and store the result in Z, then you may need to write something like:

Z = X + Y

  • More efficient and productive; however:
    • relies on the efficiency of compilers to produce efficient code.

23

ADD Z, X, Y

00001 0011 0001 0010

Assembler

Compiler

Prof. Iyad Jafar

24 of 34

The Big Picture

  • High-level programming languages offer several important benefits:
    • Allow the programmer to think in a more natural language.
    • Allow languages to be designed according to their intended use.
    • Improved programmer productivity.
    • Allow programs to be independent of the computer on which they were developed.

  • Today, little programming is done in assembly language.

24

Prof. Iyad Jafar

25 of 34

Below Your Program

  • Application software
    • Written in high-level language.
    • Allow the programmer to think in a more natural.
    • Improved productivity (conciseness).
    • Programs become independent from hardware.
  • System software
    • Compiler: translates HLL code to machine code.
    • Operating System: service code
      • Handling input/output
      • Managing memory and storage
      • Scheduling tasks & sharing resources
  • Hardware
    • Processor, memory, I/O controllers

25

Prof. Iyad Jafar

26 of 34

Program Execution

26

Prof. Iyad Jafar

27 of 34

Program Execution

  • A computer program consists of instructions and data.

  • Steps for program execution
    1. Programs are loaded into memory prior to execution
    2. Fetch the instruction: Read the instruction from memory (Control Unit)
    3. Decode the instruction: Understand what should be done (Control Unit)
    4. Execute the instruction: Perform the required task (Datapath)
    5. Repeat 2-4 until the end of program or something interrupts the CPU.

27

Fetch

Decode

Execute

End or

Interrupt

Prof. Iyad Jafar

28 of 34

Instruction Set Architecture�(ISA)

28

Prof. Iyad Jafar

29 of 34

What is Instruction Set Architecture (ISA)?

  • An abstract model that defines the interface between a computer's software and hardware.

  • It is essentially the vocabulary and grammar of the computer's machine language.

  • The ISA acts as a contract between the programmer/compiler and the processor, specifying everything a machine-language program needs to know to control the CPU, without needing to know how the hardware physically works.

29

Prof. Iyad Jafar

30 of 34

What is Instruction Set Architecture (ISA)?

  • Different processors have different ISA
    • Intel x86, MIPS, SPARC, ARM, DEC, HP, IBM, RISC-V

  • However, the same ISA can be implemented in different ways to achieve different goals:
    • Single-cycle, multi-cycle, pipelining, superscalar, multiple-issue, …

  • The power of the ISA abstraction is that it allows for binary compatibility:
    • A program compiled for the x86 ISA can run on an Intel Core i7, an AMD Ryzen, or an older Intel Pentium—all of which implement the same x86 ISA but have completely different internal microarchitectures.

30

Prof. Iyad Jafar

31 of 34

Core Components of an ISA

  • Instruction Set: The complete set of operations (or opcodes) that the CPU can execute, such as ADD, SUB, LOAD … .
  • Registers: The fast, small storage locations within the CPU that the instructions can directly operate on.
  • Data Types and Formats: The types of data the CPU can natively handle (e.g., 8-bit characters, 32-bit integers, 64-bit floating-point numbers).
  • Addressing Modes: The various ways that an instruction can specify the location of its operands (the data it will operate on).
  • Memory Architecture: How the memory system is viewed and accessed by the instructions.

31

Prof. Iyad Jafar

32 of 34

Types of ISA

  • Generally, the design of ISA follow one of two schools
    • CISC - Complex Instruction Set Computers
    • RISC - Reduced Instruction Set Computers (~1980s )

32

CISC

RISC

Many instructions and addressing modes

Few instructions and addressing modes

Instructions have different levels of complexity

(different size and execution time)

Simple instructions of fixed size

(Complex operations are achieved by combining multiple simple instructions)

Shorter programs

Longer programs

Relatively slow and expensive

Relatively fast and cheaper

Intel, AMD, Cyrix

MIPS, Sun SPARC, HP PA-RISC, IBM PowerPC, RISC-V

Prof. Iyad Jafar

33 of 34

ISA Examples

  • Intel x86 originated in the 1970s, still powers both the PC and the Cloud of the post-PC era (CISC).
    • 8086, 80286, 80386, 80486, Pentium, Core i3, Core i5, Core i7, Core i9.
  • MIPS is an elegant example of the instruction sets designed since the 1980s (RISC).
    • Gaming Consoles, Workstations and Servers, Embedded Systems and Networking.
    • Sony PlayStation (PSX), SGI Workstations, Network Routers.
  • ARM instruction set from introduced in 1985 (RISC)
    • Most popular instruction sets in the world.
    • Qualcomm Snapdragon, Samsung Exynos, Apple A-Series and M-Series.
  • RISC-V developed at UC Berkeley as open ISA and used in the book (RISC).
    • Embedded Systems, IoT, automotive and High-Performance.
    • ESP32-C, Head XuanTie, SiFive Automotive Family, Sophgo SG2042.

33

Prof. Iyad Jafar

34 of 34

Extra Readings and Videos

  • From Digital Logic course, review
    • Numbering systems
    • Conversion between binary and hexadecimal
    • Unsigned and signed numbers
    • D Flip-flops
    • Registers

34

Prof. Iyad Jafar