• 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. Allegro X Scripting - Skill
  3. Scope of Global and Local variables in Allegro SKILL

Stats

  • Replies 0
  • Subscribers 17
  • Views 1041
  • Members are here 0
More Content

Scope of Global and Local variables in Allegro SKILL

JuanCR
JuanCR 5 months ago

By default, all variables in Allegro SKILL are global. Their value is accessible at any time and anywhere within your SKILL Code.

The use of global variables in SKILL, as with any language, should be kept to a minimum. 


Global variables in SKILL

For example, in the code snippet given below, x1 and x2 become global variables by default. You can also access them from within a procedure.

x1 = 5

x2 = 10

procedure( update_vars(number1 number2)

printf("Inside proc:\t x1 is %d\t x2 is %d\t sum is %d\n" x1 x2 x1+x2)

x1 = number1

x2 = number2

)

printf("Before sum:\t x1 is %d\t x2 is %d \n" x1 x2)

update_vars(50 100)

printf("After sum: \t x1 is %d\t x2 is %d \n" x1 x2)

 

The result is: 


Defining local variables

You can define local variables by using let or prog.

x1 = 5

x2 = 10

procedure( Local_Sum(number1 number2)
   let( (x1 x2); notice we're intentionally using the same variable names
      x1 = number1
      x2 = number2
      printf("Inside Local_Sum:\t x1 is %d\t x2 is %d\t sum is is %d\n" x1 x2 x1+x2)
   )
)

printf("Before Local_Sum:\t x1 is %d\t x2 is %d\t sum is is %d\n" x1 x2 x1+x2)
Local_Sum(1 2)
printf("After Local_Sum:\t x1 is %d\t x2 is %d\t sum is is %d\n" x1 x2 x1+x2)
 
The result is: 

Interesting, isn't it? Play with the code snippets and let us know if you have any questions!
  • Cancel
  • Sign in to reply
Cadence Guidelines

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