Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Relative paths in EDK user repository TCL script

22 views
Skip to first unread message

kekely

unread,
Jan 29, 2012, 7:25:55 PM1/29/12
to
Hi,

I'm trying to create EDK repository with my own pcores. In one of this
pcores I need to use special program to generate one of its VHDL source
files. So during synthesis I need to execute something like:
/path_to_repository/my_repository/pcores/my_core/hdl/vhdl/generator

I tried to use TCL script for that purpose. I defined ELABORATE_PROC option
in .mpd file which calls TCL script executing relative path like:
exec pcores/my_core/hdl/vhdl/generator


However, when I created XPS project in directory let say /path_to_project
with "Project Peripheral Repository Search Path" set to
/path_to_repository, add mentioned pcore into this project and try to
generate bitstream, I get an error like "pcores/my_core/hdl/vhdl/generator
no such file or directory". After a while I figured out, that TCL script
inside my repository's pcore is executed in the project actual directory,
so relative path pcores/my_core/hdl/vhdl/generator is extended to absolute
path /path_to_project/pcores/my_core/hdl/vhdl/generator instead of expected
/path_to_repository/pcores/my_core/hdl/vhdl/generator.


Is there a way how I can change the working directory of the TCL script to
the directory with my repository? Maybe some system variable with the
content of "Project Peripheral Repository Search Path". Or maybe some other
way, how to correctly do the described task (calling generator program) in
my repository.



---------------------------------------
Posted through http://www.FPGARelated.com

Allan Herriman

unread,
Jan 30, 2012, 8:05:10 AM1/30/12
to
I'm not sure whether this will help at all, but TCL scripts can know
where they are (as opposed to knowing where they're being called from),
by using

info script

This allows you to use paths relative to the script being run, regardless
of the current working directory.

Example:

# converts a path relative to the script being run, into an absolute one.
proc file_rel2abs {path} {
if { [ string length [ info script ] ] > 0 } {
return [file normalize [file join [file dirname [info script]]
$path ] ]
} else {
error "confused"
}
}


N.B. info script doesn't work in Modelsim's TCL shell, if the script is
called using "do", however it does work if the script is run using
"source". This probably won't matter to you.

Regards,
Allan

kekely

unread,
Jan 31, 2012, 5:56:40 PM1/31/12
to
Thank you for such a quick reply.
Unfortunately, proposed solution didn't work in my situation. I know about
"info script", but when I tried it in my script, it returned only empty
string. Therefore, when I tried your proposed function "file_rel2abs", it
ended with error "confused".

Lukas

Allan Herriman

unread,
Feb 1, 2012, 4:58:48 AM2/1/12
to
I'm no TCL expert, but I think you might be able to work around that by
making sure that you execute your script by "sourcing" it.

From the manual page:

info script

If a Tcl script file is currently being evaluated (i.e. there is a
call to Tcl_EvalFile active or there is an active invocation of the
source command), then this command returns the name of the innermost file
being processed. Otherwise the command returns an empty string.

Regards,
Allan
0 new messages