Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
1998 Morgan Kaufmann Publishers Ch5B1
O Processador: Via de Dados e Controle(Parte C: microprogramação)
1998 Morgan Kaufmann Publishers Ch5B2
Possibilidades para o projeto de UCs
Initialrepresentation
Finite statediagram Microprogram
Sequencingcontrol
Explicit nextstate function
Microprogram counter+ dispatch ROMS
Logicrepresentation
Logicequations
Truthtables
Implementationtechnique
Programmablelogic array
Read onlymemory
• Ler “Historical perspective and further reading”• RISC x CISC• Controle
• hardwired• microprogramado (firmware)
1998 Morgan Kaufmann Publishers Ch5B3
• Valores dos sinais de controle dependem de:– Qual instrução está sendo executada– Que passo está sendo processado
• Especificar a máquina de estados finitos graficamente, ou• Usar microprogramação
• Implementação pode ser derivada da especificação
Implementando o controle
1998 Morgan Kaufmann Publishers Ch5B4• Quantos bits de estado serão necessários?
Especificação gráfica da MEF
PCWritePCSource = 10
ALUSrcA = 1ALUSrcB = 00ALUOp = 01PCWriteCond
PCSource = 01
ALUSrcA =1ALUSrcB = 00ALUOp= 10
RegDst = 1RegWrite
MemtoReg = 0MemWriteIorD = 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 fetch Instruction decode/register fetch
Jumpcompletion
BranchcompletionExecution
Memory addresscomputation
Memoryaccess
Memoryaccess Rtype completion
Writeback step
(Op = 'LW') or (Op = 'SW') (Op = Rtype)
(Op =
'BEQ
')
(Op
= 'J'
)
(Op = 'SW')
(Op =
'LW
')
4
01
9862
753
Start
1998 Morgan Kaufmann Publishers Ch5B5
MEF para controlePCWritePCWriteCondIorD
MemtoRegPCSourceALUOpALUSrcBALUSrcARegWriteRegDst
NS3NS2NS1NS0
Op5
Op4
Op3
Op2
Op1
Op0
S3 S2 S1 S0
State register
IRWrite
MemReadMemWrite
Instruction registeropcode field
Outputs
Control logic
Inputs
1998 Morgan Kaufmann Publishers Ch5B6
Implementação via PLAOp5
Op4
Op3
Op2
Op1
Op0
S3
S2
S1
S0
IorD
IRWrite
MemReadMemWrite
PCWritePCWriteCond
MemtoRegPCSource1
ALUOp1
ALUSrcB0ALUSrcARegWriteRegDstNS3NS2NS1NS0
ALUSrcB1ALUOp0
PCSource0
1998 Morgan Kaufmann Publishers Ch5B7
• ROM = "Read Only Memory"
• Uma ROM pode ser usada para implementar uma tabelaverdade– Se o endereço possui mbits, podese endereçar 2m entradas na ROM.– A saída são os bits de dados que o endereço aponta
m é a “altura”, e n é a “largura”
Implementação via 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
1998 Morgan Kaufmann Publishers Ch5B8
• Quantas entradas?6 bits para opcode, 4 bits para estado = 10 bits de endereço(i.e., 210 = 1024 endereços diferentes)
• Quantas saídas?16 saídas para controle da via de dados, 4 bits de estado= 20 bits
de saída
• ROM é 210 x 20 = 1K x 20 bits
• Ocupa muita área!
Implementação via ROM
1998 Morgan Kaufmann Publishers Ch5B9
• Divisão da tabela em duas partes— 4 bits de estado indicam 16 saídas, 24 x 16 bits da ROM— 10 bits tell you the 4 next state bits, 210 x 4 bits da ROM— Total: 4.3K bits de ROM
• PLA é muito menor— Pode compartilhar termos de produtos— Necessita apenas de entradas que produzem uma saída ativa — Pode levar em conta sinais do tipo don't care
• Tamanho é (#inputs × #productterms) + (#outputs × #productterms)Para o nosso exemplo = (10x17)+(20x17) = 460 células de PLA
•
ROM vs PLA
1998 Morgan Kaufmann Publishers Ch5B10
• Instruções complexas: o “próximo estado” é o estado atual + 1
Outro estilo de implementação
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
1998 Morgan Kaufmann Publishers Ch5B11
Visão geral
State
Op
Adder
1
PLA or ROM
Mux3 2 1 0
Dispatch ROM 1Dispatch ROM 2
0
AddrCtl
Address select logic
Instruction registeropcode field
Memória de MicroControle
µPC INCR
CC(tabelas)
IR OP
End
Dado
s
seq
Unidade de controle µprogramado
µIR
1998 Morgan Kaufmann Publishers Ch5B12
controleDispatch ROM 1 Dispatch ROM 2
Op Opcode name Value Op Opcode name Value000000 Rformat 0110 100011 lw 0011000010 jmp 1001 101011 sw 0101000100 beq 1000100011 lw 0010101011 sw 0010
State number Addresscontrol action Value of AddrCtl0 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
1998 Morgan Kaufmann Publishers Ch5B13
Microprogramação
• O que são as microinstruções?
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
1998 Morgan Kaufmann Publishers Ch5B14
Diagrama de transição de estados
PCWritePCSource = 10
ALUSrcA = 1ALUSrcB = 00ALUOp = 01PCWriteCond
PCSource = 01
ALUSrcA =1ALUSrcB = 00ALUOp= 10
RegDst = 1RegWrite
MemtoReg = 0MemWriteIorD = 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 fetch Instruction decode/register fetch
Jumpcompletion
BranchcompletionExecution
Memory addresscomputation
Memoryaccess
Memoryaccess Rtype completion
Writeback step
(Op = 'LW') or (Op = 'SW') (Op = Rtype)
(Op =
'BEQ
')
(Op
= 'J'
)
(Op = 'SW')
(Op =
'LW
')
4
01
9862
753
Start
Estado Addresscontrol action seq0 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
1998 Morgan Kaufmann Publishers Ch5B15
Um microprograma horizontal
IorD
IRW
R
Mem
RD
Mem
WR
PCW
R
PCW
Rco
nd
Mem
2Reg
RegD
st
RegW
R
AluS
rcA
AluS
rcB
AluO
P
PCSr
c
Desvio ObsFetch 0 1 1 1 0 01 00 00 Seq Lê instrução; PC < PC+4
0 11 00 Dispatch1 ALUout< end de desvioLWSW1 1 10 00 Dispatch2 end efetivo
LW2 1 1 Seq Lê memória1 0 1 Fetch Write Back
SW2 1 1 Fetch Escreve na Mem.RFormat1 1 00 10 Seq Executa ALU
0 1 1 Fetch Write BackBeq1 1 1 00 01 01 Fetch Desvio condicional
Jump1 1 10 Fetch Desvio incondicional
Estado Addresscontrol action seq0 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
1998 Morgan Kaufmann Publishers Ch5B16
• Uma metodologia de especificação– Apropriada se centenas de opcodes, modos, ciclos, etc.– Sinais especificados simbolicamente usando microinstruções
• Duas implementações da mesma arquitetura possuem o mesmo microcódigo?
Microprogramação
LabelALU
control SRC1 SRC2Register control Memory
PCWrite control Sequencing
Fetch Add PC 4 Read PC ALU SeqAdd PC Extshft Read (nada) 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 ALUOutcond FetchJUMP1 Jump address Fetch
Formato das microinstruçõesField 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 shiftbytwo 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 ALUOutcond 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.
1998 Morgan Kaufmann Publishers Ch5B18
• Não codificado– 1 bit para cada operação da via de dados– Mais rápido, requer mais memória (lógica)– Usado pelo Vax 780 — incríveis 400K de memória!
• Codificado– Enviar microinstruções e obter sinais de controle – Usa menos memória mas é mais lento
• Contexto histórico de CISC:– Muita lógica de controle para colocar em um único chip– Utilizar uma ROM (ou mesmo uma RAM) para manter o microcódigo– A adição de novas instruções é mais simples
Codificação x Não codificação
1998 Morgan Kaufmann Publishers Ch5B19
Microcódigo
• A distinção entre especificação e implementação é, algumas vezes, difícil de encontrar
• Vantagens da especificação:– Fácil de projetar e escrever– Projetar arquitetura e microcódigo em paralelo
• Vantagens da implementação (ROM) – Fácil de modificar uma vez que os valores estão em uma memória – Pode emular outras arquiteturas– Pode fazer uso de registradores internos
• Desvantagens da implementação :– Controle é implementado no mesmo chip como o processador – ROM não é mais rápida que uma RAM