• 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. convert string to list of bit

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 65
  • Views 13933
  • 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

convert string to list of bit

mmbr
mmbr over 12 years ago

I'm looking for a way to read a file containing (HEX) numbers.

For each file I read, the width of the data is different (can be more than 32/64/128 bits).

So I'm looking for a way to convert the string I read from the file to a list of bit variable.

In order to make it easy, let say I know the size of the bits list (the data width) in advance.

Any ideas?

  • Cancel
  • muffi
    muffi over 12 years ago

     <'
    extend sys{
      run() is also{
        var m_file: file;
        var list1: list of uint;
        if files.file_is_readable("text.txt"){
          m_file = files.open("text.txt", "r", "Text File");
          var m_string: string;
          while files.read(m_file, m_string) {
            list1.add(append("0x", m_string).as_a(int));
          };
          print list1 using hex;
          files.close(m_file);
          };
        };
    };
    '>

    text.txt

    ======

    234d
    134d
    254d
    034d
    234a
    294b
    844a
    234d

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • mmbr
    mmbr over 12 years ago

    muffi Hi,

    In your example list1 is a list of uint.

    I'm looking for a solution where list1 is a list of bit.

    Lets take for example a file containg a line with the number f3.

    var lob : list of bit;

    var lob_size : uint = 5;

    After the convertion function I would like to get lob with this list:

    Specman> p lob using dec
      lob =  (5 items, dec):
                                                    1  0 0 1 1      .0

    Specman> p lob using hex
      lob =  (5 items, hex):
                                                    1  0 0 1 1      .0
     

    • 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