Building Beta - Computation Structures - Lecture Slides, Slides of Computer Fundamentals

The main points are:Building Beta, Maximum Performance, Performance Measure, Clock Frequency, Incremental Featurism, Multi-Port Register Files, Register File Timing, Instruction Fetch, Load Instruction, Jmp Instruction

Typology: Slides

2012/2013

Uploaded on 04/18/2013

palmoni
palmoni 🇮🇳

4.5

(2)

75 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
L14 – Building a Beta 1
6.004 – Spring 2009 3/31/09
Building the Beta
Lab #5 due Thursday
L14 – Building a Beta 2
6.004 – Spring 2009 3/31/09
CPU Design Tradeoffs
Minimum Cost : measured by the size
of the circuit.
Best Performance/Price: measured by the
ratio of MIPS to size. In power-sensitive
applications MIPS/Watt is important too.
Maximum Performance: measured by the
numbers of instructions executed per
second
L14 – Building a Beta 3
6.004 – Spring 2009 3/31/09
Performance Measure
MIPS = Clock Frequency (MHz)
C.P.I.
Millions of Instructions per Second
Clocks per instruction
PUSHING PERFORMANCE ...
TODAY: 1 cycle/inst.
LATER: more MHz via pipelining
L14 – Building a Beta 4
6.004 – Spring 2009 3/31/09
The Beta ISA
Instruction classes
distinguished by
OPCODE:
OP
OPC
MEM
Transfer of Control
OpCode
6
Operate class: Reg[Rc] Reg[Ra] op Reg[Rb]
6 555 11
Ra Rc Rb (UNUSED)
01XXXX
Operate class: Reg[Rc] Reg[Ra] op SXT(C)
16
Ra Rc Literal C (signed) 11XXXX
Opcodes, both formats:
ADD SUB MUL* DIV* *optional
CMPEQ CMPLE CMPLT
AND OR XOR
SHL SHR SRA
LD: Reg[Rc] Mem[Reg[Ra]+SXT(C)]
ST: Mem[Reg[Ra]+SXT(C)] Reg[Rc]
JMP: Reg[Rc] PC+4; PC Reg[Ra]
BEQ: Reg[Rc] PC+4; if Reg[Ra]=0 then PC PC+4+4*SXT(C)
BNE:
LDR: Reg[Rc] Mem[PC + 4 + 4*SXT(C)]
Reg[Rc] PC+4; if Reg[Ra]0 then PC PC+4+4*SXT(C)
Ra Rc Literal C (signed) 10XXXX
Figure by MIT OpenCourseWare.
pf3
pf4
pf5

Partial preview of the text

Download Building Beta - Computation Structures - Lecture Slides and more Slides Computer Fundamentals in PDF only on Docsity!

L14 – Building a Beta 1

Building the Beta

Lab #5 due Thursday

6.004 – Spring 2009

CPU Design Tradeoffs

Minimum Cost

measured by the size

Maximum Performance: measured by thenumbers of instructions executed persecond of the circuit.Best Performance/Price: measured by theratio of MIPS to size. In power-sensitiveapplications MIPS/Watt is important too.

L14 – Building a Beta 3

Performance Measure

MIPS =

Clock Frequency (MHz)

C.P.I.

Millions of Instructions per Second

Clocks per instruction

PUSHING PERFORMANCE ...

TODAY: 1 cycle/inst.LATER: more MHz via pipelining

6.004 – Spring 2009

The Beta ISA

Instruction classesdistinguished byOPCODE:

OPOPCMEMTransfer of Control

OpCode

6 Operate class: Reg[Rc]



Reg[Ra] op Reg[Rb]

6

5

5

5

11

Ra

Rc

Rb

(UNUSED)

0 1

X X

X X Operate class: Reg[Rc]



Reg[Ra] op SXT(C)

16

Ra

Rc

Literal C (signed)

1 1

X X

X X Opcodes, both formats:

ADD

SUB

MUL*

DIV*

*optional

CMPEQ CMPLE CMPLTAND

OR

XOR

SHL

SHR

SRA

LD:

Reg[Rc]



Mem[Reg[Ra]+SXT(C)]

ST:

Mem[Reg[Ra]+SXT(C)]



Reg[Rc]

JMP:

