computer design basics - national chiao tung...

65
Digital System Design Lecture 7 1 Lan-Da Van (范倫達), Ph. D. Department of Computer Science National Chiao Tung University Taiwan, R.O.C. Spring, 2017 Computer Design Basics Source: Prof. M. Morris Mano and Prof. Charles R. Kime, Logic and Computer Design Fundamentals, 3rd Edition, 2004, Prentice Hall. [email protected] http://www.cs.nctu.edu.tw/~ldvan/

Upload: others

Post on 14-Mar-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

1

Lan-Da Van (范倫達), Ph. D.

Department of Computer ScienceNational Chiao Tung University

Taiwan, R.O.C.Spring, 2017

Computer Design Basics

Source: Prof. M. Morris Mano and Prof. Charles

R. Kime, Logic and Computer Design

Fundamentals, 3rd Edition, 2004, Prentice Hall.

[email protected]

http://www.cs.nctu.edu.tw/~ldvan/

Page 2: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

Content Relationships

Digital System

Design

DSP System: Adder, Mul, Filter

Computer Architecture

2

Page 3: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

3

Outlines

Introduction

Datapaths

The Arithmetic/Logic Unit (ALU)

The Shifter

Datapath Representation

The Control Word

A Simple Computer Architecture

Summary

Page 4: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

4

Introduction (1/2)

Computer Specification

— Instruction Set Architecture (ISA) - the specification of

a computer's appearance to a programmer at its

lowest level

— Computer Architecture - a high-level description of the

hardware implementing the computer derived from the

ISA

— The architecture usually includes additional

specifications such as speed, cost, and reliability.

Page 5: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

5

Introduction (2/2)

Simple computer architecture decomposed into:

— Datapath for performing operations

— Control unit for controlling datapath operations

A datapath is specified by:

— A set of registers

— The microoperations performed on the data stored in

the registers

— A control interface

Page 6: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

6

Datapaths

Guiding principles for basic datapaths:

— The set of registers

Collection of individual registers

A set of registers with common access resources called a

register file

A combination of the above

— Microoperation implementation

One or more shared resources for implementing

microoperations

Buses - shared transfer paths

Arithmetic-Logic Unit (ALU) - shared resource for implementing

arithmetic and logic microoperations

Shifter - shared resource for implementing shift

microoperations

Page 7: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

7

Four parallel-load

registers

Two mux-based

register selectors

Register destination

decoder

Mux B for external

constant input

Buses A and B with external

address and data outputs

ALU and Shifter with

Mux F for output select

Mux D for external data input

Logic for generating status bits

V, C, N, Z

Datapath Example

MD select 0 1MUX D

V

C

N

Z

n

n

n

n

n

n

n

n

n n

n

2 2

n

n

A data B data

Register file

1 0

MUX B A ddressoutDataout

BusA

Bus B

n

n

Function unit

A B nG select

4

Zero Detect

MF select

nn

nF

MUX F

H select2

n

A BS2:0 || Cin

A rithmetic/logicunit (A LU)

G

BS

Shifter

H

MUX

0

1

2

3

MUX

0

1

2

3

0 1 2 3

Decoder

Load

Load

Load

Load

Load enable

Write

D data

D address2

Destination select

Constant in

MB select

A select

A address

B select

B address

R3

R2

R1

R0

Bus Dn

Data in

ILIR0 0

0 1

Page 8: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

8MD select 0 1

MUX D

V

C

N

Z

n

n

n

n

n

n

n

n

n n

n

2 2

n

n

A data B data

Register file

1 0

MUX B A ddressoutDataout

BusA

Bus B

n

n

Function unit

A B nG select

4

Zero Detect

MF select

nn

nF

MUX F

H select2

n

A BS2:0 || Cin

A rithmetic/logicunit (A LU)

G

BS

Shifter

H

MUX

0

1

2

3

MUX

0

1

2

3

0 1 2 3

Decoder

Load

Load

Load

Load

Load enable

Write

D data

D address2

Destination select

Constant in

MB select

A select

A address

B select

B address

R3

R2

R1

