Altera Home Page
文档资料 许可
在线购买 下载

  主页   |   产品   |   支持   |   最终市场   |   技术中心   |   教育与活动   |   公司介绍   |   在线购买  
  mySupport   |   器件   |   软件   |   IP   |   设计范例   |   参考设计  

 产品
      MAX/MAX II
      Stratix/Stratix GX
      Nios II
  
 功能
      算法
      存储器
      总线及I/O
      逻辑
      接口与外设
      DSP
      通信
      PLL & Clocking
  
 设计输入方法
      Quartus II软件工程
      Tcl
      VHDL
      Verilog HDL
      C Code 范例
      DSP Builder
      TimeQuest
   片内调试
  
 仿真工具
      Mentor Graphics ModelSim
      Cadence NCsim
      Synopsys VCS
  
 旧范例
      图形编辑器
      AHDL
  

Quartus II Tcl Example: Archiving Projects Automatically

When you do many compilations and vary different settings during each compilation, it can be hard to remember what your settings and results were from compile to compile. By archiving a project, you can preserve a complete copy of it, including the files generated during a compile. You can archive a project with a single command at a system command- prompt, but creating a Tcl script and adding a setting to execute it automatically makes the process easier.

To make the script run automatically at the end of every compilation, use the following script, and add a new assignment to your project. The assignment name is POST_FLOW_SCRIPT_FILE. For more information on this assignment, refer to the Automatic Script Execution examples. Assuming the script is named autoqar.tcl, add the following assignment to your Quartus II Settings File (.qsf):

set_global_assignment -name POST_FLOW_SCRIPT_FILE quartus_sh:autoqar.tcl

The script creates a file name based on the current date and time. For information about changing the date and time representation, refer to the Date & Time Formatting page.

# Use these options to control what files get archived.
# -include_outputs: Includes Quartus II output files, including the
#     db directory and programming files
# -include_libraries: Includes system libraries referenced in your
#     project

set options "-include_outputs"
#set options "-include_libraries"
#set options "-include_outputs -include_libraries"

# Subdirectory to put the automatically created qars into
set qar_directory autoqar

# Generates a name for the qar based on the name of the revision
# and the current time.
proc generateQarName { project revision } {

    # time_format_string controls how the qar is named.
    # These values give the value month_dd_yyyy-hh.mm.ss.
    # For example, Jan_28_2004-13.00.05

    set time_format_string "%b_%d_%Y-%H_%M_%S"
    set time_value [clock format [clock seconds] \
      -format $time_format_string]
    
    # The name of the qar is based on the revision name and the time
    return $revision-$time_value
}

global quartus

set module_or_flow [lindex $quartus(args) 0]
set project [lindex $quartus(args) 1]
set revision [lindex $quartus(args) 2]

# If a qar is made, set this to 1 and attempt to move it later on
set ran_qar 0

# Add any modules or flows to the list in the switch statement
# As is, it'll make a qar after each compile, compile and simulate,
# and incremental fit.
switch -exact -- $module_or_flow {

    compile -
    compile_and_simulate -
    incremental_fitting {

    if { [catch {
        project_open -revision $revision $project
        set qar_name [generateQarName $project $revision]
        project_archive $options $qar_name
        project_close
    } res ] } {
        post_message -type warning $res
    } else {
        set ran_qar 1
    }
    }

}


# If a qar was made, try to move it to the right directory
if { $ran_qar } {

    if { [catch {

    file mkdir $qar_directory
    file copy $qar_name.qar $qar_directory
    file copy $qar_name.qarlog $qar_directory
    file delete $qar_name.qar
    file delete $qar_name.qarlog

    } res ] } {
    post_message -type warning $res
    } else {
         set qname [file join $qar_directory $qar_name]
    post_message "Successfully archived your project in $qname.qar"
    }
}

Design Examples Disclaimer

These design examples may only be used within Altera Corporation devices and remain the property of Altera. They are being provided on an “as-is” basis and as an accommodation; therefore, all warranties, representations, or guarantees of any kind (whether express, implied, or statutory) including, without limitation, warranties of merchantability, non-infringement, or fitness for a particular purpose, are specifically disclaimed. Altera expressly does not recommend, suggest, or require that these examples be used in combination with any other product not provided by Altera.

  请填写反馈意见