• 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. Custom IC Design
  3. VerilogA - command: $root

Stats

  • Locked Locked
  • Replies 1
  • Subscribers 126
  • Views 1075
  • 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

VerilogA - command: $root

rrihak
rrihak over 2 years ago

Hello I would like to ask, if there is any way how to use command $root in VerilogA language for current reading in the top cell of schematic? I know I can use $root for reading voltage, is it similar for current or there is another command?? Thanks 

  • Cancel
  • MarcelAhmedzai
    MarcelAhmedzai over 2 years ago

    Hi,

    One way to obtain votlages, current and other parameters is to use the $cds_get_analog_value command. Also aliased to $cgav for short.

    Unfortunately you are not able to use the $root with $cgav. So instead, you can take advantage of the string manipulation commands available to you in VerilogA to retrieve the hierarchical path which can then be used in the $cgav.

    Here is an example of the code you could use;

    ///////////////////////////////////////////////////////////////////////////////////////////////////////

    module getDiff1 ( );
    real vdiff;

    string instPath, instPath_1, instPath_cgav;
    integer pn1;

        //////////////////////////////////////////////////
        //include functions needed for string manipulation
        //////////////////////////////////////////////////
        `include "shdl_strings.vams"


    initial begin
        

        ///////////////////////////////////////////////////////////////////
        //Retrive the instance path to where this instance is in the design
        ///////////////////////////////////////////////////////////////////
        $swrite(instPath, "%m");

        $strobe("Path is %s", instPath);

        ///////////////////////////////////////////////////////////////////////////
        //Find the index for where the last "." was in the extracted instance path
        //////////////////////////////////////////////////////////////////////////
        //pn1=shdl_strrchr(instPath, ".");
        pn1=shdl_strrchr("%m", ".");

        ////////////////////////////////////////////////////////////////////////
        //Extract the substring from the instance path for the level above this
        ///////////////////////////////////////////////////////////////////////
          instPath_1=instPath.substr(0,pn1-1);

        $strobe("Path -1 is %s", instPath_1);
        
        ///////////////////////////////////
        //Construct the string for the cgav
        ///////////////////////////////////
        $swrite(instPath_cgav, "%s.I0.vdiff", instPath_1);

    //    vdiff=$cgav("I0.vdiff", "potential");
    //    $strobe("Vdiff is %f\n", vdiff);
    end


    always #0.5 begin

        //////////
        //Use cgav
        //////////
        vdiff=$cgav(instPath_cgav, "potential"); ;;<-- FOR CURRENT YOU CAN USE "flow" HERE
        $strobe("Vdiff is %f\n", vdiff);

    end

    endmodule

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////

    As you can see in my comments the use of the $cgav can be used to get the current by switching out the "potential" to "flow";

    $cgav(instPath_cgav,"flow")

    More details of using the $cds_get_analog_value can be seen in the documentation.

    Kind regards

    Marcel

    • 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