-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·42 lines (40 loc) · 1022 Bytes
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
# Parse some command line arguments
while [ $# -gt 0 ]
do
case "$1" in
-1k) PCF=icestick.pcf
DEV=1k
shift
;;
-8k) PCF=ice40hx8k-bb.pcf
DEV=8k
shift
;;
-S) ICEPROG_ARGS=-S
shift
;;
*) PCF=icestick.pcf
DEV=1k
break
;;
esac
done
# Build with open source tools
if [ -z "$1" ]
then
echo Usage: build.sh [-1k] [-8k] [-S] main_name [other .v files]
echo Example: ./build.sh demo library.v
exit 1
fi
set -e # exit if any tool errors
MAIN=$1
shift
echo Using yosys to synthesize design
yosys -p "synth_ice40 -blif $MAIN.blif" $MAIN.v $@
echo Place and route with arachne-pnr
arachne-pnr -d ${DEV} -p ${PCF} $MAIN.blif -o $MAIN.txt
echo Converting ASCII output to bitstream
icepack $MAIN.txt $MAIN.bin
echo Sending bitstream to device
iceprog ${ICEPROG_ARGS} $MAIN.bin