R0

Bus Dn

Data in

ILIR0 0

0 1

Microoperation: R0 ← R1 + R2

Datapath Example: Performing a Microoperation

Apply 01 to A select to place

contents of R1 onto Bus A

Apply 10 to B select to place

contents of R2 onto B data and

apply 0 to MB select to place

B data on Bus B

Apply 0010 to G select to perform

addition G = Bus A + Bus B

Apply 0 to MF select and 0 to MD

select to place the value of G onto

BUS D

Apply 00 to Destination select to

enable the Load input to R0

Apply 1 to Load Enable to force the

Load input to R0 to 1 so that R0 is

loaded on the clock pulse (not shown)

The overall microoperation requires

1 clock cycle

Page 9: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

9

Arithmetic/Logic Unit (ALU)

ALU:

— A combinational ckt

— Block diagram:

mode select

S2 = 0: arithmetic ops

S2 = 1: logic ops

— Design of the ALU:

1. Design the arithmetic section

2. Design the logic section

3. Combine the two sections

Page 10: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

10

There are only four functions of B to select as Y in G = A + Y + Cin:

Y

— 0

— B

— B

— 1

What functions are implemented with carry-in to the adder?

Arithmetic Circuit (1/5)

Cin = 0 Cin = 1

G = A

G = A + 1

G = A – 1

G = A + B

G = A

G = A + B

G = A + B + 1

G = A + B + 1

S1

S0

Bn

B inputlogic

nA

n

X

Cin

Y

nG X Y Cin

Cout

n-bitparalleladder

All 0’s

All 1’s

Page 11: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

11

Arithmetic Circuit (2/5)

Adding selection codes to the functions of B:

The useful arithmetic functions are labeled in the table.

Note that all four functions of B produce at least one useful function.

= =

Page 12: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

12

Arithmetic Circuit (3/5)

Block diagram:

Arithmetic circuit

C0

X + Y + C0

Page 13: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

13

Arithmetic Circuit (4/5)

Circuit design:

Select G

S1 S0 Cin = 0 Cin = 1

0 0 A A + 1

0 1 A + B A + B + 1

1 0 A + B A + B + 1

1 1 A 1 A

Select G = X + Y + C0

S1 S0 Cin = 0 Cin = 1

0 0 A + 0 + 0 A + 0 + 1

0 1 A + B + 0 A + B + 1

1 0 A + B + 0 A + B + 1

1 1 A + 1…1 + 0 A + 1…1 + 1

X = A

Y = S1S0 0 + S1S0 B

+ S1S0 B + S1S0 1

C0 = Cin

Page 14: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

14

Arithmetic Circuit (5/5)

B input logic for one stage of arithmetic ckt:

X = A

Y = S1S0 0 + S1S0 B

+ S1S0 B + S1S0 1

C0 = Cin

Page 15: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

15

A 4-bit Arithmetic CKT

Xi = Ai

Yi = Bi S0 + Bi S1

C0 = Cin

Page 16: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

16

Logic Circuit

One stage of logic ckt:

Page 17: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

17

Arithmetic Logic Unit (ALU)

Function Table:

Page 18: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

18

Arithmetic Logic Unit (ALU)

The next most significant select signals, S0 for the arithmetic circuit and S1

for the logic circuit, are wired together, completing the two select signals for

the logic circuit.

The remaining S1 completes the three select signals for the arithmetic circuit.

Page 19: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

19

Direction: Left, Right

Number of positions with examples:

— Single bit:

1 position

0 and 1 positions

— Multiple bit:

1 to n – 1 positions

0 to n – 1 positions

Filling of vacant positions

— Many options depending on instruction set

— Here, will provide input lines or zero fill

Combinational Shifter Parameters

Page 20: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

20

4-Bit Basic Left/Right Shifter

Serial Inputs:

— IR for right shift

— IL for left shift

Serial Outputs

— R for right shift (Same as MSB input)

— L for left shift (Same as LSB input)

Shift Functions:

(S1, S0) = 00 Pass B unchanged

01 Right shift

10 Left shift

11 Unused

B3

