f4pga/wrappers/sh/synth: update

Signed-off-by: Unai Martinez-Corral <umartinezcorral@antmicro.com>
This commit is contained in:
Unai Martinez-Corral 2022-09-07 02:14:06 +02:00
parent ce0c29bddb
commit 9e327656a1
2 changed files with 55 additions and 147 deletions

View File

@ -44,66 +44,28 @@ EXTRA_ARGS=()
OPT="" OPT=""
for arg in $@; do for arg in $@; do
case $arg in case $arg in
-t|--top) -t|--top) OPT="top" ;;
OPT="top" -v|--verilog) OPT="vlog" ;;
;; -d|--device) OPT="dev" ;;
-v|--verilog) -F|--family) OPT="family" ;;
OPT="vlog" -P|--part) OPT="part" ;;
;; -p|--pcf) OPT="pcf" ;;
-d|--device) -y|-f|+incdir+*|+libext+*|+define+*) OPT="xtra" ;;
OPT="dev" *)
;; case $OPT in
-F|--family) "top") TOP=$arg; OPT="" ;;
OPT="family" "dev") DEVICE=$arg; OPT="" ;;
;; "family") FAMILY=$arg; OPT="" ;;
-P|--part) "part") PART=$arg; OPT="" ;;
OPT="part" "pcf") PCF=$arg; OPT="" ;;
;; "vlog") VERILOG_FILES+=($arg) ;;
-p|--pcf) "xtra") ;;
OPT="pcf" *) print_usage ;;
;; esac
-y|-f|+incdir+*|+libext+*|+define+*) ;;
OPT="xtra" esac
;; if [ "$OPT" == "xtra" ]; then EXTRA_ARGS+=($arg); fi
*)
case $OPT in
"top")
TOP=$arg
OPT=""
;;
"vlog")
VERILOG_FILES+=($arg)
;;
"dev")
DEVICE=$arg
OPT=""
;;
"family")
FAMILY=$arg
OPT=""
;;
"part")
PART=$arg
OPT=""
;;
"pcf")
PCF=$arg
OPT=""
;;
"xtra")
;;
*)
print_usage
;;
esac
;;
esac
if [ "$OPT" == "xtra" ]; then
EXTRA_ARGS+=($arg)
fi
done done
if [ -z ${FAMILY} ]; then echo "Please specify device family"; exit 1; fi if [ -z ${FAMILY} ]; then echo "Please specify device family"; exit 1; fi
@ -120,9 +82,9 @@ export OUT_FASM_EXTRA=${TOP}_fasm_extra.fasm
export PYTHON3=$(which python3) export PYTHON3=$(which python3)
if [ -s $PCF ]; then if [ -s $PCF ]; then
export PCF_FILE=$PCF export PCF_FILE=$PCF
else else
export PCF_FILE="" export PCF_FILE=""
fi fi
DEVICE_PATH="${F4PGA_SHARE_DIR}/arch/${DEVICE}_${DEVICE}" DEVICE_PATH="${F4PGA_SHARE_DIR}/arch/${DEVICE}_${DEVICE}"
@ -145,19 +107,8 @@ else
fi fi
fi fi
YOSYS_COMMANDS=`echo ${EXTRA_ARGS[*]} | python3 -m f4pga.utils.quicklogic.convert_compile_opts` yosys_cmds=`echo ${EXTRA_ARGS[*]} | python3 -m f4pga.utils.quicklogic.convert_compile_opts`
YOSYS_COMMANDS="${YOSYS_COMMANDS//$'\n'/'; '}" `which yosys` \
-p "${yosys_cmds//$'\n'/'; '} tcl $(python3 -m f4pga.wrappers.tcl "${FAMILY}")" \
LOG=${TOP}_synth.log -l "${TOP}_synth.log" \
${VERILOG_FILES[*]}
YOSYS_SCRIPT="tcl $(python3 -m f4pga.wrappers.tcl "${FAMILY}")"
for f in ${VERILOG_FILES[*]}; do
YOSYS_SCRIPT="read_verilog ${f}; $YOSYS_SCRIPT"
done
if [ ! -z "${YOSYS_COMMANDS}" ]; then
YOSYS_SCRIPT="$YOSYS_COMMANDS; $YOSYS_SCRIPT"
fi
`which yosys` -p "${YOSYS_SCRIPT}" -l $LOG

View File

