AC1 –Micro-Arquitectura: DataPath do MIPS1 Organização ou MicroArquitectura DataPath MIPS32.

21
AC1 –Micro-Arquitectura: DataPath do MIPS 1 Organização ou MicroArquitectura DataPath MIPS32

Transcript of AC1 –Micro-Arquitectura: DataPath do MIPS1 Organização ou MicroArquitectura DataPath MIPS32.

Page 1: AC1 –Micro-Arquitectura: DataPath do MIPS1 Organização ou MicroArquitectura DataPath MIPS32.

AC1 –Micro-Arquitectura: DataPath do MIPS 1

Organização ou MicroArquitectura

DataPath MIPS32

Page 2: AC1 –Micro-Arquitectura: DataPath do MIPS1 Organização ou MicroArquitectura DataPath MIPS32.

AC1 –Micro-Arquitectura: DataPath do MIPS 2

Datapath e Controlpath

Datapath – circuito percorrido pelas instruções, endereços e resultados

Controlpath – circuito percorrido pelos sinais que controlam o datapath

IP Inst.Mem.

Data.Mem.

RegisterFile

ExecutionUnit

IP Inst.Mem.

Data.Mem.

RegisterFile

ExecutionUnit

UnidadeControlo

Page 3: AC1 –Micro-Arquitectura: DataPath do MIPS1 Organização ou MicroArquitectura DataPath MIPS32.

AC1 –Micro-Arquitectura: DataPath do MIPS 3

Datapath Intel Pentium 4

Reservation Stations

x1

Instruction TLB

32 byte

s

Instruction DecoderDescodifica umainstrução (IA-32)

por ciclo

Fornece até 3 uOps por ciclo

MicrocodeROM

Execution TraceCache

12 000 uOps

Trace cacheBranch Predictor4096 entry BTB

StoreAddr.Unit

LoadUnit

2xALU

Simple int.Store data

Branch

FPMove

St. dataExchMMXSSE2

x2 x1

2xALU

Simple int.Store data

Branch

ALU

ComplexInteger

x2

FPexecute

MMXSSE2

Iniciam execução até6 uOps por ciclo

Integer/FP RegisterRename & Allocator

L1 Data Cache8KByte 4-way

Reorder Buffer

Memory Order Buffer48 entry load, 24 entry storeL2 Cache

256/512 KB8-way 256 bit

256 bit Baseado num esquema doProf. João Luís Sobral

Page 4: AC1 –Micro-Arquitectura: DataPath do MIPS1 Organização ou MicroArquitectura DataPath MIPS32.

AC1 –Micro-Arquitectura: DataPath do MIPS 4

Elementos Combinatórios

As saídas destes elementos reagem sempre a variações nas entradas, após um certo atraso (delay) de propagação.

EXEMPLOS: um multiplexer, a ALU

ALU Operation

se (d==0) c=a senão c=b

Page 5: AC1 –Micro-Arquitectura: DataPath do MIPS1 Organização ou MicroArquitectura DataPath MIPS32.

AC1 –Micro-Arquitectura: DataPath do MIPS 5

Elementos sequenciaisAs saídas destes elementos só reagem a variações nas entradas quando se verifica um pulso do clock.São estes elementos que memorizam dados, determinando o estado do CPU.

EXEMPLOS: os registos, a memória

Convenção de temporização – os elementos sequenciais só são escritos no pulso descendente do clock. Ignoram-se os atrasos.

Regin out

RegWr

clock

out

in

RegWr

clock0

1

0

1

0

1

0

1

Page 6: AC1 –Micro-Arquitectura: DataPath do MIPS1 Organização ou MicroArquitectura DataPath MIPS32.

AC1 –Micro-Arquitectura: DataPath do MIPS 6

Sub conjunto de instruções do MIPS:

• Acesso à memória – lw e sw

• Lógico-aritméticas – add, addi, sub, and, andi, or, ori, slt e slti

• Controlo de fluxo – beq

Implementação de ciclo único:

