Skip to content
asicguru.tech@gmail.com
REGISTER LOGIN
AsicGuru Ventures
  • All Courses
  • CONTACT
  • GALLERY
  • HOME
  • Tutorials

0

Verilog Tutorial

17
  • Introduction
  • Lexical Tokens
  • Gate-Level Modelling
  • Data Types
  • Operators
  • Operands
  • Modules
  • Behavioral Modeling
  • Timing Controls
  • Procedures: Always and Initial Blocks
  • Functions
  • Tasks
  • Component Inference
  • Finite State Machines.
  • Compiler Directives
  • System Tasks and Functions
  • Test Benches

System Verilog

23
  • System Verilog Introduction
  • Data Types
  • Type Casting
  • Arrays
  • Associative Arrays
  • Dynamic Arrays
  • Queue
  • Operators
  • Procedural statements and Control flow
  • Classes
  • Inheritance
  • Encapsulation
  • This and Super operator
  • In-Line Constraints
  • Class Constraints
  • Virtual Classes
  • Parameterized Classes
  • Classes Summary
  • Singleton Classes
  • Functional Coverage Introduction
  • Covergroup
  • Tools
  • Books

Scripting

15
  • Introduction
  • Perl Tutorial
  • What is Perl
  • Perl: Syntax And Variable
  • Perl Strings
  • Perl Arrays
  • Perl Associative Arrays
  • If/While Syntax
  • File Input
  • Print Output
  • String Processing with Regular Expressions
  • Subroutines
  • Running External Programs
  • References
  • Terse Perl

Makefile

1
  • Makefile Tutorial

Interview Questions

2
  • SystemVerilog Interview Questions
  • Verilog Interview Questions

Handwritten Notes

3
  • Perl (Scripting)
  • Linting
  • CMOS Logic Design
View Categories
  • Home
  • Tutorials
  • System Verilog
  • Queue

Queue

2 min read

What is a Queue? #

A queue in SystemVerilog is a variable-size, ordered collection of homogeneous elements (i.e., all of the same type). It is a single-dimensional unpacked array that can grow or shrink dynamically during simulation.

Unlike fixed-size arrays, queues do not require a predefined upper limit, making them highly useful for scenarios where data sizes vary.

Syntax:

data_type queue_name[$];         // Unbounded queue

Why Use Queues? #

Queues offer two major advantages in verification:

1. Dynamic Size #

  • A queue can hold zero or more elements at any time.
  • You don’t need to define an artificial limit like in fixed-size arrays.
  • Ideal for dynamic data storage such as:
    • Transaction lists
    • Packets of unknown size
    • Temporary buffers

2. Ordered Access & Flexible Behavior #

  • Can emulate both:
    • FIFO behavior using push_back() and pop_front()
    • LIFO behavior using push_back() and pop_back()
  • Still allows direct index access like a regular array.

Example: Declaring and Using a Queue

module test;
  int q[$];  // Declare an unbounded queue
  int val;   
  initial begin
    q.push_back(10);        // q = {10}
    q.push_front(5);        // q = {5, 10}
    q.push_back(20);        // q = {5, 10, 20}

    $display("Queue: %p", q);               
    $display("First: %0d", q[0]);         
    $display("Last:  %0d", q[$]);           

    val = q.pop_front();                    // Removes 5
    $display("After pop_front: %p", q);     

    q.delete();                             // Delete entire queue
    $display("Size after delete: %0d", q.size());  
  end
endmodule

Output:

Queue: '{5, 10, 20} 
First: 5
Last:  20
After pop_front: '{10, 20} 
Size after delete: 0

Built In Methods

MethodDescription
push_front(item)Insert item at front
push_back(item)Insert item at end
pop_front()Remove and return item from front
pop_back()Remove and return item from end
insert(index, val)Insert value at a specific index
delete(index)Delete element at a specific index
delete()Delete all elements
size()Return current number of elements

When to Use Queues #

Use a queue when:

  • You need flexible data structures that grow/shrink during simulation
  • You’re implementing FIFO/LIFO transaction handling
  • You require random access with constant time performance
  • You want to simulate hardware buffers, transaction pools, or event queues
Updated on August 4, 2025

What are your Feelings

  • Happy
  • Normal
  • Sad
Share This Article :
  • Facebook
  • X
  • LinkedIn
  • Pinterest
Dynamic ArraysOperators

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Table of Contents
  • What is a Queue?
  • Why Use Queues?
    • 1. Dynamic Size
    • 2. Ordered Access & Flexible Behavior
  • When to Use Queues

Archives

  • May 2025

Categories

  • Slider Post
  • Uncategorized

Copyright @ Asicguru Ventures by Misbah WP | Proudly powered by WordPress