| The Datasheet Archive - 100 Million Datasheets from 7500 Manufacturers. |
QII52003-7.1.0 Developing running tool command language (Tcl) scr
Top Searches for this datasheetScripting QII52003-7.1.0 Developing running tool command language (Tcl) scripts control Altera® Quartus® software allows perform wide range functions, such compiling design writing procedures automate common tasks. scripts manage Quartus project, make assignments, define design constraints, make device assignments, compilations, perform timing analysis, import LogicLockregion assignments, Quartus Chip Editor, access reports. automate your Quartus assignments using scripts that have create them individually. scripts also facilitate project assignment migration. example, when using same prototype development board different projects, automate reassignment locations each project. Quartus software also generate script based current assignments project, which aids switching assignments another project. Quartus software commands follow industry application programming interface (API) standards using command-line options specify arguments. This simplifies learning using commands. encounter error using command argument, interpreter gives help information showing correct usage. This chapter includes sample scripts automating Quartus software. modify these example scripts with your designs. find more scripts Design Examples section Support area Altera's website. This chapter includes following topics: "Introduction" "Quartus Packages" page "Quartus Help" page "Executables Supporting Tcl" page "End-to-End Design Flows" page 3-11 "Creating Projects Making Assignments" page 3-12 "Compiling Designs" page 3-20 "Reporting" page 3-21 "Timing Analysis" page 3-24 "Automating Script Execution" page 3-29 Altera Corporation 2007 Quartus Handbook, Volume "Other Scripting Features" page 3-32 "Using Quartus Shell Interactive Mode" page 3-38 "Quartus Legacy Support" page 3-41 "Tcl Scripting Basics" page 3-41 What Tcl? (pronounced "tickle") popular scripting language that similar many shell scripting high-level programming languages. provides support control structures, variables, network socket access, APIs. industry-standard scripting language used Synopsys, Mentor Graphics®, Synplicity, Altera software. allows create custom commands works seamlessly across most development platforms. list recommended literature Tcl, refer "External References" page 3-49. create your procedures writing scripts containing basic commands, user-defined procedures, Quartus functions. then automate your design flow, Quartus software batch mode, execute individual commands interactively Quartus interactive shell. you're unfamiliar with scripting, beginner, refer "Tcl Scripting Basics" page 3-41 introduction scripting. Quartus software, beginning with version 4.1, supports Tcl/Tk version 8.4, supplied DeveloperXchange tcl.activestate.com. Quartus Packages Table 3-1. Packages Package Name advanced_timing backannotate chip_planner database_manager device flow insystem_memory_edit jtag Quartus commands grouped packages function. Table describes each package. (Part Package Description Traverse timing netlist information about timing nodes Back annotate assignments Identify modify resource usage routing with Chip Editor Manage version-compatible database files device family information from device database Compile project, command-line executables other common flows Read edit memory contents Altera devices Control jtag chain Altera Corporation 2007 Quartus Packages Table 3-1. Packages Package Name logic_analyzer_interface logiclock misc project report simulator timing timing_assignment (Part Package Description Query modify logic analyzer interface output state Create manage LogicLock regions Perform miscellaneous tasks Create manage projects revisions, make project assignments including timing assignments information from report tables, create custom reports Specifies constraints exceptions TimeQuest Analyzer Configure perform simulations Contains functions obtaining advanced information from Quartus TimeQuest Timing Analyzer SignalTap® logic analyzer Annotate timing netlist with delay information, compute report timing paths Contains functions making project-wide timing assignments, including clock assignments; commands designed process Quartus Classic Timing Analyzer assignments have been moved this package List timing paths Altera-specific commands timing_report sdc_ext default, only minimum number packages loaded automatically with each Quartus executable. This keeps memory requirement each executable possible. Because minimum number packages automatically loaded, must load other packages before commands those packages. Table lists Quartus packages available with Quartus executables indicates whether package loaded default available loaded necessary clear circle means that package available that executable. Table 3-2. Package Availability Quartus Executable (Part Quartus Executable Packages Quartus_sh Quartus_tan Quartus_cdb Quartus_sim Quartus_stp Quartus_sta Quartus_staw Console advanced_timing backannotate Altera Corporation 2007 Quartus Handbook, Volume Table 3-2. Package Availability Quartus Executable (Part Quartus Executable Packages Quartus_sh Quartus_tan Quartus_cdb Quartus_sim Quartus_stp Quartus_sta Quartus_staw Console chip_planner device flow insystem_memory_edit jtag logic_analyzer_ interface logiclock misc old_api project report sdc_ext simulator timing timing_assignment timing_report Notes Table 3-2: dark circle indicates that package loaded automatically. half-circle means that package available loaded automatically. white circle means that package available that executable. Altera Corporation 2007 Quartus Help Because different packages available different executables, must your scripts with executables that include packages scripts. example, commands timing package, must quartus_tan executable script because quartus_tan executable only with support timing package. Loading Packages load Quartus package, load_package command follows: load_package [-version <version number>] <package name> This command similar package require command (described Table page 3-6), easily alternate between different versions Quartus package with load_package command. additional information about these other Quartus command-line executables, refer Command-Line Scripting chapter volume Quartus Handbook. Access Quartus Help reference typing following command system command prompt: quartus_sh -qhelp This command runs Quartus Command-Line help browser, which documents commands options Quartus API. includes detailed descriptions examples each command. addition, information help available Quartus Scripting Reference Manual, which available Quartus Literature page Altera site. Quartus help allows easy access information about Quartus commands. access help information, type help prompt, shown Example 3-1. Quartus Help Altera Corporation 2007 Quartus Handbook, Volume Example 3-1. Help Output tcl> help -Available Quartus Packages: -Loaded -::quartus::misc ::quartus::old_api ::quartus::project ::quartus::timing_assignment ::quartus::timing_report Loaded -::quartus::device ::quartus::backannotate ::quartus::flow ::quartus::logiclock ::quartus::report Type "help -tcl" overview Quartus usages. Using -tcl option with help displays introduction Quartus that focuses help commands (short help long help) packages. help also available Quartus online help. Search command package name find details about that command package. Table summarizes help options available environment. Table 3-3. Help Options Available Quartus Environment (Part Help Command help help -tcl Description view list available Quartus packages, loaded loaded. view list commands used load packages access command-line help. Altera Corporation 2007 Quartus Help Table 3-3. Help Options Available Quartus Environment (Part Help Command help -pkg <package_name> [-version <version number>] Description view help specified Quartus package that includes list available commands. convenience, omit ::quartus:: package prefix, type help -pkg <package name> specify -version option, help currently loaded package displayed default. package which want help loaded, help latest version package displayed default. Examples: help -pkg ::quartus::p help -pkg ::quartus::project help -pkg project rhelp -pkg project -version <command_name> <command_name> -help view short help Quartus command which package loaded. Examples: project_open project_open -help package require ::quartus::<package name> [<version>] load Quartus package with specified version. <version> specified, latest version package loaded default. Example: package require ::quartus::project This command similar load_package command. advantage using load_package that alternate freely between different versions same package. Type <package name> [-version <version number>]r load Quartus package with specified version. -version option specified, latest version package loaded default. Example: load_package ::quartus::project -version help -cmd <command name> [-version <version number>] <command name> -long_help view long help Quartus command. Only <command name> -long_help requires that associated package loaded. specify -version option, help currently loaded package displayed default. package which want help loaded, help latest version package displayed default. Examples: project_open -long_help help -cmd project_open help -cmd project_open -version Altera Corporation 2007 Quartus Handbook, Volume Table 3-3. Help Options Available Quartus Environment (Part Help Command help -examples help -quartus quartus_sh -qhelp Description view examples Quartus usage. view help predefined global array that accessed view information about Quartus executable that currently running. launch viewer Quartus command-line help display help command-line executables packages. more information about this utility, refer Command-Line Scripting chapter volume Quartus Handbook. Executables Supporting Some Quartus command-line executables support scripting (refer Table 3-4). Each executable supports different sets packages. Refer Table determine appropriate executable your script. Table 3-4. Command-line Executables Supporting Scripting Executable Name quartus_sh quartus_tan quartus_cdb Executable Description Quartus Shell simple scripting shell, useful making assignments, general reporting, compiling. Quartus Classic Timing Analyzer perform simple timing reporting advanced timing analysis. Quartus Compiler Database supports back annotation, LogicLock region operations, Chip Editor functions. Quartus Simulator supports automation design simulation. Quartus TimeQuest Timing Analyzer supports terminology constraint entry reporting. Quartus SignalTap executable supports in-system debugging tools. quartus_sim quartus_sta quartus_staw quartus_stp quartus_tan quartus_cdb executables support supersets packages supported quartus_sh executable. quartus_sh executable scripts with only project management assignment commands, need Quartus command-line executable with small memory footprint. more information about these command-line executables, refer Command-Line Scripting chapter volume Quartus Handbook. Altera Corporation 2007 Executables Supporting Command-Line Options: -tcl_eval Table lists three command-line options with executables that support Tcl. Table 3-5. Command-Line Options Supporting Scripting Command-Line Option <script file> [<script args>] -tcl_eval <tcl command> Description specified script with optional arguments. Open executable interactive shell mode. Evaluate remaining command-line arguments commands. example, following command displays help project package: quartus_sh -tcl_eval help -pkg project Script Running executable with option runs specified script. also specify arguments script. Access arguments through argv variable, package such cmdline, which supports arguments following form: -<argument name> <argument value> cmdline package included <Quartus directory>/common/tcl/packages directory. example, script called myscript.tcl with argument, Stratix, type following command system command prompt: quartus_sh myscript.tcl Stratix Beginning with version 4.1, Quartus software supports argv variable. previous software versions, script arguments accessed quartus(args) global variable. Refer "Accessing Command-Line Arguments" page 3-35 more information. Interactive Shell Mode Running executable with option starts interactive shell that displays tcl> prompt. example, type quartus_tan system command prompt open Quartus Classic Timing Altera Corporation 2007 Quartus Handbook, Volume Analyzer executable interactive shell mode. Commands type shell interpreted when press Enter. script interactive shell with following command: source <script name> command recognized shell, assumed external command executed with exec command. Evaluate Running executable with -tcl_eval option causes executable immediately evaluate remaining command-line arguments commands. This useful want simple commands from other scripting languages. example, following command runs command that prints commands available project package. quartus_sh -tcl_eval help -pkg project Using Quartus Console Window commands directly Quartus Console window. View menu, click Utility Windows. default, Console window docked bottom-right corner Quartus GUI. Everything typed Console interpreted Quartus shell. Quartus Console window supports used Quartus software version earlier backward compatibility with older designs tools. messages appear System (Messages window). Errors messages written stdout stderr also shown Quartus Console window. 3-10 Altera Corporation 2007 End-to-End Design Flows Note that limited timing analysis console Quartus GUI. With timing_report package, list_path command details paths listed timing report. However, want information about timing paths that listed timing report, must quartus_tan executable shell mode script that reports paths which interested. your design uses Quartus TimeQuest Timing Analyzer, should perform scripted timing analysis TimeQuest console. Table shows, console Quartus does include support every package, cannot scripts that commands packages that supported. End-to-End Design Flows scripts control aspects design flow, including controlling other software includes scripting interface. Typically, tools include their script interpreters that extend core language functionality with tool-specific commands. example, Quartus interpreter supports core commands, adds numerous commands specific Quartus software. include commands script another script, which allows combine chain together scripts control different tools. Because scripts different tools must executed with different interpreters, difficult pass information between scripts unless script writes information into file another script reads Within Quartus software, perform many different operations design flow (such synthesis, fitting, timing analysis) from single script, making easy maintain global state information pass data between operations. However, there some limitations operations perform single script various packages supported each executable. example, cannot write single script that performs simulation with commands simulator package while using commands advanced_timing package; those packages available same executable. case where wanted include simulation advanced timing analysis commands, must write scripts. There limitations running flows from executable. Flows include operations found Start section Processing menu Quartus GUI, also documented with execute_flow command. make settings Quartus software flow your desired result, make same settings same flow command-line executable. Altera Corporation 2007 3-11 Quartus Handbook, Volume revisit example with simulation timing analysis, could write script that includes settings that configure simulation, with settings that configure timing analysis. Then, simulation timing analysis flows with execute_flow command. Configuring simulation includes specifying settings such name location stimulus file, duration simulation, whether perform glitch detection not, more. Configuring timing analysis includes specifying settings such required clock frequency, number paths report, which timing model use. make settings, then flows with execute_flow command, Quartus command-line executable. Creating Projects Making Assignments benefit scripting that easy create script that makes assignments existing project. script time restore your project settings known state. From Project menu, click Generate File Project automatically generate file with your assignments. source this file recreate your project, edit file other commands, such compiling design. file good starting point learn about project management commands assignment commands. Refer "Interactive Shell Mode" page information about sourcing script. Scripting information Quartus project settings assignments located Reference Manual. Example shows create project, make assignments, compile project. uses fir_filter tutorial design files. 3-12 Altera Corporation 2007 Creating Projects Making Assignments Example 3-2. Create Compile Project load_package flow Create project overwrite settings files that exist project_new fir_filter -revision filtref -overwrite device, name top-level BDF, name level entity set_global_assignment -name FAMILY Cyclone set_global_assignment -name DEVICE EP1C6F256C6 set_global_assignment -name BDF_FILE filtref.bdf set_global_assignment -name TOP_LEVEL_ENTITY filtref other assignments here set_location_assignment Pin_G1 Create base clock derived clock create_base_clock -fmax "100 MHz" -target clocka create_relative_clock -base_clock clocka -divide -offset "500 -target clkx2 clockb Create multicycle assignment between clock domains design. set_multicycle_assignment -from clkx2 execute_flow -compile project_close assignments created modified while project open committed Quartus settings files unless explicitly call export_assignments project_close (unless -dont_export_assignments specified). some cases, such when running execute_flow, Quartus software automatically commits changes. HardCopy Device Design information about using scripted design flow HardCopy designs, refer Script-Based Design HardCopy Devices chapter HardCopy Handbook. contains sample scripts recommendations make your HardCopy design flow easy. separate chapter HardCopy Handbook called Timing Constraints HardCopy Devices also contains information about script-based design HardCopy devices, with emphasis timing constraints. Tool Assignments target tools project Quartus software with set_global_assignment command. default tool settings each tool, need only specify tool used. interfaces available Quartus software cover design Altera Corporation 2007 3-13 Quartus Handbook, Volume entry, simulation, timing analysis, board design tools. More advanced tools such those formal verification resynthesis supported their global assignment. default, interface options <none>. Table lists interface options available Quartus software. Enclose interface assignment options that contain spaces quotation marks. Table 3-6. Interface Options Quartus Software (Part Option Design Entry Acceptable Values Design Architect Design Compiler FPGA Compiler FPGA Compiler FPGA Compiler Altera Edition FPGA Express (Level Synplify Synplify ViewDraw Precision Synthesis Custom ModelSim (VHDL output from Quartus software) ModelSim (Verilog output from Quartus software) ModelSim-Altera (VHDL output from Quartus software) ModelSim-Altera (Verilog output from Quartus software) SpeedWave Verilog-XL NC-Verilog (Verilog output from Quartus software) NC-VHDL (VHDL output from Quartus software) Scirocco (VHDL output from Quartus software) Custom Verilog Custom VHDL PrimeTime (VHDL output from Quartus software) PrimeTime (Verilog output from Quartus software) Stamp (board model) Custom Verilog Custom VHDL Simulation (EDA_SIMULATION_TOOL) Timing Analysis (EDA_TIMING_ANALYSIS_TOOL) 3-14 Altera Corporation 2007 Creating Projects Making Assignments Table 3-6. Interface Options Quartus Software (Part Option Board level tools Acceptable Values Signal Integrity (IBIS) Symbol Generation (ViewDraw) Conformal PALACE Amplify (EDA_BOARD_DESIGN_TOOL) Formal Verification (EDA_FORMAL_VERIFICATION_TOOL) Resynthesis (EDA_RESYNTHESIS_TOOL) example, generate NC-Sim Verilog simulation output file, EDA_SIMULATION_TOOL should target NC-Sim Verilog desired output, shown Example 3-3. Example 3-3. set_global_assignment -name eda_simulation_tool "NcSim (Verilog output from Quartus II)" information about using third-party simulation tools, refer volume Quartus Handbook. Example shows compilation fir_filter design files, generating VHDL Output (.vho) file output NC-Sim Verilog simulation. Altera Corporation 2007 3-15 Quartus Handbook, Volume Example 3-4. Simple Design with .vho Output This script works with quartus_sh executable project name filtref project_name filtref Open Project. does already exist, create [catch {project_open $project_name}] {project_new $project_name} Family set_global_assignment -name family APEX 20KE Device set_global_assignment -name device ep20k100eqc208-1 Optimize speed set_global_assignment -name optimization_technique speed Turn-on Fastfit fitter option reduce compile times set_global_assignment -name fast_fit_compilation Generate NC-Sim Verilog simulation Netlist set_global_assignment -name eda_simulation_tool "NcSim\ (Verilog output from Quartus II)" Create FMAX=50MHz assignment called clk1 create_base_clock -fmax 50MHz -target clk1 Create assignment set_location Pin_134 Compilation option Always write assignments constraint files before doing system call. Else, stand-alone files will pick assignments #export_assignments #qexec quartus_map <project_name> #qexec quartus_fit <project_name> #qexec quartus_asm <project_name> #qexec quartus_tan <project_name> #qexec quartus_eda <project_name> Compilation option (better) Using ::quartus::flow package, execute_flow command will export_assignments automatically equivalent steps outlined compilation option load_package flow execute_flow -compile Close Project project_close 3-16 Altera Corporation 2007 Creating Projects Making Assignments Custom options available target other tools. custom configurations, change individual interface options making additional assignments. complete list each setting line available, refer Quartus Help. Using LogicLock Regions commands work with LogicLockregions. following examples show export import LogicLock regions other designs. examples files LogicLock tutorial design. additional information about LogicLock design methodology, LogicLock Design Methodology chapter volume Quartus Handbook. compile design export LogicLock regions, follow these steps: Create project assignments. Assign virtual pins. Create LogicLock region. Assign design entity region. Compile project. Back-annotate region. Export region. Altera Corporation 2007 3-17 Quartus Handbook, Volume Example shows script that creates project called lockmult, makes required assignments compile project. Next, script compiles project, back-annotates design, exports LogicLock region. script uses procedure called assign_virtual_pins, which described after example. quartus_cdb executable this script. Example 3-5. LogicLock Export Script load_package flow load_package logiclock load_package backannotate project_new lockmult -overwrite set_global_assignment -name BDF_FILE pipemult.bdf set_global_assignment -name FAMILY Cyclone set_global_assignment -name DEVICE EP1C6F256C6 set_global_assignment -name TOP_LEVEL_ENTITY pipemult These assignments cause Quartus software generate file logic LogicLock region. file imported into top-level design. set_global_assignment -name pipemult.vqm set_global_assignment -name create_base_clock -fmax 200MHz -target clk_200 assign_virtual_pins #Prepare LogicLock data structures before #LogicLock-related commands. initialize_logiclock Create region named lockmult assign pipemult region auto-sized floating. set_logiclock -region lockmult -auto_size true -floating true set_logiclock_contents -region lockmult pipemult execute_flow -compile Back annotate LogicLock Region export logiclock_back_annotate -region lockmult -lock logiclock_export -file_name pipemult.qsf uninitialize_logiclock project_close 3-18 Altera Corporation 2007 Creating Projects Making Assignments assign_virtual_pins command procedure that makes virtual assignments bottom-level design pins, except signals specified arguments procedure. procedure defined Example 3-6. Example 3-6. assign_virtual_pins Procedure proc assign_virtual_pins skips Analysis elaboration must first names execute_flow -analysis_and_elaboration names collection. name_ids [get_names -filter -node_type pin] foreach_in_collection name_id $name_ids hierarchical path name pin. hname [get_name_info -info full_path $name_id] #Skip virtual assignment #pin list signals skipped. {[lsearch -exact $skips $hname] post_message "Setting VIRTUAL_PIN $hname" set_instance_assignment $hname -name VIRTUAL_PIN else post_message "Skipping VIRTUAL_PIN $hname" When script runs, generates netlist file named pipemult.vqm, Quartus Settings File named pipemult.qsf, which contains back-annotated assignments. then import LogicLock region another design. This example uses top-level design topmult directory. import four times top-level LogicLock tutorial design, follow these steps: Create top-level project. assignments. Elaborate design. Import LogicLock constraints. Compile project. Altera Corporation 2007 3-19 Quartus Handbook, Volume Example shows script that demonstrates previous steps. Example 3-7. LogicLock Import Script load_package flow load_package logiclock project_new topmult -overwrite set_global_assignment -name BDF_FILE topmult.bdf set_global_assignment -name VQM_FILE pipemult.vqm set_global_assignment -name FAMILY Cyclone set_global_assignment -name DEVICE EP1C6F256C6 create_base_clock -fmax 200MHz -target clk_200 LogicLock region will used four times top-level design. These assignments specify that back-annotated assignments will applied four entities top-level design. set_instance_assignment -name LL_IMPORT_FILE pipemult.qsf pipemult:inst set_instance_assignment -name LL_IMPORT_FILE pipemult.qsf pipemult:inst1 set_instance_assignment -name LL_IMPORT_FILE pipemult.qsf pipemult:inst2 set_instance_assignment -name LL_IMPORT_FILE pipemult.qsf pipemult:inst3 execute_flow -analysis_and_elaboration initialize_logiclock logiclock_import uninitialize_logiclock execute_flow -compile project_close additional information about LogicLock design methodology, refer LogicLock Design Methodology chapter volume Quartus Handbook. Quartus command-line executables from scripts. included flow package various Quartus compilation flows, each executable directly. Compiling Designs flow Package flow package includes commands running Quartus command-line executables, either individually together standard compilation sequence. execute_module command allows 3-20 Altera Corporation 2007 Reporting individual Quartus command-line executable. execute_flow command allows some modules commonlyused combinations. Altera recommends using flow package instead using system calls compiler executables. Another Quartus command-line executable from environment using qexec command, Quartus implementation exec command. example, Quartus technology mapper given project, type: qexec "quartus_map <project_name>" When qexec command compile design, assignments made script from shell) exported project database settings file before compilation. export_assignments command compile project with commands flow package ensure assignments exported project database settings file. should qexec command make system calls. also executables directly shell, using same syntax system command prompt. example, Quartus technology mapper given project, type following shell prompt: quartus_map <project_name> Reporting Once compilation finishes, sometimes necessary extract information from report evaluate results. example, need know many device resources design uses, whether meets your performance requirements. Quartus provides easy access report data don't have write scripts parse text report files. commands that access report data time, cell time. know exact cell cells want access, get_report_panel_data command specify column names coordinates) name appropriate report panel. often search data report panel. this, loop that reads report time with get_report_panel_row command. Altera Corporation 2007 3-21 Quartus Handbook, Volume Column headings report panels loop that reads report time, start with skip with column headings. get_number_of_rows command returns number rows report panel, including column heading row. Because number rows includes column heading row, your loop should continue long loop index less than number rows, illustrated following example. Report panels hierarchically arranged, each level hierarchy denoted string "||" panel name. example, name Fitter Settings report panel Fitter||Fitter Settings because Fitter folder. Panels highest hierarchy level "||" string. example, Flow Settings report panel named Flow Settings. Example shows code that prints list report panel names your project:. Example 3-8. Print Report Panel Names panel_names [get_report_panel_names] foreach panel_name $panel_names post_message "$panel_name" Example prints number failing paths each clock domain your design. uses loop access each Timing Analyzer Summary report panel. Clock domains listed column named Type with format Clock Setup:'<clock name>'. Other summary information listed Type column well. Type column matches pattern "Clock Setup*", script prints number failing paths listed column named Failed Paths. 3-22 Altera Corporation 2007 Reporting Example 3-9. Print Number Failing Paths Clock load_package report project_open my-project load_report report_panel_name "Timing Analyzer||Timing Analyzer Summary" num_rows [get_number_of_rows -name $report_panel_name] column indices Type Failed Paths columns type_column [get_report_panel_column_index -name $report_panel_name "Type"] failed_paths_column [get_report_panel_column_index -name $report_panel_name "Failed Paths"] through each line report panel {set $num_rows} {incr data, then type summary information row, number failed paths report_row [get_report_panel_row -name $report_panel_name -row row_type [lindex $report_row $type_column] failed_paths [lindex $report_row $failed_paths_column] [string match "Clock Setup*" $row_type] puts "$row_type $failed_paths failing paths" unload_report Creating Files Excel Microsoft Excel software sometimes used view manipulate timing analysis results. create file import into Excel with data from Quartus report. Example 3-10 shows simple create file with data from timing analysis panel report. could modify script command-line arguments pass name project, report panel, output file use. Altera Corporation 2007 3-23 Quartus Handbook, Volume Example 3-10. Create Files from Reports load_package report project_open my-project load_report This name report panel save file panel_name "Timing Analyzer||Clock Setup: 'clk'" csv_file "output.csv" [open $csv_file num_rows [get_number_of_rows -name $panel_name] through rows report file, including with headings, write comma-separated data $num_rows incr row_data [get_report_panel_row -name $panel_name -row puts [join $row_data ","] close unload_report Short Option Names Beginning with version Quartus software, short versions command options, long they distinguish between command's options. example, project_open command supports options: -current_revision -revision. following shortened versions -revision option: -re, -rev, -revi, -revis, -revisio. option short because other option starts with same letters revision. However, report_timing command includes options -recovery -removal. cannot shorten either those options, because they uniquely distinguish between either option. could -rec -rem. Timing Analysis Quartus software includes comprehensive APIs both Classic TimeQuest analyzers. This section includes simple advanced script examples Classic analyzer introductory scripting information about TimeQuest API. 3-24 Altera Corporation 2007 Timing Analysis Classic Timing Analysis following example script uses quartus_tan executable perform timing analysis fir_filter tutorial design. fir_filter design two-clock design that requires base clock relative clock relationship timing analysis. This script first does analysis two-clock relationship checks slack between clkx2. first pass timing analysis discovers negative slack clocks. second part script adds multicycle assignment from clkx2 re-analyzes design multi-clock, multicycle design. script does recompile design with timing assignments, timing-driven compilation used synthesis placement this design. timing assignments added only timing analyzer analyze design with create_timing_netlist report_timing commands. must compile project before running script example shown Example 3-11. Example 3-11. Classic Timing Analysis This file used with quartus_tan.exe This file will Quartus tutorial fir_filter design timing analysis portion making global timing assignment creating multi-clock assignments timing analysis multi-clock, multi-cycle design project_name fir_filter revision_name filtref project_name fir_filter revision_name filtref open project project_name project name project_open -revision $revision_name $project_name; Doing tutorial steps this section re-runs timing analysis module with multi-clock multi-cycle settings Make timing assignments #Specifying global FMAX requirement (tan tutorial) set_global_assignment -name FMAX_REQUIREMENT 45.0MHz set_global_assignment -name CUT_OFF_IO_PIN_FEEDBACK create base reference clock "clocka" specifies following: BASED_ON_CLOCK_SETTINGS clocka; OFF; FMAX_REQUIREMENT 50MHZ; DUTY_CYCLE Altera Corporation 2007 3-25 Quartus Handbook, Volume Assigns reference clocka "clk" create_base_clock -fmax 50MHZ -duty_cycle clocka -target creates relative clock "clockb" based reference clock "clocka" with following settings: BASED_ON_CLOCK_SETTINGS clocka; MULTIPLY_BASE_CLOCK_PERIOD_BY DIVIDE_BASE_CLOCK_PERIOD_BY 2;clock period half base DUTY_CYCLE OFFSET_FROM_BASE_CLOCK 500ps;The offset INVERT_BASE_CLOCK OFF; Assigns reference clock "clkx2" create_relative_clock -base_clock clocka -duty_cycle -divide -offset 500ps -target clkx2 clockb create timing netlist based timing settings create_timing_netlist does analysis clkx2 Limits path listing path Does clock setup analysis clkx2 report_timing -npaths -clock_setup -file setup_multiclock.tao output file will show negative slack clkx2 when only specifying multi-clock design. negative slack created offset from base clock removes timing netlist allow creation timing netlist analysis report_timing delete_timing_netlist adding multi-cycle setting corrects negative slack adding multicycle assignment clkx2 allow more set-up time set_multicycle_assignment -from clkx2 create timing netlist based additional timing assignments create_timing_netlist outputs result file clkx2 only report_timing -npaths -clock_setup -clock_filter clkx2 -file clkx2_setup_multicycle.tao output file will show positive slack clkx2 project_close Advanced Classic Timing Analysis There times when commands available timing analysis reporting provide access specific data need. advanced_timing package provides commands access data structures representing timing netlist your design. These commands provide low-level details about timing delays, node fan-in fan-out, timing data. Writing procedures traverse timing netlist extract information gives most control exactly data need. 3-26 Altera Corporation 2007 Timing Analysis timing netlist represented with graph, which collection nodes edges. Nodes represent elements your design such registers, combinational nodes, pins, clocks. Edges connect nodes represent connections between logic your design. Edges nodes have unique positive integer that identify them timing netlist. commands getting information about timing netlist node edge instead text-based names. example advanced_timing package, Example 3-12 shows show register-to-pin delays from registers that drive pins output bus. Specify name output (for example, address), script prints names registers driving pins delays from registers pins. Example 3-12. Report Register-to-Pin Delays load_package advanced_timing package require cmdline This procedure returns list pins with names that match name passed proc find bus_name to_return [list] foreach_in_collection node_id [get_timing_nodes -type pin] node_name [get_timing_node_info -info name $node_id] [string match $bus_name* $node_name] lappend to_return $node_id return $to_return Required arguments script name project revision, well name analyze options "project.arg" "Project name" "revision.arg" "Revision name" "bus_name.arg" "Name timing data for" array opts [::cmdline::getoptions quartus(args) $options] project_open $opts(project) -revision $opts(revision) timing netlist must created before accessing create_timing_netlist This creates data structure with additional timing data create_p2p_delays Walk through each specified foreach pin_id [find $opts(bus_name)] pin_name [get_timing_node_info -info name $pin_id] Altera Corporation 2007 3-27 Quartus Handbook, Volume puts "$pin_name source registers delays" get_delays_from_keepers command returns list non-combinational nodes design that specified timing node, with associated delays. foreach data [get_delays_from_keepers $pin_id] source_node [lindex $data max_delay [lindex $data source_node_name [get_timing_node_info -info name $source_node] puts $source_node_name $max_delay" project_close Type command shown Example 3-13 system command prompt this script. Example 3-13. quartus_tan script.tcl -project fir_filter -revision filtref -bus_name yn_out TimeQuest Timing Analysis Quartus TimeQuest Timing Analyzer includes support commands ::quartus::sdc package. Refer Quartus TimeQuest Timing Analyzer chapter volume Quartus Handbook detailed information about perform timing analysis with Quartus TimeQuest Timing Analyzer. TimeQuest Scripting versions Quartus software before 6.0, ::quartus::project package contained following SDC-like commands making timing assignments: create_base_clock create_relative_clock get_clocks set_clock_latency set_clock_uncertainty set_input_delay set_multicycle_assignment set_output_delay set_timing_cut_assignment 3-28 Altera Corporation 2007 Automating Script Execution These commands SDC-compliant. Beginning with version 6.0, these commands package named ::quartus::timing_assignment. ensure backwards compatibility with existing scripts, ::quartus::timing_assignment package loaded default following executables: quartus quartus_sh quartus_cdb quartus_sim quartus_stp quartus_tan ::quartus::timing_assignment package loaded default quartus_sta executable. ::quartus::sdc package includes SDC-compliant versions commands listed above. package available only quartus_sta executable, loaded default. Automating Script Execution Beginning with version Quartus software, configure scripts automatically various points during compilation. this capability automatically scripts that perform custom reporting, make specific assignments, perform many other tasks. following three global assignments control when script automatically: PRE_FLOW_SCRIPT_FILE -before flow starts POST_MODULE_SCRIPT_FILE -after module finishes POST_FLOW_SCRIPT_FILE -after flow finishes POST_FLOW_SCRIPT_FILE POST_MODULE_SCRIPT_FILE assignments supported beginning version 4.0, PRE_FLOW_SCRIPT_FILE assignment supported beginning version 4.1. module Quartus executable that performs step flow. example, modules Analysis Synthesis (quartus_map) timing analysis (quartus_tan). flow series modules that Quartus software runs with predefined options. example, compiling design flow that typically consists following steps (performed indicated module): Altera Corporation 2007 Analysis synthesis (quartus_map) Fitter (quartus_fit) 3-29 Quartus Handbook, Volume Assembler (quartus_asm) Timing Analyzer (quartus_tan) Other flows described help execute_flow command. addition, many commands Processing menu Quartus correspond this design flow. Making Assignment make assignment automatically script, assignment with following form your project's Quartus Settings File: set_global_assignment -name <assignment name> <executable>:<script name> assignment name following: PRE_FLOW_SCRIPT_FILE POST_MODULE_SCRIPT_FILE POST_FLOW_SCRIPT_FILE executable name Quartus command-line executable that includes interpreter. quartus_cdb quartus_sh quartus_sim quartus_sta quartus_stp quartus_tan script name name your script. Script Execution Quartus software runs scripts shown Example 3-14. Example 3-14. <executable> <script name> <flow module name> <project name> <revision name> first argument passed argv variable quartus(args) variable) name flow module being executed, depending assignment use. second argument name project, third argument name revision. 3-30 Altera Corporation 2007 Automating Script Execution When POST_MODULE_SCRIPT_FILE assignment, specified script automatically after every executable flow. string comparison with module name (the first argument passed script) isolate script processing certain modules. Execution Example Example 3-15 illustrates automatic script execution works complete flow, assuming have project called with current revision called rev_1, have following assignments Quartus Settings File your project. Example 3-15. set_global_assignment -name PRE_FLOW_SCRIPT_FILE quartus_sh:first.tcl set_global_assignment -name POST_MODULE_SCRIPT_FILE quartus_sh:next.tcl set_global_assignment -name POST_FLOW_SCRIPT_FILE quartus_sh:last.tcl When compile your project, PRE_FLOW_SCRIPT_FILE assignment causes following command before compilation begins: quartus_sh first.tcl compile rev_1 Next, Quartus software starts compilation with analysis synthesis, performed quartus_map executable. After analysis synthesis finishes, POST_MODULE_SCRIPT_FILE assignment causes following command run: quartus_sh next.tcl quartus_map rev_1 Then, Quartus software continues compilation with Fitter, performed quartus_fit executable. After Fitter finishes, POST_MODULE_SCRIPT_FILE assignment runs following command: quartus_sh next.tcl quartus_fit rev_1 Corresponding commands after other stages compilation. Finally, after compilation over, POST_FLOW_SCRIPT_FILE assignment runs following command: quartus_sh last.tcl compile rev_1 Altera Corporation 2007 3-31 Quartus Handbook, Volume Controlling Processing POST_MODULE_SCRIPT_FILE assignment causes script after every module. Because same script after every module, need include some conditional statements that restrict processing your script certain modules. example, want script only after timing analysis, should include conditional test like shown Example 3-16. checks flow module name passed first argument script executes code when module quartus_tan. Example 3-16. Restrict Processing Single Module module [lindex $quartus(args) [string match "quartus_tan" $module] Include commands here that after timing analysis post-message command display messages post_message "Running after timing analysis" Displaying Messages Because Quartus software runs scripts automatically, must post_message command display messages, instead puts command. This requirement applies only scripts that three assignments listed "Automating Script Execution" page 3-29. Refer "Using post_message Command" page 3-34 more information about this command. Other Scripting Features Quartus includes other general-purpose commands features described this section. Natural Naming Beginning with version 4.2, Quartus software supports natural naming. Natural naming means that square brackets used specify indexes hardware description languages have escaped prevent from interpreting them commands. example, 3-32 Altera Corporation 2007 Other Scripting Features signal named address identified address[0] instead address\[0\]. take advantage natural naming when making assignments, Example 3-17. Example 3-17. Natural Naming set_location_assignment address[10] Pin_M20 Quartus software defaults natural naming. turn natural naming with disable_natural_bus_naming command. more information about natural naming, type enable_natural_bus_naming Quartus prompt. Using Collection Commands Some Quartus functions return very large sets data that would inefficient lists. These data structures referred collections Quartus uses collection access collection. There Quartus commands working with collections, foreach_in_collection get_collection_size. command assign collection variable. information about which Quartus commands return collection IDs, Quartus Help search foreach_in_collection command. foreach_in_collection Command foreach_in_collection command similar foreach command. iterate through elements collection. Example 3-18 prints instance assignments open project. Example 3-18. Using Collection Commands all_instance_assignments [get_all_instance_assignments -name foreach_in_collection asgn $all_instance_assignments Information about each assignment returned list. information about list elements, refer Help get-all-instance-assignments command. [lindex $asgn name [lindex $asgn value [lindex $asgn puts "Assignment $to: $name $value" Altera Corporation 2007 3-33 Quartus Handbook, Volume get_collection_size Command get_collection_size command number elements collection. Example 3-19 prints number global assignments open project: Example 3-19. get_collection_size Command all_global_assignments [get_all_global_assignments -name num_global_assignments [get_collection_size $all_global_assignments] puts "There $num_global_assignments global assignments your project" Using post_message Command print messages that formatted like Quartus software messages, post_message command. Messages printed post_message command appear System Messages window Quartus GUI, written standard when scripts run. Arguments post_message command include optional message type required message string. message type following: info (default) extra_info warning critical_warning error specify type, Quartus software defaults info. When using Quartus software Windows, color code messages displayed system command prompt with post_message command. following line your quartus2.ini file: Example 3-20 shows post_message command. Example 3-20. post_message command post_message -type warning "Design gated clocks" 3-34 Altera Corporation 2007 Other Scripting Features Accessing Command-Line Arguments Many scripts designed accept command-line arguments, such name project revision. global variable quartus(args) list arguments typed command-line following name script. Example 3-21 shows code that prints arguments quartus(args) variable. Example 3-21. Simple Command-Line Argument Access foreach $quartus(args) puts "The value index $arg" incr copy script previous example file named print_args.tcl, displays following output when type command shown Example 3-22 command prompt. Example 3-22. Passing Command-Line Arguments Scripts quartus_sh print_args.tcl my_project 100MHz value index <my_project> value index 100MHz Beginning with version 4.1, Quartus software supports variables argv, argc, argv0 command-line argument access. Table shows equivalent information earlier versions software. Table 3-7. Quartus Support Variables Beginning with Version argc argv argv0 Equivalent Support Previous Software Versions llength $quartus(args) quartus(args) info nameofexecutable Altera Corporation 2007 3-35 Quartus Handbook, Volume Using cmdline Package cmdline package included with Quartus software more robust self-documenting command-line argument passing. cmdline package supports command-line arguments with form -<option> <value>. Example 3-23 uses cmdline package: Example 3-23. cmdline Package package require cmdline variable ::argv0 $::quartus(args) options "project.arg" "Project name" "frequency.arg" "Frequency" usage "You need specify options values" array optshash [::cmdline::getoptions ::argv $options $usage] puts "The project name $optshash(project)" puts "The frequency $optshash(frequency)" save those commands script called print_cmd_args.tcl following output when type command shown Example 3-24 command prompt: Example 3-24. Passing Command-Line Arguments Scripts quartus_sh print_cmd_args.tcl -project my_project -frequency 100MHz project name <my_project> frequency 100MHz 3-36 Altera Corporation 2007 Other Scripting Features Virtually Quartus scripts must open project. Example 3-25 opens project, optionally specify revision name. example checks whether specified project exists. does, example opens current revision, revision specify. Example 3-25. Full-Featured Method Open Projects package require cmdline variable ::argv0 $::quartus(args) options "project.arg" "Project Name" "revision.arg" "Revision Name" array optshash [::cmdline::getoptions ::argv0 $options] Ensure project exists before trying open {[project_exists $optshash(project)]} {[string equal $optshash(revision)]} There revision name specified, default current revision project_open $optshash(project) -current_revision else There revision name specified, open project with that revision project_open $optshash(project) -revision $optshash(revision) else puts "Project $optshash(project) does exist" exit rest your script goes here require this flexibility error checking, just project_open command, shown Example 3-26. Example 3-26. Simple Method Open Projects proj_name [lindex $argv project_open $proj_name more information about cmdline package, refer documentation package <Quartus installation directory> /common/tcl/packages. Altera Corporation 2007 3-37 Quartus Handbook, Volume Using Quartus Shell Interactive Mode This section presents example using quartus_sh interactive shell make some project assignments compile finite impulse response (FIR) filter tutorial project. This example assumes that already have filter tutorial design files project directory. begin, interactive shell. command initial output shown Example 3-27. Example 3-27. Interactive Shell tcl> quartus_sh tcl> Info: Info: Running Quartus Shell Info: Version Full Version Info: Copyright 1991-2007 Altera Corporation. rights reserved. Info: Your Altera Corporation's design tools, logic functions Info: other software tools, AMPP partner logic Info: functions, output files foregoing Info: (including device programming simulation files), Info: associated documentation information expressly subject Info: terms conditions Altera Program License Info: Subscription Agreement, Altera MegaCore Function License Info: Agreement, other applicable license agreement, including, Info: without limitation, that your sole purpose Info: programming logic devices manufactured Altera sold Info: Altera authorized distributors. Please refer Info: applicable agreement further details. Info: Processing started: 12:24:13 2007 Info: Info: Quartus Shell supports commands addition Info: Quartus commands. unrecognized commands Info: assumed external using Tcl's "exec" Info: command. Info: Type "exit" exit. Info: Type "help" view list Quartus packages. Info: Type "help <package name>" view list commands Info: available specified Quartus package. Info: Type "help -tcl" overview Quartus usages. Info: tcl> Create project called fir_filter, with revision called filtref typing following command prompt: project_new -revision filtref fir_filter project file project name same, Quartus software gives revision same name project. Because revision named filtref matches top-level file, design files automatically picked from hierarchy tree. 3-38 Altera Corporation 2007 Using Quartus Shell Interactive Mode Next, global assignment device with following command: set_global_assignment -name family Cyclone learn more about assignment names that with -name option, refer Quartus Help. assignment values that contain spaces, value should enclosed quotation marks. quickly compile design, ::quartus::flow package, which properly exports project assignments compiles design using proper sequence command-line executables. First, load package: load_package flow returns following: additional help ::quartus::flow package, view command-line help prompt typing: help -pkg ::quartus::flow Example 3-28 shows alternative command resulting output: Example 3-28. Help Output tcl> help -pkg flow -Tcl Package Version: -::quartus::flow -Description: -This package contains functions running flows command-line executables. -Tcl Commands: -execute_flow execute_module Altera Corporation 2007 3-39 Quartus Handbook, Volume This help display gives information about flow package commands that available with package.To learn about options available execute_flow command, type following command prompt: execute_flow view additional information example usage type following command prompt: execute_flow -long_help help -cmd execute_flow perform full compilation filter design, execute_flow command with -compile option, shown Example 3-29: Example 3-29. tcl> execute_flow -compile Info: Running Quartus Analysis Synthesis Info: Version Full Version Info: Processing started: Tues 09:30:47 2006 Info: Command: quartus_map -import_settings_files=on -export_settings_files=of fir_filter filtref Info: Writing report file filtref.tan.rpt tcl> This script compiles filter tutorial project, exporting project assignments running quartus_map, quartus_fit, quartus_asm, quartus_tan. This sequence events same selecting Start Compilation from Processing menu Quartus GUI. When finished with project, close using project_close command shown Example 3-30. Example 3-30. project_close Then, exit interactive shell, type exit prompt. 3-40 Altera Corporation 2007 Quartus Legacy Support Quartus Legacy Support Beginning with Quartus software version 3.0, command-line executables support commands used previous versions Quartus software. These commands supported with Quartus console using quartus_cmd executable system command prompt. source scripts developed earlier version Quartus software using either these methods, project assignments ported project database settings file. then command-line executables process resulting project. This necessary create file using tools that generate scripts most recent version Quartus software. should create projects scripts with latest version Quartus API. Scripting Basics core commands support variables, control structures, procedures. Additionally, there commands accessing file system network sockets, running other programs. create platform-independent graphical interfaces with widget set. commands executed immediately they typed interactive shell. also create scripts (including this chapter's examples) files them with interpreter. script does need special headers. start interactive interpreter, type quartus_sh command prompt. commands type executed immediately interpreter prompt. save series commands file, with interpreter. script named myscript.tcl, type quartus_sh myscript.tcl command prompt. Hello World Example following shows basic "Hello world" example Tcl: puts "Hello world" double quotation marks group words hello world argument. Double quotation marks allow substitutions occur group. Substitutions simple variable substitutions, result running nested command, described "Substitutions" page 3-42. curly braces grouping when want prevent substitutions. Altera Corporation 2007 3-41 Quartus Handbook, Volume Variables command assign value variable. have declare variable before using variable names case-sensitive. Example 3-31 assigns value variable named Example 3-31. Assigning Variables access contents variable, dollar sign before variable name. Example 3-32 prints "Hello world" different way. Example 3-32. Accessing Variables Hello world puts Substitutions performs three types substitution: Variable value substitution Nested command substitution Backslash substitution Variable Value Substitution Variable value substitution, shown Example 3-32, refers accessing value stored variable using dollar sign ("$") before variable name. Nested Command Substitution Nested command substitution refers interpreter evaluates code square brackets. interpreter evaluates nested commands, starting with innermost nested command, commands nested same level from left right. Each nested command result substituted outer command. Example 3-33 sets length string foo: Example 3-33. Command Substitution [string length foo] 3-42 Altera Corporation 2007 Scripting Basics Backlash Substitution Backslash substitution allows quote reserved characters Tcl, such dollar signs ("$") braces ]"). also specify other special ASCII characters like tabs lines with backslash substitutions. backslash character line continuation character, used when command wraps more than line. Example 3-34 shows backslash character line continuation: Example 3-34. Backslash Substitution this_is_a_long_variable_name [string length "Hello world."] Arithmetic expr command perform arithmetic calculations. Using curly braces group arguments this command makes arithmetic calculations more efficient preserves numeric precision. Example 3-35 sets value variable square root Example 3-35. Arithmetic with expr Command [expr sqrt(2) also supports boolean operators such (AND), (OR), (NOT), comparison operators such (less than), (greater than), (equal to). Lists list series values. Supported list operations include creating lists, appending lists, extracting list elements, computing length list, sorting list, more. Example 3-36 sets list with three numbers Example 3-36. Creating Simple Lists Altera Corporation 2007 3-43 Quartus Handbook, Volume lindex command extract information specific index list. Indexes zero-based. index specify last element list, index end-<n> count from list. Example 3-37 prints second element index list stored Example 3-37. Accessing List Elements puts [lindex llength command returns length list. Example 3-38 prints length list stored Example 3-38. List Length puts [llength lappend command appends elements list. list does already exist, list specify created. list variable name specified with dollar sign. Example 3-39 appends some elements list stored Example 3-39. Appending List lappend Arrays Arrays similar lists except that they string-based index. arrays implemented hash tables. create arrays setting each element individually using array command. element with index value Monday array called days, following command: days(Mon) Monday array command requires list index/value pairs. This example sets array called days: array days Sunday Monday Tuesday Wednesday Thursday Friday Saturday 3-44 Altera Corporation 2007 Scripting Basics Example 3-40 shows access value particular index. Example 3-40. Accessing Array Elements day_abbreviation puts $days($day_abbreviation) array names command list indexes particular array. index values returned specified order. Example 3-41 shows iterate over values array. Example 3-41. Iterating Over Arrays foreach [array names days] puts "The abbreviation $day corresponds name $days($day)" Arrays very flexible storing information script good build complex data structures. Control Structures supports common control structures, including if-then-else conditions for, foreach, while loops. position curly braces shown following examples ensures control structure commands executed efficiently correctly. Example 3-42 prints whether value variable positive, negative, zero. Example 3-42. If-Then-Else Structure puts "The value positive" elseif puts "The value negative" else puts "The value zero" Example 3-43 uses loop print each element list. Example 3-43. Loop [llength incr puts "The list element index [lindex $i]" Altera Corporation 2007 3-45 Quartus Handbook, Volume Example 3-44 uses foreach loop print each element list. Example 3-44. foreach Loop foreach element puts "The list element $element" Example 3-45 uses while loop print each element list. Example 3-45. while Loop while [llength puts "The list element index [lindex $i]" incr need expr command boolean expressions control structure commands because they invoke expr command automatically. Procedures proc command define procedure (known subroutine function other scripting programming languages). scope variables procedure local procedure. procedure returns value, return command return value from procedure. Example 3-46 defines procedure that multiplies numbers returns result. Example 3-46. Simple Procedure proc multiply product [expr return $product 3-46 Altera Corporation 2007 Scripting Basics Example 3-47 shows multiply procedure your code. must define procedure before your script calls shown below. Example 3-47. Using Procedure proc multiply product [expr return $product puts [multiply should define procedures near beginning script. want access global variables procedure, global command each procedure that uses global variable. Example 3-48 defines procedure that prints element global list numbers, then calls procedure. Example 3-48. Accessing Global Variables proc print_global_list_element global my_data puts "The list element index [lindex $my_data $i]" my_data print_global_list_element File includes commands read from write files. must open file before read from write close when read write operations done. open file, open command; close file, close command. When open file, specify name mode which open specify mode, defaults read mode. write file, specify write mode shown Example 3-49. Example 3-49. Open File Writing output [open myfile.txt supports other modes, including appending existing files reading from writing same file. open command returns file handle read write access. puts command write file specifying filehandle, shown Example 3-50. Altera Corporation 2007 3-47 Quartus Handbook, Volume Example 3-50. Write File output [open myfile.txt puts $output "This text written file." close $output read file line time with gets command. Example 3-51 uses gets command read each line file then prints with line number. Example 3-51. Read from File input [open myfile.txt] line_num while [gets $input line] Process line text here puts "$line_num: $line" incr line_num close $input Syntax Comments Arguments commands separated white space, commands terminated newline character semicolon. shown "Substitutions" page 3-42, must backslashes when command extends more than line. uses hash pound character begin comments. character must begin comment. prefer include comments same line command, sure terminate command with semicolon before character. Example 3-52 valid line code that includes command comment: Example 3-52. Comments Initializes Without semicolon, would invalid command because command would terminate until line after comment. 3-48 Altera Corporation 2007 Referenced Documents interpreter counts curly braces inside comments, which lead errors that difficult track down. Example 3-53 causes error because unbalanced curly braces: Example 3-53. Unbalanced Braces Comments code here External References more information about using Tcl, refer following sources: Practical Programming Brent Welch Toolkit, John Ousterhout Effective Tcl/TK Programming, Michael McLennan Mark Harrison Quartus example scripts www.altera.com/support/ examples/tcl/tcl.html Developer Xchange tcl.activestate.com Referenced Documents This chapter references following documents: Command-Line Scripting chapter volume Quartus Handbook Script-Based Design HardCopy Devices chapter HardCopy Handbook Volume Verification Quartus Handbook LogicLock Design Methodology chapter volume Quartus Handbook Quartus TimeQuest Timing Analyzer chapter volume Quartus Handbook Altera Corporation 2007 3-49 Quartus Handbook, Volume Document Revision History Table shows revision history this document. Table 3-8. Document Revision History Date Version 2007 v7.1.0 Changes Made Summary Changes Updated Quartus software version release, Minor updates Quartus including: software version release. Added sdc_ext information Table page Added quartus_staw information Table page Added "Referenced Documents" page 3-49 Added mini-TOC "Introduction" page Updated Quartus software revision date only. other changes made chapter. March 2007 v7.0.0 November 2006 Added revision history document. v6.1.0 2006 v6.0.0 Updated Quartus software version 6.0.0. Reorganized content. Added Quartus TimeQuest Timing Analyzer feature. October 2005 v5.1.0 August 2005 v5.0.1 Updated Quartus software version 5.1.0. Minor text changes. 2005 v5.0.0 Updated Quartus software version 5.0.0. Dec. 2004 v2.1 Aug. 2004 v2.1 June 2004 v2.0 Feb. 2004 v1.0 Updates tables figures. functionality Quartus software version 4.2. Minor typographical corrections Enhancements example scripts. Updates tables, figures. functionality Quartus software version 4.1. Initial release. 3-50 Altera Corporation 2007 Other recent searchesPE1750 - PE1750 PE1750 Datasheet NB7L86M - NB7L86M NB7L86M Datasheet KDZ6 - KDZ6 KDZ6 Datasheet HB7xx - HB7xx HB7xx Datasheet FF1152 - FF1152 FF1152 Datasheet PK049 - PK049 PK049 Datasheet 74FR9240 - 74FR9240 74FR9240 Datasheet 74ACTQ841 - 74ACTQ841 74ACTQ841 Datasheet
Privacy Policy | Disclaimer |