RTL Studio Open IDE

2.2 · SYSTEMVERILOG CLASS

Queues

Use push_back() and pop_front() to manage dynamic data buffers with queues.

Watch on YouTube

What you practice

Queues (2.2). Use push_back() and pop_front() to manage dynamic data buffers with queues. It is in Dynamic Data Types — Part 2 · Verification & OOP of the SystemVerilog Masterclass. Software-side verification: dynamic data structures, classes, and the first UVM master keys.

The same IDE is the SystemVerilog simulator. Slang lints the file, Verilator runs it, and the waveform viewer sits next to the source.

What you will learn

Today you will learn how to use SystemVerilog queues for dynamic buffer management by implementing push_back() and pop_front() operations in a testbench.

Learning objectives

  • Declare and initialize a queue using int q[$].
  • Use push_back() to append elements to the end of the queue.
  • Use pop_front() to remove and retrieve elements from the front of the queue.
  • Verify queue behavior with $display and size checks.

Theory

Queues in SystemVerilog are dynamic arrays that support efficient insertion and removal at both ends. They are declared with type q[$] and provide built-in methods like push_back(), pop_front(), push_front(), and pop_back(). The size() method returns the current number of elements.

MethodOperation
push_back()Append element to the end
pop_front()Remove and return first element
size()Return current number of elements

Queues grow and shrink automatically — ideal for FIFOs, packet buffers, and task scheduling.

Practice

  1. Open this chapter in RtlStudio — files appear automatically in Explore.
  2. Open student/tb/tb.sv from the Explore tree.
  3. Replace q.__TODO__(i * 10) with the correct method call to push elements onto the queue.
  4. Replace q.__TODO__() with the correct method call to pop elements from the queue.
  5. Run Simulation from the sidebar and check the Log panel for INFO: messages.
  6. Confirm the final INFO: PASS line appears after all elements are popped.

Summary

You practiced implementing FIFO behavior using SystemVerilog queues by inserting elements with push_back() and removing them with pop_front(). This demonstrated how queues provide efficient, dynamic buffer management for verification and OOP tasks. Queues are especially valuable for modeling streaming data, transaction logs, and testbench stimulus generation.

Run it in the Verilog IDE

  1. Open the lesson in the IDE. The SystemVerilog for this topic is already in the editor.
  2. Lint with Slang before you simulate. It covers both Verilog and SystemVerilog in this IDE.
  3. Run Verilator and inspect the VCD. Interfaces, classes, and assertions count only if the simulator agrees.
  4. Run Yosys when the lesson is synthesizable RTL, and keep testbench-only constructs out of that module.

The lesson is done when the simulation matches Queues. Change the source, run the Verilog simulator again, and read the waveform without leaving the IDE. Simulation guide · Yosys guide.