Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --synthesis-template arg to parse.py #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ def parse_arguments():
help="Name of the top module")

# Optional arguments
# Allow the caller to bring their own synthesis template
parser.add_argument("-st", "--synthesis-template", dest="synthesis_template_path",
default=TEMPLATE_FILE_PATH,
type=helpers.ap_check_file_exists,
help="Path of the template yosys synthesis script")
parser.add_argument("-l", "--label", dest="label_file_path",
required=False, default=LABEL_FILE_PATH, type=helpers.ap_check_dir_exists,
help="Path of output label file (default: %(default)s)")
Expand Down Expand Up @@ -78,7 +83,7 @@ def parse_arguments():

def create_yosys_script(args):
yosys_script = ""
with open(TEMPLATE_FILE_PATH) as template_file:
with open(args.synthesis_template_path) as template_file:
yosys_script += template_file.read()
assert("{READ_FILES}" in yosys_script)
read_verilog_commands = "\n".join(["read_verilog %s;" % os.path.abspath(f) for f in args.verilog_file_paths]) + "\n"
Expand Down Expand Up @@ -109,6 +114,9 @@ def yosys_synth(args):
if args.synthesis_file_path:
print("Using custom yosys synthesis script: %s" % args.synthesis_file_path)
yosys_synth_file_path = args.synthesis_file_path
elif args.synthesis_template_path:
print("Using custom yosys template synthesis script: %s" % args.synthesis_template_path)
yosys_synth_file_path = SYNTH_FILE_PATH
else:
yosys_synth_file_path = SYNTH_FILE_PATH

Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ python3 parse.py
The arguments for the standard mode of operation are:
* `--source`: file path(s) to the source file(s). `parse.py` will automatically generate a Yosys synthesis script. Then, the `--synthesis-file` option must not be used.
* `--synthesis-file`: In case one does not want to use the auto-generated script, this option can be used to specify a custom Yosys synthesis script. Then, the `--source` option must not be used because the script already includes the paths of the sources.
* `--synthesis-template`: an optional template yosys synthesis script that is used for patching instead of default `template/yosys_synth_template.txt`. The `--source` option can be used with this argument. The difference between `--synthesis-file` and `--synthesis-template` is that the former is directly passed to yosys, while the latter is patched with the source files passed with `--source`.
* `--top-module`: the name of the top module

Optional arguments include:
Expand Down