#!/bin/sh set -eu SOURCE_CODE_URL=https://github.com/enjoy-digital/litedram/archive/refs/tags/2023.08.tar.gz SOURCE_MD5_SUM=afc2208c08e60994d126c445574960da if [ "$#" = 0 ] || echo "$1" | grep '^-' > /dev/null then echo This scripts generates a verilog file from the Migen project litedram echo It is currently hardcoded for the ECP5 PHY echo The provided file system/external_ip/litedram_core_ecp5_phy.v is the output of this program *BUT MODIFIED* echo echo Usage: echo \ \ \ "$0" \ if ! [ "$#" = 0 ] then if ! [ "$1" = "--help" ] && ! [ "$1" = "-h" ] then exit 1 else exit 0 fi else exit 1 fi fi TEMP_DIR=$(mktemp -d) trap 'rm -rf -- "$TEMP_DIR"' EXIT CUR_DIR=$(pwd) if echo "$1" | grep '^/' > /dev/null then OUT_FILE=$1 else OUT_FILE="${CUR_DIR}/$1" fi cd "$TEMP_DIR" #echo Downloading source code... wget --output-document=source.tar.gz --quiet "$SOURCE_CODE_URL" if [ "$(md5sum source.tar.gz)" != "${SOURCE_MD5_SUM} source.tar.gz" ] then #echo source doesn\'t match md5 sum exit 1 fi #echo extracting the source... tar xvf source.tar.gz > source_dir SOURCE_DIR=$(head -n 1 source_dir) rm source_dir #echo patching the source... #Generate the following text by running this: (diff -Naur /dev/null examples/orangecrab_9086.yml | gzip -9 | base64 | tr -d '\n';echo) echo H4sIAAAAAAACA61US2+bQBA+179ihC+JMA4Pg4mlSo7sOLFaJ5bjHKqqQguMYxRg6QJ2UJX/3lkwUeKop3oOy2pmvm/niaZpcBHi7iIt4/iLqZuWZpiaboJhj6zhaGD13aFOYthDUOWlo6oq4AtLshjzCy5Y+oSBYL53qbtOv0rekVhguCNzONKtvnM5HNqubtoHkvEYNL2ng2r0LAPG4476p6MCdOEGUxQsBu2/RfIplFkUoDKi6/fZtf2omfZMcxc3pmtPlB69N1veXEHj1a8RQVZKdxLljqdITh+kC5PlIxRVhnCGL7DDFxHlwa4HOQo6JeS85kkwkV7EpUynK+szz3R1taiJOmoTauLle5YpQIi1KOnlJp4k9EKMWSUNJLqMeg5ljsAg5nvYsbhEKDiwHY9CEMhCiHGHcZQ+NdRdWN7+OEFF36qah4IlXsLDMsamWMpiPTC+OYOF4chMu/BQp9e45MA3UGwRfM5ECFzAw702nS8Wn8i81Cc+s3dUqrsy8VFIFr8qEJ4EL7P8HZiG8LmBAhj/Bku397BsWx1aTarrydKmRlGlmgTWssUEqgeEtG0pZwJ/l5gGFZyklFGalYUXxM/ehojrcAYuOnWTpQmCmAfPsHl79efkfrW6nqx/NYlU+UcwgDOQcNmCKi8w+URwRq2RGPgKB/T5EWmURkchgdmSzsl2TNmWZsIFwummTE6+X242KGgBsmJLkRhO77A8UtGOVcCThKUhNM5tNI+0kbDkosjhFNHQwgkvk3QUR/2zIuU+yrc+rbyny+08aEnfbn5rb3a5NoWsYN4+Cut8LPNgeK2/8nzt/AU14UE3kwUAAA== | base64 -d | gzip -d > 00-add_orangecrab_config.patch cd "$SOURCE_DIR" patch -s -p0 < ../00-add_orangecrab_config.patch > /dev/null #echo building the file... if ! ./setup.py build > "$TEMP_DIR/build_log" 2> "$TEMP_DIR/build_log" then echo ERROR: Failed to run setup.py cat "$TEMP_DIR/build_log" exit 1 fi cd build/lib/litedram/ if ! python3 gen.py ../../../examples/orangecrab_9086.yml --no-compile-software > "$TEMP_DIR/build_log" 2> "$TEMP_DIR/build_log" then echo ERROR: Failed to run gen.py cat "$TEMP_DIR/build_log" exit 1 fi #echo patching source file... #This is just for some yosys warnings... echo H4sIAAAAAAACA82T326CMBTG73mKc7XBECnKAHUkvMeyNEdatZE/hiLEzPnsa5nL4pYh3izrTduc3/d9Jyet4ziw3IuMuWuseYsVdzNRc1ZhTtOy4uMGJmQydTzPmYRAgrkfzEk4noYzEgZh5INN1DJs2waX8cYt9lkG3yWRUo1nj5FPvMALzpIkASci/nQUgt3tASSJASilWBfw+tmFboKylaA7j7YVwxpH8LNGzrU3iC+roqh5tcKU01bXF/8igOYot30pHaCjzFNfGG25tTCcvw4EzFo8SEjMBwuWfC0KA/S6UKabspRqyxltMBNMwlMM0T0jiyHwM3nRvHlBLbHY5phuRMHJFwt3YJpXwB0eshIZFVJfleK39BaLWh+k1dmehhpXKLXgNIxOUVrWDbyauuKP/V1jWotG/WFlbRzhholUHBnEcb+7hj6GMti3rRR51bijVM+Weljv0yEXHY0EAAA= | base64 -d | gzip -d | patch -s -p0 cp build/gateware/litedram_core.v "$OUT_FILE" #echo File built correctly!