1. Todas as instruções demoram exactamente um único ciclo do relógio

2. O período do clock tem que ser igual à instrução mais demorada

3. Nenhum componente do datapath pode ser usado mais do que uma vez

durante a mesma instrução

Datapath MIPS32 – ciclo único

Page 7: AC1 –Micro-Arquitectura: DataPath do MIPS1 Organização ou MicroArquitectura DataPath MIPS32.

AC1 –Micro-Arquitectura: DataPath do MIPS 7

Datapath : fetch da instrução

Instruções lidas do endereço apontado pelo PC.

O PC é incrementado 4 no fim do ciclo.

A mémória mantêm a instrução na saída até ao fim do ciclo.

Não são apresentados sinais de controlo da memória porque esta é só de leitura.

Esta ALU apenas realiza adições, não precisa de sinais de controlo.

A memória é dedicada a instruções, porque cada componente só pode ser usado uma vez em cada ciclo. A memória de dados será outro componente.

Page 8: AC1 –Micro-Arquitectura: DataPath do MIPS1 Organização ou MicroArquitectura DataPath MIPS32.

AC1 –Micro-Arquitectura: DataPath do MIPS 8

Datapath para instruções tipo R

As instruções R lêem 2 registos (Rs, Rt) e escrevem num terceiro (Rd).

O campo Funct da instrução vai ser usado para gerar o sinal ALUoperation.

O sinal de controlo RegWrite indica se o resultado deve ser escrito num registo.

OpCode FunctionRs Rt Rd ShAmt

Page 9: AC1 –Micro-Arquitectura: DataPath do MIPS1 Organização ou MicroArquitectura DataPath MIPS32.

AC1 –Micro-Arquitectura: DataPath do MIPS 9

Datapath para lw e sw

Instruction

16 32

R egistersWriteregister

Readdata 1

Readdata 2

Readregister 1

Readregister 2

Datam em ory

Writedata

Readdata

Writedata

S ignextend

ALUresult

ZeroALU

Address

M em Read

M em W rite

RegW rite

ALU operation3

32

32

32

Cálculo do endereço - O offset imediato é estendido (32 bits) e somado ao registo base (Rs)

lw – Os sinais MemRead e RegWrite são activados para que os dados sejam escritos no registo endereçado no campo Rtsw – O sinal MemWrite é activado para que o valor do registo endereçado no campo Rt seja escrito na memória

OpCode Rs Rt Imediato

Page 10: AC1 –Micro-Arquitectura: DataPath do MIPS1 Organização ou MicroArquitectura DataPath MIPS32.

AC1 –Micro-Arquitectura: DataPath do MIPS 10

Datapath para beq

1 6 3 2S ig n

e x t e n d

Z e r oA L U

S u m

S h i f tl e f t 2

T o b r a n c hc o n t r o l l o g ic

B r a n c h t a r g e t

P C + 4 f r o m in s t r u c t i o n d a t a p a t h

I n s t r u c t io n

A d d

R e g is t e r sW r i t er e g i s t e r

R e a dd a t a 1

R e a dd a t a 2

R e a dr e g i s t e r 1

R e a dr e g i s t e r 2

W r i t ed a t a

R e g W r i t e

A L U o p e r a t i o n3

32

Os registos Rs e Rt são comparados activando a saída Zero da ALU

O offset do campo imm da instrução é estendido para 32 bits, multiplicado por 4 e somado ao PC

O PC só é carregado com este valor se a saída Zero da ALU estiver a 1

Page 11: AC1 –Micro-Arquitectura: DataPath do MIPS1 Organização ou MicroArquitectura DataPath MIPS32.

AC1 –Micro-Arquitectura: DataPath do MIPS 11

Datapath do MIPS

RegDst – O registo a escrever pode ser o Rd (tipo-R) ou o Rt (tipo-I)

AluSrc – O operando pode ser um registo (tipo-R) ou uma constante (tipo-I)

