An 309
An 309
Introduction FPGA design software that is easy to integrate into a design flow saves
time and improves productivity. The Altera® Quartus II® software
provides designers modular executables for each step in an FPGA design
flow to make the design process customizable and flexible.
The Benefits of The Quartus II modular executables reduce the amount of design system
memory required during any step in the design flow. Because it targets
Modular only one step in the design flow, each executable is relatively compact,
Executables both in terms of file size and the amount of memory used when running.
This improves performance for all designers and is particularly beneficial
in design enviroments with heavily-used computer networks or mature
workstations with low amounts of RAM.
Altera Corporation 1
AN-309-1.0 Preliminary
Command-Line Scripting in the Quartus II Software Introductory Example
Before making changes, copy the tutorial directory and type the following
four commands at a command prompt in the new project directory that
you have created.
2 Altera Corporation
Preliminary
Design Flow Command-Line Scripting in the Quartus II Software
These four commands can be stored in a batch file for use on PCs or a shell
script file for use on UNIX workstations.
Synthesis
Fitter
Timing Analysis
Programmer
Quartus II Shell
(quartus_sh)
VO, VHO files
Altera Corporation 3
Preliminary
Command-Line Scripting in the Quartus II Software Design Flow
Modular executables are provided for each stage in the design flow
shown in Figure 1. Additional modular executables are provided for
specific tasks. Table 1 lists each Quartus II modular executable and
provides a brief description of its function.
Executable Description
quartus_map Quartus II Analysis & Synthesis builds a single project database that
integrates all the design files in a design entity or project hierarchy,
performs logic synthesis to minimize the logic of the design, and
performs analysis and synthesis on the logic in the design.
quartus_fit The Quartus II Fitter fits the logic of a design into a device. The Fitter
selects appropriate interconnection paths, pin assignments, and logic
cell assignments.
quartus_tan The Quartus II Timing Analyzer computes delays for the given design
and device and annotates them on the netlist for subsequent use by the
Simulator. Then, the Timing Analyzer performs timing analysis,
allowing you to analyze the performance of all logic in your design.
quartus_sim The Quartus II Simulator performs one of two types of simulation:
functional simulation or timing simulation. The Quartus II Simulator is a
powerful tool for testing and debugging the logical operation and
internal timing of the design entities in your project.
quartus_asm The Quartus II Assembler converts the Fitter's device, logic cell, and
pin assignments into a programming image for the device, in the form
of one or more Programmer Object Files (.pof), SRAM Object Files
(.sof), Hexadecimal (Intel-Format) Output Files (.hexout), Tabular Text
Files (.ttf), and Raw Binary Files (.rbf).
quartus_pgm The Quartus II Programmer programs the Altera provided devices. The
programmer will use one of the valid supported file format: SOF, POF,
jam, and JAM Byte-Code File (.jbc).
quartus_pgmw The Quartus II programmer GUI is a stand-alone application to
program Altera provided devices. The programmer will use one of the
valid supported file format: SOF, POF, JAM, JBC.
quartus_swb The Quartus II Software Builder creates object code from source files
to run on either the ARM-based Excalibur devices or the Nios
embedded processor.
quartus_drc The Quartus II Design Assistant checks the reliability of a design based
on a set of design rules. The Design Assistant is especially useful for
checking the reliability of a design before converting the design for
HardCopy devices.
quartus_cdb The Quartus II Compiler Database Interface generates and accesses
information on atoms. It can be used to back-annotate designs.
quartus_eda The Quartus II Netlist Writer generates output netlist files for use with
other EDA tools.
4 Altera Corporation
Preliminary
Design Flow Command-Line Scripting in the Quartus II Software
Executable Description
quartus_cpf The Quartus II Convert Programming Files converts one programing
file format to a different possible format.
quartus_sh The Quartus II Shell is a simple Quartus II Tcl interpreter.The Shell may
be started with a Tcl script to evaluate, as an interactive Tcl interpreter
(shell), or as a quick Tcl command evaluator, evaluating the remaining
command-line arguments as one or more Tcl commands.
Report file names are drawn from compiler setting names and the part of
the name of the modular executable that generated the report file. The
report file name format is <compiler setting name>.<modular executable
part>.rpt. For example, using the quartus_fit modular executable to
place-and-route a project with the compiler setting name design_top
will generate a report file named design_top.fit.rpt. Likewise, using the
quartus_tan modular executable to perform timing analysis reporting
on a project with the compiler setting name fir_filter will generate a
report file named fir_filter.tan.rpt.
Altera Corporation 5
Preliminary
Command-Line Scripting in the Quartus II Software Command-Line Scripting Help
C:\>quartus_map -h
Quartus II Analysis & Synthesis
Version 3.0 Internal Build 180 05/15/2003 SJ Full Version
Copyright (C) 1991-2003 Altera Corporation
Usage:
------
Description:
------------
Options:
--------
-f <argument file>
-c <.csf file> | --csf=<.csf file>
-l <path1;path2;...;pathN> | --lib_path=<path1;path2;...;pathN>
--lower_priority
--optimize=<area|speed>
--family=<device family>
--part=<device part>
--state_machine_encoding=<auto|minimal_bits|one_hot|user_encoded>
--enable_register_retiming[=on|off]
--enable_wysiwyg_resynthesis[=on|off]
--ignore_carry_buffers[=on|off]
--ignore_cascade_buffers[=on|off]
--analyze_project
--analyze_file=<design file>
--generate_symbol=<design file>
--generate_inc_file=<design file>
--convert_bdf_to_verilog=<.bdf file>
--convert_bdf_to_vhdl=<.bdf file>
--export_settings_files[=on|off]
--generate_sim_netlist[=on|off]
--source=<source file>
--update_wysiwyg_parameters
6 Altera Corporation
Preliminary
Command-Line Option Details Command-Line Scripting in the Quartus II Software
Help Topics:
------------
arguments
C:\>quartus_map --help=optimize
Option: --optimize=<area|speed>
Command-Line Command-line options are provided for making many common global
project settings and performing common tasks. You can use either of two
Option Details methods to make assignments to an individual entity. If the project exists,
open the project in the Quartus II GUI, change the assignment, and close
the project. The changed assignment is updated in the Quartus II project
files. Any modular executables that are run after this will use the updated
assignment. See “Command-Line Option Precedence” on page 7 for more
information. You can also make assignments using the Quartus II Tcl
scripting API. If you want to completely script the creation of a Quartus II
project you should choose this method.
Altera Corporation 7
Preliminary
Command-Line Scripting in the Quartus II Software Command-Line Option Details
project Files (.quartus), Compiler Settings Files (.csf), Entity Settings Files
(.esf), and Project Settings Files (.psf). Assignments for a particular
project can also be made by using command-line options, as described
earlier in this document. Project assignments are reflected in compiler
database files that hold intermediate compilation results and reflect
assignments made in the previous project compilation.
8 Altera Corporation
Preliminary
Command-Line Option Details Command-Line Scripting in the Quartus II Software
The third command reruns Quartus II timing analysis with a global fMAX
requirement of 100 MHz and saves the result in a file called
timing_result-100.tao. By specifying the
--export_settings_files=off command-line option, the modular
executable does not update the Quartus II project files to reflect the
different fMAX requirement. The compiler database files reflect the
changed fMAX requirement. If the --export_settings_files=off
command-line option had not been specified, the modular executable
would have updated the Quartus II project files to reflect the 100 MHz
global fMAX requirement.
Altera Corporation 9
Preliminary
Command-Line Scripting in the Quartus II Software Command-Line Scripting Examples
#!/bin/sh
FILES_WITH_ERRORS=""
# Iterate over each file with a .bdf or .v extension
for filename in `ls *.bdf *.v`
do
# Perform a syntax check on the specified file
quartus_map fir_filter --csf=filtref --analyze_file=$filename
# If the exit code is non-zero, the file has a syntax error
if [ $? -ne 0 ]
then
FILES_WITH_ERRORS="$FILES_WITH_ERRORS $filename"
fi
done
if [ -z "$FILES_WITH_ERRORS" ]
then
echo "All files passed the syntax check"
exit 0
else
10 Altera Corporation
Preliminary
Command-Line Scripting Examples Command-Line Scripting in the Quartus II Software
To attempt to fit the project called top as quickly as possible, type the
following command:
Altera Corporation 11
Preliminary
Command-Line Scripting in the Quartus II Software Command-Line Scripting Examples
you must specify the compiler settings file for the top level entity with the
--csf command-line option. The --seed command-line option specifies
the seeds to use for fitting.
After each fit, the script creates new directories for the results of each fit
and copies the complete project to the new directory so that the results are
available for viewing and debugging after the script has completed.
#/bin/sh
ERROR_SEEDS=""
quartus_map fir_filter
# Iterate over a number of seeds
for seed in 1 2 3 4 5
do
echo "Starting fit with seed=$seed"
# Perform a fitting attempt with the specified seed
quartus_fit fir_filter --csf=filtref --seed=$seed
# If the exit-code is non-zero, the fitting attempt was
# successful, so copy the project to a new directory
if [ $? -eq 0 ]
then
mkdir ../fir_filter-seed_$seed
mkdir ../fir_filter-seed_$seed/db
cp * ../fir_filter-seed_$seed
cp db/* ../fir_filter-seed_$seed/db
else
ERROR_SEEDS="$ERROR_SEEDS $seed"
fi
done
if [ -z "$ERROR_SEEDS" ]
then
echo "Seed sweeping was successful"
exit 0
else
echo "There were errors with the following seed(s)"
echo $ERROR_SEEDS
exit 1
fi
Use the design space explorer (by typing quartus_sh --dse) included
with the Quartus II software to improve design perfomance by
performing automated seed sweeping. For more information on the
design space explorer type quartus_sh --help=dse at the command
prompt or see AN 198: Timing Closure with the Quartus II Software.
12 Altera Corporation
Preliminary
Command-Line Scripting Examples Command-Line Scripting in the Quartus II Software
Makefile Implementation
You can also use the Quartus II modular executables in conjunction with
the make utility to automatically update files when other files they
depend on change. The file dependencies and commands used to update
files are specified in a text file called a Makefile. The following example is
one way of implementing a makefile with modular executables.
################################################################
# Project Configuration:
#
# Specify the name of the design (project) and compiler setting
# (csf) and the list of source files used.
################################################################
PROJECT = chiptrip
SOURCE_FILES = auto_max.v chiptrip.v speed_ch.v tick_cnt.v
time_cnt.v
ASSIGNMENT_FILES = chiptrip.quartus chiptrip.psf chiptrip.csf
################################################################
# Main Targets
#
# all: build everything
# clean: remove output files and database
# clean_all: removes settings files as well as clean.
################################################################
clean:
rm -rf *.rpt *.chg smart.log *.htm *.eqn *.pin *.sof *.pof db
clean_all: clean
rm -rf *.ssf *.csf *.esf *.fsf *.psf *.quartus *.qws
################################################################
# Executable Configuration
################################################################
MAP_ARGS = --family=Stratix
FIT_ARGS = --part=EP1S20F484C6
ASM_ARGS =
TAN_ARGS =
################################################################
# Target implementations
################################################################
Altera Corporation 13
Preliminary
Command-Line Scripting in the Quartus II Software Command-Line Scripting Examples
smart.log: $(ASSIGNMENT_FILES)
quartus_sh --determine_smart_action $(PROJECT) > smart.log
################################################################
# Project initialization
################################################################
$(ASSIGNMENT_FILES):
quartus_sh --tcl_eval project_new $(PROJECT) -overwrite
map.chg:
$(STAMP) map.chg
fit.chg:
$(STAMP) fit.chg
tan.chg:
$(STAMP) tan.chg
asm.chg:
$(STAMP) asm.chg
14 Altera Corporation
Preliminary
Command-Line Scripting Examples Command-Line Scripting in the Quartus II Software
Altera Corporation 15
Preliminary
More Help with Quartus II Modular Executables Command-Line Scripting in the Quartus II Software
More Help with More information on modular executable use and the Quartus II Tcl API
is available by typing quartus_sh --qhelp. This command starts the
Quartus II Quartus II Command Line and Tcl API Help GUI, a browser for
Modular information on the Quartus II modular executables and Tcl API
(Figure 3).
Executables
Figure 3. Quartus II Command Line and Tcl API Help
Click items under Help Topics to get more information on the topics
listed.
Copyright © 2003 Altera Corporation. All rights reserved. Altera, The Programmable Solutions Company,
the stylized Altera logo, specific device designations, and all other words and logos that are identified as
trademarks and/or service marks are, unless noted otherwise, the trademarks and service marks of Altera
Corporation in the U.S. and other countries. All other product or service names are the property of their re-
spective holders. Altera products are protected under numerous U.S. and foreign patents and pending
101 Innovation Drive applications, maskwork rights, and copyrights. Altera warrants performance of its semiconductor products
San Jose, CA 95134 to current specifications in accordance with Altera's standard warranty, but reserves the right to make chang-
(408) 544-7000 es to any products and services at any time without notice. Altera assumes no responsibility or liability
arising out of the application or use of any information, product, or service described
www.altera.com herein except as expressly agreed to in writing by Altera Corporation. Altera customers
Applications Hotline: are advised to obtain the latest version of device specifications before relying on any pub-
(800) 800-EPLD lished information and before placing orders for products or services.
Literature Services:
Printed on recycled paper
lit_req@altera.com
Altera Corporation 16
Preliminary