Registers, counters and memory
引入
8:05
数字逻辑设计
数字逻辑只需要两个电压电平、少量逻辑门和时间。一个三输入函数只有八行,因此无论在纸上还是用循环,逐行检查都不费什么工夫。这种习惯贯穿整门课:真值表、卡诺图和硬件测试平台,是自动化程度不同的三种穷举检查。
英文讲解 · 可切换中英文字幕
本课内容
| English | 释义 | 拼音 |
|---|---|---|
| register/ˈredʒɪstə/ | 寄存器 | jì cún qì |
| shift register/ʃɪft ˈredʒɪstə/ | 移位寄存器 | yí wèi jì cún qì |
| memory/ˈmeməri/ | 存储器 | cún chǔ qì |
| clock/klɒk/ | 时钟 | shí zhōng |
| synchronous counter/ˈsɪŋkrənəs ˈkaʊntə/ | 同步计数器 | tóng bù jì shù qì |
| ripple counter/ˈrɪpl ˈkaʊntə/ | 异步计数器 | yì bù jì shù qì |
| address lines/əˈdres laɪnz/ | 地址线 | dì zhǐ xiàn |
7,随后是 8
- 计分板从 7 变为 8 而其他数字保持不变。这属于寄存器更新操作,计数则是自我更新的寄存器。
- 本课构建计算机存储模块:寄存器、移位寄存器、计数器和存储器。
寄存器同时加载 n 位
- 寄存器 是一种由 D 触发器组成的行,共享同一个时钟。在每个边沿,所有 $n$ 位同时加载;在边沿之间,它们保持数据不变。
- 加载使能输入为每个边沿选择是获取新数据还是保留旧数据。这就是为什么一个数字改变时其余数字保持静止的原因。
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.
移位寄存器移动位
- 在移位寄存器 中,每个触发器的输出连接到下一个触发器的输入,因此存储的位每个时钟周期移动一个位置。
- 串行输入、并行输出将比特流转换为字;并行输入、串行输出则相反。当输入为 1, 1, 0, 1 时,右移操作产生 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.
纹波计数器与同步计数器
- 纹波计数器 级联翻转触发器:每个输出作为下一个的时钟。它结构简单,但每级都会增加延迟,导致最高位最后稳定。
- 同步计数器 从同一个边沿为所有触发器提供时钟,并通过逻辑电路计算哪些位需要翻转。所有位同时变化。


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.
范例:3 位加法计数器
- 位 0 每个时钟翻转一次;位 1 在 $Q_{0} = 1$ 时翻转;位 2 在 $Q_{1} Q_{0} = 11$ 时翻转。当某一位下方的所有位都为 1 时,该位翻转,这正是加 1 产生进位的原理。
- 复位后,计数器从 000 计到 001, …, 111,然后回绕至 000:共 $2^{3} = 8$ 个状态。
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.
示例:模-6计数器
- 同步模-6 计数器从 000 计数至 101;101 之后的下一个时钟沿写入 000。代码 110 和 111 在正常计数过程中未被使用。
- 当当前字为 101、110 或 111 时选择下一状态 000;否则加 1。这也能在下个时钟沿恢复任一未使用的代码。$Q_{2} \cdot Q_{1}$ 可检测 110 和 111,但它在 101 时为 0,因此单凭此条件不足以构成该同步计数器。
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 synchronous mod-6 counter writes 000 at the clock edge after 101, and must also recover from the unused codes. Which present states should load 000?
难度 1/5 · 今日首次完成可获 100 金币及少量额外奖励
The edge after 101 must give 000, so 101 is in the set; adding the unused 110 and 111 makes the counter recover from them too. $Q_{2} \cdot Q_{1}$ is 0 at 101, so the count would step on to 110. $Q_{2}$ alone would also clear 100.
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.
存储器:字与地址线
- 存储器 是一个字的数组。通过 $k$ 条地址线,可以从中选中 $2^{k}$ 个字中的一个,每个字宽 $m$ 位。
- 一个8K × 8存储器包含$8192 = 2^{13}$个字,每个字8位:需要13根地址线和8根数据线。
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.
三个常见误区
- 高速下依赖纹波计数器的可靠性。 它在慢速时看似正常,但在指定时钟频率下会失效,因为累积的延迟导致了问题。
- 忽略未使用状态。 N模计数器必须在通电或噪声后从非法代码中恢复。
- 混淆地址与数据宽度。 在8K × 8中,8K设置地址线,而8是字长。
复习要点
- 寄存器在共享边沿加载;移位寄存器每个时钟移动一位。
- 同步计数器在所有低位均为1时翻转某一位;N模计数器必须处理未使用的编码。
- $k$条地址线选择$2^{k}$个字。
出了什么问题?只有网站团队能看到这些信息。