whats the solution of this code ? showing error in get() the mailbox data
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
In reply to vlsique:
What is your problem? Works for me.
In reply to dave_59:
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
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