Quartus® Prime Pro Edition User Guide: Scripting

ID 683432
Date 7/07/2025
Public
Document Table of Contents

1.7.7. Fit a Design Using Different Fitter Seeds

This shell script example assumes that the Quartus® Prime software tutorial project fir_filter exists in the project directory (defined in the file fir_filter.qpf). If the tutorial files are installed on your system, this project exists in the < Quartus® Prime directory>/qdesigns<quartus_version_number> /fir_filter directory.

Because the top-level entity and project names differ, you must specify the revision name for the top-level entity with the --rev option. You can also use the --seed option to specify a specific Fitter seed for use during compilation.

The Fitter's initial placement attempt of your design's logic is a function of all the design source files, optimization settings, and the Fitter seed value. A change in any of these variables can result in a change in the Fitter's exact placement of logic.

A new Fitter run with a different seed value places the Fitter into a new area in the solution space, potentially resulting in a more favorable initial placement. If you change the Fitter seed, the Compiler might converge on a different solution because of the modified initial placements. Therefore, changing the Fitter seed can produce different place and route results.

You specify a non-negative integer as an input to the Fitter seed. Changing the Fitter seed value may not produce a better fit, but the change does make the Fitter use a different initial placement. This integer seed value allows you to try different initial placements without any change in the design or settings.

The Fitter seed is a parameter that affects the random initial placement of the Quartus® Prime Fitter. Varying the seed can result in better performance for some designs.

After each fitting attempt, the script creates new directories for the results of each fitting attempt 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_syn fir_filter --rev=filtref
# 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 --seed=$seed --rev=filtref
# 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
Tip: Use Design Space Explorer II (DSE) included with the Quartus® Prime software script (by typing quartus_dse at a command prompt) to improve design performance by performing automated seed sweeping.