Relative paths in EDK user repository TCL script

K

kekely

Guest
Hi,

I'm trying to create EDK repository with my own pcores. In one of thi
pcores I need to use special program to generate one of its VHDL sourc
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 optio
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_projec
with "Project Peripheral Repository Search Path" set t
/path_to_repository, add mentioned pcore into this project and try t
generate bitstream, I get an error like "pcores/my_core/hdl/vhdl/generato
no such file or directory". After a while I figured out, that TCL scrip
inside my repository's pcore is executed in the project actual directory
so relative path pcores/my_core/hdl/vhdl/generator is extended to absolut
path /path_to_project/pcores/my_core/hdl/vhdl/generator instead of expecte
/path_to_repository/pcores/my_core/hdl/vhdl/generator.


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



---------------------------------------
Posted through http://www.FPGARelated.com
 
On Sun, 29 Jan 2012 18:25:55 -0600, kekely wrote:

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.

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
 
On Sun, 29 Jan 2012 18:25:55 -0600, kekely wrote:

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 pat
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" se
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 wit
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.


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, regardles

of the current working directory.

Example:

# converts a path relative to the script being run, into an absolut
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
Thank you for such a quick reply.
Unfortunately, proposed solution didn't work in my situation. I know abou
"info script", but when I tried it in my script, it returned only empt
string. Therefore, when I tried your proposed function "file_rel2abs", i
ended with error "confused".

Lukas

---------------------------------------
Posted through http://www.FPGARelated.com
 
On Tue, 31 Jan 2012 16:56:40 -0600, kekely wrote:

On Sun, 29 Jan 2012 18:25:55 -0600, kekely wrote:

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.


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


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".
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
 

Welcome to EDABoard.com

Sponsor

Back
Top