#!/bin/bash # Usage: ./verify_design.sh if [ -z "$1" ]; then echo "Usage: ./verify_design.sh " exit 1 fi # Auto-load environment SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" if [ -f "$SCRIPT_DIR/setup_env.sh" ]; then source "$SCRIPT_DIR/setup_env.sh" > /dev/null fi DESIGN=$1 OPENLANE_ROOT="${OPENLANE_ROOT:-$HOME/OpenLane}" DESIGN_DIR=$OPENLANE_ROOT/designs/$DESIGN echo "========================================" echo "Verifying Design: $DESIGN" echo "========================================" # 1. Functional Verification (RTL Simulation) echo "[1] Functional Verification (Icarus Verilog)" if [ -f "$DESIGN_DIR/src/${DESIGN}_tb.v" ]; then echo " Found Testbench: ${DESIGN}_tb.v" cd $DESIGN_DIR/src iverilog -o sim ${DESIGN}.v ${DESIGN}_tb.v if [ $? -eq 0 ]; then echo " Compilation Successful." echo " Running Simulation..." vvp sim > simulation.log cat simulation.log echo " (Check output above for expected behavior)" else echo " [ERROR] Compilation Failed." fi cd $OPENLANE_ROOT else echo " [WARNING] No testbench found at $DESIGN_DIR/src/${DESIGN}_tb.v" echo " Please create one to run functional simulation." fi echo "" echo "========================================" # 2. Physical Verification (OpenLane Reports) echo "[2] Physical Verification (Latest Run)" LATEST_RUN=$(ls -td $DESIGN_DIR/runs/* | head -1) if [ -z "$LATEST_RUN" ]; then echo " [ERROR] No runs found for $DESIGN." else echo " Checking run: $(basename $LATEST_RUN)" # Check DRC DRC_RPT=$(find $LATEST_RUN -name "*drc.rpt" | head -1) if [ -f "$DRC_RPT" ]; then echo " --- DRC Report ($(basename $DRC_RPT)) ---" COUNT=$(grep -c "violation" $DRC_RPT) if [ "$COUNT" -eq "0" ]; then # Some reports might use different format, check content grep "Count: 0" $DRC_RPT > /dev/null if [ $? -eq 0 ]; then echo " [PASS] No DRC Violations found." else # Print last few lines tail -n 5 $DRC_RPT fi else echo " [FAIL] Found potential violations." tail -n 5 $DRC_RPT fi else echo " [WARNING] DRC Report not found." fi echo "" # Check LVS LVS_RPT=$(find $LATEST_RUN -name "*lvs.log" | head -1) if [ -f "$LVS_RPT" ]; then echo " --- LVS Report ($(basename $LVS_RPT)) ---" if grep -q "Total errors = 0" $LVS_RPT || grep -q "Circuits match uniquely" $LVS_RPT; then echo " [PASS] LVS Clean. Layout matches Schematic." else echo " [FAIL] LVS Mismatch." tail -n 3 $LVS_RPT fi else echo " [WARNING] LVS Report not found." fi fi echo "" echo "========================================" # 3. Formal Verification (SymbiYosys) echo "[3] Formal Verification (SymbiYosys)" if [ -f "$DESIGN_DIR/src/${DESIGN}.sby" ]; then echo " Found SBY Config: ${DESIGN}.sby" cd $DESIGN_DIR/src if command -v sby &> /dev/null; then sby -f ${DESIGN}.sby if [ $? -eq 0 ]; then echo " [PASS] Formal Proof Successful." else echo " [FAIL] Formal Proof Failed." fi else echo " [WARNING] 'sby' command not found. Skipping Formal Verification." fi cd $OPENLANE_ROOT else echo " [INFO] No SBY config found. Skipping." fi echo "========================================" echo "Verification Complete."