RegisterLogin  
Update Profile
   
You are here: Forum  
Minimize 
SVUG Community Forum
Subject: Difference between mailbox and queue
Prev Next
You are not authorized to post a reply.

Author Messages
DIPAKUser is Offline

Posts:4

12/11/2009 10:57 PM  
Hello,

My understanding for mailbox is that if we only use get method for mailbox and don't have any put method it will block the execution thread untill we did not put anything.
But I have below code in which I am use only get method, I am not using put method.

What is my understanding is simulation should be hang, But I am not seeing this result, Simulation end gracefully.

Can anyone help me or guide me.

Regards,
Dipak
mailbox transfer = new();

endclass

class test;
 
   myclass c ;
   function  new();
     c = new ;
   endfunction: new

   task get_type (int y);

      c.transfer.get(y);

   endtask:get_type

endclass:test

module top();

  test d;
  int x,y;
 
  initial
  begin
    d = new ();
    x = 5;
    d.get_type(x);
    $display("y before : %0d" , y);
    $display("y : %0d" , y);
  end

endmodule

DAVEUser is Offline

Posts:56

12/13/2009 10:55 PM  
Dipak,

Your simulation might end gracefully because it determines there is nothing left to do, but did it print all the output it was supposed to?

Also, there are a couple of problems with your code, once you do try to add a put method.

1. In your task get_type(int y), the argument y is declared by default as an input to the task. So in the call d.get_type(x), x will not get updated.

2. You are $display'ing the y that is local to module top and never assigned. The y that is inside the class/task definition is not visible from module top.

3. Your mailbox declaration should always be parametrized with the type transaction you plan to put in the mailbox. There is no way to test the type of the object put into a mailbox, and it's much safer to have the compiler check it than to find out somewhere long into your run time.

mailbox #(int) transfer;
SHALOMUser is Offline

Posts:47

12/14/2009 3:35 AM  
Your simulation might end gracefully because it determines there is nothing left to do, but did it print all the output it was supposed to?


I tried the example myself. I got the same behavior. I added a $display statement before the get_type call and found that the $display before the get_type was printed, but not the $display after the get_type. This happened to me on two simulators from different companies.

Shalom
You are not authorized to post a reply.
Forums > General Discussion > Main Discussion Area > Difference between mailbox and queue



ActiveForums 3.7
  

 Copyright 2008 by SystemVerilog User Group Contact Us    Privacy Statement