Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
10 years ago

Tcl script does not run during compilation

The tcl script that supposed to update .v file runs fine if I run it from the tcl console but it does not run during compilation.

Both .tcl and .v files are in the project files list.

Any idea?

5 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    To run a script during before compilation, you have to add it to your .qsf like so:

    set_global_assignment -name PRE_FLOW_SCRIPT_FILE quartus_sh:assign_pin.tcl

    Note that when the script runs, it does not act like Quartus is open. So you need to open and close the project. For example, if I had a project named gocubs and I wanted to create a pre-flow script called assign_pin.tcl that made a pin assignment, it would look like:

    project_open gocubs

    set_location_assignment PIN_M4 -to blaa

    project_close

    The big benefit is that it's true Tcl interpreter(unlike the .qsf reader) so you can script about whatever you want.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    To run a script during before compilation, you have to add it to your .qsf like so:

    set_global_assignment -name PRE_FLOW_SCRIPT_FILE quartus_sh:assign_pin.tcl

    Note that when the script runs, it does not act like Quartus is open. So you need to open and close the project. For example, if I had a project named gocubs and I wanted to create a pre-flow script called assign_pin.tcl that made a pin assignment, it would look like:

    project_open gocubs

    set_location_assignment PIN_M4 -to blaa

    project_close

    The big benefit is that it's true Tcl interpreter(unlike the .qsf reader) so you can script about whatever you want.

    --- Quote End ---

    Thanks!

    I have already this line in my .qsf:

    set_global_assignment -name PRE_FLOW_SCRIPT_FILE "quartus_sh:version_and_time.tcl".

    Do I have to add those lines to my .qsf?

    project_open <project_name>

    set_global_assignment -name PRE_FLOW_SCRIPT_FILE "quartus_sh:version_and_time.tcl"

    project_close
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    The "project_open...project_close" lines go in the .tcl script. When you press compile, you should see messages that it's running the pre-flow script. (If the script is just writing out an HDL file that has version and time, i.e. it's not doing anything to the project, then you don't need the project_open/project_close.

    http://www.alterawiki.com/wiki/tcl_scripts_for_automatic_build_identification

    --- Quote End ---

    Thanks for the sharing. The wiki link is useful.