Quartus® II Tcl Export Report Data ไปยังไฟล์ CSV

author-image

โดย

นักออกแบบหลายคนใช้ Excel ในบางขั้นตอนของการออกแบบFPGA ส่งออกข้อมูลจากแผงรายงาน Quartus II ไปยังไฟล์ CSV ที่คุณสามารถเปิดใน Excel ได้อย่างง่ายดาย

ขั้นตอนง่ายๆ นี้จะส่งออกข้อมูลจากแผงรายงานที่ระบุและเขียนไปยังไฟล์ โครงการต้องเปิดเมื่อคุณเรียกกระบวนการนี้ ตัวอย่างวิธีการใช้ในสคริปต์มีดังต่อไปนี้

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>

ตรวจสอบให้แน่ใจว่าคุณพูดชื่อแผงอย่างถูกต้องหากคุณป้อนที่พรอมต์คําสั่งของระบบ อักขระบางตัว เช่น แถบแนวตั้ง (|) จะมีความหมายพิเศษที่ Command Shell

เนื้อหาในหน้านี้เป็นการผสมผสานระหว่างการแปลเนื้อหาต้นฉบับภาษาอังกฤษโดยมนุษย์และคอมพิวเตอร์ เนื้อหานี้จัดทำขึ้นเพื่อความสะดวกของคุณและเพื่อเป็นข้อมูลทั่วไปเท่านั้นและไม่ควรอ้างอิงว่าสมบูรณ์หรือถูกต้อง หากมีความขัดแย้งใด ๆ ระหว่างเวอร์ชันภาษาอังกฤษของหน้านี้กับคำแปล เวอร์ชันภาษาอังกฤษจะมีผลเหนือกว่าและควบคุม ดูเวอร์ชันภาษาอังกฤษของหน้านี้