projetos digitais e microprocessadores - inf.ufpr.br · somador completo c out 4 bits c in ‘0’...
TRANSCRIPT
![Page 1: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/1.jpg)
PROJETOS DIGITAIS E MICROPROCESSADORESUNIDADE LÓGICA E ARITMÉTICA
Marco A. Zanata Alves
PROJETOS DIGITAIS E MICROPROCESSADORES 1
![Page 2: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/2.jpg)
REPRESENTAÇÃO BINÁRIACOMPLEMENTO DE 2
PROJETOS DIGITAIS E MICROPROCESSADORES 2
000
001
010
011
100
101
110
111
Representação binária
![Page 3: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/3.jpg)
REPRESENTAÇÃO BINÁRIACOMPLEMENTO DE 2
PROJETOS DIGITAIS E MICROPROCESSADORES 3
0
1
2
3
-4
-3
-2
-1 000
001
010
011
100
101
110
111
Representação decimal
-4 2 1
![Page 4: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/4.jpg)
REPRESENTAÇÃO BINÁRIACOMPLEMENTO DE 2
Overflow, acontece quando o valor armazenado é maior (em magnitude) do que o registrador pode armazenar ou representar
Underflow, acontece quando tentamos armazenar um valor menor que o menor valor absoluto que o registrador é capaz de armazenar ou representar
PROJETOS DIGITAIS E MICROPROCESSADORES 4
0
1
2
3
-4
-3
-2
-1 000
001
010
011
100
101
110
111
overflow
underflow
![Page 5: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/5.jpg)
OVERFLOW DURANTE SOMAS
Se X e Y tiverem sinais opostos, nunca ocorrerá overflow
Overflow, poderá ocorrer apenas se X e Y tiverem sinais iguais
Overflow acontece quando X e Y tem sinais iguais, e o resultado tiver um sinal diferente
Pos + Pos = Neg Overflow
Neg + Neg = Pos Overflow
PROJETOS DIGITAIS E MICROPROCESSADORES 5
![Page 6: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/6.jpg)
REPRESENTAÇÃO BINÁRIACOMPLEMENTO DE 2
Converta os números:
1100 00002
0100 00002
1111 11112
1000 00002
1000 11112
PROJETOS DIGITAIS E MICROPROCESSADORES 6
-128 64 32 16 8 4 2 1
Qual o bit
mais
significativo?
![Page 7: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/7.jpg)
INTRODUÇÃO A UNIDADE LÓGICA E ARITMÉTICA (ULA)
Construa um circuito com:
8 entradas de dados 𝑏3, 𝑏2, 𝑏1, 𝑏0, 𝑎3, 𝑎2, 𝑎1, 𝑎0
1 entrada de seleção Op
4 saídas 𝑠3, 𝑠2, 𝑠1, 𝑠0
tal que:
𝑆3𝑆2𝑆1𝑆0 = 𝐴 + 𝐵 se Op=0, 𝐴 − 𝐵 se Op=1
Todas as operações são com números sem sinal. Desconsidere os casos em que há overflow.
PROJETOS DIGITAIS E MICROPROCESSADORES 7
![Page 8: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/8.jpg)
Somador completo4 bits c in ‘0’cout
a3 a2 a1 a0b3 b2 b1 b0
Somador completo4 bits c in ‘1’cout
D 1 D 0 D 1 D 0 D 1 D 0 D 1 D 0
MUX MUX MUX MUX
Op
s3 s2 s1PROJETOS DIGITAIS E MICROPROCESSADORES 8
![Page 9: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/9.jpg)
UNIDADE LÓGICA-ARITMÉTICA
Unidade Lógica-Aritmética (ULA): circuito digital que faz operações lógicas e aritméticas. A operação a ser feita é selecionada pelos bits de seleção de operação/função
A ULA do exercício anterior só possui 1 bit de operação, para escolher entre soma e subtração.
Representado por um trapézio chanfrado
PROJETOS DIGITAIS E MICROPROCESSADORES 9
ULA
![Page 10: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/10.jpg)
UNIDADE LÓGICA-ARITMÉTICA
𝑅𝑒𝑔𝐷𝑒𝑠𝑡 <= 𝑈𝐿𝐴 𝐹𝑢𝑛, 𝑟𝑒𝑔𝐴, 𝑟𝑒𝑔𝐵 𝐹𝑢𝑛 ∈ {+,−,≪,≫,∧,∨,∨}
PROJETOS DIGITAIS E MICROPROCESSADORES 10
ULAA
B
R
Clock
Reg.
FonteReg.
Dest.4
4
4
Fun
Qtos. bits
para
Fun?
![Page 11: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/11.jpg)
UNIDADE LÓGICA-ARITMÉTICA
𝑅𝑒𝑔𝐷𝑒𝑠𝑡 <= 𝑈𝐿𝐴 𝐹𝑢𝑛, 𝑟𝑒𝑔𝐴, 𝑟𝑒𝑔𝐵 𝐹𝑢𝑛 ∈ {+,−,≪,≫,∧,∨,∨, ¬}
PROJETOS DIGITAIS E MICROPROCESSADORES 11
ULAA
B
R
Clock
Reg.
FonteReg.
Dest.4
4
4
Fun
𝐴 = 0101𝐵 = 0001𝐴 + 𝐵 = 0101 + 0001 = 1011𝐴 − 𝐵 = 0101 − 0001 = 0100𝐴 ≪ 1 = 0101 ≪ 1 = 1010𝐴 ≫ 1 = 0101 ≫ 1 = 0010𝐴 ∧ 𝐵 = 0101 ∧ 0001 = 0001𝐴 ∨ 𝐵 = 0101 ∨ 0001 = 0101𝐴 ∨ 𝐵 = 0101 ∨ 0001 = 0100¬𝐴 = ¬0101 = 1010
![Page 12: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/12.jpg)
UNIDADE LÓGICA-ARITMÉTICA
PROJETOS DIGITAIS E MICROPROCESSADORES 12
R
A
B
Clock
Reg.
FonteReg.
Dest.
Fun
d0d1d2d3
d0d1d2d3
d0d1d2d3
ULA
ULA
ULA
ULA
O que temos
dentro de
uma ULA?
![Page 13: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/13.jpg)
DENTRO DA UNIDADE LÓGICA-ARITMÉTICA
PROJETOS DIGITAIS E MICROPROCESSADORES 13
Mux
0 +
1 −
2 ≪
3 ≫
4 ∧
5 ∨
6 ∨
7 ¬
𝐴
𝐵
𝑅𝐴𝑖−1
𝐴𝑖+1
Fun
vem
+
vai
-
3
/
![Page 14: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/14.jpg)
OTIMIZANDO SOMADORES
PROJETOS DIGITAIS E MICROPROCESSADORES 14
![Page 15: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/15.jpg)
BLOCOS SOMADORES BINÁRIOS
𝑠𝑖 = 𝑎𝑖 ⊕𝑏𝑖 ⊕ 𝑐𝑖−1
𝑐𝑖 = 𝑎𝑖𝑏𝑖 + (𝑎𝑖 + 𝑏𝑖) · 𝑐𝑖−1
ci
si
ci− 1
Bloco somador
completo
(Full Adder)
ai bi
PROJETOS DIGITAIS E MICROPROCESSADORES 15
![Page 16: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/16.jpg)
SOMADOR DE 4 BITS
Construa um somador de 4 bits, com FullAdders
PROJETOS DIGITAIS E MICROPROCESSADORES 16
Somador completo
4 bits
𝑏3…𝑏0 𝑎3…𝑎0
𝑐𝑖𝑛𝑐𝑜𝑢𝑡
𝑟3…𝑟0
![Page 17: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/17.jpg)
SOMADOR DE 4 BITS
PROJETOS DIGITAIS E MICROPROCESSADORES 17
FA vemvai
val
A B
FA vemvai
val
A B
FA vemvai
val
A B
FA vemvai
val
A B
Vem=0
A0=1
B0=0
A1=1
B1=1
A2=0
B2=0
A3=0
B3=1
R=1 R=1 R=0 R=1
Vai=0
![Page 18: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/18.jpg)
SUBTRATOR DE 4 BITS
Construa um subtrator de 4 bits
PROJETOS DIGITAIS E MICROPROCESSADORES 18
![Page 19: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/19.jpg)
SUBTRATOR DE 4 BITS
Construa um subtrator de 4 bits
PROJETOS DIGITAIS E MICROPROCESSADORES 19
Somador completo
4 bits
𝑏3…𝑏0 𝑎3…𝑎0
𝑐𝑖𝑛 = 1𝑐𝑜𝑢𝑡
𝑟3…𝑟0
Sinal
sub
![Page 20: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/20.jpg)
MELHORA NO SOMADOR
PROJETOS DIGITAIS E MICROPROCESSADORES 20
FA vemvai
val
A B
FA vemvai
val
A B
FA vemvai
val
A B
FA vemvai
val
A B
Vem
A0
B0
A1
B1
A2
B2
A3
B3
R R R R
Vai
atraso
![Page 21: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/21.jpg)
MELHORA NO SOMADOR
Os somadores com propagação de Vai-um (ripple carry) são muito lentos
O resultado (𝑉𝑎𝑖𝑛) só será conhecido após todos os (𝑉𝑒𝑚𝑚 , 𝑚 <𝑛) serem computados, um após o outro
Qual o número de portas lógicas entre 𝑉𝑒𝑚0 e 𝑉𝑎𝑖𝑛?
PROJETOS DIGITAIS E MICROPROCESSADORES 21
ci
si
ci− 1
ai bi
Ideia: adiantar
o sinal de Vai-um
![Page 22: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/22.jpg)
SOMADOR CARRY-LOOKAHEAD
Esse somador utiliza uma técnica para aceleração do cálculo do carry
Para cada soma, nós vamos adiantar o sinal de carry a partir das entradas já disponíveis, sem esperar a propagação das informações sendo calculadas
Para isso iremos precisar de mais portas lógicas para transformar trabalho sequencial em trabalho paralelo
Com o aumento da lógica, normalmente fazemos blocos somadores de 4 bits. Onde os blocos são ligados em série
PROJETOS DIGITAIS E MICROPROCESSADORES 22
![Page 23: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/23.jpg)
SOMADOR CARRY-LOOKAHEAD
Iremos então antecipar o calculo do vai-um em função dos bits menos significativos
PROJETOS DIGITAIS E MICROPROCESSADORES 23
𝐴 𝐵 𝑉𝟎 𝑅 𝑉𝟏
0 0 0 0 0
0 1 0 1 0
1 0 0 1 0
1 1 0 0 1
0 0 1 1 0
0 1 1 0 1
1 0 1 0 1
1 1 1 1 1
𝐺𝑖 = 𝑎𝑖 ∙ 𝑏𝑖 Gera vai-um
𝑃𝑖 = 𝑎𝑖 + 𝑏𝑖 Propaga vai-um
𝐴𝑖 𝐵𝑖
𝐺𝑖 𝑃𝑖
![Page 24: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/24.jpg)
SOMADOR CARRY-LOOKAHEAD
𝐺𝑖 = 𝑎𝑖 ∙ 𝑏𝑖 Gera vai-um
𝑃𝑖 = 𝑎𝑖 + 𝑏𝑖 Propaga vai-um
𝑉1 = 𝐺0 + 𝑃0 ∙ 𝑉0
𝑉2 = 𝐺1 + 𝑃1 ∙ 𝐺0 + 𝑃1 ∙ 𝑃0 ∙ 𝑉0
𝑉3 = 𝐺2 + 𝑃2 ∙ 𝐺1 + 𝑃2 ∙ 𝑃1 ∙ 𝐺0 + 𝑃2 ∙ 𝑃1 ∙ 𝑃0 ∙ 𝑉0
𝑉4 = 𝐺3 + 𝑃3 ∙ 𝐺2 + 𝑃3 ∙ 𝑃2 ∙ 𝐺1 + 𝑃3 ∙ 𝑃2 ∙ 𝑃1 ∙ 𝐺0 + 𝑃3 ∙ 𝑃2 ∙ 𝑃1 ∙ 𝑃0 ∙ 𝑉0
…
PROJETOS DIGITAIS E MICROPROCESSADORES 24
Assim calculamos 4 vai-uns
em paralelo!
Evita-se calcular 5 vai-uns
em paralelo devido ao custo
em portas lógicas, além do
atraso não compensar
![Page 25: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/25.jpg)
SOMADOR CARRY-LOOKAHEAD 2BITS
PROJETOS DIGITAIS E MICROPROCESSADORES 25
𝐴0 𝐵0
𝐺0 𝑃0
𝐶0 𝐴1 𝐵1
𝐺1 𝑃1
𝐶2
𝑆1
𝑆0 𝐶1
![Page 26: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/26.jpg)
PROJETOS DIGITAIS E MICROPROCESSADORES 26
𝐴0 𝐵0
𝐺0 𝑃0
𝐶0 𝐴1 𝐵1
𝐺1 𝑃1
𝐶2
𝑆1
𝑆0 𝐶1
ci
si
ci− 1
ai bi
ci
si
ai bi
Qual o
caminho
crítico?
![Page 27: PROJETOS DIGITAIS E MICROPROCESSADORES - inf.ufpr.br · Somador completo c out 4 bits c in ‘0’ b 3 b 2 b 1 b 0 a 3 a 2 a 1 a 0 Somador completo c out 4 bits c in ‘1’ D 1 D](https://reader030.vdocuments.mx/reader030/viewer/2022020416/5c5eb70409d3f2ca1f8cb0af/html5/thumbnails/27.jpg)
PROJETOS DIGITAIS E MICROPROCESSADORES 27
EXEMPLOCOMPLETO