IR IL

S

Serialoutput L

Serialoutput R

2

B2 B1 B0

H0H1H2H3

SMUX

0 1 2S

MUX

0 1 2S

MUX

0 1 2S

MUX

0 1 2

Page 21: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

21

Barrel Shifter (1/2)

A rotate is a shift in which the bits shifted out are inserted into the positions vacated.

The circuit rotates its contents left from 0 to 3 positions depending on S:S = 00 position unchanged S = 10 rotate left by 2 positionsS = 01 rotate left by 1 positions S = 11 rotate left by 3 positions

See Table 10-3 in text for details

D3

S0

3 S1 S0

MUX

D2 D1 D0

Y0Y1Y2Y3

S1

012 3 S1 S0

MUX

012 3 S1 S0

MUX

012 3 S1 S0

MUX

012

Page 22: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

22

Barrel Shifter (2/2)

— E.g.: 4-bit Barrel shifter

Page 23: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

2323

Datapath Representation (1/3)

Block diagram of datapath:

Page 24: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

24

Datapath Representation (2/3)

Have looked at detailed design of

ALU and shifter in the datapath

on previous slide.

Here we move up one level in the

hierarchy from that datapath.

The registers, and the multiplexer,

decoder, and enable hardware for

accessing them become a register

file .

The ALU, shifter, Mux F and

status hardware become a

function unit.

The remaining muxes and buses

which handle data transfers are at

the new level of the hierarchy.

Address out

Data out

Constant in

MB select

Bus A

Bus B

FS

V

C

N

Z

MD select

n

D dataWrite

D address

A address B address

A data B data

2m

x nRegister file

m

m m

n nn

n

n

A B

Functionunit

F

4

MUX B1 0

MUX D0 1

n nData in

Page 25: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

25

Datapath Representation (3/3)

In the register file:

— Multiplexer select inputs become A

address and B address.

— Decoder input becomes D address

— Multiplexer outputs become A data

and B data.

— Input data to the registers becomes

D data.

— Load enable becomes write.

The register file now appears like a

memory based on clocked flip-flops

(the clock is not shown).

The function unit labeling is quite

straightforward except for FS.

Address out

Data out

Constant in

MB select

Bus A

Bus B

FS

V

C

N

Z

MD select

n

D dataWrite

D address

A address B address

A data B data

2mx n

Register file

m

m m

n nn

n

n

A B

Functionunit

F

4

MUX B

1 0

MUX D0 1

nn

Data in

Page 26: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

26

Boolean Equations:

MFS = F3 F2

GSi = Fi

HSi = Fi

FS(3:0)MFSelect

GSelect(3:0)

HSelect(1:0) Microoperation

0000 0 0000 XX

0001 0 0001 XX

0010 0 0010 XX

0011 0 0011 XX

0100 0 0100 XX

0101 0 0101 XX

0110 0 0110 XX

0111 0 0111 XX

1000 0 1 X00 XX

1001 0 1 X01 XX

1010 0 1 X10 XX

1011 0 1 X11 XX

1100 1 XXXX 00

1101 1 XXXX 01

1110 1 XXXX 10

F A

F A 1+

F A B

F A B 1

F A B

F A B 1

F A 1

F A

F A B

F A B

F A B

F A

F B

F sr B

F sl B

+

+ +

+

+ +

Definition of Function Unit Select (FS) Codes

Shifter

Page 27: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

27

The Control Word

The datapath has many control inputs.

The signals driving these inputs can be defined and

organized into a control word.

To execute a microinstruction, we apply control word

values for a clock cycle. For most microoperations, the

positive edge of the clock cycle is needed to perform the

register load.

The datapath control word format and the field definitions

are shown on the next slide.

Page 28: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

28

The Control Word Fields

Fields

— DA – D Address

— AA – A Address

— BA – B Address

— MB – Mux B

— FS – Function Select

— MD – Mux D

— RW – Register Write

The connections to datapath are shown on the next slide.

Control word

DA AA BA M

BFS M

D

R

W

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Page 29: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

29

Control Word Block Diagram

10

8

