Quartus® II Tcl 出口報告資料至 CSV 檔案

author-image

作者

許多設計人員在 FPGA 設計的某個階段使用 Excel。將數據從 Quartus II 報告面板匯出到可在 Excel 中打開的 CSV 檔非常簡單。

此簡單過程從指定的報告面板匯出資料並將其寫入檔。調用此過程時,項目必須處於打開狀態。下面是如何在腳本中使用它的示例。

proc panel_to_csv { panel_name csv_file } {

    set fh [open $csv_file w]
    load_report
    set num_rows [get_number_of_rows -name $panel_name]

    # Go through all the rows in the report file, including the
    # row with headings, and write out the comma-separated data
    for { set i 0 } { $i < $num_rows } { incr i } {
        set row_data [get_report_panel_row -name $panel_name -row $i]
        puts $fh [join $row_data ","]
    }

    unload_report
    close $fh
}

 

下面是使用該過程的腳本。使用以下命令在系統命令提示符處運行此命令。

load_package report
package require cmdline

proc panel_to_csv { panel_name csv_file } {

    set fh [open $csv_file w]
    load_report
    set num_rows [get_number_of_rows -name $panel_name]

    # Go through all the rows in the report file, including the
    # row with headings, and write out the comma-separated data
    for { set i 0 } { $i < $num_rows } { incr i } {
        set row_data [get_report_panel_row -name $panel_name -row $i]
        puts $fh [join $row_data ","]
    }

    unload_report
    close $fh
}

set options {\
    { "project.arg" "" "Project name" } \
    { "revision.arg" "" "Revision name" } \
    { "panel.arg" "" "Panel name" } \
    { "file.arg" "" "Output file name"} \
}
array set opts [::cmdline::getoptions quartus(args) $options]

project_open $opts(project) -revision $opts(revision)

panel_to_csv $opts(panel) $opts(file)

unload_report

您可以使用以下命令在命令提示符處運行此文稿。

quartus_sh -t script.tcl -project <project name> -revision <revision name> -panel <panel name> -file <file name>

如果在系統命令提示符下輸入面板名稱參數,請確保正確引用該參數。某些字元(如豎線(|))在命令外殼中具有特殊含義。

這個頁面的內容綜合了英文原始內容的人工翻譯譯文與機器翻譯譯文。本內容是基於一般資訊目的,方便您參考而提供,不應視同完整或準確的內容。如果這個頁面的英文版與譯文之間發生任何牴觸,將受英文版規範及管轄。 查看這個頁面的英文版。