Mostly working workflow for programming the FPGA
This commit is contained in:
parent
f4f8978227
commit
6feb0209a4
|
@ -0,0 +1,3 @@
|
|||
*.asc
|
||||
*.bin
|
||||
*.json
|
|
@ -0,0 +1,22 @@
|
|||
# Note: Yosys chokes on spaces in library directories (reported to yosys)
|
||||
# Library path if not overriden (environment)
|
||||
NEXTPNR_OPTS=--up5k --package sg48
|
||||
ICETIME_OPTS=-d up5k
|
||||
FN=bldc
|
||||
|
||||
${FN}.bin: ${FN}.asc
|
||||
icepack ${FN}.asc ${FN}.bin
|
||||
|
||||
${FN}.json: ${FN}.v
|
||||
./run_yosys.sh ${FN}
|
||||
|
||||
${FN}.asc: ${FN}.json ${FN}.pcf
|
||||
nextpnr-ice40 ${NEXTPNR_OPTS} --pcf "${FN}.pcf" --json "${FN}.json" --asc "${FN}.asc"
|
||||
|
||||
#${FN}.rpt: ${FN}.pcf ${FN}.txt
|
||||
# icetime $ICETIME_OPTS -p "${FN}.pcf" -mtr "${FN}.rpt" "${FN}.txt"
|
||||
|
||||
clean:
|
||||
rm ${FN}.json ${FN}.asc ${FN}.bin
|
||||
|
||||
flash: $FN.bin
|
|
@ -0,0 +1,3 @@
|
|||
set_io --warn-no-port if_int 32
|
||||
|
||||
set_io --warn-no-port clk 20
|
|
@ -0,0 +1,13 @@
|
|||
module bldc (
|
||||
input clk,
|
||||
output if_int
|
||||
);
|
||||
|
||||
reg tmp = 0;
|
||||
assign if_int = tmp;
|
||||
|
||||
always @(posedge clk) begin
|
||||
tmp <= ~tmp;
|
||||
end
|
||||
|
||||
endmodule
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
flashrom -p ft2232_spi:type=232H,port=A
|
|
@ -0,0 +1,131 @@
|
|||
#!/bin/bash
|
||||
# Script by Al Williams (Hackaday)
|
||||
|
||||
#### Things you might want to change:
|
||||
#### Note that none of these will clobber what's already there
|
||||
#### In the environment/env file/command line
|
||||
|
||||
# Note: Yosys chokes on spaces in library directories (reported to yosys)
|
||||
# Library path if not overriden (environment)
|
||||
DEF_YOSYS_LIBDIR=".:library"
|
||||
# Default yosys options
|
||||
DEF_YOSYS_OPTS=
|
||||
# Default read_verilog options
|
||||
DEF_YOSYS_V_OPTS=-noautowire
|
||||
# default Arachne-pnr options
|
||||
DEF_ARACHNE_OPTS=-d\ 1k
|
||||
# default icetime options
|
||||
DEF_ICETIME_OPTS=-d\ hx1k
|
||||
# default project name
|
||||
DEF_YOSYS_PROJECT=
|
||||
|
||||
# You probably don't need to change much below this line
|
||||
|
||||
# for -n option. Put it here so you can override the default
|
||||
# in the env file but that's not likely to happen
|
||||
PROG=1
|
||||
|
||||
# Set per directory defaults
|
||||
# look for ice40flow.env in current directory
|
||||
if [ -f ice40flow.env ]
|
||||
then
|
||||
# Note that if you want to not clobber existing environment
|
||||
# You should set the DEF_ variables from above
|
||||
# If you set the others you will override command line/user environment
|
||||
# which is probably not what you want
|
||||
source ice40flow.env
|
||||
fi
|
||||
|
||||
|
||||
# Note: Yosys chokes on spaces in library directories (reported to yosys)
|
||||
# Library path if not overriden (environment)
|
||||
YOSYS_LIBDIR=${YOSYS_LIBDIR:-$DEF_YOSYS_LIBDIR}
|
||||
# Default yosys options
|
||||
YOSYS_OPTS=${YOSYS_OPTS:-$DEF_YOSYS_OPTS}
|
||||
# Default read_verilog options
|
||||
YOSYS_V_OPTS=${YOSYS_V_OPTS:-$DEF_YOSYS_V_OPTS}
|
||||
# default Arachne-pnr options
|
||||
ARACHNE_OPTS=${ARACHNE_OPTS:-$DEF_ARACHNE_OPTS}
|
||||
# default icetime options
|
||||
ICETIME_OPTS=${ICETIME_OPTS:-$DEF_ICETIME_OPTS}
|
||||
# Default project
|
||||
YOSYS_DEFPROJECT=${YOSYS_DEFPROJECT:-$DEF_YOSYS_PROJECT}
|
||||
|
||||
|
||||
|
||||
|
||||
# Handle -n options (didn't use getopts for one option)
|
||||
# Note the default is set before reading env
|
||||
# so if you wanted to never program you could
|
||||
# set PROG=0 in the env file
|
||||
# but there would be no good way to override
|
||||
# Maybe put PROG=${PROG:-0} so you could say
|
||||
# PROG=1 ice40flow to program? I don't know...
|
||||
if [ "$1" == "-n" ]
|
||||
then
|
||||
PROG=0
|
||||
shift
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# If you provide project name in environment we will
|
||||
# use that unless you provide the name on the command line
|
||||
# No project is an error
|
||||
FN=${1-$YOSYS_DEFPROJECT}
|
||||
if [ ! -z "$FN" -a ! -f "$FN.v" ]
|
||||
then
|
||||
echo 1>&2 "Can't find $FN.v"
|
||||
unset FN
|
||||
fi
|
||||
|
||||
if [ -z "$FN" ]
|
||||
then
|
||||
echo 1>&2 "Usage: ice40flow [-n] project"
|
||||
echo 1>&2 " -n = Do not program device"
|
||||
echo 1>&2 " Note: project name of foo implies foo.v exists"
|
||||
echo 1>&2 " do not supply the .v suffix on the project name"
|
||||
echo 1>&2 " You can set the following options in the environment or in ice40flow.env:"
|
||||
echo 1>&2 " YOSYS_DEFPROJECT = default project name if not specified on command line"
|
||||
echo 1>&2 " YOSYS_LIBDIR = Colon separated directories to search (no spaces)"
|
||||
echo 1>&2 " YOSYS_OPTS = Options to pass to yosys (try -Qq for quiet output)"
|
||||
echo 1>&2 " YOSYS_V_OPTS = Options to pass to yosys read_verilog (default -noautowire)"
|
||||
echo 1>&2 " ARACHNE_OPTS = Options to pass to Arachne-pnr (default -d 1k)"
|
||||
echo 1>&2 " ICETIME_OPTS = Options to pass to icetime (default -d hx1k)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# temporary test to warn people about Yosys not liking spaces in the libdir
|
||||
if [[ "$YOSYS_LIBDIR" =~ " " ]]
|
||||
then
|
||||
echo 1>&2 "Error: Yosys currently won't accept spaces in library directory names!"
|
||||
echo 1>&2 "Please change the library path and try again."
|
||||
exit 99
|
||||
fi
|
||||
|
||||
if [[ "$FN" =~ " " ]]
|
||||
then
|
||||
echo 1>&2 "Error: Please do not use spaces in the project name!"
|
||||
exit 98
|
||||
fi
|
||||
|
||||
|
||||
|
||||
yosys $YOSYS_OPTS <<EOF~
|
||||
read_verilog $YOSYS_V_OPTS "$FN.v"
|
||||
$( IFS=':'; for LD in $YOSYS_LIBDIR; do echo hierarchy -libdir $LD ; done )
|
||||
synth_ice40 -blif $FN.blif
|
||||
EOF~
|
||||
if [ $? != 0 ]
|
||||
then exit
|
||||
fi
|
||||
if ! arachne-pnr $ARACHNE_OPTS -p "$FN.pcf" -o "$FN.txt" "$FN.blif"
|
||||
then exit
|
||||
fi
|
||||
icetime $ICETIME_OPTS -p "$FN.pcf" -mtr "$FN.rpt" "$FN.txt"
|
||||
icepack $FN.txt $FN.bin
|
||||
if [ $PROG == 1 ]
|
||||
then iceprog $FN.bin
|
||||
else
|
||||
echo 1>&2 "Programming disabled by -n option"
|
||||
fi
|
|
@ -0,0 +1,12 @@
|
|||
# Generally, you want to only set DEF_xxx variables here
|
||||
# unless you really mean to override the user's environment
|
||||
|
||||
# DEF_YOSYS_LIBDIR = Default library path (colon separated directories; default .:library)
|
||||
# DEF_YOSYS_OPTS = Default yosys command line options (default none)
|
||||
# DEF_YOSYS_V_OPTS = Default yosys read_verilog options (default -noautowire)
|
||||
# DEF_ARACHNE_OPTS = Default arachne-pnr options (default -d 1k)
|
||||
# DEF_ICETIME_OPTS = Default icetime options (default -d hx1k)
|
||||
# DEF_YOSYS_PROJECT = Default project name (default none)
|
||||
|
||||
DEF_YOSYS_PROJECT=top
|
||||
DEF_YOSYS_OPTS=-qQ
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
|
||||
YOSYS_LIBDIR=".:library"
|
||||
YOSYS_OPTS=
|
||||
YOSYS_V_OPTS=-noautowire
|
||||
|
||||
FN=$1
|
||||
|
||||
yosys ${YOSYS_OPTS} <<EOF~
|
||||
read_verilog ${YOSYS_V_OPTS} "${FN}.v"
|
||||
$( IFS=':'; for LD in ${YOSYS_LIBDIR}; do echo hierarchy -libdir ${LD} ; done )
|
||||
synth_ice40 -top ${FN} -json ${FN}.json
|
||||
EOF~
|
||||
|
||||
|
Loading…
Reference in New Issue