• 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 SKILL
  3. How to convert a floating point number into a string with...

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 143
  • Views 9250
  • 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 convert a floating point number into a string with unit prefix?

Volker T
Volker T over 2 years ago

Dear all,

VerilogA knows a string format specifier %r to convert a floating point number into a string with suitable unit prefix (..., a, p, n, u, m, k, M, G, T...), such that something like

printf("Number = %r", 0.00375)

prints

"3.75m"

Is there anything alike in SKILL?

I find %g, %f and the lot, but nothing that can convert a floating point number like 0.00347 into a string with unit prefix like "3.47m".

However, this is everyday work for all the Cadence Tools, so I guess there must be at least a function that can accomplish this.

Thank you very much!

  • Cancel
Parents
  • ebecheto
    ebecheto over 2 years ago

    aelSuffixNotation(2e-5);=> "20u"

    the reverse function is evalstring :

    evalstring("3.14u");=> 3.14e-06

    Exemple of all the units available :

    (foreach mapcar x  logRg(1e-15 1e+15 1.0/3) aelSuffixNotation(x))
    ;=> ("1f" "1p" "1n" "1u" "1m" "1" "1K" "1M" "1G" "1T")

    Regards,

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • ebecheto
    ebecheto over 2 years ago

    aelSuffixNotation(2e-5);=> "20u"

    the reverse function is evalstring :

    evalstring("3.14u");=> 3.14e-06

    Exemple of all the units available :

    (foreach mapcar x  logRg(1e-15 1e+15 1.0/3) aelSuffixNotation(x))
    ;=> ("1f" "1p" "1n" "1u" "1m" "1" "1K" "1M" "1G" "1T")

    Regards,

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
  • Andrew Beckett
    Andrew Beckett over 2 years ago in reply to ebecheto
    ebecheto said:

    the reverse function is evalstring :

    evalstring("3.14u");=> 3.14e-06

    Sorry to be picky, but the reverse function is not evalstring, That is evaluating something as SKILL, and I wouldn't recommend this - I often give the example 'what if the string you are trying to evaluate happens to be "(exit)" or something like that?'.

    The reverse function is aelNumber(). You can also use cdfParseFloatString. You can also use the SKILL parser without evaluation by using car(linereadstring(numberString))

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • Volker T
    Volker T over 2 years ago in reply to ebecheto

    Perfect, thank you very much indeed!

    • 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