Example #1
0
def test_prologue_add_file(mocker):
    """ Test that add file calls to the registry """
    pro = Prologue()
    mocker.patch.object(pro, "registry", autospec=True)
    ignore_dup = choice((True, False))
    pro.add_file("test_file_1234", ignore_duplicate=ignore_dup)
    pro.registry.add_file.assert_called_once_with(
        "test_file_1234",
        ignore_duplicate=ignore_dup,
    )
Example #2
0
import sys

from prologue import Prologue

# Check for right number of arguments, then extract them
if len(sys.argv) != 4:
    print("SYNTAX: python3 verilog.py <INPUTDIR> <TOPFILE> <OUTPUT>")
    sys.exit(1)

in_dir = Path(sys.argv[1])
top    = Path(sys.argv[2])
output = Path(sys.argv[3])

# Setup preprocessor instance
pro = Prologue(
    comment         ="//",
    delimiter       ="`",
    shared_delimiter=True,      # Verilog uses "`" to signal a defined variable
    implicit_sub    =False,     # Every substitution must be prefixed with "`"
    explicit_style  =("`", ""),
)

# Find all files within the input directory and add them to the registry
for f_path in in_dir.glob("*.*"):
    pro.add_file(f_path)

# Kick off evaluate using the top-level file
with open(output, "w") as fh:
    for line in pro.evaluate(top.parts[-1]):
        fh.write(line + "\n")