Adders and flip-flops · Somadores e flip-flops
| English | Português |
|---|---|
| carry/ˈkæri/ | carry |
| half adder/hɑːf ˈædə/ | meio somador |
| full adder/fʊl ˈædə/ | somador completo |
| flip-flop/flɪp flɒp/ | flip-flop |
| ripple-carry adder/ˈrɪpl ˈkæri ˈædə/ | somador ripple-carry |
| bistable/baɪˈsteɪbl/ | bistável |
| counters/ˈkaʊntəz/ | contadores |
| SRAM/ˈesræm/ | SRAM |
| SR flip-flop/ˌes ˈɑː flɪp flɒp/ | SR flip-flop |
| JK flip-flop/ˌdʒeɪ ˈkeɪ flɪp flɒp/ | JK flip-flop |
| toggle/ˈtɒɡl/ | toggle |
How a machine that only knows true and false does arithmetic
- A processor has no adder in the sense of a thing that knows numbers. It has gates that answer true or false, and nothing else.
- Yet $1 + 1 = 10$ falls out of two gates: an XOR gives the sum digit, an AND gives the carry. That is the entire arithmetic unit in miniature, and chaining copies of it adds numbers of any width.
- The other half of a computer is remembering, and one bit of memory is also just gates, wired so that their outputs feed back into their inputs and hold.
- This lesson is the half adder 半加器, the full adder 全加器, and the flip-flop 触发器 that stores a bit.
Como uma máquina que só sabe verdadeiro e falso faz aritmética
- Um processador não tem um somador no sentido de uma coisa que conhece números. Ele tem portas que respondem verdadeiro ou falso, e nada mais.
- No entanto, $1 + 1 = 10$ surge de duas portas: um XOR dá o dígito da soma, um AND dá o acarreio. Esse é a unidade inteira de aritmética em miniatura, e encadeando cópias dele soma números de qualquer largura.
- A outra metade de um computador é lembrar, e um bit de memória também são apenas portas, conectadas de forma que suas saídas retroalimentam suas entradas e permanecem.
- Esta lição é o adiçador parcial 半加器, o adiçador completo 全加器, e o flip-flop 触发器 que armazena um bit.
The half adder
- A half adder adds two single bits, $A$ and $B$, producing a sum $S$ and a carry 进位 $C$.
| A | B | S | C |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
- Read the columns: $S$ is 1 when exactly one input is 1, which is XOR. $C$ is 1 only when both are 1, which is AND. So $S = A \oplus B$ and $C = A \cdot B$.
- It ignores any carry in, which is why it is only "half" an adder and cannot be chained on its own.
Two gates, and binary addition exists
O somador parcial
- Um adiçador parcial soma dois bits únicos, $A$ e $B$, produzindo uma soma $S$ e um carry 进位 $C$.
| A | B | S | C |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
- Leia as colunas: $S$ é 1 quando exatamente uma entrada é 1, que é XOR. $C$ é 1 apenas quando ambas são 1, que é AND. Então $S = A \oplus B$ e $C = A \cdot B$.
- Ignora qualquer carry in (entrada de transporte), razão pela qual é apenas um somador "meio" e não pode ser encadeado sozinho.

Duas portas lógicas, e existe a adição binária
The gates inside an adder · As portas dentro de um somador
A half-adder's sum bit is an XOR gate and its carry is an AND gate — toggle A and B and watch the truth-table row light up. · O bit de soma de um half-adder é uma porta XOR e seu carry é uma porta AND — alterne A e B e veja a linha da tabela-verdade acender.
In a half adder, the sum output S is produced by which gate? · Em um half adder, qual porta produz a saída S (soma)?
$S = A \text{ XOR } B$ (1 when the inputs differ); the carry is $A \text{ AND } B$. · $S = A \text{ XOR } B$ (1 quando as entradas diferem); o carry é $A \text{ AND } B$.
In a half adder the carry output C is produced by which single gate? · Em um half adder, qual porta única produz a saída C (carry)?
C is 1 only when both inputs are 1, which is AND. The sum S is 1 when exactly one input is 1, which is XOR. · C é 1 apenas quando ambas as entradas são 1, o que é AND. A soma S é 1 quando exatamente uma entrada é 1, o que é XOR.
The full adder
- A full adder adds three bits: $A$, $B$ and a carry-in, producing a sum and a carry-out. $S = A \oplus B \oplus C_{\text{in}}$.
- It can be built from two half adders plus an OR gate: the first half adder adds $A$ and $B$, the second adds that sum to the carry-in, and the OR combines the two carries.
- Chain full adders so that each carry-out feeds the next carry-in, and you have a multi-bit ripple-carry adder 行波进位加法器: four of them add two 4-bit numbers.
The carry is what has to travel, which is why it is called ripple
O somador completo
- Um somador completo soma três bits: $A$, $B$ e um carry-in, produzindo uma soma e um carry-out. $S = A \oplus B \oplus C_{\text{in}}$.
- Pode ser construído a partir de dois somadores meio mais uma porta OR: o primeiro somador meio adiciona $A$ e $B$, o segundo adiciona essa soma ao carry-in, e a porta OR combina os dois carries.
- Encadeie somadores completos de modo que cada carry-out alimente o próximo carry-in, e terá um somador ripple-carry 行波进位加法器: quatro deles somam dois números de 4 bits.

