Verano 2004

18
Organización del Computador I Verano Control Multiciclo Basado en el capítulo 5 del libro de Patterson y Hennessy Verano 2004 Profesora Borensztejn

description

Organización del Computador I Verano Control Multiciclo Basado en el capítulo 5 del libro de Patterson y Hennessy. Verano 2004. Profesora Borensztejn. Resumen. Preguntas sencillas. - PowerPoint PPT Presentation

Transcript of Verano 2004

Page 1: Verano 2004

Organización del Computador I Verano

Control Multiciclo Basado en el capítulo 5 del libro de Patterson y Hennessy

Verano 2004 Profesora Borensztejn

Page 2: Verano 2004

Resumen

Step nameAction for R-type

instructionsAction for memory-reference

instructionsAction for branches

Action for jumps

Instruction fetch IR = Memory[PC]PC = PC + 4

Instruction A = Reg [IR[25-21]]decode/register fetch B = Reg [IR[20-16]]

ALUOut = PC + (sign-extend (IR[15-0]) << 2)

Execution, address ALUOut = A op B ALUOut = A + sign-extend if (A ==B) then PC = PC [31-28] IIcomputation, branch/ (IR[15-0]) PC = ALUOut (IR[25-0]<<2)jump completion

Memory access or R-type Reg [IR[15-11]] = Load: MDR = Memory[ALUOut]completion ALUOut or

Store: Memory [ALUOut] = B

Memory read completion Load: Reg[IR[20-16]] = MDR

Page 3: Verano 2004

• ¿Cuantos ciclos necesita este código para ejecutar?

lw $t2, 0($t3)lw $t3, 4($t3)beq $t2, $t3, Label #asuma que no add $t5,

$t2, $t3sw $t5, 8($t3)

Label: ...

• ¿Que sucede en el ciclo octavo?• ¿En que ciclo se ejecuta la suma de $t2 y $t3?

Preguntas sencillas

Page 4: Verano 2004

• El valor de las señales de control depende de:– Que instrucción está siendo ejecutada

– Que paso de la instrucción está siendo realizado

• El funcionamiento del sistema se especifica:– Gráficamente mediante una máquina de estados o,

– Usando microprogramación

• La implementación luego se deriva a partir de la especificación.

Implementación del Control

Page 5: Verano 2004

Especificación mediante

máquina de estados finita PCWrite

PCSource = 10

ALUSrcA = 1ALUSrcB = 00ALUOp = 01PCWriteCond

PCSource = 01

ALUSrcA =1ALUSrcB = 00ALUOp= 10

RegDst = 1RegWrite

MemtoReg = 0

MemWriteIorD = 1

MemReadIorD = 1

ALUSrcA = 1ALUSrcB = 10ALUOp = 00

RegDst = 0RegWrite

MemtoReg =1

ALUSrcA = 0ALUSrcB = 11ALUOp = 00

MemReadALUSrcA = 0

IorD = 0IRWrite

ALUSrcB = 01ALUOp = 00

PCWritePCSource = 00

Instruction fetchInstruction decode/

register fetch

Jumpcompletion

BranchcompletionExecution

Memory addresscomputation

Memoryaccess

Memoryaccess R-type completion

Write-back step

(Op = 'LW') or (Op = 'SW') (Op = R-type)