14

0

13

11

Bus D

Constant inn

n

MUX B

1 0

D dataWrite

D address

A address B address

A data B data

8 x n

Register file

A B

Function

unit

n

n

n

MUX D

0 1

nn

Data in

Bus A

Bus B

RW

12

AA

15

DA

n

BA

9

Address out

Data out

V

C

N

Z

7

MD 1

MB 6

4 FS

5

3

2

A specific version of

the datapath:

— 8 regs

— 16 binary control inputs

7 fields

a control word

a particular -op

Page 30: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

30

F A

Encoding of Control World

DA, AA, BA MB FS MD RW

Function Code Function Code Function Code Function Code Function Code

R0 000 Register 0 0000 Function 0 No write 0

R1 001 Constant 1 0001 Data In 1 Write 1

R2 010 0010

R3 011 0011

R4 100 0100

R5 101 0101

R6 110 0110

R7 111 0111

1000

1001

1010

1011

1100

1101

1110

F A

F A 1+

B

F A B 1

F A B

F A B 1

F A 1

F A

F A B

F A B

F A B

F AF B

F sr B

F sl B

+

+ +

+

+ +

Control Word Encoding

Page 31: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

31

Microoperations for the Datapath

DA AA BA MB FS MD RW

R1 R2 R3 Register Function Write

R4 — R6 Register Function Write

R7 R7 — Re gister Function Write

R1 R0 — Con stant Func tion Write

—— R3 Register — — No Wr ite

R4 —— — — Data in Write

R5 R0 R0 Register Function Write

R 1 R 2 R 3– F A B 1+ +=

R4 sl R6 F sl B=

R 7 R 7 1+ F A 1+=

R 1 R 0 2+ F A B+=

Data out R 3

R 4 Data in

R 5 0 F A B=

DA AA BA MB FS MD RW

001 010 011 0 0101 0 1

100 XXX 110 0 1110 0 1

111 111 XXX 0 0001 0 1

001 000 XXX 1 0010 0 1

XXX XXX 011 0 XXXX X 0

100 XXX XXX X XXXX 1 1

101 000 000 0 1010 0 1

R 1 R 2 R 3–

R 4 sl R6

R 7 R 7 1+

R 1 R 0 2+

Data out R 3

R 4 Data in

R 5 0

Microoperation

Microoperation

——

Page 32: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

32

Datapath Simulation

1 4 7 1 0 4 5

2 0 7 0

3 6 0 3 0

X X

2 0 7 0

3 6 0 2 3 0

14 1 2 0 10

2 0 0 1 X

18 18

1 255 2

2

3

4 12 18

5 0

6

7 8

Clock

DA

1 4

A A

2

BA

3 6

Constant_in 2

MB

A ddress_out

Data_out

FS

5

Status_bits

Data_in

MD

RW

reg0 0

reg1

reg2

reg3

reg4

reg5

reg6

reg7

7 8

5

R1 R2 + R3 +1

R4 sl R6

R7 R7 +1

R1 R0 +2

Data out R3

R4 Data in

R5 0

VCNZ

Page 33: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

33

Computer Operation:— is specified by an instr stored in binary, in the

computer’s memory.

— How does the control unit execute an op? The control unit in the computer uses the addr or addrs

provided by the program counter to retrieve the instr from mem.

It then decodes the opcode bits and other information in the instr to perform the required -ops for the execution of the instr.

Microoperation:— is specified by the bits in a control word produced

by hardware or read from control memory.

Computer Operation

Page 34: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

34

An typical instruction specifies:

— Operation to be performed

— Operands to use, and

— Where to place the result, or

— Which instruction to execute next

Instructions are stored in RAM or ROM as a program

The addresses for instructions in a computer are provided by a program counter (PC) that can

— Count up

— Load a new address based on an instruction and, optionally, status information

The PC and associated control logic are part of the Control Unit.

Executing an instruction - activating the necessary sequence of operations specified by the instruction

Execution is controlled by the control unit and performed:

— In the datapath

— In the control unit

— In external hardware such as memory or input/output

Instruction Set Architecture (1/2)