O carry é o que tem de viajar, daí ser chamado ripple
Match each building block to what it does. · Associe cada bloco construtivo ao que ele faz.
Adders add bits (chain full adders for multi-bit addition); flip-flops store a bit (the JK fixes the SR forbidden state). · Somadores somam bits (encadeie full adders para adição multi-bit); flip-flops armazenam um bit (o JK corrige o estado proibido do SR).
How does a full adder differ from a half adder? · Como um full adder difere de um half adder?
A full adder adds A, B and a carry-in (so adders can be chained) — built from two half adders plus an OR gate. · Um full adder soma A, B e um carry-in (para que somadores possam ser encadeados) — construído de dois half adders mais uma porta OR.
Worked example: why a full adder, not two half adders
- Explain why a 4-bit adder is built from full adders rather than half adders.
- Adding two 4-bit numbers column by column, every column except the rightmost may receive a carry from the column to its right, so it has three inputs to add, not two.
- A half adder has no carry-in, so it cannot take that third input, and the carry would simply be lost.
- Only the least significant column has no carry-in, so a half adder would do there; in practice all four are full adders, with the first carry-in tied to 0.
Exemplo resolvido: porquê um somador completo, não dois somadores meio
- Explique porquê um somador de 4 bits é construído com somadores completos em vez de somadores meio.
- Ao adicionar dois números de 4 bits coluna por coluna, todas as colunas exceto a mais à direita podem receber um carry da coluna à sua direita, pelo que têm três entradas para somar, não duas.
- Um somador meio não tem carry-in, pelo que não pode aceitar essa terceira entrada, e o carry seria simplesmente perdido.
- Apenas a coluna menos significativa não tem carry-in, onde um somador meio bastaria; na prática, usam-se todos os quatro como somadores completos, com o primeiro carry-in ligado a 0.
Why must a 4-bit adder use full adders rather than half adders? · Por que um adder de 4 bits deve usar full adders em vez de half adders?
A half adder does produce a carry; what it lacks is a carry-in, so it cannot accept the carry arriving from the previous column. · Um half adder realmente produz um carry; o que lhe falta é um carry-in, então ele não pode aceitar o carry que chega da coluna anterior.
Put the construction of a 4-bit ripple-carry adder in order. · Coloque a construção de um adder ripple-carry de 4 bits na ordem correta.
Gates make a half adder, half adders make a full adder, full adders chain into a word-width adder. The carry rippling along is what gives it its name. · Portas fazem um half adder, half adders fazem um full adder, full adders encadeiam em um adder de largura de palavra. O carry rastejando ao longo é o que lhe dá o nome.
Flip-flops
- A flip-flop is a bistable 双稳态 circuit: it has two stable states, 0 and 1, and it remembers the one it is in. It stores exactly one bit.
- It is the basic element of registers, where $n$ bits means $n$ flip-flops, of counters, and of SRAM 静态RAM cells.
- Unlike an adder, whose output depends only on its inputs now, a flip-flop's output depends on its past inputs. That is what memory means at the circuit level.
Flip-flops
- Um flip-flop é um circuito bistável 双稳态: tem dois estados estáveis, 0 e 1, e lembrança do estado em que se encontra. Armazena exatamente um bit.
- É o elemento básico de registos, onde $n$ bits significa $n$ flip-flops, de contadores e de células de SRAM 静态RAM.
- Ao contrário de um somador, cuja saída depende apenas das suas entradas atuais, a saída de um flip-flop depende das suas entradas passadas. Isso é o que memória significa ao nível do circuito.
A flip-flop is used to: · Um flip-flop é usado para:
A flip-flop has two stable states and holds one bit — the building block of registers and SRAM. · Um flip-flop tem dois estados estáveis e segura um bit — o bloco construtivo de registros e SRAM.
A flip-flop is bistable — it has two stable states and remembers one bit — which makes it the building block of registers and SRAM. · Um flip-flop é bistável — tem dois estados estáveis e lembra um bit — o que o torna o bloco construtivo de registros e SRAM.
Chaining flip-flops gives registers and counters; SRAM cache is built from them (no refresh needed, unlike DRAM). · Encadear flip-flops dá registros e contadores; cache SRAM é construído a partir deles (sem necessidade de refresh, diferentemente de DRAM).
SR and JK
- An SR flip-flop SR触发器 has inputs S (set) and R (reset) and outputs $Q$ and $\overline{Q}$, built from two cross-coupled NOR gates.
S=1, R=0sets $Q$ to 1.S=0, R=1resets $Q$ to 0.S=0, R=0holds the current state, which is the memory.S=1, R=1is invalid: it asks for set and reset at once.- A JK flip-flop JK触发器 removes that flaw by giving the
1,1input a meaning: toggle 翻转, so the output flips to its opposite. That makes it ideal for counters 计数器, since a chain of toggling flip-flops counts in binary. - A JK is usually clocked: the inputs act only on a clock edge, which keeps every flip-flop in the machine in step.
The invalid input turned into a useful one
SR e JK
- Um flip-flop SR SR触发器 tem entradas S (set) e R (reset) e saídas $Q$ e $\overline{Q}$, construído com duas portas NOR acopladas cruzadamente.
S=1, R=0define $Q$ para 1.S=0, R=1redefine $Q$ para 0.S=0, R=0mantém o estado atual, que é a memória.S=1, R=1é inválido: pede set e reset ao mesmo tempo.- Um flip-flop JK JK触发器 remove esse defeito dando ao input
1,1um significado: toggle 翻转, para que a saída mude para o oposto. Isso torna-o ideal para contadores 计数器, já que uma cadeia de flip-flops com toggle conta em binário. - Um JK é geralmente com clock: as entradas atuam apenas numa borda de clock, mantendo todos os flip-flops da máquina sincronizados.

