diff --git a/ariths_gen/core/arithmetic_circuits/general_circuit.py b/ariths_gen/core/arithmetic_circuits/general_circuit.py index aabd64a..0d73e03 100644 --- a/ariths_gen/core/arithmetic_circuits/general_circuit.py +++ b/ariths_gen/core/arithmetic_circuits/general_circuit.py @@ -46,6 +46,11 @@ class GeneralCircuit(): return self.pyc(*args) + def __str__(self): + return f"<{type(self).__name__} prefix={self.prefix} " + (", ".join([f"input={i}" for i in self.inputs])) + ">" + + #super().__init__(prefix, name, out_N, inner_component, inputs=[a, b], signed=signed, **kwargs) + def add_component(self, component): """Adds a component into list of circuit's inner subcomponents. diff --git a/ariths_gen/wire_components/buses.py b/ariths_gen/wire_components/buses.py index dba69d4..da97b38 100644 --- a/ariths_gen/wire_components/buses.py +++ b/ariths_gen/wire_components/buses.py @@ -80,6 +80,9 @@ class Bus(): def __getitem__(self, i): return self.bus[i] + def __getitem__(self, i): + return self.get_wire(i) + # Connecting output wire of the inner circuit component to desired position in the described circuit's output bus def connect(self, bus_wire_index: int, inner_component_out_wire: Wire, inserted_wire_desired_index: int = -1): """Connects given 'Wire' object to a 'bus_wire_index' within this bus. @@ -103,6 +106,9 @@ class Bus(): elif inserted_wire_desired_index != -1: self.bus[bus_wire_index] = Wire(name=inner_component_out_wire.name, prefix=inner_component_out_wire.parent_bus.prefix, index=inserted_wire_index, value=inner_component_out_wire.value, parent_bus=self) + def __setitem__(self, i, v): + self.connect(i, v) + def connect_bus(self, connecting_bus: object, start_connection_pos: int = 0, end_connection_pos: int = -1, offset: int = 0): """Ensures connection of specified bus wires to this bus wires. @@ -144,6 +150,9 @@ class Bus(): else: return "" + def __str__(self): + return f"" + """ C CODE GENERATION """ def get_declaration_c(self): """Bus declaration in C code. diff --git a/ariths_gen/wire_components/wires.py b/ariths_gen/wire_components/wires.py index a4f1b7a..91821a4 100644 --- a/ariths_gen/wire_components/wires.py +++ b/ariths_gen/wire_components/wires.py @@ -246,6 +246,13 @@ class Wire(): else: return self.prefix + def __str__(self): + if self.is_const(): + return f"" + elif self.is_buswire(): + return f"" + else: + return f"" # Wires with constant values # class ConstantWireValue0(Wire): @@ -281,6 +288,7 @@ class ConstantWireValue0(Wire): return True + class ConstantWireValue1(Wire): """Class representing wire carrying constant value 1 used to interconnect components. @@ -312,3 +320,4 @@ class ConstantWireValue1(Wire): bool: True, because constant wire carries a constant value 1. """ return True +