Week 2 · Day 9 · 7 hours

Verilog RTL I – Sequential

Combinational, arithmetic, sequential, counters, timers

Daily plan

What you will learn and practise

Complete the stages in order and retain the requested evidence.

Theory · 2h

Clocked always blocks
Non-blocking assignment
Sync/async reset
Enable/load/clear patterns
Shift registers

Guided lab · 2h

1. DFF
2. Sync-reset DFF
3. Async-reset DFF
4. Enable DFF
5. 4/8-bit registers
6. Register with load/clear

Independent lab · 2h

7. SISO/SIPO/PISO/PIPO
8. Bidirectional shift register
9. Universal shift register
10. Toggle FF
11. Edge detector
12. Pulse generator/stretcher

Debug and assignment · 1h

Debug blocking/NBA misuse, reset polarity, clock edge
Waveform explanation exercise

Expected deliverable

Sequential RTL collection + waveforms

Practical work

Implement predictable sequential RTL using nonblocking assignments, defined reset behavior, enables and shift-register structures.

Setup
  1. Create project_workspace/week2_verilog_rtl1/day9.
  2. Use a repeatable clock/reset testbench.
  3. Capture waveforms for reset, enable/load and normal operation.
Execution steps
  1. Implement DFF, synchronous-reset DFF and asynchronous-reset DFF.
  2. Implement enable DFF and 4/8-bit registers.
  3. Implement register with load/clear.
  4. Implement SISO, SIPO, PISO and PIPO shift registers.
  5. Implement bidirectional and universal shift registers.
  6. Implement toggle FF, edge detector and pulse generator/stretcher.
  7. Verify reset and control priority using waveforms.
Written assignment
  1. Why are nonblocking assignments preferred for clocked state updates?
  2. Compare synchronous and asynchronous reset behavior.
  3. Explain the effect of reset polarity and reset priority.
  4. Describe load/enable/clear priority for a register specification.
  5. From a supplied waveform, identify the sampling edge and explain the observed state transitions.
Debug challenge

Repair blocking/nonblocking misuse, incorrect reset polarity and wrong clock-edge sensitivity, then compare the corrected waveform.

Evidence to retain
  • sequential RTL collection
  • testbench
  • annotated waveform screenshots/files
  • debug notes
  • written answers
Completion criteria
  • State changes only at intended clock events
  • Reset behavior matches specification
  • Control priority is verified
  • Waveform explanation matches RTL semantics
Executable lab

Build, run and retain evidence

project_workspace/week2_verilog_rtl1/day9_sequential/

Required files
  • rtl/dff.v
  • rtl/register.v
  • rtl/shift_registers.v
  • rtl/edge_pulse.v
  • tb/tb_day9.v
Mandatory tests
  • Synchronous and asynchronous reset behavior
  • Enable hold/update
  • Load/clear priority
  • SISO/SIPO/PISO/PIPO multi-cycle movement
  • Bidirectional/universal shift behavior
  • Edge detector/pulse timing
Compile
iverilog -g2012 -Wall -o sim/day9.vvp rtl/*.v tb/tb_day9.v
Run
vvp sim/day9.vvp | tee logs/day9.log
Waveform
gtkwave sim/day9.vcd
PASS criteria
  • State changes only as specified
  • Reset/control priority checks PASS
  • No compile errors
  • Waveform shows required clock-edge evidence
Knowledge check

Review before completing Day 9

  1. MCQ

    Which assignment type is normally used for state registers in clocked RTL?

    Review answer

    Nonblocking assignment (<=).

  2. Code reading

    What is the behavioral difference between synchronous and asynchronous reset?

    Review answer

    Synchronous reset acts on the active clock edge; asynchronous reset can act independently through the event control.

  3. Debug

    A register updates with blocking assignment inside posedge logic. Why is this unsafe style?

    Review answer

    It can create simulation ordering/race behavior unlike simultaneous register updates.

  4. Short answer

    Why must load, clear and enable priority be explicitly defined?

    Review answer

    Simultaneous controls otherwise have ambiguous intended behavior.

Skills and assessment traceability

Sequential RTL

  • clocked always
  • nonblocking assignment
  • reset
  • enable/load/clear
  • shift/pulse behavior

Assessment: Q4