A entrada inválida transformou-se numa útil
For an SR flip-flop, which statements are correct? Select all · todos that apply. · Para um SR flip-flop, quais afirmações estão corretas? Selecione todas as opções aplicáveis.
Toggling on 1,1 is the JK's improvement. On an SR that input asks for set and reset at once and is invalid. · Alternar em 1,1 é a melhoria do JK. Em um SR, essa entrada pede set e reset ao mesmo tempo e é inválida.
The JK flip-flop's toggle behaviour is what makes it suitable for building counters. · O comportamento de alternância (toggle) do flip-flop JK é o que o torna adequado para construir contadores.
A chain of flip-flops each toggling on its input counts in binary. Clocking them keeps every stage in step. · Uma cadeia de flip-flops onde cada um alterna na sua entrada conta em binário. Clocká-los mantém todos os estágios sincronizados.
Worked example: trace an SR flip-flop
- $Q$ is currently 0. Give $Q$ after the inputs S=1 R=0, then S=0 R=0, then S=0 R=1.
- S=1, R=0 sets the output, so $Q$ becomes 1.
- S=0, R=0 holds, so $Q$ stays 1. This is the step that shows it is a memory: the inputs say nothing, and the output persists.
- S=0, R=1 resets, so $Q$ becomes 0. If S=1 and R=1 were applied, the answer is that the input is invalid, not a value.
Exemplo resolvido: rastrear um flip-flop SR
- $Q$ está atualmente a 0. Dê $Q$ após as entradas S=1 R=0, depois S=0 R=0, depois S=0 R=1.
- S=1, R=0 define a saída, então $Q$ torna-se 1.
- S=0, R=0 mantém, então $Q$ permanece 1. Este é o passo que mostra que é uma memória: as entradas não dizem nada, e a saída persiste.
- S=0, R=1 redefine, então $Q$ torna-se 0. Se S=1 e R=1 fossem aplicados, a resposta é que a entrada é inválida, não um valor.
Marks that slip away
- $S = A \oplus B$ and $C = A \cdot B$: XOR for the sum, AND for the carry. Swapping them loses both marks.
- "Half" means no carry-in, not "half the bits".
- A full adder is two half adders plus an OR, and the OR combines the two carries.
- On an SR flip-flop,
0,0holds and1,1is invalid. The JK's improvement is that1,1toggles.
Marcas que escapam
- $S = A \oplus B$ e $C = A \cdot B$: XOR para a soma, AND para o carry. Trocá-los perde ambas as marcações.
- "Meio" significa sem carry-in, não "metade dos bits".
- Um somador completo é dois somadores meio mais uma OR, e a OR combina os dois carries.
- Num flip-flop SR,
0,0mantém e1,1é inválido. A melhoria do JK é que1,1faz toggle.
You've got it
- half adder: two bits in, $S = A \oplus B$ from an XOR and $C = A \cdot B$ from an AND; no carry-in
- full adder: three bits in, built from two half adders plus an OR; chain them, carry-out to carry-in, for a ripple-carry adder
- a flip-flop is bistable and stores one bit; $n$ flip-flops make an $n$-bit register, and they are the cells of SRAM
- SR: set, reset,
0,0holds,1,1invalid · JK:1,1toggles, which is what makes counters, and it is clocked to stay synchronised
Entendeu?
- somador meio: duas bits de entrada, $S = A \oplus B$ de um XOR e $C = A \cdot B$ de um AND; sem carry-in
- somador completo: três bits de entrada, construído a partir de dois somadores meio mais uma OR; encadeá-los, carry-out para carry-in, para um somador ripple-carry
- um flip-flop é bistável e armazena um bit; $n$ flip-flops fazem um registo de $n$ bits, e são as células de SRAM
- SR: set, reset,
0,0mantém,1,1inválido · JK:1,1faz toggle, o que faz os contadores, e é com clock para manter a sincronização