-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* trying to clean up if-then-else jungle * only whitespace diffs, see git diff -w * new way to update docker for amber. is it better? i dunno * oops no do not want to change how garnet is handled in gen_rtl * CI test no longer overrides gen_rtl.sh docker choice * Remove env-var docker-image-override mechanism * Replace nonexistant archipelago commit * kratos update requires pip install * exit codes why not * final cleanup * cleaned up and updated gen_rtl.sh * Prepare to adapt test_amber_rtl_build as a docker-based standalone check * temporarily turn off docker pruning for fast test turnaround * AN_CELL/AO_CELL hack for gemstone * clean up some if statements * MUCH simpler docker-amber-update mechanism * separate amber-updates function in gen_rtl.sh * Reference design(s) for RTL golden test(s), gzipped to save space * prettified some comments * little cleanup in comments and such * final tweaks
- Loading branch information
Showing
5 changed files
with
243 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
#!/bin/bash | ||
|
||
cmd=$0 | ||
cmd=amber-rtl-build-check.sh | ||
|
||
function HELP { cat <<EOF | ||
DESCRIPTION: Builds RTL for a 4x2 amber grid, compares to reference build. | ||
USAGE (default is "--local"): | ||
$cmd --docker # Use gen_rtl.sh to build design.v from inside a container | ||
$cmd --local # Generate design.v locally i.e. maybe we're already in a container | ||
EXAMPLE test from outside docker | ||
cd /tmp/scratch # (optional) | ||
$cmd --docker && echo PASS || echo FAIL | ||
EXAMPLE test from inside docker | ||
cd /tmp/scratch # (optional) | ||
# 1. Setup / fire up a docker container | ||
image=stanfordaha/garnet:latest | ||
container=deleteme | ||
docker pull \$image | ||
docker run -id --name \$container --rm -v /cad:/cad \$image bash | ||
function dexec { docker exec \$container /bin/bash -c "\$*"; } | ||
# 2a. Run the test using garnet branch e.g. "amber-docker-updates" | ||
dexec "cd /aha/garnet && git fetch origin && git checkout origin/amber-docker-updates" | ||
dexec "/aha/garnet/mflowgen/common/rtl/gen_rtl.sh --get-amber-updates-only > tmp" | ||
dexec "set -x; source tmp" | ||
dexec "/aha/garnet/tests/test_amber_rtl_build/amber-rtl-build-check.sh --local" | ||
# 2b. OR run the test using local copy of repo | ||
# Setup | ||
GARNET_HOME=/nobackup/steveri/github/garnet | ||
< See item 1 above for rest of setup> | ||
# Copy local repo to docker container | ||
dexec "rm -rf /aha/garnet" | ||
git clone \$GARNET_HOME /tmp/garnet | ||
docker cp /tmp/garnet \$container:/aha/garnet | ||
/bin/rm -rf /tmp/garnet | ||
# Update the docker container for amber build | ||
updates=\`dexec "/aha/garnet/mflowgen/common/rtl/gen_rtl.sh --get-amber-updates-only"\` | ||
dexec "set -x; \$updates" | ||
# Run the test | ||
bc=/aha/garnet/tests/test_amber_rtl_build/amber-rtl-build-check.sh | ||
dexec "\$bc --local" | ||
EOF | ||
} | ||
|
||
[ "$1" == "--help" ] && HELP && exit | ||
|
||
# Always debug (for now) | ||
# Use "-v" as first arg if want extra debug info | ||
# [ "$1" == "-v" ] && shift && set -x | ||
|
||
# width=32 # slow 32x16 | ||
width=4 # quick 4x2 | ||
height=$((width/2)) | ||
|
||
# E.g. if script is "$GARNET_HOME/tests/test_amber_rtl_build/amber-rtl-build-check.sh" | ||
# then scriptdir is "$GARNET_HOME/tests/test_amber_rtl_build" | ||
scriptpath=$0 | ||
scriptpath=`readlink $scriptpath || echo $scriptpath` # Full path of script dir | ||
scriptdir=${scriptpath%/*} # E.g. "build_tarfile.sh" or "foo/bar" | ||
|
||
echo '--- RTL test BEGIN' `date` | ||
|
||
if [ "$1" == "--docker" ]; then | ||
|
||
# Use gen_rtl.sh to build a docker environment and use that to build the RTL | ||
export array_width=$width | ||
export array_height=$height | ||
export glb_tile_mem_size=256 | ||
export num_glb_tiles=16 | ||
export pipeline_config_interval=8 | ||
export interconnect_only=False | ||
export glb_only=False | ||
export soc_only=False | ||
export PWR_AWARE=True | ||
export use_container=True | ||
|
||
# export use_local_garnet=True | ||
export use_local_garnet=False # for now | ||
|
||
export save_verilog_to_tmpdir=False | ||
export rtl_docker_image=default | ||
|
||
export WHICH_SOC=amber | ||
|
||
export GARNET_HOME=`cd $scriptdir/../..; pwd` | ||
echo "--- Found GARNET_HOME=$GARNET_HOME" | ||
|
||
# Build a docker environment and use that to build RTL "outputs/design.v" | ||
# (gen_rtl.sh copies final design.v to "./outputs" subdirectory) | ||
mkdir -p outputs | ||
$GARNET_HOME/mflowgen/common/rtl/gen_rtl.sh | ||
mv outputs/design.v . | ||
|
||
else | ||
# RTL-build flags | ||
flags="--width $width --height $((width/2)) --pipeline_config_interval 8 -v --glb_tile_mem_size 256" | ||
echo "FLAGS: $flags" | ||
|
||
# Prep/clean | ||
cd /aha | ||
rm -rf garnet/genesis_verif | ||
rm -f garnet/garnet.v | ||
|
||
# Build new rtl | ||
export WHICH_SOC='amber' | ||
source /aha/bin/activate; # Set up the build environment | ||
aha garnet $flags | ||
|
||
# Assemble final design.v | ||
cd /aha/garnet | ||
cp garnet.v genesis_verif/garnet.v | ||
cat genesis_verif/* > design.v | ||
cat global_buffer/systemRDL/output/glb_pio.sv >> design.v | ||
cat global_buffer/systemRDL/output/glb_jrdl_decode.sv >> design.v | ||
cat global_buffer/systemRDL/output/glb_jrdl_logic.sv >> design.v | ||
cat global_controller/systemRDL/output/*.sv >> design.v | ||
|
||
# For better or worse: I put this in gen_rtl.sh | ||
# Hack it up! FIXME should use same mechanism as onyx...define AO/AN_CELL | ||
# Also see: garnet/mflowgen/common/rtl/gen_rtl.sh, gemstone/tests/common/rtl/{AN_CELL.sv,AO_CELL.sv} | ||
cat design.v \ | ||
| sed 's/AN_CELL inst/AN2D0BWP16P90 inst/' \ | ||
| sed 's/AO_CELL inst/AO22D0BWP16P90 inst/' \ | ||
> /tmp/tmp.v | ||
mv -f /tmp/tmp.v design.v | ||
fi | ||
|
||
printf "\n" | ||
echo "+++ Compare result to reference build" | ||
|
||
# Reference designs are gzipped to saze space | ||
ref=garnet-4x2.v | ||
cp $scriptdir/ref/$ref.gz .; gunzip $ref.gz | ||
f1=design.v; f2=$ref | ||
|
||
# Need 'sed s/unq...' to handle the case where both designs are | ||
# exactly the same but different "unq" suffixes e.g. | ||
# < Register_unq3 Register_inst0 ( | ||
# > Register_unq2 Register_inst0 ( | ||
function vcompare { sort $1 | sed 's/,$//' | sed 's/unq[0-9*]/unq/'; } | ||
|
||
ndiffs=`diff -I Date <(vcompare $f1) <(vcompare $f2) | wc -l` | ||
|
||
if [ "$ndiffs" != "0" ]; then | ||
|
||
# ------------------------------------------------------------------------ | ||
# TEST FAILED | ||
|
||
printf "Test FAILED with $ndiffs diffs\n\n" | ||
printf "Top 40 diffs:" | ||
diff -I Date <(vcompare $f1) <(vcompare $f2) | head -40 | ||
exit 13 | ||
fi | ||
|
||
echo "Test PASSED" | ||
|
||
|
||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.