(Op

= 'B

EQ')

(Op

= 'J

')

(Op = 'SW

')

(Op

= 'L

W')

4

01

9862

753

Start

Page 6: Verano 2004

• Implementación:

Máquina de Estados para el control

PCWrite

PCWriteCond

IorD

MemtoReg

PCSource

ALUOp

ALUSrcB

ALUSrcA

RegWrite

RegDst

NS3NS2NS1NS0

Op5

Op4

Op3

Op2

Op1

Op0

S3

S2

S1

S0

State register

IRWrite

MemRead

MemWrite

Instruction registeropcode field

Outputs

Control logic

Inputs

Page 7: Verano 2004

Implementación con PLAOp5

Op4

Op3

Op2

Op1

Op0

S3

S2

S1

S0

IorD

IRWrite

MemReadMemWrite

PCWritePCWriteCond

MemtoRegPCSource1

ALUOp1

ALUSrcB0ALUSrcARegWriteRegDstNS3NS2NS1NS0

ALUSrcB1ALUOp0

PCSource0

Page 8: Verano 2004

• ROM = "Read Only Memory"– Se graba la memoria con valores fijos

• Se usa la ROM para implementar la Tabla de Verdad– Con direcciones de m-bits, podemos direccionar 2m entradas en la ROM.– Las salidas son los datos (palabras) direccionadas

m is the "heigth", and n is the "width"

Implementación con ROM

m n

0 0 0 0 0 1 10 0 1 1 1 0 00 1 0 1 1 0 00 1 1 1 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 11 1 0 0 1 1 01 1 1 0 1 1 1

Page 9: Verano 2004

• ¿Cuantas entradas tenemos?6 bits para el opcode, 4 bits para el estado = 10

líneas de direcciones (210 = 1024 different addresses)• ¿Cuantas salidas?

16 señales de controldel camino de datos, 4 bits de estado= 20 outputs

• ROM es 210 x 20 = 20K bits

• Problema: mucho desperdicio, ya que para muchisimas entradas, las salidas son idénticas. – Por ejemplo, el codígo de operación se ignora muchas veces

Implementación con ROM

Page 10: Verano 2004

• Se podrían hacer dos ROMS:

— 4 bits de estado se usan como dirección de las palabras de salida: 24 x 16

bits de ROM

— 10 bits se usan como dirección para la función de transición (nuevo

estado): 210 x 4 bits of ROM

— Total: 4.3K bits of ROM

• PLA es mas pequeña

— puede compartir términos producto

— solo utiliza las entradas que producen valores

— puede considerar los “no importa”

1. Tamaño es (#inputs #product-terms) + (#outputs #product-terms)

En el ejemplo = (10x17)+(20x17) = 460 PLA cells

Una celda de PLA es un poco mas grande que una de ROM

ROM vs PLA

Page 11: Verano 2004

• En las instrucciones complejas (muchos ciclos) el siguiente estado es generalmente el secuencial

Otra posible implementación

AddrCtl

Outputs

PLA or ROM

State

Address select logic

Op

[5–

0]

Adder

Instruction registeropcode field

1

Control unit

Input

PCWritePCWriteCondIorD

MemtoRegPCSourceALUOpALUSrcBALUSrcARegWriteRegDst

IRWrite

MemReadMemWrite

BWrite

Page 12: Verano 2004

Detalle de implementaciónDispatch ROM 1 Dispatch ROM 2

Op Opcode name Value Op Opcode name Value000000 R-format 0110 100011 lw 0011000010 jmp 1001 101011 sw 0101000100 beq 1000100011 lw 0010101011 sw 0010

State number Address-control action Value of AddrCtl

0 Use incremented state 31 Use dispatch ROM 1 12 Use dispatch ROM 2 23 Use incremented state 34 Replace state number by 0 05 Replace state number by 0 06 Use incremented state 37 Replace state number by 0 08 Replace state number by 0 09 Replace state number by 0 0

State

Op

Adder

1

PLA or ROM

Mux3 2 1 0

Dispatch ROM 1Dispatch ROM 2

0

AddrCtl

Address select logic

Instruction registeropcode field

Page 13: Verano 2004

Microprogramación¿Porque microprogramación?

PCWritePCWriteCondIorD

MemtoRegPCSourceALUOpALUSrcBALUSrcARegWrite

AddrCtl

Outputs

Microcode memory

IRWrite

MemReadMemWrite

RegDst

Control unit

Input

Microprogram counter

Address select logic

Op[

5–

0]

Adder

1

Datapath

Instruction registeropcode field

BWrite

• La ROM es la memoria donde se guardan las instrucciones para el camino de datos (microinstrucciones)

• La dirección de la ROM (microPC) es el estado

Page 14: Verano 2004

• Es una metodología de especificación– Apropiada para arquitecturas con cientos de

instrucciones, modos, alto CPI, etc.– Las señales se especifican simbólicamente usando

microinstrucciones– Se define el formato de la microinstrucción,

estructurado en campos.– Luego cada campo se asocia a un conjunto de señales

Microprogramación

Page 15: Verano 2004

• Dos implementaciones de la misma arquitectura, comparten el microcódigo?

Microprogramación

LabelALU

control SRC1 SRC2Register control Memory

PCWrite control Sequencing

Fetch Add PC 4 Read PC ALU SeqAdd PC Extshft Read Dispatch 1

Mem1 Add A Extend Dispatch 2LW2 Read ALU Seq

Write MDR FetchSW2 Write ALU FetchRformat1 Func code A B Seq

Write ALU FetchBEQ1 Subt A B ALUOut-cond FetchJUMP1 Jump address Fetch

Page 16: Verano 2004

Formato de MicroinstrucciónField name Value Signals active Comment

Add ALUOp = 00 Cause the ALU to add.ALU control Subt ALUOp = 01 Cause the ALU to subtract; this implements the compare for

branches.Func code ALUOp = 10 Use the instruction's function code to determine ALU control.

SRC1 PC ALUSrcA = 0 Use the PC as the first ALU input.A ALUSrcA = 1 Register A is the first ALU input.B ALUSrcB = 00 Register B is the second ALU input.

SRC2 4 ALUSrcB = 01 Use 4 as the second ALU input.Extend ALUSrcB = 10 Use output of the sign extension unit as the second ALU input.Extshft ALUSrcB = 11 Use the output of the shift-by-two unit as the second ALU input.Read Read two registers using the rs and rt fields of the IR as the register

numbers and putting the data into registers A and B.Write ALU RegWrite, Write a register using the rd field of the IR as the register number and

Register RegDst = 1, the contents of the ALUOut as the data.control MemtoReg = 0

Write MDR RegWrite, Write a register using the rt field of the IR as the register number andRegDst = 0, the contents of the MDR as the data.MemtoReg = 1

Read PC MemRead, Read memory using the PC as address; write result into IR (and lorD = 0 the MDR).

Memory Read ALU MemRead, Read memory using the ALUOut as address; write result into MDR.lorD = 1

Write ALU MemWrite, Write memory using the ALUOut as address, contents of B as thelorD = 1 data.

ALU PCSource = 00 Write the output of the ALU into the PC.PCWrite

PC write control ALUOut-cond PCSource = 01, If the Zero output of the ALU is active, write the PC with the contentsPCWriteCond of the register ALUOut.

jump address PCSource = 10, Write the PC with the jump address from the instruction.PCWrite

Seq AddrCtl = 11 Choose the next microinstruction sequentially.Sequencing Fetch AddrCtl = 00 Go to the first microinstruction to begin a new instruction.

Dispatch 1 AddrCtl = 01 Dispatch using the ROM 1.Dispatch 2 AddrCtl = 10 Dispatch using the ROM 2.

Page 17: Verano 2004

Microcódigo: Ventajas-Desventajas

• Ventajas en la especificación:

– Fácil de diseñar: se escribe el microprograma

• Implementación en ROM (off-chip)

– Fácil de cambiar

– Puede emular otras arquitecturas

– Puede usar registros internos

• Desventajas de la implementación

– Control se implementa (hoy) en el mismo chip que el camino de

datos

– La ROM no es mas rápida que la RAM (CISC vs RISC)

Page 18: Verano 2004

FIN Control