From 1c76dad8d2bed09270661c1d9ab79d1cfc2a9b2a Mon Sep 17 00:00:00 2001 From: whitequark Date: Sun, 14 Jun 2020 09:25:54 +0000 Subject: [PATCH] back.cxxrtl: allow injecting black boxes. --- nmigen/back/cxxrtl.py | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/nmigen/back/cxxrtl.py b/nmigen/back/cxxrtl.py index 8010539..38cb41b 100644 --- a/nmigen/back/cxxrtl.py +++ b/nmigen/back/cxxrtl.py @@ -5,23 +5,38 @@ from . import rtlil __all__ = ["YosysError", "convert", "convert_fragment"] -def _convert_rtlil_text(rtlil_text, *, src_loc_at=0): +def _convert_rtlil_text(rtlil_text, black_boxes, *, src_loc_at=0): + if black_boxes is not None: + if not isinstance(black_boxes, dict): + raise TypeError("CXXRTL black boxes must be a dictionary, not {!r}" + .format(black_boxes)) + for box_name, box_source in black_boxes.items(): + if not isinstance(box_name, str): + raise TypeError("CXXRTL black box name must be a string, not {!r}" + .format(box_name)) + if not isinstance(box_source, str): + raise TypeError("CXXRTL black box source code must be a string, not {!r}" + .format(box_source)) + # FIXME: update this requirement once Yosys updates its node version yosys = find_yosys(lambda ver: ver >= (0, 9)) - return yosys.run(["-q", "-"], """ -read_ilang <