Ready-to-run snippets

Code Examples

Ready-to-run Verilog, SystemVerilog, and UVM examples. Click any to open it live in the IDE.

← All examples

Queues

SystemVerilog Data Types

Simple introduction to SV Queues, see more at https://www.chipverify.com/systemverilog/systemverilog-queue

Open in IDE
testbench.v
module tb;
  	// Create a queue that can store "string" values
  	string   fruits[$] =  { "orange", "apple", "kiwi" };

	initial begin
   		// Iterate and access each queue element
  		foreach (fruits[i])
    		$display ("fruits[%0d] = %s", i, fruits[i]);

  		// Display elements in a queue
  		$display ("fruits = %p", fruits);

      	// Delete all elements in the queue
      	fruits = {};
      	$display ("After deletion, fruits = %p", fruits);
	end
endmodule
Admin mode — edit and delete controls are visible on each row. Use the IDE to add new snippets via File → Save as Snippet.