MemtoReg – O valor a escrever num registo pode vir da ALU ou da memória (lw)

PCSrc – O valor a escrever no PC pode ser PC+4 ou o PC+4+offset de beq

NOTA: Falta gerar os sinais de controlo, que entre outros, se baseiam no Opcode (Instruction[31-26]) e no Funct (Instruction[5-0])

MemtoReg

Mem Read

MemW rite

ALUSrc

RegDst

PC

Instructionmemory

Readaddress

Instruction[31– 0]

Instruction [20– 16]

Instruction [25– 21]

Add

RegW rite

4

16 32Instruction [15– 0]

0Registers

W riteregisterW ritedata

W ritedata

Readdata 1

Readdata 2

Readregister 1Readregister 2

S ignextend

ALUresult

Zero

Datamemory

Address Readdata M

ux

1

0

Mux

1

0

Mux

1

0

Mux

1

Instruction [15– 11]

Shiftleft 2

PC Src

ALU

Add ALUresult

ALU operation(Rs)

(Rt)

(Rd)

(Imm)

U.C.Instruction [31-26] (op)

Page 12: AC1 –Micro-Arquitectura: DataPath do MIPS1 Organização ou MicroArquitectura DataPath MIPS32.

AC1 –Micro-Arquitectura: DataPath do MIPS 12

Instrução do Tipo-R (fetch)

MemtoReg

Mem Read

MemW rite

ALUSrc

RegDst

PC

Instructionmemory

Readaddress

Instruction[31– 0]

Instruction [20– 16]

Instruction [25– 21]

Add

RegW rite

4

16 32Instruction [15– 0]

0Registers

W riteregisterW ritedata

W ritedata

Readdata 1

Readdata 2

Readregister 1Readregister 2

S ignextend

ALUresult

Zero

Datamemory

Address Readdata M

ux

1

0

Mux

1

0

Mux

1

0

Mux

1

Instruction [15– 11]

Shiftleft 2

PC Src

ALU

Add ALUresult

ALU operation(Rs)

(Rt)

(Rd)

(Imm)

A instrução apontada pelo PC é lida e o valor do PC é incrementado de 4(mas não é escrito no registo)

U.C.Instruction [31-26] (op)

Page 13: AC1 –Micro-Arquitectura: DataPath do MIPS1 Organização ou MicroArquitectura DataPath MIPS32.

AC1 –Micro-Arquitectura: DataPath do MIPS 13

Instrução do Tipo-R (decode/operand fetch)

MemtoReg

Mem Read

MemW rite

ALUSrc

RegDst

PC

Instructionmemory

Readaddress

Instruction[31– 0]

Instruction [20– 16]

Instruction [25– 21]

Add

RegW rite

4

16 32Instruction [15– 0]

0Registers

W riteregisterW ritedata

W ritedata

Readdata 1

Readdata 2

Readregister 1Readregister 2

S ignextend

ALUresult

Zero

Datamemory

Address Readdata M

ux

1

0

Mux

1

0

Mux

1

0

Mux

1

Instruction [15– 11]

Shiftleft 2

PC Src

ALU

Add ALUresult

ALU operation(Rs)

(Rt)

(Rd)

(Imm)

A unidade de controlo descodifica a instrução e gera os sinais de controlo.Os registos são lidos.

RegDst 0

RegWrite 1

ALUSrc 1

MemWrite 0

MemRead 0

MemtoReg 0

ALU operation ???

PCSrc 1

U.C.Instruction [31-26] (op)

Page 14: AC1 –Micro-Arquitectura: DataPath do MIPS1 Organização ou MicroArquitectura DataPath MIPS32.

AC1 –Micro-Arquitectura: DataPath do MIPS 14

Instrução do Tipo-R (execute)

A ALU realiza a operação.

MemtoReg

Mem Read

MemW rite

ALUSrc

RegDst

PC

Instructionmemory

Readaddress

Instruction[31– 0]

Instruction [20– 16]

Instruction [25– 21]

Add

RegW rite

4