Reg[Rc]



PC+4; PC



Reg[Ra]

BEQ:

Reg[Rc]



PC+4; if Reg[Ra]=0 then PC



PC+4+4*SXT(C)

BNE:LDR:

Reg[Rc]



Mem[PC + 4 + 4*SXT(C)]

Reg[Rc]



PC+4; if Reg[Ra]



0 then PC



PC+4+4*SXT(C)

Ra

Rc

Literal C (signed)

1 0

X X

X X

Figure by MIT OpenCourseWare.

L14 – Building a Beta 5

Approach: Incremental FeaturismEach instruction class can be implemented using a simple componentrepertoire. We’ll try implementing data paths for each class individually,and merge them (using MUXes, etc).Steps:

1. Operate instructions2. Load & Store Instructions3. Jump & Branch instructions4. Exceptions5. Merge data paths

Our Bag of Components:

Registers

Muxes

ALU

A^

B

“Black box” ALU

DataMemory

WDARDR/W

Register

File

(3-port)

RA

RA

WAWEWD

RD

RD

InstructionMemory

A D

Memories

L14 – Building a Beta 6

6.004 – Spring 2009

1 0^ DQ

s

Q D

EN clk

Multi-Port Register Files

Register

File (3-port)

RA

RA

WAWEWD

RD

RD

CLK

Write Enable

Write Address

Write Data

(independent Read addresses)

(Independent Read Data)

2 combinational READ ports,1 clocked WRITE portinternal logic ensures Reg[31] reads as 0

dest asel

bsel

EN

EN

EN

EN

clk

ReadPort A

ReadPort B

WritePort

L14 – Building a Beta 7

Register File Timing

CLK

RA RD WE WA WD

A

Reg[A]

A

new Reg[A]

2 combinational READ ports, 1 clocked WRITE port

What if (say) WA=RA1???

RD1 reads “old” value of Reg[RA1] until next clock edge!

new Reg[A]

t^ S

t^ h

t

PD

tPD

L14 – Building a Beta 8

6.004 – Spring 2009

Starting point: ALU Ops

Means, to BETA,

Reg[R4]

Reg[R2] + Reg[R3]

OpCode

Rb

Ra

(unused)

Rc

32-bit (4-byte) ADD instruction:

First, we’ll need hardware to:

• Read next 32-bit instruction• DECODE instruction: ADD, SUB, XOR, etc• READ operands (Ra, Rb) from Register File;• PERFORM indicated operation;• WRITE result back into Register File (Rc).

L14 – Building a Beta 13

Store Instruction

WA

Rc: <25:21>

PC +

InstructionMemory

A

D

Ra: <20:16>

Register

File

RA

RA

RD

RD

ALU

A^

B

WA

WDWE

ALUFN

Control Logic

BSEL

C: SXT(<15:0>)

Data Memory

WD RD

R/W

Adr

Wr

WDSEL

BSELWDSELALUFNWr

Rb: <15:11>

RA2SEL

Rc: <25:21>

RA2SEL

WERF

WERF

No WERF!

ST:

Mem[Reg[Ra]+SXT(C)]



Reg[Rc]

Ra

Rc

Literal C (signed)

1 0

0 1

1 0

6.004 – Spring 2009

JMP Instruction

WA

Rc: <25:21>

PC +

InstructionMemory

A

D

Ra: <20:16>

Register

File

RA

RA

RD

RD

ALU

A^

B

WA

WDWE

ALUFN

Control Logic

BSEL

C: SXT(<15:0>)

Data Memory

WD RD

R/W

Adr

Wr

WDSEL

BSELWDSELALUFNWr

Rb: <15:11>

RA2SEL

Rc: <25:21>

RA2SEL

JT

PCSEL

JT

PCSEL

WERF

WERF

JMP:^ PC+

Reg[Rc]



PC+4; PC



Reg[Ra]

Ra

Rc

Literal C (signed)

1 0

0 1

1 1

L14 – Building a Beta 15

BEQ/BNE Instructions

Data Memory

WD RD

R/W

Adr

Wr

WDSEL

WA

PCSEL

JT

PC +

InstructionMemory

A

D

Rb: <15:11>

RA2SEL

Rc: <25:21>

Ra: <20:16>

Register

File

