Altera Home Page
Literature Licensing
Buy On-Line Download

  Home   |   Products   |   Support   |   End Markets   |   Technology Center   |   Education & Events   |   Corporate   |   Buy On-Line  
  Knowledge Database   |   Devices   |   Design Software   |   Intellectual Property   |   Design Examples   |   mySupport   |   Reference Designs  

 Products
      MAX/MAX II
      Stratix/Stratix GX
      Nios II
  
 Functionality
      Arithmetic
      Memory
      Bus & I/O
      Logic
      Interfaces & Peripherals
      DSP
      Communications
      PLL & Clocking
  
 Design Entry
      Quartus II Project
      Tcl
      VHDL
      Verilog HDL
      C Code Examples
      DSP Builder
      TimeQuest
   On-Chip Debugging
  
 Simulation Tools
      Mentor Graphics ModelSim
      Cadence NCsim
      Synopsys VCS
  
 Legacy Examples
      Graphic Editor
      AHDL
  

Quartus II Tcl Example: Export Report Data to CSV File

Many designers use Excel at some stage of an FPGA design. It's easy to export data from a Quartus® II report panel to a CSV file that you can open in Excel.

This simple procedure exports data from a specified report panel and writes it to a file. A project must be open when you call this procedure. An example of how to use it in a script follows.

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
}

Here's a script that uses the procedure. Run this at a system command prompt with the command below.

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

You can run this script at a command prompt with the following command.

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

Ensure you quote the panel name argument properly if you enter it at a system command prompt. Certain characters, such as the vertical bar (|) have special meaning at a command shell.

  Please Give Us Feedback