Page 35: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

35

Instruction Set Architecture (2/2)

Instructions: (assembly language level)

— Instruction:

a collection of bits that instructs the computer to perform a

specific op

operation code (opcode), operands

— Instruction set:

the collection of instrs for a computer

— Instruction set architecture (ISA):

a thorough description of the instr set

— Program:

A list of instrs that specifies the ops, the operands, and the

sequence in which processing is to occur.

Page 36: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

36

Storage Resources

The storage resources are "visible" to the programmer at the

lowest software level (typically, machine or assembly language).

Storage resources

for the SC =>

Separate instruction and

data memories imply

"Harvard architecture"

Done to permit use of

single clock cycle per

instruction implementation

Due to use of "cache" in

modern computer

architectures, is a fairly

realistic model

Instructionmemory

215x 16

Datamemory

215 x16

Register file8 x 16

Program counter

(PC)

Page 37: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

37

Instruction Format (1/5)

An instruction consists of a bit vector.

The fields of an instruction are subvectors representing

specific functions and having specific binary codes

defined.

The format of an instruction defines the subvectors and

their function.

An ISA usually contains multiple formats.

The SC ISA contains the three formats presented on the

next slide.

Page 38: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

38

Instruction Format (2/5)

The three formats are: Register, Immediate, and Jump and Branch.

All formats contain an Opcode field in bits 9 through 15.

The Opcode specifies the operation to be performed.

More details on each format are provided on the next three slides.

(c) Jump and Branch

(a) Register

OpcodeDestination

register (DR)Source reg-ister A (SA)

Source reg-ister B (SB)

15 9 8 6 5 3 2 0

(b) Immediate

OpcodeDestination

register (DR)Source reg-ister A (SA)

15 9 8 6 5 3 2 0

Operand (OP)

OpcodeSource reg-ister A (SA)

15 9 8 6 5 3 2 0

Address (AD)(Right)

Address (AD)(Left)

Page 39: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

39

Instruction Format (3/5)

This format supports instructions represented by:

— R1 ← R2 + R3

— R1 ← sl R2

There are three 3-bit register fields:

— DR - specifies destination register (R1 in the examples)

— SA - specifies the A source register (R2 in the first example)

— SB - specifies the B source register (R3 in the first example and R2

in the second example)

Why is R2 in the second example SB instead of SA?

— The source for the shifter in our datapath to be used in

implementation is Bus B rather than Bus A

(a) Register

OpcodeDestination

register (DR)

Source reg-

ister A (SA)

Source reg-

ister B (SB)

15 9 8 6 5 3 2 0

Page 40: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

40

Instruction Format (4/5)

(b) Immediate

OpcodeDestination

register (DR)

Source reg-

ister A (SA)

15 9 8 6 5 3 2 0

Operand (OP)

This format supports instructions described by:

— R1 ← R2 + 3

The B Source Register field is replaced by an Operand field OP

which specifies a constant.

The Operand:

— 3-bit constant

— Values from 0 to 7

The constant:

— Zero-fill (on the left of) the Operand to form 16-bit constant

— 16-bit representation for values 0 through 7

Page 41: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

41

Instruction Format (5/5)

This instruction supports changes in the sequence of instruction

execution by adding an extended, 6-bit, signed 2’s-complement

address offset to the PC value.

The 6-bit Address (AD) field replaces the DR and SB fields

— Example: Suppose that a jump is specified by the Opcode and the PC

contains 45 (0…0101101) and Address contains – 12 (110100). Then

the new PC value will be:

0…0101101 + (1…110100) = 0…0100001 (45 + (– 12) = 33)

The SA field is retained to permit jumps and branches on N or Z

based on the contents of Source register A.

(c) Jump and Branch

OpcodeSource reg-

ister A (SA)

15 9 8 6 5 3 2 0

Address (AD)

(Right)

Address (AD)

(Left)

Page 42: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

42

Instruction Specifications (1/2)

The specifications provide:

— The name of the instruction

— The instruction's opcode

— A shorthand name for the opcode called a mnemonic

