Verilog RTL I – Fundamentals
Combinational, arithmetic, sequential, counters, timers
What you will learn and practise
Complete the stages in order and retain the requested evidence.
Verilog module/ports/nets/variables
Operators and continuous assignment
Parameters; hierarchy and instantiation
Compilation and basic simulation flow
1. AND/OR/XOR/XNOR
2. NAND/NOR
3. Multi-gate module
4. Half adder
5. Full adder
6. Full adder using half adders
7. Half/full subtractor
8. 4-bit ripple adder
9. Parameterized N-bit adder
10. Comparator
11. Parity generator/checker
Fix syntax, width, port and undeclared-signal bugs
Write one parameterized arithmetic block
Working RTL + basic TB for arithmetic blocks
Build and simulate synthesizable Verilog fundamentals using correct modules, ports, signals, operators, hierarchy and parameters.
- Create project_workspace/week2_verilog_rtl1/day6 with rtl, tb, sim and logs directories.
- Use Icarus Verilog for compile/simulation and GTKWave for waveform inspection.
- Keep one compile/run log for the final evidence.
- Implement AND, OR, XOR, XNOR, NAND and NOR modules.
- Implement half adder and full adder, then build a full adder hierarchically from half adders.
- Implement half/full subtractor and a 4-bit ripple-carry adder.
- Convert the adder into a parameterized N-bit module.
- Implement comparator and parity generator/checker blocks.
- Write a basic testbench that exercises nominal and boundary input combinations.
- Explain the difference between a net and a procedural variable in Verilog.
- Explain continuous assignment and when assign is appropriate.
- Explain why explicit vector widths matter in arithmetic RTL.
- Describe parameter elaboration and one benefit of parameterized RTL.
- Draw the hierarchy of a full adder built from two half adders and identify all interconnect signals.
Repair instructor-provided syntax, port-map, undeclared-signal and width-mismatch defects, then explain each correction.
- RTL source files
- basic testbench
- compile/simulation log
- waveform or terminal result
- written answers
- All required modules compile without errors
- Testbench demonstrates correct arithmetic behavior
- Parameterized block works for at least two widths
- Learner can explain module/port/net/parameter choices
Build, run and retain evidence
project_workspace/week2_verilog_rtl1/day6_fundamentals/
rtl/gates.vrtl/half_adder.vrtl/full_adder.vrtl/ripple_adder.vrtl/adder_n.vrtl/comparator.vrtl/parity.vtb/tb_day6.v
- All basic gate truth-table combinations
- Half/full adder carry cases
- 4-bit ripple adder 0+0, 1+1, 15+1 and representative vectors
- Parameterized adder at two widths
- Comparator equal/less/greater cases
- Parity even/odd cases
iverilog -g2012 -Wall -o sim/day6.vvp rtl/*.v tb/tb_day6.vRunvvp sim/day6.vvp | tee logs/day6.logWaveformgtkwave sim/day6.vcd- Testbench terminates with PASS
- No $fatal/$error
- Compile has no errors
- Required VCD and log exist
Review before completing Day 6
- MCQ
Which Verilog object represents a continuously driven connection?
Review answer
wire
- Code reading
For output [W:0] sum = {1'b0,a}+{1'b0,b}, explain why the output is W+1 bits.
Review answer
The extra bit preserves carry-out.
- Debug
A 4-bit adder declares a 4-bit result but must preserve carry. Identify the defect.
Review answer
The result width is insufficient; use W+1 bits or a separate carry.
- Short answer
Why is named port mapping safer for larger hierarchical RTL?
Review answer
It makes signal-to-port intent explicit and reduces ordering mistakes.
Fundamentals
- modules/ports
- nets/variables
- operators/assign
- parameters/hierarchy
- basic simulation
Assessment: Q1