From 7e1112cf8156344bc9d5e1434a01f3c618b7b4eb Mon Sep 17 00:00:00 2001 From: honzastor Date: Wed, 6 Mar 2024 00:42:12 +0100 Subject: [PATCH] Added individual input bus attributes to CGP Circuit objects to allow for the generation of output CGP representation. --- ariths_gen/core/cgp_circuit.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ariths_gen/core/cgp_circuit.py b/ariths_gen/core/cgp_circuit.py index ae4e3df..cbb5fbc 100644 --- a/ariths_gen/core/cgp_circuit.py +++ b/ariths_gen/core/cgp_circuit.py @@ -43,6 +43,13 @@ class UnsignedCGPCircuit(GeneralCircuit): inputs = [Bus(N=bw, prefix=f"input_{chr(i)}") for i, bw in enumerate(input_widths, start=0x61)] + # Assign each Bus object in self.inputs to a named attribute of self + for bus in inputs: + # Here, bus.prefix is 'input_a', 'input_b', etc. + # We strip 'input_' and use the remaining part (e.g., 'a', 'b') to create the attribute name + attr_name = bus.prefix.replace('input_', '') + setattr(self, attr_name, bus) + # Adding values to the list self.vals = {} j = 2 # Start from two, 0=False, 1=True