— A specification for the instruction format

— A register transfer description of the instruction, and

— A listing of the status bits that are meaningful during an

instruction's execution (not used in the architectures defined in

this chapter)

Page 43: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

43

Instruction Specifications (2/2)

R[DR] M[R[SA]]

M[R[SA]] R[SB]

Page 44: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

44

Example of Instructions and Data in Memory

Memory Representation of Instructions and Data

DeciimalAddress Memory Contents

DecimalOpcode Other Fields Operation

25 0000101 001 010 011 5 (Subtract) DR:1, SA:2, SB:3 R1 R2 R3

35 0100000 000 100 101 32 (Store ) SA:4, SB:5 M[R4] R5

45 1000010 010 111 011 66 (Add

Immediate)

DR: 2, SA:7, OP :3 R2 R7 +3

55 1100000 101 110 100 96 (Branch

on Zero)

AD: 44, SA:6 If R6 = 0,

PC PC 20

70 00000000011000000 Data = 192. Aft er execution of instruction in 35,

Data = 80.

Suppose R4 contains 70 and R5 contains 80.

Page 45: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

45

BusA Bus B

A ddress out

Data outMW

Data in

MUX B

1 0

MUX D0 1

DATA PATH

RWDA

A A

Constant�in

BA

MB

FS

V

C

N

Z

Function�unit

A B

F

MDBus D

IR(2:0)

Data in A ddress

Data�memory

Data out

DRegister

fileA B

Instructionmemory

A ddress

Instruction

Zero fill

DA

BA

AA

FS

MD

RW

MW

MB

Instruction decoder

JB

Extend

LP B

C

BranchControl

VCNZ

JBL

P BC

IR(8:6) || IR(2:0)

PC

CONTROL

Jump A ddress

A Simple Computer Architecture

Page 46: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

46

Control Unit

The Data Memory has been attached to the Address Out and

Data Out and Data In lines of the Datapath.

The MW input to the Data Memory is the Memory Write signal

from the Control Unit.

For convenience, the Instruction Memory, which is not usually a

part of the Control Unit is shown within it.

The Instruction Memory address input is provided by the PC and

its instruction output feeds the Instruction Decoder.

Zero-filled IR(2:0) becomes Constant In

Extended IR(8:6) || IR(2:0) and Bus A are address inputs to the

PC.

The PC is controlled by Branch Control logic.

Page 47: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

47

PC Function (1/2)

PC function is based on instruction specifications involving jumps and

branches:

In addition to the above register transfers, the PC must also

implement: PC ← PC + 1

The first two transfers above require addition to the PC of: Address

Offset = Extended IR(8:6) || IR(2:0)

The third transfer requires that the PC be loaded with: Jump Address

= Bus A = R[SA]

The counting function of the PC requires addition to the PC of 1.

Branchon Zero BRZ if (R[SA] = 0) PC

←PC+ se AD

Branch on Negative BRN if (R[SA] < 0) PC PC+ seADJump JMP PC R[SA]

Page 48: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

48

PC Function (2/2)

Branch Control determines the PC transfers based on five of its

inputs defined as follows:

— N,Z – negative and zero status bits

— PL – load enable for the PC

— JB – Jump/Branch select: If JB = 1, Jump, else Branch

— BC – Branch Condition select: If BC = 1, branch for N = 1, else

branch for Z = 1.

The above is summarized by the following table:

Sufficient information is provided here to design the PC.

PC Operation PL JB BC

Count Up 0 X X

Jump 1 1 X

Branch on Negative (else Count Up) 1 0 1

Branch on Zero (else Count Up) 1 0 0

Page 49: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

49

Encoding of Control Word

Page 50: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

50

Instruction Decoder (1/5)

The combinational instruction decoder converts the instruction into

the signals necessary to control all parts of the computer during the

single cycle execution.

The input is the 16-bit instruction.

The outputs are control signals:

— Register file addresses DA, AA, and BA.

— Function Unit Select FS

— Multiplexer Select controls MB and MD.

— Register file and Data Memory Write controls RW and MW.

— PL, JB, and BC controls PC.

