Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17268 Discussions

Post compile file copy script

Altera_Forum
Honored Contributor II
1,671 Views

Hello, 

 

I am trying to create a script so that the .sof file is copied to a specific location after the build is done. I went as far as adding this to the .qsf file: 

 

set_global_assignment -name POST_FLOW_SCRIPT_FILE "quartus_sh:post_compile.tcl" 

 

Now, I don't know what to put in the post_compile.tcl file to actually do the file copy. The build fails at the end because there is no post_compile.tcl yet. 

 

Does anyone know how to do this? 

 

Thank you!
0 Kudos
6 Replies
Altera_Forum
Honored Contributor II
567 Views

How about consulting a tcl manual? Unfortunately, I'm not aware of the copy syntax, but I know where to read about.

0 Kudos
Altera_Forum
Honored Contributor II
567 Views

I was not sure if Altera was using standard Tcl. I ended up adding this: 

file copy -force src.rbf dest.rbf 

Right now, I am hardcoding the "src.rbf" name. I eventually would like to be able to use the top name for it so that this script can be generic and can be used for other projects. I will add a post when I find out how to do that. 

 

Thank you
0 Kudos
Altera_Forum
Honored Contributor II
567 Views

Tcl has some direct commands for finding file names, stripping the prefix off, etc. (I don't remember the names though.) When writing out a file, I always use the following, which looks to see if the file exists, copies it to a .bak file, and then opens a new one. (The file used here was a .csf) 

 

set filename src 

if {[file exists $filename.csf]} { 

if {[file exists $filenam.csf.bak]} { 

puts "removing $filenam.csf.bak" 

file delete $filename.csf.bak 

file copy $filename.csf $filename.csf.bak 

puts "moving $filename.csf to $filename.csf.bak" 

file delete $filename.csf 

 

set file [file open $filename.csf a] 

 

puts $file "Add some text to the file" 

puts $file "Add some more" 

 

close $file
0 Kudos
Altera_Forum
Honored Contributor II
567 Views

I got this working by doing this: 

 

set rbf_file_name ".rbf" post_message "### Copying output $rbf_file_name" file copy -force $rbf_file_name new_dir/$rbf_file_name  

 

This is what the Altera site says about the arguments passed in: 

 

 

--- Quote Start ---  

 

The first argument passed in the quartus(args) variable is the name of the flow or module being executed, depending on the assignment you use. The second argument is the name of the project, and the third argument is the name of the revision 

--- Quote End ---  

 

 

I am not sure how the output file name relates to these, but the script above seems to work fine.
0 Kudos
Altera_Forum
Honored Contributor II
567 Views

You're selecting the second argument, which is the project name. Most output files are named after the revision, so I would change it to that. (In most projects the project name and revision name are the same, in which case it technically doesn't matter, but revision is probably correct.) Remember that: 

a) Project name is the name of your .qpf. 

b) Revision is the name of the .qsf. 

There can be only one .qpf but multiple .qsf files, which are controlled under Project -> Revisions...
0 Kudos
Altera_Forum
Honored Contributor II
567 Views

Thank you Rysc! 

 

This is the kind of clarification I was looking for. I did notice that argv[1] and [2] are the same, but that is probably because I have a simple project.
0 Kudos
Reply