HDL and verification basics
مُقدَّم
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.
وصف العتاد بالأكواد
- لغة وصف العتاد (HDL) مثل Verilog أو VHDL تصف ما هو الدائرة وكيفية سلوكها. يحول أداة التوليد البوابات منها إلى عتاد.
- فقط الكود القابل للتوليد يمكن أن يصبح عتاد: كتل
assignمستمرة،always @(*)وalways @(posedge clk)مسجلات.
Any Verilog that simulates correctly can be turned into gates.
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Simulation accepts constructs with no hardware meaning, such as delays and $display. Only the synthesizable subset becomes gates.
جمع كامل في أربعة أسطر
- يسرد الوحدة منافذها، ثم يحدد معادلتي الخرج من الدرس السابق.
module full_adder(input a, b, cin,
output sum, cout);
assign sum = a ^ b ^ cin;
assign cout = (a & b) | (cin & (a ^ b));
endmodule
^هي XOR،&هي AND،|هي OR. كلassignيعمل دائمًا وبشكل متوازٍ، مثل الأسلاك التي تمثلها.
Match each Verilog operator to its gate.
الصعوبة 2/5 · 140 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
These bitwise operators map one-to-one onto gates, which is why assign lines read like a schematic.
لوحة الاختبار تتحقق منه
- لوحة الاختبار هي كود يقود المدخلات إلى الوحدة ويتحقق من المخرجات. تعمل فقط في المحاكاة ولا تصبح عتاد أبدًا.
- قد تستخدم أشياء لا يستطيع العتاد فعلها: تأخير مثل
#10، حلقات تكرار لحالات الاختبار، و$displayلطباعة النتائج.
Which construct belongs ONLY in a testbench?
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Delays simulate but do not synthesise: hardware has no #10. The other three all become gates or flip-flops.
مثال محلول: تحقق مستقل
- تقود لوحة الاختبار جميع 8 تركيبات
a،b،cinوتتحقق من $a + b + c_{in} = 2 \cdot c_{out} + s$ في كل مرة. جميع 8 اجتازت. - يعتمد التحقق على الحساب، وليس وصف بوابة ثانٍ. نسخة من التصميم ستكرر أي خطأ فيه، لذا لن تثبت شيئًا.


An exhaustive testbench for a block with 5 one-bit inputs must try how many input combinations?
الصعوبة 2/5 · 140 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
$2^{5} = 32$. Small blocks are cheap to check completely; a 64-bit adder is not, which is why big designs mix exhaustive checks of parts with random tests.
A testbench that checks a full adder against a second gate copy of the same design is —
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
The reference must be independent: arithmetic ($a + b + c_{in} = 2c_{out} + s$) or a hand trace. A restated implementation repeats the very bug you are looking for.
مثال محلول: مسجل إزاحة
- مسجل إزاحة متسلسل 4-بت هو خط واحد يتم تشغيله بالنبضات. عملية الربط
{q[2:0], sin}تزيل البت العلوي وتضعsinعلى اليمين.
module shift4(input clk, sin,
output reg [3:0] q);
always @(posedge clk)
q <= {q[2:0], sin};
endmodule
- من 0000 مع
sin= 1، 0، 1، 1، يُظهر المحاكاة 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.
The 4-bit shift register q <= {q[2:0], sin}, starting at 0000, with sin = 1, 0, 1, 1 over four clocks traces q as —
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Each edge shifts left and admits sin on the right, giving 0001, 0010, 0101, 1011. The concatenation is the shift.
ثلاثة أخطاء شائعة
- مقياس اختبار يعيد صياغة التصميم. يتحقق من الكود مقابل نفسه؛ استخدم الحساب أو المسار اليدوي.
- هيئات مقياس الاختبار في وحدة عتادية. التأخير و
$displayلا يمكن تصنيعهما. - بدون إعادة تعيين. يبدأ المسجل بدون إعادة تعيين بحالة غير معروفة في العتاد، حتى لو كانت المحاكاة تبدو سليمة.
A counter module has no reset. In simulation every register starts at x (unknown). What does that tell you?
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Real flip-flops power up at random values. The x in simulation is a warning, not a simulator fault; a reset puts the counter in a known state.
مراجعة
- الوحدات القابلة للتصنيع تتحول إلى بوابات؛ مقياس الاختبار يقوم بالمحاكاة فقط.
- تحقق من مرجع مستقل: الحساب أو تسلسل تم تتبعه.
- تُفحص مساحات الإدخال الصغيرة بشكل شامل؛ يُرفق كل مقياس بمقياس الاختبار الخاص به.
ما المشكلة؟ لا يرى ذلك سوى فريق الموقع.