16 32Instruction [15– 0]

0Registers

W riteregisterW ritedata

W ritedata

Readdata 1

Readdata 2

Readregister 1Readregister 2

S ignextend

ALUresult

Zero

Datamemory

Address Readdata M

ux

1

0

Mux

1

0

Mux

1

0

Mux

1

Instruction [15– 11]

Shiftleft 2

PC Src

ALU

Add ALUresult

ALU operation(Rs)

(Rt)

(Rd)

(Imm)

RegDst 0

RegWrite 1

ALUSrc 1

MemWrite 0

MemRead 0

MemtoReg 0

ALU operation ???

PCSrc 1

U.C.Instruction [31-26] (op)

Page 15: AC1 –Micro-Arquitectura: DataPath do MIPS1 Organização ou MicroArquitectura DataPath MIPS32.

AC1 –Micro-Arquitectura: DataPath do MIPS 15

Instrução do Tipo-R (writeback)

Apenas no fim do ciclo é que os registos são escritos (PC inclusive).

RegDst 0

RegWrite 1

ALUSrc 1

MemWrite 0

MemRead 0

MemtoReg 0

ALU operation ???

PCSrc 1

É possível distinguir 4 fases diferentes de execução, mas todas são realizadas no mesmo ciclo do clock.

MemtoReg

Mem Read

MemW rite

ALUSrc

RegDst

PC

Instructionmemory

Readaddress

Instruction[31– 0]

Instruction [20– 16]

Instruction [25– 21]

Add

RegW rite

4

16 32Instruction [15– 0]

0Registers

W riteregisterW ritedata

W ritedata

Readdata 1

Readdata 2

Readregister 1Readregister 2

S ignextend

ALUresult

Zero

Datamemory

Address Readdata M

ux

1

0

Mux

1

0

Mux

1

0

Mux

1

Instruction [15– 11]

Shiftleft 2

PC Src

ALU

Add ALUresult

ALU operation(Rs)

(Rt)

(Rd)

(Imm)

U.C.Instruction [31-26] (op)

Page 16: AC1 –Micro-Arquitectura: DataPath do MIPS1 Organização ou MicroArquitectura DataPath MIPS32.

AC1 –Micro-Arquitectura: DataPath do MIPS 16

Instrução lógico-aritmética (Tipo I)

RegDst 1

RegWrite 1

ALUSrc 0

MemWrite 0

MemRead 0

MemtoReg 0

ALU operation ???

PCSrc 1

MemtoReg

Mem Read

MemW rite

ALUSrc

RegDst

PC

Instructionmemory

Readaddress

Instruction[31– 0]

Instruction [20– 16]

Instruction [25– 21]

Add

RegW rite

4

16 32Instruction [15– 0]

0Registers

W riteregisterW ritedata

W ritedata

Readdata 1

Readdata 2

Readregister 1Readregister 2

S ignextend

ALUresult

Zero

Datamemory

Address Readdata M

ux

1

0

Mux

1

0

Mux

1

0

Mux

1

Instruction [15– 11]

Shiftleft 2

PC Src

ALU

Add ALUresult

ALU operation(Rs)

(Rt)

(Rd)

(Imm)

fetch

decode/operand fetch

execute

writeback

U.C.Instruction [31-26] (op)

Page 17: AC1 –Micro-Arquitectura: DataPath do MIPS1 Organização ou MicroArquitectura DataPath MIPS32.

AC1 –Micro-Arquitectura: DataPath do MIPS 17

Instrução beq

RegDst X

RegWrite 0

ALUSrc 1

MemWrite 0

MemRead 0

MemtoReg X

ALU operation 110

PCSrc Zero???

MemtoReg

Mem Read

MemW rite

ALUSrc

RegDst

PC

Instructionmemory

Readaddress

Instruction[31– 0]

Instruction [20– 16]

Instruction [25– 21]

Add

RegW rite

4

16 32Instruction [15– 0]

0Registers

W riteregisterW ritedata

W ritedata

