cvw/bin/lint-spyglass.sh
Jordan Carlin 16509ef485
Spyglass improvements
- Update `site-setup.sh` to add `spyglass` to the path
- Update `cvw.prj` to use environment variables so temporary files created using sed are not needed
- Only delete reports for configurations that are being run
2025-06-21 14:02:09 -07:00

76 lines
2.2 KiB
Bash
Executable file

#!/bin/bash
###############################################################################
# Script Name: lint_spyglass.sh
# Author: james.stine@okstate.edu 11 June 2025
# SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
# Description:
# Automates Synopsys SpyGlass linting for Wally RISC-V configurations.
# Supports command-line options for custom goals and configs.
###############################################################################
# Check WALLY environment
if [ -z "$WALLY" ]; then
echo "Error: WALLY environment variable is not set."
echo "Please source your setup before running this script."
exit 1
fi
# === Defaults ===
GOAL="lint/lint_rtl"
DEFAULT_CONFIGS=(rv32e rv64gc rv32gc rv32imc rv32i rv64i)
CONFIGS=()
# === Parse command-line options ===
while [[ $# -gt 0 ]]; do
case "$1" in
-g|--goal)
GOAL="$2"
shift 2
;;
-c|--configs)
IFS=',' read -r -a CONFIGS <<< "$2"
shift 2
;;
-h|--help)
echo "Usage: $0 [-g lint_goal] [-c config1,config2,...]"
echo " -g, --goal Linting goal (e.g., lint/lint_rtl or lint/lint_rtl_enhanced)"
echo " -c, --configs Comma-separated list of configs to run (e.g., rv32e,rv64gc)"
echo "Defaults: goal=$GOAL, configs=${DEFAULT_CONFIGS[*]}"
exit 0
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
# Use default configs if none provided
if [ ${#CONFIGS[@]} -eq 0 ]; then
CONFIGS=("${DEFAULT_CONFIGS[@]}")
fi
# Spyglass work directories/files
SPYGLASS_DIR="$WALLY/synthDC/spyglass"
SPYGLASS_PRJ="$SPYGLASS_DIR/cvw.prj"
# Iterate configs
errors=0
for config in "${CONFIGS[@]}"; do
# Clean output directory
rm -rf "$SPYGLASS_DIR/lint-spyglass-reports/$config"
# Run SpyGlass
echo "Running spyglass for: $config with goal: $GOAL"
WALLY_CONFIG=$config spyglass -project "$SPYGLASS_PRJ" -goal "$GOAL" -batch
if [ $? -ne 0 ]; then
echo "Error running spyglass for configuration: $config"
errors=$((errors + 1))
else
echo "Completed: $config"
fi
done
exit $errors