SystemVerilog Testbench | Generator File Development (Part 1) | SV Testbench for Decoder-Based RAM
Why It Matters
A well‑structured generator with mailbox‑based communication accelerates RAM verification, ensuring scalable, repeatable stimulus and faster defect identification.
Key Takeaways
- •Generator class randomizes transaction inputs before sending to driver.
- •Mailboxes mediate communication between generator and read/write drivers.
- •Constructor passes mailbox handles and configurable write/read counts.
- •Inline constraints ensure only write operations are randomized in phase one.
- •Acknowledgment mailbox confirms completion of each write transaction.
Summary
The video walks through building a SystemVerilog testbench generator for a decoder‑based RAM, focusing on the code that creates and drives stimulus transactions. After reviewing the verification plan, interface, and transaction class, the presenter introduces the RAM_generator class, which encapsulates mailbox handles, write/read counters, and a constructor that receives these handles from the environment.
Key implementation details include randomizing transaction fields (address and data) while fixing the operation to a write, using an inline constraint ("with {op==WRITE;}") to enforce this rule. The generator places each randomized transaction into a write mailbox, which the write driver consumes, and then waits for a bit‑type acknowledgment from a separate write_done mailbox. The constructor also accepts configurable numbers of writes and reads, defaulting to 32 each, allowing flexible test scenarios.
The presenter highlights that mailbox instances must be created in the top‑level environment—not inside the generator or driver—to enable proper communication. An interview‑style Q&A illustrates alternative ways to pass handles, such as a dedicated getter method, but emphasizes the common practice of using the new() constructor for handle propagation. The example also shows how a dynamic array stores generated addresses for later reference.
By modularizing stimulus generation, mailbox coordination, and acknowledgment handling, the approach streamlines verification of the decoder‑based RAM, improves reusability across projects, and reduces manual testbench maintenance. Engineers can quickly adjust transaction depth, inject constraints, and monitor driver responses, accelerating functional coverage and bug detection.
Comments
Want to join the conversation?
Loading comments...