Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
16606 Discussions

access environmental variables in _hw.tcl files

Altera_Forum
Honored Contributor II
2,374 Views

Hello all, 

 

When I try to print an environmental variables in the Quartus TCL Console (e.g. puts $::env(PATH) ) it works, but whenever I try to access it within a _hw.tcl component script it doesn't and I get the following error during elaboration: 

 

Can't read "::env(PATH)": no such element in array 

 

Could anyone shed some light on this? 

 

Thank you.
0 Kudos
6 Replies
Altera_Forum
Honored Contributor II
1,028 Views

I found the same issue, but never had time to look into it much further. 

 

The following command might be useful to you to use as a work around (if all you want is the path to the _hw.tcl file): 

 

set path_to_script ]]  

 

where 'info script' gives you the _hw.tcl file, 'file normalize' gives you the full path to that script, and 'file dirname' strips off the _hw.tcl name. 

 

At that point, you can use names relative to the _hw.tcl location. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
1,028 Views

Dear Dave, 

 

Thank you for your reply. However, I want to reference the path of a separate file (not the TCL script) in order to add it with the add_fileset_file command. Using a path relative to the location of the TCL script would work, but would not be elegant at all since the file to be added is several layers of hierarchy away. 

 

I will probably submit a service request with Altera.
0 Kudos
Altera_Forum
Honored Contributor II
1,028 Views

 

--- Quote Start ---  

 

I want to reference the path of a separate file (not the TCL script) in order to add it with the add_fileset_file command. Using a path relative to the location of the TCL script would work, but would not be elegant at all since the file to be added is several layers of hierarchy away. 

 

--- Quote End ---  

 

 

That was the situation I was also faced with. It would be nicer if the Tcl interpreter preserved the environment variables, but it doesn't. 

 

 

--- Quote Start ---  

 

I will probably submit a service request with Altera. 

--- Quote End ---  

 

 

Please post their response here.  

 

I'd like to see a more elegant solution too :) 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
1,028 Views

This is fixed in Quartus 13.0 as far as I can see.

0 Kudos
Altera_Forum
Honored Contributor II
1,028 Views

 

--- Quote Start ---  

This is fixed in Quartus 13.0 as far as I can see. 

--- Quote End ---  

 

Awesome, thanks for posting :) 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
1,028 Views

After some further testing I concluded that this was already fixed from Quartus/Qsys 12.1 onwards. 

 

The solution is that you need to use the correct package command that forces the component to be interpreted by the latest version of Qsys (and not SOPC Builder, for which reading environment variables doesn't work). 

 

For example, change the package command in your TCL file from e.g.: 

 

package require -exact sopc 11.0 

 

to either: 

 

package require -exact qsys 12.1 

 

or 

 

package require -exact qsys 13.0 

 

depending on the Quartus version you are using.
0 Kudos
Reply