# Queue in System verilog

**URL:** <https://verificationacademy.com/forums/t/queue-in-system-verilog/34024>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, queue\
**Created:** [February 5, 2018, 6:44am UTC](https://verificationacademy.com/forums/t/queue-in-system-verilog/34024 "2018-02-05T06:44:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mudititm](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/d26b3c/32.png) [@mudititm](https://verificationacademy.com/forums/u/mudititm)\
**Post date:** [February 5, 2018, 6:44am UTC](https://verificationacademy.com/forums/t/queue-in-system-verilog/34024/1 "2018-02-05T06:44:43Z")

</div>

whats the solution of this code ? showing error in **get() the mailbox**  **data**

```verilog
module top;

   class sample;

	//Queue check

	int intQ[$];

	mailbox mbox = new();

	int a;

	task run();

		fork

		begin

			//repeat (10) intQ.push_back ($urandom_range(11, 100));

			repeat (10) mbox.put($urandom_range(11, 100));

		end

		begin

			repeat(10) begin

			//a = intQ.pop_front();

			mbox.get(a);

			$display("a = %d", a);

			end

		end

		join

	endtask

endclass

sample s_inst;

   initial begin

	   s_inst = new();

	   s_inst.run();

   end

endmodule

```

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [February 5, 2018, 7:16am UTC](https://verificationacademy.com/forums/t/queue-in-system-verilog/34024/2 "2018-02-05T07:16:33Z")

</div>

_In reply to [vlsique](https://verificationacademy.com/forums/t/queue-in-system-verilog/34024):_

What is your problem? Works for me.

---

<div class="post-metadata">

**Author:** ![mudititm](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/d26b3c/32.png) [@mudititm](https://verificationacademy.com/forums/u/mudititm)\
**Post date:** [February 5, 2018, 9:03am UTC](https://verificationacademy.com/forums/t/queue-in-system-verilog/34024/3 "2018-02-05T09:03:05Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/queue-in-system-verilog/34024/2):_

ncsim: \*E,MBXWID (./ii.sv,31|10): The type of the message variable is not equivalent to the type of the message in the mailbox [SystemVerilog].  
a = 0  
mbox.get(a);  
|  
ncsim: \*E,MBXWID (./ii.sv,31|10): The type of the message variable is not equivalent to the type of the message in the mailbox [SystemVerilog].  
a = 0  
mbox.get(a);  
|  
ncsim: \*E,MBXWID (./ii.sv,31|10): The type of the message variable is not equivalent to the type of the message in the mailbox [SystemVerilog].  
a = 0  
ncsim: \*W,RNQUIE: Simulation is complete.  
ncsim\> exit

---

<div class="post-metadata">

**Author:** ![Subhra\_Bera](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/subhra_bera/32/3838_2.png) [@Subhra\_Bera](https://verificationacademy.com/forums/u/Subhra_Bera)\
**Post date:** [February 7, 2018, 10:21am UTC](https://verificationacademy.com/forums/t/queue-in-system-verilog/34024/4 "2018-02-07T10:21:52Z")

</div>

```verilog
module top;
 
   class sample;
 
	//Queue check
 
	int intQ[$];
     
     mailbox mbox = new();
 //inspite of int I declared logic here
     logic[31:0] a;
 
	task run();
 
		fork
 
		begin
 
			//repeat (10) intQ.push_back ($urandom_range(11, 100));
 
			repeat (10) mbox.put($urandom_range(11, 100));
 
		end
 
		begin
 
			repeat(10) begin
 
			//a = intQ.pop_front();
 
			mbox.get(a);
 
			$display("a = %d", a);
 
			end
 
		end
 
		join
 
	endtask
 
endclass
 
sample s_inst;
 
   initial begin
 
	   s_inst = new();
 
	   s_inst.run();
 
   end
 
endmodule

```

Actually it’s a tool specific problem.  
You have not parameterized your mailbox. So there was a mismatch in data types. What you are putting in the queue is logic[31:0] data type. But tried to get the data in int type varible. That’s where the problem was. I have changed the code. Now it works fine. **Always try to use parametized mailbox.**  
Thanks  
Subhra