@ -35,55 +35,12 @@ SURELOG=0
for arg in $@; do for arg in $@; do
echo $arg echo $arg
case "$arg" in case "$arg" in
-t|--top) -v|--verilog) VERILOGLIST=1 XDCLIST=0 TOPNAME=0 DEVICENAME=0 PARTNAME=0 SURELOG=0 ;;
echo "adding top" -x|--xdc) VERILOGLIST=0 XDCLIST=1 TOPNAME=0 DEVICENAME=0 PARTNAME=0 SURELOG=0 ;;
VERILOGLIST=0 -t|--top) VERILOGLIST=0 XDCLIST=0 TOPNAME=1 DEVICENAME=0 PARTNAME=0 SURELOG=0 ;;
XDCLIST=0 -d|--device) VERILOGLIST=0 XDCLIST=0 TOPNAME=0 DEVICENAME=1 PARTNAME=0 SURELOG=0 ;;
TOPNAME=1 -p|--part) VERILOGLIST=0 XDCLIST=0 TOPNAME=0 DEVICENAME=0 PARTNAME=1 SURELOG=0 ;;
DEVICENAME=0 -s|--surelog) VERILOGLIST=0 XDCLIST=0 TOPNAME=0 DEVICENAME=0 PARTNAME=0 SURELOG=1 ;;
PARTNAME=0
SURELOG=0
;;
-x|--xdc)
VERILOGLIST=0
XDCLIST=1
TOPNAME=0
DEVICENAME=0
PARTNAME=0
SURELOG=0
;;
-v|--verilog)
VERILOGLIST=1
XDCLIST=0
TOPNAME=0
DEVICENAME=0
PARTNAME=0
SURELOG=0
;;
-d|--device)
VERILOGLIST=0
XDCLIST=0
TOPNAME=0
DEVICENAME=1
PARTNAME=0
SURELOG=0
;;
-p|--part)
VERILOGLIST=0
XDCLIST=0
TOPNAME=0
DEVICENAME=0
PARTNAME=1
SURELOG=0
;;
-s|--surelog)
VERILOGLIST=0
XDCLIST=0
TOPNAME=0
DEVICENAME=0
PARTNAME=0
SURELOG=1
;;
*) *)
if [ $VERILOGLIST -eq 1 ]; then if [ $VERILOGLIST -eq 1 ]; then
VERILOG_FILES+=($arg) VERILOG_FILES+=($arg)
@ -107,27 +64,27 @@ for arg in $@; do
esac esac
done done
if [ ${#VERILOG_FILES[@]} -eq 0 ]; then if [ ${#VERILOG_FILES[@]} -eq 0 ]; then echo "Please provide at least one Verilog file"; exit 1; fi
echo "Please provide at least one Verilog file"
exit 1
fi
DATABASE_DIR=${DATABASE_DIR:-$(prjxray-config)} export TOP="${TOP}"
export USE_ROI='FALSE'
export INPUT_XDC_FILES="${XDC_FILES[*]}"
export OUT_JSON="$TOP.json"
export OUT_SDC="${TOP}.sdc"
export SYNTH_JSON="${TOP}_io.json"
export OUT_SYNTH_V="${TOP}_synth.v"
export OUT_EBLIF="${TOP}.eblif"
export PART_JSON=`realpath ${DATABASE_DIR:-$(prjxray-config)}/$DEVICE/$PART/part.json`
export OUT_FASM_EXTRA="${TOP}_fasm_extra.fasm"
export PYTHON3="${PYTHON3:-$(which python3)}"
export TOP=${TOP} yosys_read_cmds=""
export USE_ROI="FALSE" yosys_files="${VERILOG_FILES[*]}"
export INPUT_XDC_FILES=${XDC_FILES[*]}
export OUT_JSON=$TOP.json
export OUT_SDC=${TOP}.sdc
export SYNTH_JSON=${TOP}_io.json
export OUT_SYNTH_V=${TOP}_synth.v
export OUT_EBLIF=${TOP}.eblif
export PART_JSON=`realpath ${DATABASE_DIR}/$DEVICE/$PART/part.json`
export OUT_FASM_EXTRA=${TOP}_fasm_extra.fasm
export PYTHON3=${PYTHON3:-$(which python3)}
yosys_read_cmds="read_verilog"
if [ -n "$SURELOG_CMD" ]; then if [ -n "$SURELOG_CMD" ]; then
yosys_read_cmds="plugin -i uhdm; read_verilog_with_uhdm ${SURELOG_CMD[*]}" yosys_read_cmds="plugin -i uhdm; read_verilog_with_uhdm ${SURELOG_CMD[*]} ${VERILOG_FILES[*]}"
yosys_files=""
fi fi
yosys -p "$yosys_read_cmds ${VERILOG_FILES[*]}; tcl $(python3 -m f4pga.wrappers.tcl)" -l "${TOP}_synth.log" yosys \
-p "$yosys_read_cmds; tcl $(python3 -m f4pga.wrappers.tcl)" \
-l "${TOP}_synth.log" \
$yosys_files