RA

RA

RD

RD

BSEL

C: SXT(<15:0>)

Z

ALU

A^

B

PC+4+4*SXT(C

WA

WDWE

4*SXT(<15:0>)

ALUFN

Control Logic

Z PCSELRA2SELBSELWDSELALUFNWr

Rc: <25:21>

JT

WERF

WERF

PC+

BEQ:

Reg[Rc]



PC+4; if Reg[Ra]=0 then PC



PC+4+4*SXT(C)

BNE:

Reg[Rc]



PC+4; if Reg[Ra]



0 then PC



PC+4+4*SXT(C)

Ra

Rc

Literal C (signed)

1 0

1 1

1 0

Ra

Rc

Literal C (signed)

1 0

1 1

0 1

6.004 – Spring 2009

Load Relative Instruction

Hey, WAIT A MINUTE.

What’s Load Relative good for anyway??? I

thought

• Code is “PURE”, i.e. READ-ONLY; and stored in a “PROGRAM” region of

memory;

• Data is READ-WRITE, and stored either

• On the STACK (local); or• In some GLOBAL VARIABLE region; or• In a global storage HEAP.

So why an instruction designed to load data

that’s “near” the instruction???

C:

X = X * 123456;

BETA:

LD(X, r0)LDR(c1, r1)MUL(r0, r1, r0)ST(r0, X)...

c1:

LONG(123456)

Addresses & other large constants

LDR:

Reg[Rc]



Mem[PC + 4 + 4*SXT(C)]

Ra

Rc

Literal C (signed)

1 0

1 1

1 1

L14 – Building a Beta 17

LDR Instruction

Data Memory

WD RD

R/W

Adr

Wr

WDSEL

WA

PCSEL

JT

IFPC +

InstructionMemory

A

D

Rb: <15:11>

RA2SEL

Rc: <25:21>

Ra: <20:16>

Register

File

RA

RA

RD

RD

BSEL

C:SXT( <15:0>)

Z

ALU

A^

B

WA

WDWE

ALUFN

Control Logic

Z PCSELRA2SELBSELWDSELALUFNWr

PC+

Rc: <25:21>

PC+4+4*SXT(C)

ASEL

JT

ASEL

WERF

WERF

LDR:

Reg[Rc]



Mem[PC + 4 + 4*SXT(C)]

Ra

Rc

Literal C (signed)

1 0

1 1

1 1

6.004 – Spring 2009

Exceptions

What if something BAD happens?

Execution of an illegal op-code

Reference to non-existent memory

Divide by zero

Or, maybe, just something unanticipated…

User hits a key

A packet comes in via the network

GOAL: handle all these cases (and more) in

SOFTWARE:

Treat each such case as an (implicit) procedure call…

Procedure handles problem, returns to interrupted program.

TRANSPARENT

to interrupted program!

Important added capability: handlers for certain errors (illegal op-codes) can extend instruction set using software (Lab 7!).

L14 – Building a Beta 19

Exception Processing

Plan:

Interrupt running program

Invoke exception handler (like a procedure call)

Return to continue execution.

We’d like RECOVERABLE INTERRUPTS for

• Synchronous events, generated by CPU or system

FAULTS (eg, Illegal Instruction, divide-by-0, illegal mem address)TRAPS & system calls (eg, read-a-character)

• Asynchronous events, generated by I/O

(eg, key struck, packet received, disk transfer complete)

KEY: TRANSPARENCY to interrupted program.

• ^

Most difficult for asynchronous interrupts

6.004 – Spring 2009

Implementation…

How exceptions work:

Don’t execute current instruction

Instead fake a “forced” procedure call

save current PC (actually current PC + 4)

load PC with

exception vector

0x4 for synch. exception, 0x8 for asynch. exceptions

Question: where to save current PC + 4?

Our approach: reserve a register (R30, aka XP)

Prohibit user programs from using XP. Why?

LD(R31,A,R0)LD(R31,B,R1)DIV(R0,R1,R2)ST(R2,C,R31)

IllOp:

PUSH(XP) Fetch inst. at Mem[Reg[XP]–4] check for DIV opcode, get reg numbersperform operation in SW, fill result reg

POP(XP)JMP(XP)

Forced byhardware

Example: DIV unimplemented