• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Functional Verification
  3. mailboxes

Stats

  • Locked Locked
  • Replies 8
  • Subscribers 64
  • Views 16546
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

mailboxes

archive
archive over 17 years ago

Dear users,

I'm very new in programming SystemVerilog and hope, you can help me.

I just wanna use a mailbox inside a class and have written the following code:

class test;

.................

mailbox mbx_get;                           // mbx_get: layer gets data, mbx_put: layer sends data, mbx_int1 and mbx_int2: intern mailbox
mailbox mbx_put;
mailbox mbx_int1;
mailbox mbx_int2;
 
mbx_int1 = new;                           // mbx_int1: send (intern) from attach_header() to snd_pkt_phy()
mbx_int2 = new;                           // mbx_int2: send (intern) from receive_pkt_phy() to remove_header()


// Code

endclass : test


Note: class declaration is inside a program block.
Trying to compile this code fails with the error message (there are more, but these are the first:

ncvlog: *E,NOIPRT (class_layer2.sv,25|8): Unrecognized declaration 'mailbox' [SystemVerilog].
  mailbox mbx_put;
        |
ncvlog: *E,NOIPRT (class_layer2.sv,26|8): Unrecognized declaration 'mailbox' [SystemVerilog].
  mailbox mbx_int1;
        |
ncvlog: *E,NOIPRT (class_layer2.sv,27|8): Unrecognized declaration 'mailbox' [SystemVerilog].
  mailbox mbx_int2;
        |
ncvlog: *E,NOIPRT (class_layer2.sv,28|8): Unrecognized declaration 'mailbox' [SystemVerilog].


Can you tell me what to to. Searching by google just give me one hit and so, I couldn't solve the problem. Do I have to include something equivalent to the header-files in C programming language?

My second question ist the following:
I want to separate my classes from the program. Is there any possibility to generate something like object-files containing my classes?

I hope you can help me.
Thanks and best wishes!
Sebastian


Originally posted in cdnusers.org by sebastian
  • Cancel
  • archive
    archive over 17 years ago

    I'm not sure about the errors you received (class not recognized) unless you either didn't pass the +sv switch to ncverilog (or use irun with a file with a .sv extension) or you were using a fairly old version (IUS58 or older).

    However, there are some coding errors. You typically construct the mailbox outside the class and then pass the handle into the class via the new method.

    module test;
     class mb_test;
       mailbox mbx_get;
       mailbox mbx_put;

       function new(mailbox m1, m2);
         mbx_int1 = m1;
         mbx_int2 = m2;
       endfunction

       // Code
     endclass :

     mb_test mailbox mb_in = new();
     mailbox mb_out = new();

     mb_test t = new(mb_in, mb_out);

    endmodule


    Originally posted in cdnusers.org by tpylant
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • archive
    archive over 17 years ago

    Hi Sebastian,
    I suspect you have an old IUS version, do ncvlog -version

    Here is a simple code that should work fine in NC, as a starting point.
    program test(); mailbox mbx; initial begin mbx = new(); end endprogram

    In your code you seem to be missing initial begin, but maybe you posted pseudo-code here.

    Some old version didn't support mailbox and Cadence folks wrote a custom class for the same, you can try and find it in this forum, but I recommend you upgrade to latest release.

    HTH
    Ajeetha, CVC
    www.noveldv.com


    Originally posted in cdnusers.org by ajeetha
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • archive
    archive over 17 years ago

    I'm not sure about the errors you received (class not recognized) unless you either didn't pass the +sv switch to ncverilog (or use irun with a file with a .sv extension) or you were using a fairly old version (IUS58 or older).

    However, there are some coding errors. You typically construct the mailbox outside the class and then pass the handle into the class via the new method.

    module test; class mb_test; mailbox mbx_get; mailbox mbx_put; function new(mailbox m1, m2); mbx_int1 = m1; mbx_int2 = m2; endfunction // Code endclass : mb_test mailbox mb_in = new(); mailbox mb_out = new(); mb_test t = new(mb_in, mb_out); endmodule <\code>


    Originally posted in cdnusers.org by tpylant
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • archive
    archive over 17 years ago

    Hi,

    thanks for the really fast and very very professional answers. A ncvlog -version says me, that my version is 5.7, which ist too old, isn't it?
    Even your little testprogram does not compile, because the unrecognized option mailbox. I think, I should ask the system administrator for installing a newer version of systemverilog.

    A basic question I have is the following: can I create a mailbox or any object inside a class? I think it is possible. The reason, I have declared the two mailboxes inside the class is, that I have two forever tasks, which read and write in these mailboxes.Even if it is bad programmig style, I would be interested, if it is possible.

    Best regards
    Sebastian


    Originally posted in cdnusers.org by sebastian
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • archive
    archive over 17 years ago

    We addressed that exact topic almost exactly a year ago before we had support for classes. I did a search on mailboxes from this forum and found it. Go to http://www.cdnusers.org/Forums/tabid/52/view/topic/forumid/66/postid/2739/Default.aspx and you can find the discussion and an attachment that has the code for creating a mailbox class.

    Tim


    Originally posted in cdnusers.org by tpylant
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • archive
    archive over 17 years ago

    Thanks for your help.

    I thougth, mailboxes are a genial invention, but actually I have problems over problems: I wanted to put an string into a mailbox, but it seems to me, that this isn't working, is that correct?
    I'm really sorry about my silly questions, but there is no one else I could ask and I am really disappointed!

    Another question is, how I can simulate a written program in SystemVerilog. I call ncvlog -SV filename.sv, but after that, no file for simulation is ready.
    Could you help me???

    Thanks for your patience!
    Sebastian


    Originally posted in cdnusers.org by sebastian
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • archive
    archive over 17 years ago

    Me again:

    Thank you very much for the code examples, I'm trying to understand this code at the moment. You've helped me a lot.

    Best wishes
    Sebastian


    Originally posted in cdnusers.org by sebastian
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • archive
    archive over 17 years ago

    >> Another question is, how I can simulate a written program in SystemVerilog.
    >> I call ncvlog -SV filename.sv, but after that, no file for simulation is ready.

    You need to elab and then simulate. Rather I believe the recommended approach going forward is to use the modern, more powerful "irun" command.

    Try:


      irun my_file.sv


    HTH
    Ajeetha, CVC
    www.noveldv.com  


    Originally posted in cdnusers.org by ajeetha
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information