f4pga/wrappers/sh/generate_bitstream: convert arg parser from shell to python
Signed-off-by: Unai Martinez-Corral <umartinezcorral@antmicro.com>
This commit is contained in:
parent
eaed7ea8ad
commit
23557375fd
|
@ -706,57 +706,27 @@ PYTHONPATH='{F4PGA_SHARE_DIR}/scripts':$PYTHONPATH \
|
||||||
|
|
||||||
def generate_bitstream():
|
def generate_bitstream():
|
||||||
print("[F4PGA] Running (deprecated) generate_bitstream")
|
print("[F4PGA] Running (deprecated) generate_bitstream")
|
||||||
p_run_bash_cmds(
|
parser = ArgumentParser(description=__doc__, formatter_class=RawDescriptionHelpFormatter)
|
||||||
f"""
|
parser.add_argument("--device", "-d", required=True, type=str, help="")
|
||||||
set -e
|
parser.add_argument("--fasm", "-f", required=True, type=str, help="")
|
||||||
eval set -- "$(
|
parser.add_argument("--bit", "-b", required=True, type=str, help="")
|
||||||
getopt \
|
parser.add_argument("--format", "-r", required=False, type=str, help="")
|
||||||
--options=d:f:r:b:P: \
|
args = parser.parse_args()
|
||||||
--longoptions=device:,fasm:,format:,bit:,part: \
|
|
||||||
--name $0 -- {' '.join(sys_argv[1:])}
|
if not Path(args.fasm).exists():
|
||||||
)"
|
raise Exception(f"File <{args.fasm}> does not exist!")
|
||||||
"""
|
|
||||||
+ """
|
fmt = "4byte" if args.format is None else args.format
|
||||||
DEVICE=""
|
db_root = F4PGA_SHARE_DIR / "fasm_database" / args.device
|
||||||
FASM=""
|
|
||||||
BIT_FORMAT="4byte"
|
if "qlf_k4n8" in args.device:
|
||||||
BIT=""
|
p_run_bash_cmds(
|
||||||
PART=""
|
f"'{which('qlf_fasm')}' --db-root '{db_root}' --format '{fmt}' --assemble '{args.fasm}' '{args.bit}'"
|
||||||
while true; do
|
)
|
||||||
case "$1" in
|
elif args.device in ["ql-eos-s3", "ql-pp3e"]:
|
||||||
-d|--device) DEVICE=$2; shift 2;;
|
p_run_bash_cmds(f"qlfasm --dev-type '{args.device}' '{args.fasm}' '{args.bit}'")
|
||||||
-f|--fasm) FASM=$2; shift 2;;
|
else:
|
||||||
-r|--format) BIT_FORMAT=$2; shift 2;;
|
raise Exception(f"[bitstream generation] Unsupported device '{args.device}'!")
|
||||||
-b|--bit) BIT=$2; shift 2;;
|
|
||||||
-P|--part) PART=$2; shift 2;;
|
|
||||||
--) break;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
if [ -z $DEVICE ]; then echo "Please provide device name"; exit 1; fi
|
|
||||||
if [ -z $FASM ]; then echo "Please provide an input FASM file name"; exit 1; fi
|
|
||||||
if [ ! -f "$FASM" ]; then echo "File <$FASM> does not exist!"; exit 1; fi
|
|
||||||
if [ -z $BIT ]; then echo "Please provide an output bistream file name"; exit 1; fi
|
|
||||||
"""
|
|
||||||
+ f"""
|
|
||||||
if [[ "$DEVICE" =~ ^(qlf_k4n8.*)$ ]]; then
|
|
||||||
'{which('qlf_fasm')}' \
|
|
||||||
--db-root '{F4PGA_SHARE_DIR}/fasm_database/'"${{DEVICE}}" \
|
|
||||||
--format "$BIT_FORMAT" \
|
|
||||||
--assemble \
|
|
||||||
"$FASM" \
|
|
||||||
"$BIT"
|
|
||||||
elif [[ "$DEVICE" =~ ^(ql-eos-s3|ql-pp3e)$ ]]; then
|
|
||||||
qlfasm \
|
|
||||||
--dev-type \
|
|
||||||
"$DEVICE" \
|
|
||||||
"$FASM" \
|
|
||||||
"$BIT"
|
|
||||||
else
|
|
||||||
echo "ERROR: Unsupported device '${{DEVICE}}' for bitstream generation"
|
|
||||||
exit -1
|
|
||||||
fi
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def generate_libfile():
|
def generate_libfile():
|
||||||
|
|
|
@ -388,7 +388,7 @@ if [ "$FAMILY" == "qlf_k4n8" ]; then
|
||||||
elif [ "$FAMILY" == "pp3" ]; then
|
elif [ "$FAMILY" == "pp3" ]; then
|
||||||
echo -e "\
|
echo -e "\
|
||||||
\${BUILDDIR}/\${TOP}.bit: \${BUILDDIR}/\${TOP}.fasm\n\
|
\${BUILDDIR}/\${TOP}.bit: \${BUILDDIR}/\${TOP}.fasm\n\
|
||||||
cd \${BUILDDIR} && symbiflow_generate_bitstream -d \${DEVICE} -f \${TOP}.fasm -P \${PARTNAME} -b \${TOP}.bit >> $LOG_FILE 2>&1\n\
|
cd \${BUILDDIR} && symbiflow_generate_bitstream -d \${DEVICE} -f \${TOP}.fasm -b \${TOP}.bit >> $LOG_FILE 2>&1\n\
|
||||||
" >>$MAKE_FILE
|
" >>$MAKE_FILE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue