• 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. Ref to variables

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 65
  • Views 13117
  • 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

Ref to variables

Leo1008
Leo1008 over 15 years ago

 Hi,

I wanted to know if I can pass, to a class method , references of variables not defined in that class??

 

Insiya

  • Cancel
  • hipooja
    hipooja over 15 years ago

    Hi,

     

    I do not think you can pass a variable which is not defined in the class ,to its method.This is because the class must know beforehand the type of the variable (I think)

     

    For example when you pass the channel handle to the constructor of the driver ,you need to define the channel handle before utilizing it.Oki let me put up a pseudo code for this

     

    Top

    class env_top extends vmm_env {

    virtual function build() {

    vmm_channel channel = new():

    //The channel connects the gen and driver.

    gen = new(channel);

    drv = new (channel) ;

    } //end build

    -------------------------------------------------

    class atm_drv extends vmm_xactor

    {

     vmm_channel channel_drv;

      function new(vmm_channel channel) {

       if(channel == null ) channel = new;

       this.channel_drv = channel;

    } //end function new

     

    //Usage

    virtual task main () {

     this.channel_drv.peek_t(vmm_data transaction)

     @posedge clk

     ----driver code

    } //end of main     

       Note : the code is not correct syntactiacally.

    Regards,

    Pooja

     

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • tpylant
    tpylant over 15 years ago
    Anything you want the class to use that is outside of the class needs to be passed into the class via the new constructor.

    class foo;

      int a;

      function new(int in);

        a = in;

      endfunction

    endclass

    module test;

      foo f;

      initial f = new(10); // the value 10 is passed into the class

    endmodule


    Tim
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Leo1008
    Leo1008 over 15 years ago

    Thanks Pooja and thanks Tim.

    Even I was thinking that may be I could pass something not defined in the class via the new constructor. Now I am sure :).

    Insiya

    • 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