blob: e0d82dc1de4195a18ff644bf3962b7dea3349007 [file]
#!/usr/bin/env python3
# Copyright (C) 2020 The SymbiFlow Authors.
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
from . import vlog_to_pbtype
from . import vlog_to_model
import argparse
import sys
from .yosys.run import get_yosys
def main(args):
# Check if Yosys can be found. Print an error message if not.
if get_yosys() is None:
print("ERROR: Cannot find the Yosys binary or its not executable.")
return -1
if args.mode == "pb_type":
with open(args.outfile, "w") as fp:
fp.write(vlog_to_pbtype.vlog_to_pbtype(
args.infiles, args.outfile, args.top))
else:
with open(args.outfile, "w") as fp:
fp.write(vlog_to_model.vlog_to_model(
args.infiles, args.includes, args.top, args.outfile))
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description="Verilog to XML"
)
parser.add_argument(
'infiles',
metavar='input.v',
type=str,
nargs='+',
help="""\
One or more Verilog input files, that will be passed to Yosys internally.
They should be enough to generate a flattened representation of the model,
so that paths through the model can be determined.
"""
)
parser.add_argument(
'--top',
help="""\
Top level module, will usually be automatically determined from the file name
%.sim.v
"""
)
parser.add_argument(
'--outfile',
'-o',
type=str,
default="output.xml",
help="""\
Output filename, default 'output.xml'
"""
)
parser.add_argument(
'--includes',
help="""\
Comma separate list of include directories.
""",
default=""
)
parser.add_argument(
'--mode',
type=str,
default='pb_type',
choices=['pb_type', 'model'],
help="""\
Output file type, possible values are: pb_type and model.
Default value is pb_type
"""
)
args = parser.parse_args()
sys.exit(main(args))