HDLおよび検証基礎
導入済み
8:05
ディジタルロジック設計
Digital logic needs only two voltage levels, a handful of gates, and time. A three-input function has just eight rows, so checking every row is free, on paper…
英語のナレーション・英語と中国語の字幕を切り替え可能
このレッスンの内容
| English | 意味 |
|---|---|
| simulation/ˌsɪmjʊˈleɪʃn/ | シミュレーション |
| hardware description language/ˈhɑːdweə dɪˈskrɪpʃn ˈlæŋɡwɪdʒ/ | ハードウェア記述言語 |
| synthesizable/ˈsɪnθəsaɪzəbl/ | 合成可能 |
| testbench/ˈtestbentʃ/ | テーストベンチ |
64 gates, 64 chances to slip
- Wire 64 gates by hand and each connection is a chance for a mistake. Modern chips have billions.
- Industry describes hardware in a language and checks its behaviour with simulation and other verification methods.
Describe hardware in code
- A hardware description language 硬件描述语言 (HDL) such as Verilog or VHDL describes what a circuit is and how it behaves. A synthesis tool turns it into gates.
- Only synthesizable 可综合 code can become hardware: continuous
assign,always @(*)blocks andalways @(posedge clk)registers.
正しくシミュレーションできるすべてのVerilogはゲートに変換可能である。
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
シミュレーションではハードウェアとしての意味を持たない構文、例えば遅延と $display を受け付けます。合成可能な部分のみがゲートになります。
A full adder in four lines
- The module lists its ports, then states the two output equations from the earlier lesson.
module full_adder(input a, b, cin,
output sum, cout);
assign sum = a ^ b ^ cin;
assign cout = (a & b) | (cin & (a ^ b));
endmodule
^is XOR,&is AND,|is OR. Everyassignruns all the time, in parallel, like the wires it stands for.
各Verilog演算子を対応するゲートにマッチさせよ。
難易度 2/5 · 140 コイン + 今日初回達成時の小ボーナス
これらのビット演算子はゲートと1対1に対応するため、assign 行は回路図のように読めます。
The testbench checks it
- A testbench 测试平台 is code that drives inputs into the module and checks the outputs. It runs only in simulation 仿真 and never becomes hardware.
- It may use things hardware cannot: delays such as
#10, loops over test cases, and$displayto print results.
テストベンチにのみ使用される構文はどれか?
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
遅延はシミュレーションされますが合成されません: ハードウェアに #10 はありません。他の3つはすべてゲートまたはフリップフロップになります。
Worked example: an independent check
- The testbench drives all 8 combinations of
a,b,cinand checks $a + b + c_{in} = 2 \cdot c_{out} + s$ each time. All 8 pass. - The check uses arithmetic, not a second gate description. A copy of the design would repeat any mistake in it, so it would prove nothing.

5ビットの入力を持つブロックの完全テストベンチでは、何通りの入力組み合わせを試す必要がありますか?
難易度 2/5 · 140 コイン + 今日初回達成時の小ボーナス
$2^{5} = 32$。小さなブロックは完全に検証するのが安価ですが、64ビット加算器はそうではありません。そのため、大きな設計では部分の完全検証とランダムテストを併用します。
同一設計の第2のゲートコピーに対してフル加算器を検査するテスターは —
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
参照は独立している必要があります:演算($a + b + c_{in} = 2c_{out} + s$)または手動トレースです。再記述された実装は、あなたが探しているバグそのものを繰り返してしまいます。
Worked example: a shift register
- A 4-bit serial-in shift register is one clocked line. The concatenation
{q[2:0], sin}drops the top bit and putssinin at the right.
module shift4(input clk, sin,
output reg [3:0] q);
always @(posedge clk)
q <= {q[2:0], sin};
endmodule
- From 0000 with
sin= 1, 0, 1, 1, simulation shows q = 0001, 0010, 0101, 1011.
The concatenation becomes a clocked bit transfer
$Q^{+}=\{Q_2,Q_1,Q_0,sin\}$
Follow q <= {q[2:0], sin} at each rising edge. From an explicitly initialized 0000, the lesson’s inputs 1, 0, 1, 1 produce 0001, 0010, 0101, 1011. Each new position takes an old bit; the previous Q₃ shifts out.
4 ビットシフトレジスタ q <= {q[2:0], sin} は、初期値 0000 で開始し、sin = 1, 0, 1, 1 が4つのクロック期間にわたって入力される場合、q の遷移は —
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
各エッジで左へシフトし、右側に sin を受け入れることで、0001, 0010, 0101, 1011 が得られます。この連結がシフトです。
Three common slips
- A testbench that restates the design. It checks the code against itself; use arithmetic or a hand trace.
- Testbench constructs in a hardware module. Delays and
$displaydo not synthesise. - No reset. A register without one starts in an unknown state in hardware, even if simulation looks fine.
カウンタモジュールにはリセットがありません。シミュレーションではすべてのレジスタが x(不明)から開始されます。これは何を意味しますか?
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
実際のフリップフロップはランダムな値で起動します。シミュレーションにおける x は警告であり、シミュレータの不具合ではありません。リセットによってカウンタを既知の状態に戻せます。
Recap
| Module | Testbench | |
|---|---|---|
| Becomes | gates | nothing: it only simulates |
| May use | assign, always blocks |
also delays #10, loops, $display |
| Job | describe the circuit | drive inputs and check outputs |
- Check against an independent reference: arithmetic or a traced sequence.
- Small input spaces are checked exhaustively; ship each module with its testbench.
何が問題でしたか?この内容はサイトの運営チームだけが確認します。