Readdata 1

Readdata 2

Readregister 1Readregister 2

S ignextend

ALUresult

Zero

Datamemory

Address Readdata M

ux

1

0

Mux

1

0

Mux

1

0

Mux

1

Instruction [15– 11]

Shiftleft 2

PC Src

ALU

Add ALUresult

ALU operation(Rs)

(Rt)

(Rd)

(Imm)

fetch

decode/operand fetch

execute

writeback

U.C.Instruction [31-26] (op)

Page 18: AC1 –Micro-Arquitectura: DataPath do MIPS1 Organização ou MicroArquitectura DataPath MIPS32.

AC1 –Micro-Arquitectura: DataPath do MIPS 18

Instrução lw

RegDst 1

RegWrite 1

ALUSrc 0

MemWrite 0

MemRead 1

MemtoReg 1

ALU operation 010

PCSrc 1

MemtoReg

Mem Read

MemW rite

ALUSrc

RegDst

PC

Instructionmemory

Readaddress

Instruction[31– 0]

Instruction [20– 16]

Instruction [25– 21]

Add

RegW rite

4

16 32Instruction [15– 0]

0Registers

W riteregisterW ritedata

W ritedata

Readdata 1

Readdata 2

Readregister 1Readregister 2

S ignextend

ALUresult

Zero

Datamemory

Address Readdata M

ux

1

0

Mux

1

0

Mux

1

0

Mux

1

Instruction [15– 11]

Shiftleft 2

PC Src

ALU

Add ALUresult

ALU operation(Rs)

(Rt)

(Rd)

(Imm)

fetch

decode/operand fetch

execute

writeback mem

Exige 5 fases, todas executadas no mesmo ciclo

U.C.Instruction [31-26] (op)

Page 19: AC1 –Micro-Arquitectura: DataPath do MIPS1 Organização ou MicroArquitectura DataPath MIPS32.

AC1 –Micro-Arquitectura: DataPath do MIPS 19

Datapath MIPS – 5 fases

MemtoReg

Mem Read

MemW rite

ALUSrc

RegDst

PC

Instructionmemory

Readaddress

Instruction[31– 0]

Instruction [20– 16]

Instruction [25– 21]

Add

RegW rite

4

16 32Instruction [15– 0]

0Registers

W riteregisterW ritedata

W ritedata

Readdata 1

Readdata 2

Readregister 1Readregister 2

S ignextend

ALUresult

Zero

Datamemory

Address Readdata M

ux

1

0

Mux

1

0

Mux

1

0

Mux

1

Instruction [15– 11]

Shiftleft 2

PC Src

ALU

Add ALUresult

ALU operation(Rs)

(Rt)

(Rd)

(Imm)

U.C.Instruction [31-26] (op)

fetch decode/operand fetch

execute mem

writeback Ocorre no pulso descendente do relógio, resultando na escrita do PC e dos registos

Page 20: AC1 –Micro-Arquitectura: DataPath do MIPS1 Organização ou MicroArquitectura DataPath MIPS32.

AC1 –Micro-Arquitectura: DataPath do MIPS 20

Datapath ciclo único - Resumo

• Existem 5 fases de execução: fetch, decode/operand fetch, execute, memory, writeback

• Todos os sinais de controlo são gerados na fase de decode• Todas as instruções demoram exactamente um ciclo a executar• O ciclo tem que ser suficientemente longo para permitir a execução

de todas as fases• Apenas as instruções do tipo load/store necessitam da fase memory.

Corolários

1. Todas as instruções levam tanto tempo como a instrução mais longa

2. Cada componente do CPU só pode ser usado uma vez por ciclo

Page 21: AC1 –Micro-Arquitectura: DataPath do MIPS1 Organização ou MicroArquitectura DataPath MIPS32.

AC1 –Micro-Arquitectura: DataPath do MIPS 21

Sumário

Tema H & P

Datapath single cycle Sec. 5.1, 5.2, 5.3 (ignorar o controlo)