Part 6 · Testbench Architecture · Intermediate
Testbench Anatomy & Layering
Hub — the layered testbench stack, tb_top harness, environment class, test classes, the program-block debate, and a complete mini testbench walkthrough.
Overview
A class-based testbench has two worlds: the static module world (tb_top, clocks, resets, interfaces, the DUT) and the dynamic class world (transactions, generators, drivers, monitors, scoreboards, environments, tests). The static world exists at elaboration; the dynamic world is constructed at run time and reaches pins only through virtual interface handles. This topic dissects each layer, shows the construction conventions, and ends with a complete annotated mini testbench.
Sub-topics
The Layered Testbench — signal/command/functional/scenario/test layers and why layering enables reuse.
tb_top: The Static Harness — clock/reset generation, interface instances, DUT hookup, vif handoff.
The Environment Class — the container that constructs components and wires mailboxes.
Tests as Classes — base_test, derived tests, plusarg selection, end-of-test orchestration.
program Blocks: Use or Skip? — what program changes and why much of industry skips it.
Walkthrough: Complete Mini Testbench — end-to-end annotated TB for a simple DUT.
TB ANATOMY — topic map
TEST LAYER base_test, smoke_test, stress_test (lesson 4)
│ builds
ENVIRONMENT env: gen + drv + mon + scb + wiring (lesson 3)
│ runs inside
STATIC HARNESS tb_top: clk, rst, interface, DUT (lesson 2)
│ scheduling semantics
program vs module the race-avoidance debate (lesson 5)
All layers stacked: THE LAYERED TESTBENCH (lesson 1)
All layers together: COMPLETE MINI TESTBENCH (lesson 6)Key takeaways
Static module world and dynamic class world meet only at the virtual interface boundary.
Each layer has one responsibility — that is what makes pieces swappable and reusable.
The mini-testbench walkthrough (lesson 6) is the interview deliverable; earlier lessons build it piece by piece.