Verilog Verification – Self-Checking
Testbenches, self-checking, regression, debugging
What you will learn and practise
Complete the stages in order and retain the requested evidence.
Expected-value generation
Reference model concept
Automatic checking
Boundary/corner testing
Result summaries
1. Self-check adder/MUX/comparator
2. ALU reference model
3. Counter/shift register checkers
4. Timer checker
5. FSM checker
6. Register-block checking
7. FIFO checker
8. Arbiter checker
9. IRQ controller checker
10. Auto summary TOTAL/PASS/FAIL/ERROR
Inject one DUT bug and prove checker catches it
Write test plan for timer or FIFO
Self-checking TB + test plan
Extend the reusable Day 16 testbench into a self-checking Verilog environment with an explicit expected-value model, automatic comparisons, boundary/corner tests, error accounting, and a concise test plan.
- Create project_workspace/week4_verilog_verification/day17_self_checking with rtl, tb, sim, logs and docs directories.
- Reuse the deterministic clock/reset and PASS/FAIL discipline established on Day 16.
- Use plain Verilog verification constructs only; SystemVerilog classes/interfaces, SVA, coverage and UVM are outside Week 4.
- Create a parameterized ALU DUT with arithmetic, logical and compare operations suitable for deterministic checking.
- Define expected-result generation independently in the testbench rather than copying DUT implementation structure.
- Create a reusable check task that compares actual and expected result and updates TOTAL/PASS/FAIL/ERROR counters.
- Run nominal directed tests for every supported ALU operation.
- Add boundary vectors: all-zero, all-one, maximum positive, sign-boundary and carry/overflow-relevant operands where applicable.
- Add repeated vector execution so every check is reported consistently without manual waveform inspection.
- Adapt the same checker pattern conceptually to counter, timer, FSM, register block, FIFO, arbiter and IRQ-controller outputs from earlier weeks.
- Inject one intentional DUT defect, prove that the checker reports failure, save the failing evidence, restore the DUT and rerun to PASS.
- Generate a final TOTAL/PASS/FAIL/ERROR summary and retain log/VCD evidence.
- Write a compact timer-or-FIFO test plan mapping requirements to nominal, boundary, negative and error-oriented tests.
- Explain the difference between DUT implementation logic and an independent reference/expected-value model.
- Prepare a test matrix containing requirement, stimulus, expected result and evidence for at least eight cases.
- Explain why boundary and corner tests are necessary even when nominal tests pass.
- Document the injected defect, the exact checker failure, root cause and clean rerun result.
Inject a single functional defect into the ALU (for example, an incorrect operation selection or arithmetic result), demonstrate that the self-checker catches it without relying on visual waveform inspection, then patch and rerun with FAIL=0.
- rtl/alu.v and tb/tb_alu_selfcheck.v
- logs/day17_selfcheck_fail.log showing the injected defect was detected
- logs/day17_selfcheck_pass.log showing the corrected DUT passes
- sim/day17_selfcheck.vcd
- docs/test_plan.md mapping requirements to tests and expected results
- Expected values are generated independently from DUT implementation structure.
- Nominal and boundary/corner cases are automatically checked.
- Injected DUT bug produces at least one deterministic FAIL/ERROR result.
- Corrected DUT rerun reports TOTAL > 0 and FAIL=0.
- Test plan and simulation evidence are retained in project_workspace.
Understand the architecture and debug flow
Independent expected-value generation is compared automatically with DUT output.
The unchanged checker must expose the defect before patching and then prove the clean rerun.
Build, run and retain evidence
project_workspace/week4_verilog_verification/day17_self_checking/
rtl/alu.vtb/tb_alu_selfcheck.vsim/day17_selfcheck.vvpsim/day17_selfcheck.vcdlogs/day17_selfcheck_pass.logdocs/test_plan.md
- Every documented ALU operation has at least one nominal self-checking test.
- Zero, all-one and arithmetic boundary vectors are exercised.
- Expected result is computed in the testbench and compared automatically.
- TOTAL/PASS/FAIL/ERROR counters are printed at completion.
- An intentionally injected DUT bug is detected without manual waveform judgement.
- After repair, the same regression finishes with FAIL=0.
- Test-plan entries identify requirement, stimulus, expected result and evidence.
iverilog -g2012 -Wall -o sim/day17_selfcheck.vvp rtl/alu.v tb/tb_alu_selfcheck.vRunvvp sim/day17_selfcheck.vvp | tee logs/day17_selfcheck_pass.logWaveformgtkwave sim/day17_selfcheck.vcd- Compile completes without errors.
- Injected-bug run records a deterministic checker failure.
- Clean run reports TOTAL > 0, PASS = TOTAL and FAIL = 0.
- Boundary/corner cases are present in the retained test list.
- Test plan, logs and waveform are retained under project_workspace.
Review before completing Day 17
- Concept
What makes a Verilog testbench self-checking?
Review answer
It generates or stores expected behavior, compares DUT outputs automatically, records pass/fail status, and produces an objective summary without requiring a person to judge every waveform.
- Reasoning
Why should a reference model avoid simply duplicating the DUT implementation?
Review answer
Duplicating the same structure can reproduce the same design mistake in both places. An independently expressed expected model improves the chance that implementation defects are detected.
- Coverage reasoning
What is the purpose of boundary and corner tests on Day 17?
Review answer
They exercise values and transitions where width, sign, carry, reset, limit and state-related defects commonly appear even when ordinary nominal vectors pass.
- Debug
What evidence proves that the checker itself is capable of detecting a defect?
Review answer
An intentionally injected DUT defect must produce a deterministic FAIL/ERROR result, followed by a corrected DUT run using the same checker that finishes with FAIL=0.
Self-checking Verilog verification
- Generate expected values independently from DUT implementation.
- Automate actual-versus-expected comparison and result accounting.
- Design nominal, boundary and corner tests from requirements.
- Demonstrate checker effectiveness through controlled defect injection.
- Produce a requirement-to-test plan and retain reproducible evidence.
Assessment: Week 4 automated self-checking testbench, injected-bug detection, test-plan evidence