Registers, counters and memory
導入済み| English | 意味 |
|---|---|
| register/ˈredʒɪstə/ | レジスタ |
| shift register/ʃɪft ˈredʒɪstə/ | シフトレジスタ |
| memory/ˈmeməri/ | メモリ |
| synchronous counter/ˈsɪŋkrənəs ˈkaʊntə/ | 同期カウンタ |
| ripple counter/ˈrɪpl ˈkaʊntə/ | リプルカウンタ |
| address lines | アドレス線 |
7, then 8
- A scoreboard changes from 7 to 8 while every other digit stays still. That is a register updating, and counting is a register that updates itself.
- This lesson builds the storage blocks of a computer: registers, shift registers, counters and memory.
Registers load n bits together
- A register 寄存器 is a row of D flip-flops sharing one clock. At each edge all $n$ bits load at once; between edges they hold.
- A load-enable input chooses, for each edge, whether to take new data or keep the old. That is how one digit changes while the rest stand still.
In a register with load-enable low, the stored bits follow the data inputs at each clock edge.
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
With load-enable low each flip-flop is fed its own output, so it keeps its value. Only an enabled edge loads new data.
Shift registers move bits along
- In a shift register 移位寄存器 each flip-flop's output feeds the next one's input, so the stored bits move one place per clock.
- Serial in, parallel out turns a bit stream into a word; parallel in, serial out does the reverse. Shifting right with inputs 1, 1, 0, 1 gives 1000, 1100, 0110, 1011.
One clock edge moves every stored bit
$Q^{+}=\{sin,Q_3,Q_2,Q_1\}$
Starting from 0000, clock the lesson’s right-shift input stream 1, 1, 0, 1 to get 1000, 1100, 0110, 1011. Follow each old bit to its new position, and distinguish selecting the next input from clocking it into storage.
A 4-bit right-shift register starts at 0000. Inputs 1, 0, 0, 1 enter at the left over four clocks. What does it hold?
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Trace: 1000, 0100, 0010, 1001. The first bit in has moved furthest right.
Ripple and synchronous counters
- A ripple counter 异步计数器 chains toggle flip-flops: each output clocks the next. It is simple, but each stage adds its delay, so the top bit settles late.
- A synchronous counter 同步计数器 clocks every flip-flop from the same edge and computes which bits toggle with logic. Every bit changes together.

In a synchronous counter all the flip-flops receive the same clock edge.
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
That is the definition. Logic decides which bits toggle, so all bits change together and no delay accumulates, unlike a ripple counter.
Worked example: the 3-bit up-counter
- Bit 0 toggles every clock; bit 1 when $Q_{0} = 1$; bit 2 when $Q_{1} Q_{0} = 11$. A bit toggles when every bit below it is 1, which is how adding 1 carries.
- After reset it counts 000, 001, …, 111 and rolls over to 000: $2^{3} = 8$ states.
In a 3-bit synchronous up-counter, bit 2 toggles when —
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Bit k toggles when all lower bits are 1, which is when they roll over. The count 000 … 111 with $2^{3} = 8$ states is the check.
Worked example: a mod-6 counter
- A synchronous mod-6 counter runs 000 to 101; the next clock edge after 101 writes 000. The codes 110 and 111 are unused in normal counting.
- Choose next state 000 when the present word is 101, 110 or 111; otherwise add 1. This also recovers from either unused code at the next edge. $Q_{2} \cdot Q_{1}$ detects 110 and 111, but it is 0 at 101, so that condition alone does not make this synchronous counter.
Predict the toggles, then clock the new count
$Q^{+}=Q\oplus T$
Trace the 3-bit counter’s eight states and see why each bit toggles when all lower old bits are 1. Compare synchronous mod-6, where 101 goes directly to 000. Load either unused code 110 or 111 and check recovery at the next clock edge.
A mod-6 counter must return to 000 from 101. The cleanest reset condition is —
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Legal counts 000 to 101 never have $Q_{2} = Q_{1} = 1$, so $Q_{2} \cdot Q_{1}$ picks out exactly the unused codes and clears to 000. $Q_{2}$ alone would also clear 100 and 101.
A mod-10 counter is built from binary flip-flops. How many of its codes are unused?
難易度 2/5 · 140 コイン + 今日初回達成時の小ボーナス
Ten states need 4 flip-flops ($2^{4} = 16$), leaving $16 - 10 = 6$ unused codes: 1010 to 1111.
Memory: words and address lines
- Memory 存储器 is an array of words. With $k$ address lines 地址线, it selects one of $2^{k}$ words, each $m$ bits wide.
- An 8K × 8 memory holds $8192 = 2^{13}$ words of 8 bits: 13 address lines and 8 data lines.
An 8K × 8 memory needs how many address lines?
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
$k$ address bits select one of $2^{k}$ words: $8192 = 2^{13}$, so 13 lines. The 8 is the word width (data lines), not the address.
Three common slips
- Trusting a ripple counter at speed. It looks fine slowly and fails at the specified clock, because the delays add up.
- Ignoring unused states. A mod-N counter must recover from an illegal code after power-up or noise.
- Mixing up address and data width. In 8K × 8, the 8K sets the address lines and the 8 is the word size.
Recap
- Registers load on a shared edge; shift registers move bits one place per clock.
- Synchronous counters toggle a bit when all lower bits are 1; mod-N counters must handle unused codes.
- $k$ address lines select $2^{k}$ words.