• 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. How to get the value of a string when using the string in...

Stats

  • Locked Locked
  • Replies 0
  • Subscribers 64
  • Views 13388
  • 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

How to get the value of a string when using the string in a hierarchical path

jaichandra
jaichandra over 8 years ago

Hi all

        Is there a way to use the value of string variable in systemverilog.  I have a text file with the pin name and the value to be driven to that pin, on each line.

There are around 50 pins. The name of the pin declared in the interface and the text file are same. I want to read the pin name and value from text file into a string and integer.

Then use the string to refer the signal in interface and drive the value to it. The code i want to use is roughly as show below.

 The interface vif has pins pinabc and pinbcd declared in it. obviously here when i use vif.pin the tool is searching for a pin with name "pin" in interface. Is there a way to get

  the value of the string pin.

----------------file.txt-------------------------

 pinabc   20

 pinbcd   30

---------------sv code----------------------------------

   interger FILE,pin_val;

   string line,pin;

   FILE = $fopen("./file.txt","r");

  while ($fgets(line,FILE)) begin

      void'($sscanf(line,"%s %d\n",pin,pin_val));

      vif.pin = pin_val;

  end

  • 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