View
59
Download
0
Category
Preview:
DESCRIPTION
Exemplo de arquitetura registrador-registrador- MIPS. MIPS. ISA – todas as instruções de 32 bits, em 3 formatos: Máquina RISC – aritmética registrador-registrador 32 registradores de 32 bits Memória endereçada por 32 bits, organizada em bytes – ou seja, - PowerPoint PPT Presentation
Citation preview
Exemplo de arquitetura registrador-registrador- MIPS
MIPS
• ISA – todas as instruções de 32 bits, em 3 formatos:
• Máquina RISC – aritmética registrador-registrador• 32 registradores de 32 bits• Memória endereçada por 32 bits, organizada em bytes – ou seja,
a diferença de endereçamento de uma palavra (32 bits) e outra, da memória, é múltipla de 4.
230 words têm endereços de bytes 0, 4, 8, ... 232-4
op rs rt rd funct
op rs rt 16 bit address
op 26 bit address
R
I
J
Name Register number Usage$zero 0 the constant value 0$v0-$v1 2-3 values for results and expression evaluation$a0-$a3 4-7 arguments$t0-$t7 8-15 temporaries$s0-$s7 16-23 saved$t8-$t9 24-25 more temporaries$gp 28 global pointer$sp 29 stack pointer$fp 30 frame pointer$ra 31 return address
Banco de 32 Registradores do MIPS
Notação: sempre usa $ como prefixo
$0...
$31
Instruções típicas• Instrução Significado
add $s1,$s2,$s3 $s1 = $s2 + $s3sub $s1,$s2,$s3 $s1 = $s2 – $s3slt $s1,$s2,$s3 se $s2 < $s3 então $s1=1 senão $s1=0
lw $s1,100($s2) $s1 = Memory[$s2+100] sw $s1,100($s2) Memory[$s2+100] = $s1
bne $s4,$s5,L Próx. instr. é no Label se $s4< >$s5 beq $s4,$s5,L Próx. instr. é no Label se $s4 = $s5
j Label Próx. instr. é no Label
• Formatos:
op rs rt rd funct
op rs rt 16 bit address
op 26 bit address
R
I
J
R
I
I
J
6 5 5 5 5 6
addi $29, $29, 4I andi $29, $29, 6
ori $29, $29, 4 slti $t1, $s1, 2
Instruções aritméticas usando operandos imediatos (constantes)
instrução significado
$29 = $29+ 4$29 = $29 and 6
$29 = $29 or 4
Formato:
op rs rd 16 bits imediato
Se $s1 < 2 então $t1=1 senão $t1=0
I
Byte Halfword Word
Registers
Memory
Memory
Word
Memory
Word
Register
Register
1. Immediate addressing
2. Register addressing
3. Base addressing
4. PC-relative addressing
5. Pseudodirect addressing
op rs rt
op rs rt
op rs rt
op
op
rs rt
Address
Address
Address
rd . . . funct
Immediate
PC
PC
+
+
Modos de Endereçamentoimediato
registrador
memória
(instrução)
(instrução)
(dados)
memória
memória
HARDWARE: Unidades funcionais necessáriasMem. instrução Mem.dados
Banco de registradores
PCSomador
Extensão de sinal
ALU
Implementação de MIPS em um único ciclo
Instruction RegDst ALUSrcMemto-
RegReg
WriteMem Read
Mem Write Branch ALUOp1 ALUp0
R-format 1 0 0 1 0 0 0 1 0lw 0 1 1 1 1 0 0 0 0sw X 1 X 0 0 1 0 0 0beq X 0 X 0 0 0 1 0 1
PC
Instructionmemory
Readaddress
Instruction[31– 0]
Instruction [20– 16]
Instruction [25– 21]
Add
Instruction [5– 0]
MemtoReg
ALUOp
MemWrite
RegWrite
MemRead
BranchRegDst
ALUSrc
Instruction [31– 26]
4
16 32Instruction [15– 0]
0
0Mux
0
1
Control
Add ALUresult
Mux
0
1
RegistersWriteregister
Writedata
Readdata 1
Readdata 2
Readregister 1
Readregister 2
Signextend
Shiftleft 2
Mux
1
ALUresult
Zero
Datamemory
Writedata
Readdata
Mux
1
Instruction [15– 11]
ALUcontrol
ALUAddress
Mem.instrução Mem. dados
regsPC
controle
Controle:
Operation2
Operation1
Operation0
Operation
ALUOp1
F3
F2
F1
F0
F (5– 0)
ALUOp0
ALUOp
ALU control block
R-format Iw sw beq
Op0
Op1
Op2
Op3
Op4
Op5
Inputs
Outputs
RegDst
ALUSrc
MemtoReg
RegWrite
MemRead
MemWrite
Branch
ALUOp1
ALUOpO
- decodificação do opcode e geração dos sinais de controle
ALU-control
sina
is d
e co
ntro
le
opco
de
control
Fluxo numa instrução aritmética (R-format)
Instruction RegDst ALUSrcMemto-
RegReg
WriteMem Read
Mem Write Branch ALUOp1 ALUp0
R-format 1 0 0 1 0 0 0 1 0lw 0 1 1 1 1 0 0 0 0sw X 1 X 0 0 1 0 0 0beq X 0 X 0 0 0 1 0 1
PC
Instructionmemory
Readaddress
Instruction[31– 0]
Instruction [20– 16]
Instruction [25– 21]
Add
Instruction [5– 0]
MemtoReg
ALUOp
MemWrite
RegWrite
MemRead
BranchRegDst
ALUSrc
Instruction [31– 26]
4
16 32Instruction [15– 0]
0
0Mux
0
1
Control
Add ALUresult
Mux
0
1
RegistersWriteregister
Writedata
Readdata 1
Readdata 2
Readregister 1
Readregister 2
Signextend
Shiftleft 2
Mux
1
ALUresult
Zero
Datamemory
Writedata
Readdata
Mux
1
Instruction [15– 11]
ALUcontrol
ALUAddress
RegDst
ALUSrcMemtoReg
ALUOp
Circuito de Controle (decodificação do opcode e geração dos sinais de controle)
R-format Iw sw beq
Op0
Op1
Op2
Op3
Op4
Op5
Inputs
Outputs
RegDst
ALUSrc
MemtoReg
RegWrite
MemRead
MemWrite
Branch
ALUOp1
ALUOpO
sina
is d
e co
ntro
le1
00
100010
Instruction RegDst ALUSrcMemto-
RegReg
WriteMem Read
Mem Write Branch ALUOp1 ALUp0
R-format 1 0 0 1 0 0 0 1 0lw 0 1 1 1 1 0 0 0 0sw X 1 X 0 0 1 0 0 0beq X 0 X 0 0 0 1 0 1
opco
de0
00
000
Fluxo para a instrução lw
Instruction RegDst ALUSrcMemto-
RegReg
WriteMem Read
Mem Write Branch ALUOp1 ALUp0
R-format 1 0 0 1 0 0 0 1 0lw 0 1 1 1 1 0 0 0 0sw X 1 X 0 0 1 0 0 0beq X 0 X 0 0 0 1 0 1
PC
Instructionmemory
Readaddress
Instruction[31– 0]
Instruction [20– 16]
Instruction [25– 21]
Add
Instruction [5– 0]
MemtoReg
ALUOp
MemWrite
RegWrite
MemRead
BranchRegDst
ALUSrc
Instruction [31– 26]
4
16 32Instruction [15– 0]
0
0Mux
0
1
Control
Add ALUresult
Mux
0
1
RegistersWriteregister
Writedata
Readdata 1
Readdata 2
Readregister 1
Readregister 2
Signextend
Shiftleft 2
Mux
1
ALUresult
Zero
Datamemory
Writedata
Readdata
Mux
1
Instruction [15– 11]
ALUcontrol
ALUAddress
LMD (Load Mem. Data)
Circuito de Controle (para lw)
R-format Iw sw beq
Op0
Op1
Op2
Op3
Op4
Op5
Inputs
Outputs
RegDst
ALUSrc
MemtoReg
RegWrite
MemRead
MemWrite
Branch
ALUOp1
ALUOpO
sina
is d
e co
ntro
le0
11
110000
Instruction RegDst ALUSrcMemto-
RegReg
WriteMem Read
Mem Write Branch ALUOp1 ALUp0
R-format 1 0 0 1 0 0 0 1 0lw 0 1 1 1 1 0 0 0 0sw X 1 X 0 0 1 0 0 0beq X 0 X 0 0 0 1 0 1
opco
de1
00
011
Fluxo para a instrução sw
Instruction RegDst ALUSrcMemto-
RegReg
WriteMem Read
Mem Write Branch ALUOp1 ALUp0
R-format 1 0 0 1 0 0 0 1 0lw 0 1 1 1 1 0 0 0 0sw X 1 X 0 0 1 0 0 0beq X 0 X 0 0 0 1 0 1
PC
Instructionmemory
Readaddress
Instruction[31– 0]
Instruction [20– 16]
Instruction [25– 21]
Add
Instruction [5– 0]
MemtoReg
ALUOp
MemWrite
RegWrite
MemRead
BranchRegDst
ALUSrc
Instruction [31– 26]
4
16 32Instruction [15– 0]
0
0Mux
0
1
Control
Add ALUresult
Mux
0
1
RegistersWriteregister
Writedata
Readdata 1
Readdata 2
Readregister 1
Readregister 2
Signextend
Shiftleft 2
Mux
1
ALUresult
Zero
Datamemory
Writedata
Readdata
Mux
1
Instruction [15– 11]
ALUcontrol
ALUAddress
SMD – Store Mem. Data
Circuito de Controle (para sw)
R-format Iw sw beq
Op0
Op1
Op2
Op3
Op4
Op5
Inputs
Outputs
RegDst
ALUSrc
MemtoReg
RegWrite
MemRead
MemWrite
Branch
ALUOp1
ALUOpO
sina
is d
e co
ntro
le0
01
001000
Instruction RegDst ALUSrcMemto-
RegReg
WriteMem Read
Mem Write Branch ALUOp1 ALUp0
R-format 1 0 0 1 0 0 0 1 0lw 0 1 1 1 1 0 0 0 0sw X 1 X 0 0 1 0 0 0beq X 0 X 0 0 0 1 0 1
opco
de1
10
011
Fluxo para a instrução beq
Instruction RegDst ALUSrcMemto-
RegReg
WriteMem Read
Mem Write Branch ALUOp1 ALUp0
R-format 1 0 0 1 0 0 0 1 0lw 0 1 1 1 1 0 0 0 0sw X 1 X 0 0 1 0 0 0beq X 0 X 0 0 0 1 0 1
PC
Instructionmemory
Readaddress
Instruction[31– 0]
Instruction [20– 16]
Instruction [25– 21]
Add
Instruction [5– 0]
MemtoReg
ALUOp
MemWrite
RegWrite
MemRead
BranchRegDst
ALUSrc
Instruction [31– 26]
4
16 32Instruction [15– 0]
0
0Mux
0
1
Control
Add ALUresult
Mux
0
1
RegistersWriteregister
Writedata
Readdata 1
Readdata 2
Readregister 1
Readregister 2
Signextend
Shiftleft 2
Mux
1
ALUresult
Zero
Datamemory
Writedata
Readdata
Mux
1
Instruction [15– 11]
ALUcontrol
ALUAddress
Circuito de Controle (para beq)
R-format Iw sw beq
Op0
Op1
Op2
Op3
Op4
Op5
Inputs
Outputs
RegDst
ALUSrc
MemtoReg
RegWrite
MemRead
MemWrite
Branch
ALUOp1
ALUOpO
sina
is d
e co
ntro
le0
00
000101
Instruction RegDst ALUSrcMemto-
RegReg
WriteMem Read
Mem Write Branch ALUOp1 ALUp0
R-format 1 0 0 1 0 0 0 1 0lw 0 1 1 1 1 0 0 0 0sw X 1 X 0 0 1 0 0 0beq X 0 X 0 0 0 1 0 1
opco
de0
00
100
Fluxo de dados multiciclo – usando uma única memória para instruções e dados
Shiftleft 2
PC
Memory
MemData
Writedata
Mux
0
1
RegistersWriteregister
Writedata
Readdata 1
Readdata 2
Readregister 1
Readregister 2
Mux
0
1
Mux
0
1
4
Instruction[15– 0]
Signextend
3216
Instruction[25– 21]
Instruction[20– 16]
Instruction[15– 0]
Instructionregister
1 Mux
0
3
2
Mux
ALUresult
ALUZero
Memorydata
register
Instruction[15– 11]
A
B
ALUOut
0
1
Address
ALUSrcA
ALUSrcB
IorD
RegDst
MemtoReg
• Usar o PC para a leitura da instrução e carga da mesma no registrador de instrução (Instruction Register).
• Incrementar o valor do PC por 4 e carregar o resultado no PC.
IR = Memory[PC];PC = PC + 4;
Podemos obter os valores dos sinais de controle?
Passo 1: Busca da instrução (Instruction Fetch)
• Leitura dos registradores rs e rt • Computar o endereço de branch no caso da instrução de branch
A = Reg[IR[25-21]];B = Reg[IR[20-16]];ALUOut = PC + (sign-extend(IR[15-0]) << 2);
• Preparando para acionar as linhas de controle baseadas no tipo de instrução
(a instrução está sendo "decodificada" na lógica de controle)
Passo 2: Decod. da Instrução e Busca de Registradores
• ALU está realizando uma das três funções, baseadas no tipo de instrução
• Referência à memória:
ALUOut = A + sign-extend(IR[15-0]);
• R-type:
ALUOut = A op B;
• Branch:
if (A==B) PC = ALUOut;
Passo 3 (dependente da instrução)
• Acesso à memória através de loads e stores
MDR = Memory[ALUOut];ou
Memory[ALUOut] = B;
• Fim das instruções R-type
Reg[IR[15-11]] = ALUOut;
A escrita é realizada no fim do ciclo, na borda
Passo 4 (R-type ou acesso à memória)
• Reg[IR[20-16]]= MDR;
Fim da instrução load!
Passo 5 (Write-back, para instrução load)
Recommended