UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Observer ronakbajaj
Observer
12,374 Views
Registered: ‎01-05-2012

Automating Vivado HLS

Hi all,

 

I wanted to automate the synthesis of Vivado HLS projects. I have written a Python script... which first starts the Vivado HLS in command line prompt and then executes the script.tcl

 

 

This is how my Python script look like...

 

----------

os.chdir(<working directory>)

os.system(r'D:\Xilinx\Vivado_HLS\2013.1\bin\vivado_hls_cmd.bat')     # Start Vivado HLS

os.system(r'vivado_hls -f <project_name>\solution1\script.tcl')            # Run tcl script

----------

 

but, after command 2 (#Start Vivado HLS), it moves to command line prompt and don't execute rest of the commands in Python script. 

 

If I don't run this command, the system couldn't recognize 'vivado_hls' command for running tcl script. I have added the path "D:\Xilinx\Vivado_HLS\2013.1\bin\" in PATH env variable, but still it couldn't recognize 'vivado_hls'

 

Is there any way I can start vivado_hls and directly run tcl script or if there is any mistake in my Python script?

 

Thanks in advance.

 

0 Kudos
10 Replies
Teacher muzaffer
Teacher
12,364 Views
Registered: ‎03-31-2012

Re: Automating Vivado HLS

The issue is with your assumption that line 3 will be directed to the HLS. It is still run by the command line script which is invoking HLS. One solution is to add the script.tcl option to your HLS invocation directly, ie modify line 2 and add the option to run the script there.
Another option would be be get the process handle of the child process which line 2 creates and send lines to its standard input but that's more complicated. Just call HLS with the right options to run your script when it starts.
- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
0 Kudos
Observer ronakbajaj
Observer
12,361 Views
Registered: ‎01-05-2012

Re: Automating Vivado HLS

Hi Muzaffer,

 

I already tried the 1st option. Changing line #2 to:

#option1

os.system(r'D:\Xilinx\Vivado_HLS\2013.1\bin\vivado_hls_cmd.bat vivado_hls -f <project_name>\solution1\script.tcl')

 

#option2

os.system(r'D:\Xilinx\Vivado_HLS\2013.1\bin\vivado_hls_cmd.bat -f <project_name>\solution1\script.tcl')

 

But this did not worked. It just opens the command prompt after starting vivado_hls.

 

0 Kudos
Teacher muzaffer
Teacher
12,354 Views
Registered: ‎03-31-2012

Re: Automating Vivado HLS

I think i see the issue. vivado_hls_cmd is just a batch file which sets up the environment so that you can run the vivado_hls tools. You should not run it in addition to vivado_hls but before it. I am not sure if python keeps the same shell for multiple os.system calls but what you need to do is:
os.system(vivado_hls_cmd.bat)
os.system(vivado_hls -f script.tcl)
assuming the second os.system call runs in the same context as the first one. otherwise, vivado_hls might not be found if it is a clean shell.
- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
0 Kudos
Observer ronakbajaj
Observer
12,338 Views
Registered: ‎01-05-2012

Re: Automating Vivado HLS

That's precisely the problem I am facing. In general, Python keeps the same shell for multiple os.system calls.

 

But, in this case, when I make the function call 

os.system(vivado_hls_cmd.bat)

 

the control moves from Python script to command prompt, and it do not execute further commands (of Python script), which is 

os.system(vivado_hls -f script.tcl)

in this case.

 

 

 

0 Kudos
Teacher muzaffer
Teacher
12,335 Views
Registered: ‎03-31-2012

Re: Automating Vivado HLS

you can always execute both commands in the same shell by separating them with a comma ie os.system("vivado_hsl_cmd.bat; vivado_hls -f script.tcl"). These two commands would be executed in the same shell.
- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
0 Kudos
Observer ronakbajaj
Observer
12,333 Views
Registered: ‎01-05-2012

Re: Automating Vivado HLS

Tried this as well... doesn't work :(

 

As soon as it executes the bat file, it just moves control from Python script to command prompt (even if there are more commands in the same string), and wait for further commands on command prompt.

 

Also tried running os.system("START /K vivado_hls_cmd.bat") and some other similar commands... not working.

 

0 Kudos
Teacher muzaffer
Teacher
12,330 Views
Registered: ‎03-31-2012

Re: Automating Vivado HLS

The problem is with the vivado_hls_cmd batch file which starts another shell internally. Making a copy and removing the %COMSPEC% lines from it should enable the final solution I suggested to work. I am not sure why xilinx felt the need to spawn another shell from this script.
- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
0 Kudos
Xilinx Employee
Xilinx Employee
12,231 Views
Registered: ‎03-24-2010

Re: Automating Vivado HLS

Have you tried add "D:\Xilinx\Vivado_HLS\2013.1\bin\..\Win_x86\bin" to PATH, and call "vivado_hls_bin.exe -f script.tcl"?

Regards,
brucey
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------
0 Kudos
Visitor syedhabib
Visitor
2,752 Views
Registered: ‎06-02-2017

Re: Automating Vivado HLS

Hi, 

 

Were you able to perform this task? if yes, how?

I want to do something similar. I am unable to execute TCL script even from the command prompt.

I am using command prompt on windows 8

 

Following what you have done:

First I enter this command:

>>  E:\Xilinx\Vivado_HLS\2016.2\bin\vivado_hls_cmd.bat

Vivado HLS command prompt open

then I enter

>> <location>\my_tcl.tcl

The TCL apparently does start but it gives me error:

invalid command name "open_hw"

 

I am unable to resolve this error. once this work on cmd line, I would like to move to python. If you have done it already it will be great.

 

Another way of running script:

In order to execute my TCL file I follow these steps:

E:\Xilinx\Vivado\2016.2\bin\vivado.bat -mode tcl

once the vivado terminal is ready I enter this command

source <location>\my_tcl.tcl

 

this works perfectly but I am not sure how to automate this from python as the first line moves into vivado tcl mode and expect some command on the terminal. the next line never executes before exiting vivado.

 

Kindly help me out

 

Regards

 

 

0 Kudos
Observer nikhilghanathe
Observer
970 Views
Registered: ‎12-28-2014

Re: Automating Vivado HLS

Hi all,

This can be done by using a subprocess.call api in python which has the path of a batch script as the argument.

process = subprocess.call([<FPGAHLSAutomationPath>])

 

The batch script could be something like this:

@echo off

set PATH=%PATH%;C:\Xilinx\Vivado\2017.3\bin
vivado_hls -f <path to script>.tcl

 

This works perfectly fine. No hassles.

 

Cheers!

 

0 Kudos