The register file outputs are simply pass-through signals:

— DA = DR, AA = SA, and BA = SB

Determination of the remaining signals is more complex.

Page 51: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

51

Instruction Decoder (2/5)

The remaining control signals do not depend on the addresses, so

must be a function of IR(15:9).

Formulation requires examining relationships between the outputs

and the opcodes.

Observe that for other than branches and jumps, FS = IR(12:9)

This implies that the other control signals should depend as much as

possible on IR(15:13) (which actually were assigned with decoding in

mind!).

To make some sense of this, we divide instructions into types as

shown in the table on the next page

Page 52: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

52

Instruction Decoder (3/5)

Truth Table for Instruction Decoder Logic

Instruction Function Type

Instruction Bits Control Word Bits

15 14 13 9 MB MD RW MW PL JB BC

Function unit operations using

registers

0 0 0 X 0 0 1 0 0 X X

Memory read 0 0 1 X 0 1 1 0 0 X X

Memory write 0 1 0 X 0 X 0 1 0 X X

Function unit operations using

register and constant

1 0 0 X 1 0 1 0 0 X X

Conditional branch on zero (Z) 1 1 0 0 X X 0 0 1 0 0

Conditional branch on negative (N) 1 1 0 1 X X 0 0 1 0 1

Unconditional Jump 1 1 1 X X X 0 0 1 1 X

Page 53: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

53

Instruction Decoder (4/5)

The types are based on the blocks controlled and the seven signals to be

generated; types can be divided into two groups:

— Datapath and Memory Control (First 4 types)

— PC Control (Last 3 types)

In Datapath and Memory Control blocks controlled are considered:

— Mux B (4th type)

— Memory and Mux D (2nd and 3rd types)

— By assigning codes with no or only one 1 for these, implementation of MB, MD,

RW and MW are simplified.

In Control Unit more of a bit setting approach was used:

— Bit 15 = Bit 14 = 1 were assigned to generate PL.

— Bit 13 values were assigned to generate JB.

— Bit 9 was used as BC which contradicts FS = 0000 needed for branches. To

force FS(6) to 0 for branches, Bit 9 into FS(6) is disabled by PL.

Also, useful bit correlations between values in the two groups were

exploited in assigning the codes.

Page 54: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

54

Instruction Decoder (5/5)

The end result by use of

the types, careful

assignment of codes,

and use of don't cares,

yields very simple logic:

This completes the

design of most of the

essential parts of

the single-cycle

simple computer

19–17

DA

16–14

AA

13–11

BA

10

MB

9–6

FS

5

MD

4

RW

3

MW

2

PL

1

JB

0

BC

Instruction

Opcode DR SA SB

Control word

15 14 13 12 11 10 9 8–6 5–3 2–0

Page 55: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

55

Sample Instruction Execution

Decoding, control inputs and paths shown for ADI, LD

and BRZ on next 6 slides

Page 56: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

56

Decoding for ADI

19–17

DA

16–14

AA

13–11

BA

10

MB

9–6

FS

5

MD

4

RW

3

MW

2

PL

1

JB

0

BC

Instruction

Opcode DR SA SB

Control word

15 14 13 12 11 10 9 8–6 5–3 2–0

1 0 0 0 0 1 0

1 10 0 1 0 0 00 0 0

Page 57: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

57

Bus A Bus B

Address out

Data outMW

Data in

MUX B1 0

MUX D0 1

DATAPATH

RWDA

AA

Constantin

BA

MB

FS

V

C

N

Z

Functionunit

A B

F

MDBus D

IR(2:0)

Data in Address

Datamemory

Data out

Registerfile

D

A B

Instructionmemory

Address

Instruction

Zero fill

DA

BA

AA

FS

MD

RW

MW

MB

Instruction decoder

JB

Extend

LP B

C

BranchControl

VCNZ

JBL

P BC

IR(8:6) || IR(2:0)

PC

CONTROL

Control Inputs and Paths for ADI

1 1

0 0

1 0 0 00 0 0

0 0 1 0

1

0

1

0

0 0 0

+

