• 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. Blogs
  2. System, PCB, & Package Design
  3. BoardSurfers: Data Type Conversion in Allegro SKILL Pro…
Kirti Sikri
Kirti Sikri

Community Member

Blog Activity
Options
  • Subscribe by email
  • More
  • Cancel
CDNS - RequestDemo

Try Cadence Software for your next design!

Free Trials
PCB
Allegro SKILL Programming
Allegro X PCB Editor
BoardSurfers
Data Conversion
PCB Editor
PCB design
23.1
allegro x
SKILL

BoardSurfers: Data Type Conversion in Allegro SKILL Programming

18 Apr 2024 • 4 minute read

 Data type conversion is a crucial aspect of programming that helps you handle data across different data types seamlessly. The SKILL language supports several data types, including integer and floating-point numbers, character strings, arrays, and a highly flexible linked list structure to represent data aggregates. Efficient conversion between different data types is essential for various Allegro SKILL tasks. Let's delve into how to perform these conversions and explore some essential functions and techniques.

Comparing Data Conversions

SKILL language offers automatic data conversion based on the context of usage. To understand this, let us compare the following two examples:

Example 1:

X = 1
Y = 2.0
X/Y = 0.5

Here, X is automatically converted to a float data type because of Y, resulting in a float type value.

Example 2:

X=1
Y=2
X/Y = 0

No conversion takes place here as both the variables are of the same data type, integer.

Allegro SKILL Functions for Data Type Conversions

Some SKILL functions that are useful for data type conversions are included in the following table:

Data Conversion Type Function to use
Integer to Float

float()

Example: 
X = float(34)

Result:

X = 34.0

Float to Integer

int()

Example:
X = 2.9
Xint = int(X)

Result:

X = 2

Caution: Potential truncation issues with this operation.

String to Integer and Float

atoi() converts string to integer 

Example:

X = atoi("10")

Result:

X = 10

atof() converts string to float

Example:

Y = atof("1.2e-12")

Result:

Y = 1.2e-12

Numeric Strings to Numbers

evalstring() numeric strings to numbers (integers or floats)

Example:

  • evalstring("10")
    Result: 10
  • evalstring("10.0")
    Result: 10.0
  • evalstring("1+2")
    Result: 3

NOTE: You must cautiously use the evalstring() function to convert numeric strings. Any error in providing data type to this function may lead to incorrect results.
For example: evalstring("10/2.") => 5.0

Integer to String

sprintf()with %d format directive

Example:

sprintf(str, " %d ", 2)

Result: "2"

sprint() converts integer 2 to a string "2" (in double quotes) and stores it in the variable str.

Float to String

sprintf() with %g format directive

Example:

sprintf(str, "%g", 1.2e-12)

Result: "1.2e-12"

sprintf() converts the floating point number into a string "1.2e-12" and stores it in the variable str.

Any Number to String

sprintf()with %n format directive

Example:

sprintf(str, "%n", 1.)
sprintf(nil, "%n",1) 

Result:

sprintf() converts the integer or floating-point number (in the [-]ddd.ddd format) number to string.

Symbol to String
  • get_pname (s_arg): Returns the print name of a symbol as a string
  • symbolToString (s_symbolName): Converts a symbol to a string of the same name

Example:

The following functions convert the symbol name x to a string and save it to the variable y:
y=get_pname('x) => "x"
y=symbolToString('x) => "x"

String to Symbol

stringToSymbol() converts a string to a symbol

Example: 

The following function converts a string to a symbol:
y=stringToSymbol("test")=> test

List to String

buildString() converts a list to a string

Example:

aList=list("R1" "R2" "R3") => ("R1" "R2" "R3")
buildString(aList ",") => "R1,R2,R3"

String to List

  • parseString() breaks a string into a list of substrings with break characters

Example:

parseString("R1 R2 R3\n" )
 =>("R1" "R2" "R3")

parseString() breaks a string into a list of substrings with specified break characters, which are indicated by an optional second argument

Example:

parseString( "Now is the time" ) => ("Now" "is" "the" "time")

The default break character is a space.

parseString( "prepend" "e" ) => ("pr" "p" "nd" )

  • axlStringRemoveSpaces strips leading or trailing whitespace from a string

Example:

axlStringRemoveSpaces(" a ")

Result: a

axlStringRemoveSpaces( '(" a " " b "))

Result: '(“a” “b”)

Conclusion

Understanding data type conversion is essential for effective Allegro SKILL programming. You can seamlessly convert different data types using the available functions and techniques. This ensures an efficient handling and processing of data in your Allegro SKILL scripts, helping you tackle complex design automation tasks.

Contact Us

For any feedback or topics you want us to include in our blogs, write to us at pcbbloggers@cadence.com.

Subscribe to stay updated about our upcoming blogs.

About BoardSurfers

The BoardSurfers series provides solutions to the various tasks related to the creation and management of PCB design using the Allegro platform products. The name and logo of this series are designed to resonate with the vision of making the design and manufacturing tasks enjoyable, just like surfing the waves. Regular, new blog posts by experts cover every aspect of the PCB design process, such as library management, schematic design, constraint management, stackup design, placement, routing, artwork, verification, and much more.


CDNS - RequestDemo

Have a question? Need more information?

Contact Us

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information