From: Jacob Lifshay Date: Tue, 1 Nov 2022 01:51:36 +0000 (-0700) Subject: validate that tied outputs are equivalent to their corresponding input X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=da998d8fa19a8c888f7e55e4dd5432fb39d7167d;p=bigint-presentation-code.git validate that tied outputs are equivalent to their corresponding input --- diff --git a/src/bigint_presentation_code/compiler_ir2.py b/src/bigint_presentation_code/compiler_ir2.py index 382d66c..7109e77 100644 --- a/src/bigint_presentation_code/compiler_ir2.py +++ b/src/bigint_presentation_code/compiler_ir2.py @@ -661,9 +661,13 @@ class GenericOpProperties: self.outputs = tuple(outputs) fixed_locs = [] # type: list[tuple[Loc, int]] for idx, out in enumerate(self.outputs): - if out.tied_input_index is not None \ - and out.tied_input_index >= len(self.inputs): - raise ValueError(f"tied_input_index out of range: {out}") + if out.tied_input_index is not None: + if out.tied_input_index >= len(self.inputs): + raise ValueError(f"tied_input_index out of range: {out}") + tied_inp = self.inputs[out.tied_input_index] + if tied_inp.tied_to_input(out.tied_input_index) != out: + raise ValueError(f"output can't be tied to non-equivalent " + f"input: {out} tied to {tied_inp}") if out.fixed_loc is not None: for other_fixed_loc, other_idx in fixed_locs: if not other_fixed_loc.conflicts(out.fixed_loc):