No Write

Increment

PC

Page 58: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

58

Decoding for LD

19–17

DA

16–14

AA

13–11

BA

10

MB

9–6

FS

5

MD

4

RW

3

MW

2

PL

1

JB

0

BC

Instruction

Opcode DR SA SB

Control word

15 14 13 12 11 10 9 8–6 5–3 2–0

0 0 1 0 0 0 0

0 10 0 0 0 1 00 1 0

Page 59: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

59

Bus A Bus B

Address out

Data outMW

Data in

MUX B1 0

MUX D0 1

DATAPATH

RWDA

AA

Constantin

BA

MB

FS

V

C

N

Z

Functionunit

A B

F

MDBus D

IR(2:0)

Data in Address

Datamemory

Data out

Registerfile

D

A B

Instructionmemory

Address

Instruction

Zero fill

DA

BA

AA

FS

MD

RW

MW

MB

Instruction decoder

JB

Extend

LP B

C

BranchControl

VCNZ

JBL

P BC

IR(8:6) || IR(2:0)

PC

CONTROL

Control Inputs and Paths for LD

0 1

0 0

0 0 1 00 1 0

0 0 0 0

0

1

1

0

0 1 0

No Write

Increment

PC

Page 60: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

60

Decoding for BRZ

19–17

DA

16–14

AA

13–11

BA

10

MB

9–6

FS

5

MD

4

RW

3

MW

2

PL

1

JB

0

BC

Instruction

Opcode DR SA SB

Control word

15 14 13 12 11 10 9 8–6 5–3 2–0

1 1 0 0 0 0 0

1 00 0 0 0 0 10 0 0

Page 61: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

61

Bus A Bus B

Address out

Data outMW

Data in

MUX B1 0

MUX D0 1

DATAPATH

RWDA

AA

Constantin

BA

MB

FS

V

C

N

Z

Functionunit

A B

F

MDBus D

IR(2:0)

Data in Address

Datamemory

Data out

Registerfile

D

A B

Instructionmemory

Address

Instruction

Zero fill

DA

BA

AA

FS

MD

RW

MW

MB

Instruction decoder

JB

Extend

LP B

C

BranchControl

VCNZ

JBL

P BC

IR(8:6) || IR(2:0)

PC

CONTROL

Control Inputs and Paths for BRZ

1 0

0 0

0 0 0 10 0 0

0 0 0 0

1

0

0

0

1 0 0

No Write

Branch on

Z

No Write

Page 62: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

62

[R3] = 248, M[248] = 2, M[249] = 83

M[250] 83 - (2 + 3)

LD R1, R3 ;R1 M[R3] (R1 = 2)

ADI R1, R1, 3 ;R1 R1 + 3 (R1 = 5)

NOT R1, R1 ;Complement R1

INC R1, R1 ;R1 R1 + 1 (R1 = 5)

INC R3, R3 ;R3 R3 + 1 (R3 = 249)

LD R2, R3 ;R2 M[R3] (R2 = 83)

ADD R2, R2, R1 ;R2 R2 + R1 (R2 = 78)

INC R3, R3 ;R3 R3 + 1 (R3 = 250)

ST R3, R2 ;M[R3] R2 (M[250] = 78)

Program Sample

Page 63: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

63

Single-Cycle Computer Issues

Worse case delay path in a single-cycle computer:

Page 64: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

64

i. in the area of performing complex

ops multiple-cycle control

ii. with instrs and data in the same

memory multiple-cycle control

iii. has a lower limit on the clock

period based on a long worst case

delay path• 17 ns 58.8 MHz

pipelined control

Shortcomings of a Single-Cycle Computer

Page 65: Computer Design Basics - National Chiao Tung Universityviplab.cs.nctu.edu.tw/course/DSD2017_Spring/DSD_Lecture... · 2017-05-02 · Barrel Shifter (1/2) A rotate is a shift in which

Digital System Design

Lecture 7

65

Summary

Datapath:

— Major components:

Register files,

Buses,

ALUs,

Shifters

— Control word

Control design for programmed systems

— Single-cycle computer