diff --git a/core/arithmetic_circuits/general_circuit.html b/core/arithmetic_circuits/general_circuit.html index 7f2455b..3c8a222 100644 --- a/core/arithmetic_circuits/general_circuit.html +++ b/core/arithmetic_circuits/general_circuit.html @@ -3,13 +3,13 @@ - + ariths_gen.core.arithmetic_circuits.general_circuit API documentation - + @@ -37,7 +37,7 @@

Classes

class GeneralCircuit -(prefix: str, name: str, out_N: int, inner_component: bool = False, inputs: list = [], one_bit_circuit: bool = False, signed: bool = False, signed_out=None, outname=None, **kwargs) +(prefix: str,
name: str,
out_N: int,
inner_component: bool = False,
inputs: list = [],
one_bit_circuit: bool = False,
signed: bool = False,
signed_out=None,
outname=None,
**kwargs)

Class represents a general circuit and ensures its generation to various representations.

@@ -953,6 +953,19 @@

Returns

str
C code library includes.
+
+ +Expand source code + +
@staticmethod
+def get_includes_c():
+    """Generates necessary C library includes for output representation.
+
+    Returns:
+        str: C code library includes.
+    """
+    return f"#include <stdio.h>\n#include <stdint.h>\n\n"
+
def get_unique_types(components: list, multi_bit: bool = False) @@ -971,6 +984,26 @@

Returns

list
List of unique composite class types.
+
+ +Expand source code + +
@staticmethod
+def get_unique_types(components: list, multi_bit: bool = False):
+    """Retrieves just the unique representatives of class types present inside the provided components list.
+
+    Args:
+        components (list): List of components to be filtered.
+        multi_bit (bool): Specifies whether the provided components list is composed of multi bit type circuits. Defaults to False.
+
+    Returns:
+        list: List of unique composite class types.
+    """
+    if multi_bit is True:
+        return list({(type(c), tuple(i.N for i in c.inputs)): c for c in components[::-1]}.values())
+    else:
+        return list({type(c): c for c in components}.values())
+

Methods

@@ -987,6 +1020,35 @@

Args

component
Subcomponent to be added into list of components composing described circuit.
+
+ +Expand source code + +
def add_component(self, component):
+    """Adds a component into list of circuit's inner subcomponents.
+    
+    Additionally it adds all the gates of the component to the circuit's list of gates and all
+    sbcomponents prefixes to check for naming duplicates which could cause issues in the circuit generation.
+
+    Args:
+        component: Subcomponent to be added into list of components composing described circuit.
+    """
+    # TODO should be refactored in ArithsGen rework
+    # We should probably check also wire names for especially hierarchical generation
+    if isinstance(component, TwoInputLogicGate):
+        if component.disable_generation is False:
+            self.circuit_gates.append(component)
+    else:
+        self.circuit_gates.extend(component.get_circuit_gates())
+        for prefix in component._prefixes:
+            assert prefix not in self._prefixes, f"Component with prefix {prefix} already exists in the circuit."
+        self._prefixes.extend(component._prefixes)
+
+    assert component.prefix not in self._prefixes, f"Component with prefix {component.prefix} already exists in the circuit."
+    self._prefixes.append(component.prefix)
+    self.components.append(component)
+    return component
+
def get_blif_code_flat(self, file_object) @@ -998,6 +1060,22 @@

Args

file_object : TextIOWrapper
Destination file object where circuit's representation will be written to.
+
+ +Expand source code + +
def get_blif_code_flat(self, file_object):
+    """Generates flat Blif code representation of corresponding arithmetic circuit.
+
+    Args:
+        file_object (TextIOWrapper): Destination file object where circuit's representation will be written to.
+    """
+    file_object.write(self.get_prototype_blif())
+    file_object.write(self.get_declaration_blif())
+    file_object.write(self.get_function_blif_flat())
+    file_object.write(self.get_function_out_blif())
+    file_object.write(f".end\n")
+
def get_blif_code_hier(self, file_object) @@ -1009,6 +1087,19 @@

Args

file_object : TextIOWrapper
Destination file object where circuit's representation will be written to.
+
+ +Expand source code + +
def get_blif_code_hier(self, file_object):
+    """Generates hierarchical Blif code representation of corresponding arithmetic circuit.
+
+    Args:
+        file_object (TextIOWrapper): Destination file object where circuit's representation will be written to.
+    """
+    file_object.write(self.get_circuit_blif()+"\n")
+    file_object.write(self.get_function_blocks_blif())
+
def get_c_code_flat(self, file_object) @@ -1020,6 +1111,25 @@

Args

file_object : TextIOWrapper
Destination file object where circuit's representation will be written to.
+
+ +Expand source code + +
def get_c_code_flat(self, file_object):
+    """Generates flat C code representation of corresponding arithmetic circuit.
+
+    Args:
+        file_object (TextIOWrapper): Destination file object where circuit's representation will be written to.
+    """
+    file_object.write(self.get_includes_c())
+    file_object.write(self.get_prototype_c())
+    file_object.write(self.out.get_declaration_c())
+    file_object.write(self.get_declaration_c_flat()+"\n")
+    file_object.write(self.get_init_c_flat()+"\n")
+    file_object.write(self.get_function_out_c_flat())
+    file_object.write(self.out.return_bus_wires_sign_extend_c_flat())
+    file_object.write(f"  return {self.out.prefix}"+";\n}")
+
def get_c_code_hier(self, file_object) @@ -1031,6 +1141,20 @@

Args

file_object : TextIOWrapper
Destination file object where circuit's representation will be written to.
+
+ +Expand source code + +
def get_c_code_hier(self, file_object):
+    """Generates hierarchical C code representation of corresponding arithmetic circuit.
+
+    Args:
+        file_object (TextIOWrapper): Destination file object where circuit's representation will be written to.
+    """
+    file_object.write(self.get_includes_c())
+    file_object.write(self.get_function_blocks_c())
+    file_object.write(self.get_circuit_c())
+
def get_cgp_code_flat(self, file_object) @@ -1042,6 +1166,20 @@

Args

file_object : TextIOWrapper
Destination file object where circuit's representation will be written to.
+
+ +Expand source code + +
def get_cgp_code_flat(self, file_object):
+    """Generates flat CGP chromosome representation of corresponding arithmetic circuit.
+
+    Args:
+        file_object (TextIOWrapper): Destination file object where circuit's representation will be written to.
+    """
+    file_object.write(self.get_parameters_cgp())
+    file_object.write(self.get_triplets_cgp())
+    file_object.write(self.get_outputs_cgp())
+
def get_circuit_blif(self) @@ -1053,6 +1191,22 @@

Returns

str
Hierarchical Blif code of subcomponent's function block.
+
+ +Expand source code + +
def get_circuit_blif(self):
+    """Generates hierarchical Blif code subcomponent's function block.
+
+    Returns:
+        str: Hierarchical Blif code of subcomponent's function block.
+    """
+    return f"{self.get_prototype_blif()}" + \
+           f"{self.get_declaration_blif()}" + \
+           f"{self.get_invocations_blif_hier()}" + \
+           f"{self.get_function_out_blif()}" + \
+           f".end\n"
+
def get_circuit_c(self) @@ -1064,12 +1218,42 @@

Returns

str
Hierarchical C code of subcomponent's function block.
+
+ +Expand source code + +
def get_circuit_c(self):
+    """Generates hierarchical C code subcomponent's function block.
+
+    Returns:
+        str: Hierarchical C code of subcomponent's function block.
+    """
+    return f"{self.get_prototype_c()}" + \
+           f"{self.out.get_declaration_c()}" + \
+           f"{self.get_declarations_c_hier()}\n" + \
+           f"{self.get_init_c_hier()}\n" + \
+           f"{self.get_function_out_c_hier()}" + \
+           f"{self.out.return_bus_wires_sign_extend_c_hier()}" + \
+           f"  return {self.out.prefix}"+";\n}"
+
def get_circuit_def(self) ‑> Dict[str, Wire]

returns IDs and wires of the inputs and output

+
+ +Expand source code + +
def get_circuit_def(self) -> Dict[str, Wire]:
+    """ returns IDs and wires of the inputs and output"""
+    # TODO delete? (probably replaced by get_hier_subcomponent_def)
+    #.{circuit_block.a.prefix}({self.a.prefix}), .{circuit_block.b.prefix}({self.b.prefix}), .{circuit_block.out.prefix}({self.out.prefix}));\n"
+    r = {chr(97 + i): self.inputs[i] for i in range(len(self.inputs))}
+    r['out'] = self.get_global_prefix() + "_out"
+    return r
+
def get_circuit_gates(self, verilog_output: bool = False) @@ -1084,6 +1268,30 @@

Returns

list
List of composite logic gates.
+
+ +Expand source code + +
def get_circuit_gates(self, verilog_output: bool = False):
+    """Gets a list of all the logic gates in circuit that should be generated.
+
+    Args:            
+        verilog_output (bool): Specifies whether the call has been invoked by a verilog output generation method.
+    Returns:
+        list: List of composite logic gates.
+    """
+    gates = []
+    for c in self.components:
+        if isinstance(c, TwoInputLogicGate):
+            if (c.disable_generation is False) and (verilog_output is False or getattr(c, "use_verilog_instance", False) is False):
+                gates.append(c)
+        else:
+            # Check whether it is necessary to use gates for the Verilog component
+            # description (ArithsGen internally defined comp) or not (technology specific instance)
+            if verilog_output is False or ((hasattr(c, "use_verilog_instance") and c.use_verilog_instance is False) or hasattr(c, "use_verilog_instance") is False):
+                gates.extend(c.get_circuit_gates(verilog_output))
+    return gates
+
def get_circuit_v(self) @@ -1095,9 +1303,25 @@

Returns

str
Hierarchical Verilog code of subcomponent's function block.
+
+ +Expand source code + +
def get_circuit_v(self):
+    """Generates hierarchical Verilog code subcomponent's function block.
+
+    Returns:
+        str: Hierarchical Verilog code of subcomponent's function block.
+    """
+    return f"{self.get_prototype_v()}" + \
+           f"{self.get_declarations_v_hier()}\n" + \
+           f"{self.get_init_v_hier()}\n" + \
+           f"{self.get_function_out_v_hier()}" + \
+           f"endmodule"
+
-def get_circuit_wire_index(self, wire: Wire) +def get_circuit_wire_index(self,
wire: Wire)

Searches for circuit's wire unique index position within the circuit. Used for cgp chromosome generation.

@@ -1111,6 +1335,26 @@

Returns

int
Wire's index position number within the circuit.
+
+ +Expand source code + +
def get_circuit_wire_index(self, wire: Wire):
+    """Searches for circuit's wire unique index position within the circuit. Used for cgp chromosome generation.
+
+    Args:
+        wire (Wire): Wire to retrieve index position of.
+
+    Returns:
+        int: Wire's index position number within the circuit.
+    """
+    if wire.is_const():
+        return wire.cgp_const
+    else:
+        for w in self.circuit_wires:
+            if wire.name == w[1]:
+                return w[2]
+
def get_circuit_wires(self) @@ -1120,6 +1364,45 @@

Returns

Constant wire with value 0 has constant index of 0. Constant wire with value 1 has constant index of 1. Other wires indexes start counting from 2 and up.

+
+ +Expand source code + +
def get_circuit_wires(self):
+    """Gets a list of all wires in circuit along with their index position for cgp chromosome generation and stores them inside `self.circuit_wires` list.
+
+    Constant wire with value 0 has constant index of 0.
+    Constant wire with value 1 has constant index of 1.
+    Other wires indexes start counting from 2 and up.
+    """
+    circuit_wires_names = []
+
+    for input in self.inputs:
+        if isinstance(input, Bus):
+            [self.circuit_wires.append(
+                (w, f"{w.name}", self.save_wire_id(wire=w))) for w in input.bus]
+            [circuit_wires_names.append(w.name) for w in input.bus]
+        else:
+            self.circuit_wires.append(
+                (input, f"{input.name}", self.save_wire_id(wire=input)))
+            circuit_wires_names.append(input.name)
+
+    for gate in self.circuit_gates:
+        if gate.a.name not in circuit_wires_names:
+            self.circuit_wires.append(
+                (gate.a, gate.a.name, self.save_wire_id(wire=gate.a)))
+            circuit_wires_names.append(gate.a.name)
+
+        if hasattr(gate, 'b') and gate.b.name not in circuit_wires_names:
+            self.circuit_wires.append(
+                (gate.b, gate.b.name, self.save_wire_id(wire=gate.b)))
+            circuit_wires_names.append(gate.b.name)
+
+        if gate.out.name not in circuit_wires_names:
+            self.circuit_wires.append(
+                (gate.out, gate.out.name, self.save_wire_id(wire=gate.out)))
+            circuit_wires_names.append(gate.out.name)
+
def get_component_types(self, verilog_output: bool = False) @@ -1137,6 +1420,29 @@

Returns

list
List of unique component types describing the circuit.
+
+ +Expand source code + +
def get_component_types(self, verilog_output: bool = False):
+    """Retrieves a list of all the unique types of subcomponents composing the circuit.
+
+    Returning list consists of only the unique types of logic gates, one bit circuits and multi bit circuits.
+
+    Args:
+        verilog_output (bool): Specifies whether the call has been invoked by a verilog output generation method.
+    Returns:
+        list: List of unique component types describing the circuit.
+    """
+    gate_comps = self.get_unique_types(components=self.get_circuit_gates(verilog_output))
+    one_bit_comps = self.get_unique_types(
+        components=self.get_one_bit_components())
+    multi_bit_comps = self.get_unique_types(components=self.get_multi_bit_components(),
+                                            multi_bit=True)
+
+    all_components = gate_comps + one_bit_comps + multi_bit_comps
+    return all_components
+
def get_declaration_blif(self) @@ -1148,6 +1454,21 @@

Returns

str
Flat Blif code containing declaration of circuit's wires.
+
+ +Expand source code + +
def get_declaration_blif(self):
+    """Generates flat Blif code declaration of input/output circuit wires.
+
+    Returns:
+        str: Flat Blif code containing declaration of circuit's wires.
+    """
+    return f".inputs {''.join([w.get_wire_declaration_blif() for w in self.inputs])}\n" + \
+           f".outputs{self.out.get_wire_declaration_blif()}\n" + \
+           f".names vdd\n1\n" + \
+           f".names gnd\n0\n"
+
def get_declaration_c_flat(self) @@ -1159,6 +1480,18 @@

Returns

str
Flat C code arithmetic circuit's wires declaration.
+
+ +Expand source code + +
def get_declaration_c_flat(self):
+    """Generates flat C code declaration of input/output circuit wires.
+
+    Returns:
+        str: Flat C code arithmetic circuit's wires declaration.
+    """
+    return f"".join([c.get_declaration_c_flat() for c in self.components])
+
def get_declaration_c_hier(self) @@ -1172,6 +1505,22 @@

Returns

str
Hierarchical C code of subcomponent arithmetic circuit's wires declaration.
+
+ +Expand source code + +
def get_declaration_c_hier(self):
+    """Generates hierarchical C code declaration of corresponding subcomponent input/output wires inside the upper component.
+
+    Generates wires used to connect input/output values to/from invocation of the corresponding function block into inner wires present
+    inside the upper component from which function block has been invoked.
+
+    Returns:
+        str: Hierarchical C code of subcomponent arithmetic circuit's wires declaration.
+    """
+    return "".join([f"  {self.c_data_type} {i.prefix} = 0;\n" for i in self.inputs if ((isinstance(i, Wire)) or (not all((w.is_const()) or (w.parent_bus is not None and w.prefix == i.prefix) for w in i.bus)))]) + \
+           f"  {self.c_data_type} {self.out.prefix} = 0;\n"
+
def get_declaration_v_flat(self) @@ -1183,6 +1532,18 @@

Returns

str
Flat Verilog code arithmetic circuit's wires declaration.
+
+ +Expand source code + +
def get_declaration_v_flat(self):
+    """Generates flat Verilog code declaration of input/output circuit wires.
+
+    Returns:
+        str: Flat Verilog code arithmetic circuit's wires declaration.
+    """
+    return f"".join([c.get_declaration_v_flat() for c in self.components])
+
def get_declaration_v_hier(self) @@ -1196,6 +1557,21 @@

Returns

str
Hierarchical Verilog code of subcomponent arithmetic circuit's wires declaration.
+
+ +Expand source code + +
def get_declaration_v_hier(self):
+    """Generates hierarchical Verilog code declaration of corresponding subcomponent input/output wires inside the upper component.
+
+    Generates wires used to connect input/output values to/from invocation of the corresponding function block into inner wires present
+    inside the upper component from which function block has been invoked.
+
+    Returns:
+        str: Hierarchical Verilog code of subcomponent arithmetic circuit's wires declaration.
+    """
+    return "".join(b.get_wire_declaration_v() for b in self.inputs + [self.out] if (b == self.out) or (not all((w.is_const()) or (w.parent_bus is not None and w.prefix == b.prefix) for w in b.bus)))
+
def get_declarations_c_hier(self) @@ -1207,6 +1583,18 @@

Returns

str
Hierarchical C code containing unique declaration of arithmetic circuit wires.
+
+ +Expand source code + +
def get_declarations_c_hier(self):
+    """Generates hierarchical C code declaration of input/output circuit wires.
+
+    Returns:
+        str: Hierarchical C code containing unique declaration of arithmetic circuit wires.
+    """
+    return "".join([c.get_declaration_c_hier() for c in self.components])
+
def get_declarations_v_hier(self) @@ -1218,6 +1606,18 @@

Returns

str
Hierarchical Verilog code containing unique declaration of arithmetic circuit wires.
+
+ +Expand source code + +
def get_declarations_v_hier(self):
+    """Generates hierarchical Verilog code declaration of input/output circuit wires.
+
+    Returns:
+        str: Hierarchical Verilog code containing unique declaration of arithmetic circuit wires.
+    """
+    return "".join([c.get_declaration_v_hier() for c in self.components])
+
def get_function_blif_flat(self) @@ -1229,6 +1629,18 @@

Returns

str
Flat Blif code containing invocation of inner subcomponents logic gates Boolean functions.
+
+ +Expand source code + +
def get_function_blif_flat(self):
+    """Generates flat Blif code with invocation of subcomponents logic gates functions via their corresponding truth tables.
+
+    Returns:
+        str: Flat Blif code containing invocation of inner subcomponents logic gates Boolean functions.
+    """
+    return "".join(c.get_function_blif_flat() for c in self.components)
+
def get_function_block_blif(self) @@ -1240,6 +1652,19 @@

Returns

str
Hierarchical Blif code of multi-bit arithmetic circuit's function block description.
+
+ +Expand source code + +
def get_function_block_blif(self):
+    """Generates hierarchical Blif code representation of corresponding multi-bit arithmetic circuit used as function block in hierarchical circuit description.
+
+    Returns:
+        str: Hierarchical Blif code of multi-bit arithmetic circuit's function block description.
+    """
+    # Obtain proper circuit name with its bit width
+    return f"{self.get_hier_subcomponent_def(parent_kwargs=self.kwargs).get_circuit_blif()}"
+
def get_function_block_c(self) @@ -1251,6 +1676,18 @@

Returns

str
Hierarchical C code of multi-bit arithmetic circuit's function block description.
+
+ +Expand source code + +
def get_function_block_c(self):
+    """Generates hierarchical C code representation of corresponding multi-bit arithmetic circuit used as function block in hierarchical circuit description.
+
+    Returns:
+        str: Hierarchical C code of multi-bit arithmetic circuit's function block description.
+    """
+    return f"{self.get_hier_subcomponent_def(parent_kwargs=self.kwargs).get_circuit_c()}\n\n"
+
def get_function_block_v(self) @@ -1262,6 +1699,19 @@

Returns

str
Hierarchical Verilog code of multi-bit arithmetic circuit's function block description.
+
+ +Expand source code + +
def get_function_block_v(self):
+    """Generates hierarchical Verilog code representation of corresponding multi-bit arithmetic circuit used as function block in hierarchical circuit description.
+
+    Returns:
+        str: Hierarchical Verilog code of multi-bit arithmetic circuit's function block description.
+    """
+    # Obtain proper circuit name with its bit width
+    return f"{self.get_hier_subcomponent_def(parent_kwargs=self.kwargs).get_circuit_v()}\n\n"
+
def get_function_blocks_blif(self) @@ -1273,6 +1723,21 @@

Returns

str
Hierarchical Blif code of all subcomponents function blocks description.
+
+ +Expand source code + +
def get_function_blocks_blif(self):
+    """Generates hierarchical Blif code representation of all subcomponents function blocks present in corresponding arithmetic circuit.
+
+    Returns:
+        str: Hierarchical Blif code of all subcomponents function blocks description.
+    """
+    # Retrieve all unique component types composing this circuit and add them kwargs from the parent circuit to allow propagatation of config settings for subcomponents
+    # (iterating backwards as opposed to other representations so the top modul is always above its subcomponents)
+    self.component_types = self.get_component_types()
+    return "\n".join([c.get_function_block_blif() for c in self.component_types[::-1]])
+
def get_function_blocks_c(self) @@ -1284,6 +1749,20 @@

Returns

str
Hierarchical C code of all subcomponents function blocks description.
+
+ +Expand source code + +
def get_function_blocks_c(self):
+    """Generates hierarchical C code representation of all subcomponents function blocks present in corresponding arithmetic circuit.
+
+    Returns:
+        str: Hierarchical C code of all subcomponents function blocks description.
+    """
+    # Retrieve all unique component types composing this circuit and add them kwargs from the parent circuit to allow propagatation of config settings for subcomponents
+    self.component_types = self.get_component_types()
+    return "".join([c.get_function_block_c() for c in self.component_types])
+
def get_function_blocks_v(self) @@ -1295,6 +1774,20 @@

Returns

str
Hierarchical Verilog code of all subcomponents function blocks description.
+
+ +Expand source code + +
def get_function_blocks_v(self):
+    """Generates hierarchical Verilog code representation of all subcomponents function blocks present in corresponding arithmetic circuit.
+
+    Returns:
+        str: Hierarchical Verilog code of all subcomponents function blocks description.
+    """
+    # Retrieve all unique component types composing this circuit and add them kwargs from the parent circuit to allow propagatation of config settings for subcomponents
+    self.component_types = self.get_component_types(verilog_output=True)
+    return "".join([c.get_function_block_v() for c in self.component_types])
+
def get_function_out_blif(self) @@ -1306,6 +1799,18 @@

Returns

str
Flat Blif code containing output bus wires assignment.
+
+ +Expand source code + +
def get_function_out_blif(self):
+    """Generates flat Blif code assignment of corresponding arithmetic circuit's output bus wires.
+
+    Returns:
+        str: Flat Blif code containing output bus wires assignment.
+    """
+    return f"{self.out.get_wire_assign_blif(output=True)}"
+
def get_function_out_c_flat(self) @@ -1317,6 +1822,18 @@

Returns

str
Flat C code containing output bus wires assignment.
+
+ +Expand source code + +
def get_function_out_c_flat(self):
+    """Generates flat C code assignment of corresponding arithmetic circuit's output bus wires.
+
+    Returns:
+        str: Flat C code containing output bus wires assignment.
+    """
+    return self.out.return_bus_wires_values_c_flat()
+
def get_function_out_c_hier(self) @@ -1328,6 +1845,18 @@

Returns

str
Hierarchical C code containing output bus wires assignment.
+
+ +Expand source code + +
def get_function_out_c_hier(self):
+    """Generates hierarchical C code assignment of corresponding arithmetic circuit's output bus wires.
+
+    Returns:
+        str: Hierarchical C code containing output bus wires assignment.
+    """
+    return self.out.return_bus_wires_values_c_hier()
+
def get_function_out_python_flat(self) @@ -1339,6 +1868,18 @@

Returns

str
Flat Python code containing output bus wires assignment.
+
+ +Expand source code + +
def get_function_out_python_flat(self):
+    """Generates flat Python code assignment of corresponding arithmetic circuit's output bus wires.
+
+    Returns:
+        str: Flat Python code containing output bus wires assignment.
+    """
+    return self.out.return_bus_wires_values_python_flat()
+
def get_function_out_v_flat(self) @@ -1350,6 +1891,18 @@

Returns

str
Flat Verilog code containing output bus wires assignment.
+
+ +Expand source code + +
def get_function_out_v_flat(self):
+    """Generates flat Verilog code assignment of corresponding arithmetic circuit's output bus wires.
+
+    Returns:
+        str: Flat Verilog code containing output bus wires assignment.
+    """
+    return self.out.return_bus_wires_values_v_flat()
+
def get_function_out_v_hier(self) @@ -1361,6 +1914,18 @@

Returns

str
Hierarchical Verilog code containing output bus wires assignment.
+
+ +Expand source code + +
def get_function_out_v_hier(self):
+    """Generates hierarchical Verilog code assignment of corresponding arithmetic circuit's output bus wires.
+
+    Returns:
+        str: Hierarchical Verilog code containing output bus wires assignment.
+    """
+    return self.out.return_bus_wires_values_v_hier()
+
def get_hier_subcomponent_def(self, parent_kwargs: dict = {}) @@ -1377,6 +1942,44 @@

Returns

GeneralCircuit
A new instance of the current circuit block with proper prefix and input wires.
+
+ +Expand source code + +
def get_hier_subcomponent_def(self, parent_kwargs: dict = {}):
+    """ Creates and returns a new instance of the current circuit block used for definition of a subcomponent in a hierarchical circuit.
+
+    Args:
+        parent_kwargs (dict): Dictionary containing all the configuration settings of the parent circuit block.
+
+    Returns:
+        GeneralCircuit: A new instance of the current circuit block with proper prefix and input wires.
+    """
+    # Obtain proper circuit name with its input bit widths
+    init_signature = inspect.signature(self.__class__.__init__)
+    init_params = list(init_signature.parameters.keys())
+    default_circuit_name = init_signature.parameters['name'].default
+    circuit_type = default_circuit_name + "x".join(str(getattr(self, chr(97+i)).N) for i, _ in enumerate(self.inputs))
+    # Initialize and fill args for the new instance based on the current instance
+    init_args = {}
+
+    for param in init_params[1:]:  # Skip 'self'
+        attr = getattr(self, param, None)  # Get the attribute from the current instance
+
+        if attr is not None:  # If attribute does not exist, it will use default value from the signature
+            if isinstance(attr, Bus):  # If the input is a Bus, create a copy of the Bus object with same length, but proper prefix
+                init_args[param] = Bus(N=attr.N, prefix=param)
+            elif isinstance(attr, Wire):  # If the input is a Wire, create a copy of the Wire object with proper prefix
+                init_args[param] = Wire(name=param)
+            else:  # Copy other types of attributes
+                init_args[param] = copy.deepcopy(attr)
+
+    init_args['name'] = circuit_type
+    init_args['prefix'] = ""
+
+    circuit_block = self.__class__(**init_args, **parent_kwargs)
+    return circuit_block
+
def get_init_c_flat(self) @@ -1388,6 +1991,18 @@

Returns

str
Flat C code initialization of arithmetic circuit wires.
+
+ +Expand source code + +
def get_init_c_flat(self):
+    """Generates flat C code initialization and assignment of corresponding arithmetic circuit's input/output wires.
+
+    Returns:
+        str: Flat C code initialization of arithmetic circuit wires.
+    """
+    return "".join([c.get_assign_c_flat() if isinstance(c, TwoInputLogicGate) else c.get_init_c_flat() for c in self.components])
+
def get_init_c_hier(self) @@ -1399,6 +2014,18 @@

Returns

str
Hierarchical C code initialization of arithmetic circuit wires.
+
+ +Expand source code + +
def get_init_c_hier(self):
+    """Generates hierarchical C code initialization and assignment of corresponding arithmetic circuit's input/output wires.
+
+    Returns:
+        str: Hierarchical C code initialization of arithmetic circuit wires.
+    """
+    return "".join([c.get_gate_invocation_c() if isinstance(c, TwoInputLogicGate) else c.get_out_invocation_c() for c in self.components])
+
def get_init_python_flat(self) @@ -1410,6 +2037,18 @@

Returns

str
Flat Python code initialization of arithmetic circuit wires.
+
+ +Expand source code + +
def get_init_python_flat(self):
+    """Generates flat Python code initialization and assignment of corresponding arithmetic circuit's input/output wires.
+
+    Returns:
+        str: Flat Python code initialization of arithmetic circuit wires.
+    """
+    return "".join([c.get_assign_python_flat() if isinstance(c, TwoInputLogicGate) else c.get_init_python_flat() for c in self.components])
+
def get_init_v_flat(self) @@ -1421,6 +2060,18 @@

Returns

str
Flat Verilog code initialization of arithmetic circuit wires.
+
+ +Expand source code + +
def get_init_v_flat(self):
+    """Generates flat Verilog code initialization and assignment of corresponding arithmetic circuit's input/output buses wires.
+
+    Returns:
+        str: Flat Verilog code initialization of arithmetic circuit wires.
+    """
+    return "".join([c.get_assign_v_flat() if isinstance(c, TwoInputLogicGate) else c.get_init_v_flat() for c in self.components])
+
def get_init_v_hier(self) @@ -1432,6 +2083,18 @@

Returns

str
Hierarchical Verilog code initialization of arithmetic circuit wires.
+
+ +Expand source code + +
def get_init_v_hier(self):
+    """Generates hierarchical Verilog code initialization and assignment of corresponding arithmetic circuit's input/output wires.
+
+    Returns:
+        str: Hierarchical Verilog code initialization of arithmetic circuit wires.
+    """
+    return "".join([c.get_gate_invocation_v() if isinstance(c, TwoInputLogicGate) else c.get_out_invocation_v() for c in self.components])
+
def get_instance_num(self, cls, count_disabled_gates: bool = True) @@ -1450,6 +2113,24 @@

Returns

int
Number of instances of the same class type.
+
+ +Expand source code + +
def get_instance_num(self, cls, count_disabled_gates: bool = True):
+    """Informs how many instances of the same type are already present inside circuit's components list.
+
+    Args:
+        cls (type): Class type for which to count the number of instances in the components list.
+        count_disabled_gates (bool, optional): Indicates whether logic gates that aren't generated should be also counted. Defaults to True.
+    Returns:
+        int: Number of instances of the same class type.
+    """
+    if issubclass(cls, TwoInputLogicGate) and count_disabled_gates is False:
+        return sum(isinstance(c, cls) for c in self.components if isinstance(c, cls) and c.disable_generation is False)
+    else:
+        return sum(isinstance(c, cls) for c in self.components)
+
def get_invocation_blif_hier(self) @@ -1462,6 +2143,41 @@

Returns

str
Hierarchical Blif code of subcomponent's model invocation and output assignment.
+
+ +Expand source code + +
def get_invocation_blif_hier(self):
+    """Generates hierarchical Blif code invocation of corresponding arithmetic circuit's generated function block.
+
+    Used for multi-bit subcomponent's modul invocation.
+
+    Returns:
+        str: Hierarchical Blif code of subcomponent's model invocation and output assignment.
+    """
+    # Getting name of circuit type for proper Blif code generation without affecting actual generated composition
+    init_signature = inspect.signature(self.__class__.__init__)
+    default_circuit_name = init_signature.parameters['name'].default
+    circuit_type = default_circuit_name + "x".join(str(getattr(self, chr(97+i)).N) for i, _ in enumerate(self.inputs))
+    if self.out.N > 1:
+        return "".join([w.get_wire_assign_blif(output=True) for w in self.inputs]) + \
+               f".subckt {circuit_type}" + \
+               "".join([f" {chr(97+i)}[{b.bus.index(w)}]={b.prefix}[{b.bus.index(w)}]" if b.N > 1 else f" {chr(97+i)}={b.prefix}" for i, b in enumerate(self.inputs) for w in b.bus]) + \
+               "".join([f" {circuit_type}_out[{self.out.bus.index(o)}]={o.name}" for o in self.out.bus if not o.is_const()]) + "\n"
+    else:
+        return "".join([w.get_wire_assign_blif(output=True) for w in self.inputs]) + \
+               f".subckt {circuit_type}" + \
+               "".join([f" {chr(97+i)}[{b.bus.index(w)}]={b.prefix}[{b.bus.index(w)}]" if b.N > 1 else f" {chr(97+i)}={b.prefix}" for i, b in enumerate(self.inputs) for w in b.bus]) + \
+               "".join([f" {circuit_type}_out={o.name}" for o in self.out.bus if not o.is_const()]) + "\n"
+        
+    # TODO delete
+    return f"{self.a.get_wire_assign_blif(output=True)}" + \
+           f"{self.b.get_wire_assign_blif(output=True)}" + \
+           f".subckt {circuit_type}" + \
+           "".join([f" a[{self.a.bus.index(w)}]={self.a.prefix}[{self.a.bus.index(w)}]" for w in self.a.bus]) + \
+           "".join([f" b[{self.b.bus.index(w)}]={self.b.prefix}[{self.b.bus.index(w)}]" for w in self.b.bus]) + \
+           "".join([f" {circuit_type}_out[{self.out.bus.index(o)}]={o.name}" for o in self.out.bus]) + "\n"
+
def get_invocations_blif_hier(self) @@ -1473,6 +2189,18 @@

Returns

str
Hierarchical Blif code containing invocations of inner subcomponents function blocks.
+
+ +Expand source code + +
def get_invocations_blif_hier(self):
+    """Generates hierarchical Blif code with invocations of subcomponents function blocks.
+
+    Returns:
+        str: Hierarchical Blif code containing invocations of inner subcomponents function blocks.
+    """
+    return "".join(c.get_invocation_blif_hier() for c in self.components)
+
def get_multi_bit_components(self) @@ -1484,6 +2212,27 @@

Returns

list
List of composite multi bit circuits.
+
+ +Expand source code + +
def get_multi_bit_components(self):
+    """Retrieves a list of all the multi bit circuits present as subcomponents inside the circuit.
+
+    Returns:
+        list: List of composite multi bit circuits.
+    """
+    multi_bit_comps = []
+    for c in self.components:
+        if isinstance(c, TwoInputLogicGate):
+            continue
+        elif all(isinstance(i, Wire) for i in self.inputs):
+            continue
+        else:
+            multi_bit_comps.append(c)
+            multi_bit_comps.extend(c.get_multi_bit_components())
+    return multi_bit_comps
+
def get_one_bit_components(self) @@ -1495,6 +2244,27 @@

Returns

list
List of composite one bit circuits.
+
+ +Expand source code + +
def get_one_bit_components(self):
+    """Retrieves a list of all the one bit circuits (besides logic gates) present as subcomponents inside the circuit.
+
+    Returns:
+        list: List of composite one bit circuits.
+    """
+    one_bit_comps = []
+    for c in self.components:
+        if isinstance(c, TwoInputLogicGate):
+            continue
+        elif all(isinstance(i, Wire) for i in self.inputs):
+            one_bit_comps.append(c)
+        else:
+            one_bit_comps.extend(c.get_one_bit_components())
+
+    return one_bit_comps
+
def get_out_invocation_c(self) @@ -1509,6 +2279,28 @@

Returns

str
Hierarchical C code of subcomponent's C function invocation and output assignment.
+
+ +Expand source code + +
def get_out_invocation_c(self):
+    """Generates hierarchical C code invocation of corresponding arithmetic circuit's generated function block.
+
+    Assigns input values from other subcomponents into multi-bit input buses used as inputs for function block invocation.
+    Assigns output values from invocation of the corresponding function block into inner wires present inside
+    the upper component from which function block has been invoked.
+
+    Returns:
+        str: Hierarchical C code of subcomponent's C function invocation and output assignment.
+    """
+    # Getting name of circuit type for proper C code generation without affecting actual generated composition
+    init_signature = inspect.signature(self.__class__.__init__)
+    default_circuit_name = init_signature.parameters['name'].default
+    circuit_type = default_circuit_name + "x".join(str(getattr(self, chr(97+i)).N) for i, _ in enumerate(self.inputs))
+    # TODO .. now only works for input buses
+    return "".join(w.return_bus_wires_values_c_hier() for w in self.inputs) + \
+           f"  {self.out.prefix} = {circuit_type}({', '.join(w.prefix if isinstance(w, Bus) else w.get_wire_value_c_hier() for w in self.inputs)});\n"
+
def get_out_invocation_v(self) @@ -1523,6 +2315,29 @@

Returns

str
Hierarchical Verilog code of subcomponent's module invocation and output assignment.
+
+ +Expand source code + +
def get_out_invocation_v(self):
+    """Generates hierarchical Verilog code invocation of corresponding arithmetic circuit's generated function block.
+
+    Assigns input values from other subcomponents into multi-bit input buses used as inputs for function block invocation.
+    Assigns output values from invocation of the corresponding function block into inner wires present inside
+    the upper component from which function block has been invoked.
+
+    Returns:
+        str: Hierarchical Verilog code of subcomponent's module invocation and output assignment.
+    """
+    # Getting name of circuit type and insitu copying out bus for proper Verilog code generation without affecting actual generated composition
+    init_signature = inspect.signature(self.__class__.__init__)
+    default_circuit_name = init_signature.parameters['name'].default
+    circuit_type = default_circuit_name + "x".join(str(getattr(self, chr(97+i)).N) for i, _ in enumerate(self.inputs))
+    circuit_block = self.get_hier_subcomponent_def(parent_kwargs=self.kwargs)
+    # TODO .. now only works for input buses
+    return "".join([c.return_bus_wires_values_v_hier() for c in self.inputs]) + \
+           f"  {circuit_type} {circuit_type}_{self.out.prefix}(" + ",".join([f".{a.prefix}({b.prefix})" for a, b in zip(circuit_block.inputs, self.inputs)]) + f", .{circuit_block.out.prefix}({self.out.prefix}));\n"
+
def get_outputs_cgp(self) @@ -1534,6 +2349,18 @@

Returns

str
List of arithmetic circuit's output wire indexes.
+
+ +Expand source code + +
def get_outputs_cgp(self):
+    """Generates list of output wires indexes of described arithmetic circuit from MSB to LSB.
+
+    Returns:
+        str: List of arithmetic circuit's output wire indexes.
+    """
+    return "(" + ",".join([str(self.get_circuit_wire_index(o)) for o in self.out.bus]) + ")"
+
def get_parameters_cgp(self) @@ -1547,6 +2374,22 @@

Returns

str
CGP chromosome parameters of described arithmetic circuit.
+
+ +Expand source code + +
def get_parameters_cgp(self):
+    """Generates CGP chromosome parameters of corresponding arithmetic circuit.
+
+    In total seven parameters represent: total inputs, total outputs, number of rows, number of columns (gates),
+    number of each gate's inputs, number of each gate's outputs, quality constant value.
+
+    Returns:
+        str: CGP chromosome parameters of described arithmetic circuit.
+    """
+    # self.circuit_gates = self.get_circuit_gates() TODO delete
+    return f"{{{sum(input_bus.N for input_bus in self.inputs)},{self.out.N},1,{len(self.circuit_gates)},2,1,0}}"
+
def get_previous_component(self, number: int = 1) @@ -1563,6 +2406,21 @@

Returns

component
Desired previously added composite component.
+
+ +Expand source code + +
def get_previous_component(self, number: int = 1):
+    """Retrieves previously added composite subcomponent from circuit's list of components.
+
+    Args:
+        number (int, optional): Offset indicating which lastly added component will be retrieved. Defaults to 1.
+
+    Returns:
+        component: Desired previously added composite component.
+    """
+    return self.components[-number]
+
def get_prototype_blif(self) @@ -1574,6 +2432,18 @@

Returns

str
Model's name in Blif code.
+
+ +Expand source code + +
def get_prototype_blif(self):
+    """Generates Blif code model name of described arithmetic circuit.
+
+    Returns:
+        str: Model's name in Blif code.
+    """
+    return f".model {self.prefix}\n"
+
def get_prototype_c(self) @@ -1585,6 +2455,18 @@

Returns

str
Function's name and parameters in C code.
+
+ +Expand source code + +
def get_prototype_c(self):
+    """Generates C code function header to describe corresponding arithmetic circuit's interface in C code.
+
+    Returns:
+        str: Function's name and parameters in C code.
+    """
+    return f"{self.c_data_type} {self.prefix}(" + ",".join([f"{self.c_data_type} {x.prefix}" for x in self.inputs]) + ")" + "{" + "\n"
+
def get_prototype_python(self) @@ -1596,6 +2478,18 @@

Returns

str
Function's name and parameters in Python code.
+
+ +Expand source code + +
def get_prototype_python(self):
+    """Generates Python code function header to describe corresponding arithmetic circuit's interface in Python code.
+
+    Returns:
+        str: Function's name and parameters in Python code.
+    """
+    return f"def {self.prefix}(" + ", ".join([f"{x.prefix}" for x in self.inputs]) + ")" + ":" + "\n"
+
def get_prototype_v(self) @@ -1607,6 +2501,18 @@

Returns

str
Module's name and parameters in Verilog code.
+
+ +Expand source code + +
def get_prototype_v(self):
+    """Generates Verilog code module header to describe corresponding arithmetic circuit's interface in Verilog code.
+
+    Returns:
+        str: Module's name and parameters in Verilog code.
+    """
+    return f"module {self.prefix}(" + ", ".join(f"input [{x.N-1}:0] {x.prefix}" for x in self.inputs) + f", output [{self.out.N-1}:0] {self.out.prefix});\n"
+
def get_python_code_flat(self, file_object, retype=True) @@ -1619,6 +2525,23 @@

Args

Destination file object where circuit's representation will be written to.

retype (bool) specifies if signed output should return int64_t

+
+ +Expand source code + +
def get_python_code_flat(self, file_object, retype=True):
+    """Generates flat Python code representation of corresponding arithmetic circuit.
+
+    Args:
+        file_object (TextIOWrapper): Destination file object where circuit's representation will be written to.
+        retype (bool) specifies if signed output should return int64_t
+    """
+    file_object.write(self.get_prototype_python())
+    file_object.write(self.get_init_python_flat()+"\n")
+    file_object.write(self.get_function_out_python_flat())
+    file_object.write(self.out.return_bus_wires_sign_extend_python_flat(retype=True))
+    file_object.write(f"  return {self.out.prefix}"+"\n")
+
def get_triplets_cgp(self) @@ -1635,6 +2558,27 @@

Returns

str
List of triplets each describing logic function of corresponding two input logic gate and as a whole describe the arithmetic circuit.
+
+ +Expand source code + +
def get_triplets_cgp(self):
+    """Generates list of logic gate triplets (first input wire, second input wire, logic gate function) using wires unique position indexes within the described circuit.
+
+    Each triplet represents unique logic gate within the described arithmetic circuit. Besides the contained input wires indexes and gate's inner logic function, an output wire
+    with incremented index position is also created and remembered to be appropriately driven as an input to another logic gate or as the circuit's output.
+
+    Constant wire with value 0 has constant index of 0.
+    Constant wire with value 1 has constant index of 1.
+    Other wires indexes start counting from 2 and up.
+
+    Returns:
+        str: List of triplets each describing logic function of corresponding two input logic gate and as a whole describe the arithmetic circuit.
+    """
+    self.get_circuit_wires()
+    return "".join([g.get_triplet_cgp(a_id=self.get_circuit_wire_index(g.a), out_id=self.get_circuit_wire_index(g.out)) if isinstance(g, OneInputLogicGate) else
+                   g.get_triplet_cgp(a_id=self.get_circuit_wire_index(g.a), b_id=self.get_circuit_wire_index(g.b), out_id=self.get_circuit_wire_index(g.out)) for g in self.circuit_gates])
+
def get_v_code_flat(self, file_object) @@ -1646,6 +2590,22 @@

Args

file_object : TextIOWrapper
Destination file object where circuit's representation will be written to.
+
+ +Expand source code + +
def get_v_code_flat(self, file_object):
+    """Generates flat Verilog code representation of corresponding arithmetic circuit.
+
+    Args:
+        file_object (TextIOWrapper): Destination file object where circuit's representation will be written to.
+    """
+    file_object.write(self.get_prototype_v())
+    file_object.write(self.get_declaration_v_flat()+"\n")
+    file_object.write(self.get_init_v_flat() + "\n")
+    file_object.write(self.get_function_out_v_flat())
+    file_object.write(f"endmodule")
+
def get_v_code_hier(self, file_object) @@ -1657,9 +2617,22 @@

Args

file_object : TextIOWrapper
Destination file object where circuit's representation will be written to.
+
+ +Expand source code + +
def get_v_code_hier(self, file_object):
+    """Generates hierarchical Verilog code representation of corresponding arithmetic circuit.
+
+    Args:
+        file_object (TextIOWrapper): Destination file object where circuit's representation will be written to.
+    """
+    file_object.write(self.get_function_blocks_v())
+    file_object.write(self.get_circuit_v())
+
-def save_wire_id(self, wire: Wire) +def save_wire_id(self,
wire: Wire)

Returns appropriate wire index position within the circuit.

@@ -1676,6 +2649,30 @@

Returns

int
Wire's index position within circuit.
+
+ +Expand source code + +
def save_wire_id(self, wire: Wire):
+    """Returns appropriate wire index position within the circuit.
+
+    Constant wire with value 0 has constant index of 0.
+    Constant wire with value 1 has constant index of 1.
+    Other wires indexes start counting from 2 and up.
+
+    Args:
+        wire (Wire): Wire that will be stored at this circuit index position.
+
+    Returns:
+        int: Wire's index position within circuit.
+    """
+    if wire.is_const():
+        return wire.cgp_const
+    else:
+        # [1] is reservation for a constant wire with value 1
+        pos = max([1] + [x[2] for x in self.circuit_wires])
+        return pos + 1
+
@@ -1766,7 +2763,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/core/arithmetic_circuits/index.html b/core/arithmetic_circuits/index.html index 6d3544b..d52f34d 100644 --- a/core/arithmetic_circuits/index.html +++ b/core/arithmetic_circuits/index.html @@ -3,13 +3,13 @@ - + ariths_gen.core.arithmetic_circuits API documentation - + @@ -66,7 +66,7 @@

Sub-modules

diff --git a/core/arithmetic_circuits/multiplier_circuit.html b/core/arithmetic_circuits/multiplier_circuit.html index cdf8f6b..f94fe8f 100644 --- a/core/arithmetic_circuits/multiplier_circuit.html +++ b/core/arithmetic_circuits/multiplier_circuit.html @@ -3,13 +3,13 @@ - + ariths_gen.core.arithmetic_circuits.multiplier_circuit API documentation - + @@ -37,7 +37,7 @@

Classes

class MultiplierCircuit -(prefix: str, name: str, out_N: int, inner_component: bool = False, inputs: list = [], one_bit_circuit: bool = False, signed: bool = False, outname: str = '', **kwargs) +(prefix: str,
name: str,
out_N: int,
inner_component: bool = False,
inputs: list = [],
one_bit_circuit: bool = False,
signed: bool = False,
outname: str = '',
**kwargs)

Class represents a general multiplier circuit derived from GeneralCircuit class.

@@ -366,6 +366,37 @@

Returns

int, int
Current algorithms stage and maximum bits (height) allowed in a column for current stage.
+
+ +Expand source code + +
@staticmethod
+def get_maximum_height(initial_value: int):
+    """Used in dadda multipliers to get multiplier's maximum height.
+
+    Maximum height sequence as defined here: https://en.wikipedia.org/wiki/Dadda_multiplier
+    d(j=1) = 2; d(j+1) = floor(1.5*d)
+
+    `j` stands for initial stage value
+    `d` stands for maximum height for current initial stage value
+
+    Args:
+        initial_value (int): Initial algorithms stage value.
+
+    Returns:
+        int, int: Current algorithms stage and maximum bits (height) allowed in a column for current stage.
+    """
+    stage = 0
+    d = 2
+    while True:
+        stage += 1
+        max_height = d
+        # Calculating maximum height sequence
+        # d(j=1) = 2; d(j+1) = floor(1.5*d)
+        d = math.floor(1.5*d)
+        if d >= initial_value:
+            return stage, max_height
+

Methods

@@ -389,6 +420,31 @@

Returns

Wire
Return Wire present at specified position.
+
+ +Expand source code + +
def add_column_wire(self, column: int, bit: int):
+    """Retrieves wire from desired partial product column bit position.
+
+    If bit pair (AND/NAND gate) is present at the desired position, it is reduced and replaced with AND/NAND gate output wire accordingly.
+    Either former logic gate's output wire or present wire is returned.
+
+    Args:
+        column (int): Partial product column index.
+        bit (int): Bit position within the chosen column.
+
+    Returns:
+        Wire: Return Wire present at specified position.
+    """
+    # Checks if a logic gate is present at desired column bit position. If so the gate is added to circuit's list of subcomponents,
+    # and the former logic gates's output bit replaces the gate at desired column bit position. This output wire is also returned to the caller.
+    if isinstance(self.columns[column][bit+1], AndGate) or isinstance(self.columns[column][bit+1], NandGate):
+        self.add_component(self.columns[column][bit+1])
+        return self.get_previous_component(1).out
+    else:
+        return self.columns[column][bit+1]
+
def add_column_wires(self, column: list, column_index: int) @@ -407,6 +463,48 @@

Returns

list
Updated column list containing corresponding number of input bit pairs to form proper pp column.
+
+ +Expand source code + +
def add_column_wires(self, column: list, column_index: int):
+    """Fills circuit's partial product column with corresponding bit pairs.
+
+    Args:
+        column (list): List representing column of partial product bits.
+        column_index (int): Index of partial products column.
+
+    Returns:
+        list: Updated column list containing corresponding number of input bit pairs to form proper pp column.
+    """
+    # Adding neccessary number of lists (based on number of bits in the column – stored in `column[0]`)
+    # to column that each represent individual bit pairs for described column (these bit pairs are then combined in AND/NAND gates)
+    [column.append([]) for _ in range(column[0])]
+    # Filling column bit pair lists with appropriate bits
+    if column_index <= self.N-1:
+        [column[column[0]-index].append(self.a.get_wire(index)) for index in range(0, column[0])]
+        [column[index+1].append(self.b.get_wire(index)) for index in range(0, column[0])]
+    else:
+        [column[self.a.N-index].append(self.a.get_wire(index)) for index in range(self.a.N-1, self.a.N-column[0]-1, -1)]
+        [column[index-(self.a.N-1-column[0])].append(self.b.get_wire(index)) for index in range(self.a.N-column[0], self.a.N)]
+
+    # Converting unsigned column pp bit pair lists into AND gates
+    if self.signed is False:
+        column[1:] = [AndGate(a=column[i][0], b=column[i][1], prefix=self.prefix+'_and_'+str(column[i][0].index)+'_'+str(column[i][1].index), parent_component=self) for i in range(1, len(column))]
+    # Converting signed column pp bit pair lists into AND/NAND gates (based on Baugh-Wooley multiplication algorithm)
+    else:
+        # First half of partial product columns contains only AND gates
+        if column_index < self.N-1 or column_index == self.out.N-2:
+            column[1:] = [AndGate(a=column[i][0], b=column[i][1], prefix=self.prefix+'_and_'+str(column[i][0].index)+'_'+str(column[i][1].index), parent_component=self) for i in range(1, len(column))]
+        # Second half of partial product columns contains NAND/AND gates
+        else:
+            column[1] = NandGate(a=column[1][0], b=column[1][1], prefix=self.prefix+'_nand_'+str(column[1][0].index)+'_'+str(column[1][1].index), parent_component=self)
+            column[-1] = NandGate(a=column[-1][0], b=column[-1][1], prefix=self.prefix+'_nand_'+str(column[-1][0].index)+'_'+str(column[-1][1].index), parent_component=self)
+            if len(column[2:-1]) != 0:
+                column[2:-1] = [AndGate(a=column[i][0], b=column[i][1], prefix=self.prefix+'_and_'+str(column[i][0].index)+'_'+str(column[i][1].index), parent_component=self) for i in range(2, len(column)-1)]
+
+    return column
+
def add_row_wires(self, row: list, row_index: int) @@ -425,6 +523,49 @@

Returns

list
Updated row list containing corresponding number of input bit pairs to form proper pp row.
+
+ +Expand source code + +
def add_row_wires(self, row: list, row_index: int):
+    """Fills circuit's partial product row with corresponding bit pairs.
+
+    Args:
+        row (list): List representing row of partial product bits.
+        row_index (int): Index of partial products row.
+
+    Returns:
+        list: Updated row list containing corresponding number of input bit pairs to form proper pp row.
+    """
+    # Number of partial products present in the row (should be equal to circuit's input bus size)
+    row_pp_count = self.N
+    # Adding neccessary number of lists (based on number of bits in the row – stored in `row_pp_count`)
+    # to row that each represent individual bit pairs for described row (these bit pairs are then combined in AND/NAND gates)
+    [row.append([]) for _ in range(row_pp_count)]
+
+    # Filling row bit pair lists with appropriate bits
+    [row[index].append(self.a.get_wire(index)) for index in range(row_pp_count)]
+    [row[index].append(self.b.get_wire(row_index)) for index in range(row_pp_count)]
+
+    # Converting unsigned rows of pp bit pair lists into AND gates
+    if self.signed is False:
+        row[0:] = [self.add_component(AndGate(a=row[i][0], b=row[i][1], prefix=self.prefix+'_and_'+str(row[i][0].index)+'_'+str(row[i][1].index), parent_component=self)).out for i in range(row_pp_count)]
+    # Converting signed rows of pp bit pair lists into AND/NAND gates (based on Baugh-Wooley multiplication algorithm)
+    else:
+        # Partial product bit pairs of all rows (expect for the last one) are connected to AND gates, besides the last pp bit pair in each row that is connected to a NAND gate
+        if row_index != self.N-1:
+            row[0:row_pp_count-1] = [self.add_component(AndGate(a=row[i][0], b=row[i][1], prefix=self.prefix+'_and_'+str(row[i][0].index)+'_'+str(row[i][1].index), parent_component=self)).out for i in range(row_pp_count-1)]
+
+            row[row_pp_count-1] = self.add_component(NandGate(a=row[row_pp_count-1][0], b=row[row_pp_count-1][1], prefix=self.prefix+'_nand_'+str(row[row_pp_count-1][0].index)+'_'+str(row[row_pp_count-1][1].index), parent_component=self)).out
+        # Partial product bit pairs of the last row are connected to NAND gates besides the last pp pair that is connected to an AND gate
+        else:
+            row[0:row_pp_count-1] = [self.add_component(NandGate(a=row[i][0], b=row[i][1], prefix=self.prefix+'_nand_'+str(row[i][0].index)+'_'+str(row[i][1].index), parent_component=self)).out for i in range(row_pp_count-1)]
+
+            row[row_pp_count-1] = self.add_component(AndGate(a=row[row_pp_count-1][0], b=row[row_pp_count-1][1], prefix=self.prefix+'_and_'+str(row[row_pp_count-1][0].index)+'_'+str(row[row_pp_count-1][1].index), parent_component=self)).out
+
+    pp_row_wires = Bus(prefix=f"pp_row{row_index}", wires_list=row)
+    return pp_row_wires
+
def get_column_height(self, column_num: int) @@ -441,6 +582,21 @@

Returns

int
Height of the current bit column.
+
+ +Expand source code + +
def get_column_height(self, column_num: int):
+    """Retrieves the current height of desired partial products column.
+
+    Args:
+        column_num (int): Index of pp column.
+
+    Returns:
+        int: Height of the current bit column.
+    """
+    return self.columns[column_num][0]
+
def get_column_wire(self, column: int, bit: int) @@ -461,6 +617,29 @@

Returns

Wire
Return Wire present at specified position.
+
+ +Expand source code + +
def get_column_wire(self, column: int, bit: int):
+    """Retrieves wire from desired partial product column bit position.
+
+    If bit pair (AND/NAND gate) is present at the desired position, AND/NAND gate output wire is returned,
+    if not the wire present at the desired position is returned.
+
+    Args:
+        column (int): Partial product column index.
+        bit (int): Bit position within the chosen column.
+
+    Returns:
+        Wire: Return Wire present at specified position.
+    """
+    # Checks if a logic gate is present at desired column bit position. If so, its output bit is returned.
+    if isinstance(self.columns[column][bit+1], AndGate) or isinstance(self.columns[column][bit+1], NandGate):
+        return self.columns[column][bit+1].out
+    else:
+        return self.columns[column][bit+1]
+
def get_previous_partial_product(self, a_index: int, b_index: int, mult_type='') @@ -481,6 +660,50 @@

Returns

Wire
Previous row's component wire of corresponding pp.
+
+ +Expand source code + +
def get_previous_partial_product(self, a_index: int, b_index: int, mult_type=""):
+    """Used in array and approximate multipliers to get previous row's component output wires for further connection to another component's input.
+
+    Args:
+        a_index (int): First input wire index.
+        b_index (int): Second input wire index.
+        mult_type (string, optional): Specifies what type of multiplier circuit has called this method. It is used for proper retrieval of index into the components list to allow appropriate interconnection of the multiplier circuit's inner subcomponents. It expects "" for ordinary multipliers, `bam` or `tm` for specific approximate multipliers. Defaults to "".
+
+    Returns:
+        Wire: Previous row's component wire of corresponding pp.
+    """
+    # To get the index of previous row's connecting adder and its generated pp
+    if mult_type == "bam":
+        # TODO alter to be more compact
+        ids_sum = 0
+        for row in range(self.horizontal_cut + self.ommited_rows, b_index):
+            first_row_elem_id = self.vertical_cut-row if self.vertical_cut-row > 0 else 0
+            # First pp row composed just from gates
+            if row == self.horizontal_cut + self.ommited_rows:
+                # Minus one because the first component has index 0 instead of 1
+                ids_sum += sum([1 for gate_pos in range(first_row_elem_id, self.N)])-1
+            elif row == b_index-1:
+                ids_sum += sum([2 for gate_adder_pos in range(first_row_elem_id, self.N) if gate_adder_pos <= a_index+1])
+            else:
+                ids_sum += sum([2 for gate_adder_pos in range(first_row_elem_id, self.N)])
+        # Index calculation should be redone, but it works even this way
+        index = ids_sum+2 if a_index == self.N-1 else ids_sum
+    elif mult_type == "tm":
+        index = ((b_index-self.truncation_cut-2) * ((self.N-self.truncation_cut)*2)) + ((self.N-self.truncation_cut-1)+2*(a_index-self.truncation_cut+2))
+    else:
+        index = ((b_index-2) * ((self.N)*2)) + ((self.N-1)+2*(a_index+2))
+
+    # Get carry wire as input for the last adder in current row
+    if a_index == self.N-1:
+        index = index-2
+        return self.components[index].get_carry_wire()
+    # Get sum wire as input for current adder
+    else:
+        return self.components[index].get_sum_wire()
+
def init_column_heights(self) @@ -492,6 +715,20 @@

Returns

list
List of partial product columns with their bit pairs.
+
+ +Expand source code + +
def init_column_heights(self):
+    """Creates appropriate number of partial product columns along with filling them with corresponding number of bit pairs.
+
+    Returns:
+        list: List of partial product columns with their bit pairs.
+    """
+    columns = [[num] if num <= self.N else [num - (num - self.N)*2] for num in range(1, self.out.N)]
+    columns = [self.add_column_wires(column=col, column_index=columns.index(col)) for col in columns]
+    return columns
+
def init_row_lengths(self) @@ -503,9 +740,23 @@

Returns

list
List of partial product rows with their bit pairs.
+
+ +Expand source code + +
def init_row_lengths(self):
+    """Creates appropriate number of partial product rows along with filling them with corresponding number of bit pairs.
+
+    Returns:
+        list: List of partial product rows with their bit pairs.
+    """
+    rows = [[] for _ in range(self.N)]
+    rows = [self.add_row_wires(row=row, row_index=rows.index(row)) for row in rows]
+    return rows
+
-def update_column_heights(self, curr_column: int, curr_height_change: int, next_column: int = 0, next_height_change: int = 0) +def update_column_heights(self,
curr_column: int,
curr_height_change: int,
next_column: int = 0,
next_height_change: int = 0)

Updates height of desired column and optionally also its subsequent column.

@@ -523,9 +774,30 @@

Args

next_height_change : int, optional
Height change for the chosen subsequent pp column. Defaults to 0.
+
+ +Expand source code + +
def update_column_heights(self, curr_column: int, curr_height_change: int, next_column: int = 0, next_height_change: int = 0):
+    """Updates height of desired column and optionally also its subsequent column.
+
+    Used within dadda and wallace multipliers to perform gradual reduction of partial product columns through the stages.
+    Allows to choose the height change to take effect on the chosen column index and optionally also the same for the following
+    column if it should also be affected.
+
+    Args:
+        curr_column (int): Current pp column index.
+        curr_height_change (int): Height change for the chosen current pp column.
+        next_column (int, optional): Subsequent pp column index. Defaults to 0.
+        next_height_change (int, optional): Height change for the chosen subsequent pp column. Defaults to 0.
+    """
+    self.columns[curr_column][0] = self.get_column_height(curr_column)+curr_height_change
+    if next_column-1 == curr_column:
+        self.columns[next_column][0] = self.get_column_height(next_column)+next_height_change
+
-def update_column_wires(self, curr_column: int, adder: GeneralCircuit, next_column: int = 0) +def update_column_wires(self,
curr_column: int,
adder: GeneralCircuit,
next_column: int = 0)

Provides bit height reduction of the chosen column.

@@ -540,6 +812,34 @@

Args

next_column : int, optional
Subsequent pp column index. Defaults to 0.
+
+ +Expand source code + +
def update_column_wires(self, curr_column: int, adder: GeneralCircuit, next_column: int = 0):
+    """Provides bit height reduction of the chosen column.
+
+    Inserts chosen column's top bits into an `adder` circuit to reduce its bit height.
+    Generated sum is stored to the bottom of the column and generated carry bit is stored to the top of the next column.
+
+    Args:
+        curr_column (int): Current pp column index.
+        adder (GeneralCircuit): Two/three input one bit adder.
+        next_column (int, optional): Subsequent pp column index. Defaults to 0.
+    """
+    if hasattr(adder, "c"):
+        self.columns[curr_column].pop(1)
+        self.columns[curr_column].pop(1)
+        self.columns[curr_column].pop(1)
+        self.columns[curr_column].insert(self.get_column_height(curr_column), adder.get_sum_wire())
+    else:
+        self.columns[curr_column].pop(1)
+        self.columns[curr_column].pop(1)
+        self.columns[curr_column].insert(self.get_column_height(curr_column), adder.get_sum_wire())
+
+    if next_column-1 == curr_column:
+        self.columns[next_column].insert(1, adder.get_carry_wire())
+

Inherited members

@@ -648,7 +948,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/core/cgp_circuit.html b/core/cgp_circuit.html index 6352e7d..084ec2e 100644 --- a/core/cgp_circuit.html +++ b/core/cgp_circuit.html @@ -3,13 +3,13 @@ - + ariths_gen.core.cgp_circuit API documentation - + @@ -37,7 +37,7 @@

Classes

class SignedCGPCircuit -(code: str, input_widths: list = None, inputs: list = None, prefix: str = '', name: str = 'cgp', **kwargs) +(code: str,
input_widths: list = None,
inputs: list = None,
prefix: str = '',
name: str = 'cgp',
**kwargs)

Signed circuit variant that loads CGP code and is able to export it to C/verilog/Blif/CGP.

@@ -127,7 +127,7 @@

Inherited members

class UnsignedCGPCircuit -(code: str = '', input_widths: list = None, inputs: list = None, prefix: str = '', name: str = 'cgp', **kwargs) +(code: str = '',
input_widths: list = None,
inputs: list = None,
prefix: str = '',
name: str = 'cgp',
**kwargs)

Unsigned circuit variant that loads CGP code and is able to export it to C/verilog/Blif/CGP.

@@ -276,6 +276,20 @@

Static methods

+
+ +Expand source code + +
@staticmethod
+def get_inputs_outputs(code: str):
+    cgp_prefix, cgp_core, cgp_outputs = re.match(
+        r"{(.*)}(.*)\(([^()]+)\)", code).groups()
+
+    c_in, c_out, c_rows, c_cols, c_ni, c_no, c_lback = map(
+        int, cgp_prefix.split(","))
+
+    return c_in, c_out
+

Inherited members

@@ -377,7 +391,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/core/index.html b/core/index.html index 4cd233f..4e4f7c2 100644 --- a/core/index.html +++ b/core/index.html @@ -3,13 +3,13 @@ - + ariths_gen.core API documentation - + @@ -76,7 +76,7 @@

Sub-modules

diff --git a/core/logic_gate_circuits/index.html b/core/logic_gate_circuits/index.html index 9426a35..c45ef03 100644 --- a/core/logic_gate_circuits/index.html +++ b/core/logic_gate_circuits/index.html @@ -3,13 +3,13 @@ - + ariths_gen.core.logic_gate_circuits API documentation - + @@ -61,7 +61,7 @@

Sub-modules

diff --git a/core/logic_gate_circuits/logic_gate_circuit.html b/core/logic_gate_circuits/logic_gate_circuit.html index 88b18c6..bdcd9f6 100644 --- a/core/logic_gate_circuits/logic_gate_circuit.html +++ b/core/logic_gate_circuits/logic_gate_circuit.html @@ -3,13 +3,13 @@ - + ariths_gen.core.logic_gate_circuits.logic_gate_circuit API documentation - + @@ -37,7 +37,7 @@

Classes

class MultipleInputLogicGate -(a: Bus, two_input_gate_cls, parent_component: object, prefix: str = '') +(a: Bus,
two_input_gate_cls,
parent_component: object,
prefix: str = '')

Class representing multiple input logic gate internally composed of corresponding two input logic gates.

@@ -122,7 +122,7 @@

Args

class OneInputLogicGate -(a: Wire, prefix: str = 'gate', outid: int = 0, parent_component: object = None) +(a: Wire,
prefix: str = 'gate',
outid: int = 0,
parent_component: object = None)

Class representing one input logic gates.

@@ -399,6 +399,22 @@

Returns

str
List containing logic gate's output wire indexes (one in this case).
+
+ +Expand source code + +
@staticmethod
+def get_output_cgp(out_id: int):
+    """Generates list of output wires indexes of described one input logic gate from MSB to LSB.
+
+    Args:
+        out_id (int): Output wire index position.
+
+    Returns:
+        str: List containing logic gate's output wire indexes (one in this case).
+    """
+    return f"({out_id})"
+

Methods

@@ -413,6 +429,22 @@

Returns

str
Blif logic gate's wires declaration.
+
+ +Expand source code + +
def get_declaration_blif(self):
+    """Generates Blif code declaration of one input logic gate's wires.
+
+    Returns:
+        str: Blif logic gate's wires declaration.
+    """
+    return f".inputs {self.a.get_wire_declaration_blif()}\n" + \
+           f".outputs" + \
+           "".join([f" {self.out.name}\n" if self.disable_generation is False else f" {self.out.name}_out\n" for _ in range(1)]) + \
+           f".names vdd\n1\n" + \
+           f".names gnd\n0\n"
+
def get_function_block_blif(self) @@ -424,6 +456,22 @@

Returns

str
Blif logic gate subcomponent description.
+
+ +Expand source code + +
def get_function_block_blif(self):
+    """Generates Blif code representation of corresponding one input logic gate used as subcomponent in hierarchical circuit description.
+
+    Returns:
+        str: Blif logic gate subcomponent description.
+    """
+    gate_block = type(self)(a=Wire(name="a"), prefix="out")
+    return f"{gate_block.get_prototype_blif_hier()}" + \
+           f"{gate_block.get_declaration_blif()}" + \
+           f"{gate_block.get_function_blif()}" + \
+           f".end\n"
+
def get_function_block_v(self) @@ -435,6 +483,21 @@

Returns

str
Verilog code of logic gate's function block description.
+
+ +Expand source code + +
def get_function_block_v(self):
+    """Generates Verilog code representation of corresponding logic gate used as a function block in hierarchical circuit description.
+
+    Returns:
+        str: Verilog code of logic gate's function block description.
+    """
+    gate_block = type(self)(a=Wire(name="a"), prefix="out")
+    return f"{gate_block.get_prototype_v_hier()}" + \
+           f"  assign {gate_block.out.name} = {gate_block.get_function_v()};\n" + \
+           f"endmodule\n\n"
+
def get_function_c(self) @@ -446,6 +509,18 @@

Returns

str
C code description of logic gate's Boolean function (with bitwise shifted input).
+
+ +Expand source code + +
def get_function_c(self):
+    """Generates C code representing corresponding one input logic gate's Boolean function using bitwise operators between its bitwise shifted input.
+
+    Returns:
+        str: C code description of logic gate's Boolean function (with bitwise shifted input).
+    """
+    return f"{self.operator}({self.a.get_wire_value_c_flat()}) & 0x01"
+
def get_function_v(self) @@ -457,6 +532,18 @@

Returns

str
Verilog description of logic gate's Boolean function.
+
+ +Expand source code + +
def get_function_v(self):
+    """Generates Verilog code representing corresponding one input logic gate's Boolean function using bitwise operators between its input.
+
+    Returns:
+        str: Verilog description of logic gate's Boolean function.
+    """
+    return f"{self.operator}{self.a.get_wire_value_v_flat()}"
+
def get_gate_triplet_cgp(self) @@ -468,6 +555,27 @@

Returns

str
Triplet and output lists describing function of corresponding one input logic gate.
+
+ +Expand source code + +
def get_gate_triplet_cgp(self):
+    """Generates flat CGP triplet and output representation of corresponding logic gate itself.
+
+    Returns:
+        str: Triplet and output lists describing function of corresponding one input logic gate.
+    """
+    if self.a.is_const():
+        a_id = self.a.cgp_const
+    else:
+        a_id = 2
+
+    if self.out.is_const():
+        out_id = self.out.cgp_const
+    else:
+        out_id = a_id+1 if a_id == 2 else 2
+    return self.get_triplet_cgp(a_id=a_id, out_id=out_id) + self.get_output_cgp(out_id=out_id)
+
def get_invocation_blif_hier(self, top_modul: bool = False, *args, **kwargs) @@ -484,6 +592,26 @@

Returns

str
Blif logic gate subcomponent invocation.
+
+ +Expand source code + +
def get_invocation_blif_hier(self, top_modul: bool = False, *args, **kwargs):
+    """Generates Blif code invocation of corresponding one input logic gate's generated subcomponent.
+
+    Args:
+        top_modul (bool, optional): Specifies whether the described circuit has logic gate as its top modul component (used for self logic gate generation). Defaults to False.
+
+    Returns:
+        str: Blif logic gate subcomponent invocation.
+    """
+    # No function block is generated if one of the inputs is a wire with constant value.
+    # I.e. either the constant or the second input wire is propagated to the output for the corresponding logic gate's logic function.
+    if self.disable_generation and top_modul is False:
+        return ""
+    else:
+        return f".subckt {self.gate_type} a={self.a.get_wire_value_blif()} out={self.out.get_wire_value_blif()}\n"
+
def get_prototype_c_flat(self) @@ -495,6 +623,18 @@

Returns

str
Function's name and parameter in flat C code.
+
+ +Expand source code + +
def get_prototype_c_flat(self):
+    """Generates flat C code function header to describe corresponding one input logic gate's interface in flat C code.
+
+    Returns:
+        str: Function's name and parameter in flat C code.
+    """
+    return f"uint8_t {self.prefix}(uint8_t {self.a.name})" + "{" + "\n"
+
def get_prototype_c_hier(self) @@ -506,6 +646,18 @@

Returns

str
Function's name and parameters in hierarchical C code.
+
+ +Expand source code + +
def get_prototype_c_hier(self):
+    """Generates hierarchical C code function header to describe corresponding one input logic gate's interface in hierarchical C code.
+
+    Returns:
+        str: Function's name and parameters in hierarchical C code.
+    """
+    return f"uint8_t {self.gate_type}(uint8_t {self.a.name})" + "{" + "\n"
+
def get_prototype_v_flat(self) @@ -517,6 +669,19 @@

Returns

str
Module's name and parameter in flat Verilog.
+
+ +Expand source code + +
def get_prototype_v_flat(self):
+    """Generates flat Verilog module header to describe corresponding one input logic gate's interface in flat Verilog.
+
+    Returns:
+        str: Module's name and parameter in flat Verilog.
+    """
+    return f"module {self.prefix}(input {self.a.name}" + \
+           "".join([f", output {self.out.name});\n" if self.disable_generation is False else f", output {self.out.name}_out);\n" for _ in range(1)])
+
def get_prototype_v_hier(self) @@ -528,6 +693,18 @@

Returns

str
Module's name and parameter in hierarchical Verilog.
+
+ +Expand source code + +
def get_prototype_v_hier(self):
+    """Generates hierarchical Verilog module header to describe corresponding one input logic gate's interface in hierarchical Verilog.
+
+    Returns:
+        str: Module's name and parameter in hierarchical Verilog.
+    """
+    return f"module {self.gate_type}(input {self.a.name}, output {self.out.name});\n"
+
def get_triplet_cgp(self, a_id: int, out_id: int) @@ -552,6 +729,30 @@

Returns

str
Triplet describing function of corresponding one input logic gate.
+
+ +Expand source code + +
def get_triplet_cgp(self, a_id: int, out_id: int):
+    """Generates logic gate triplet (first input wire, second input wire, logic gate function) using wires unique position indexes within the described circuit.
+
+    Each triplet represents unique logic gate within the described circuit. In this case of one input logic gate, the same input wire index is driven to both inputs.
+    Besides the contained input wires indexes and gate's inner logic function, an output wire with incremented index position is also created and remembered to be
+    appropriately driven as an input to another logic gate or as the circuit's output.
+
+    Constant wire with value 0 has constant index of 0.
+    Constant wire with value 1 has constant index of 1.
+    Other wires indexes start counting from 2 and up.
+
+    Args:
+        a_id (int): First (used also as the second) input wire index position.
+        out_id (int): Outpu wire index position
+
+    Returns:
+        str: Triplet describing function of corresponding one input logic gate.
+    """
+    return f"([{out_id}]{a_id},{a_id},{self.cgp_function})"
+

Inherited members

@@ -584,7 +785,7 @@

Inherited members

class TwoInputInvertedLogicGate -(a: Wire, b: Wire, prefix: str = 'gate', outid: int = 0, parent_component: object = None) +(a: Wire,
b: Wire,
prefix: str = 'gate',
outid: int = 0,
parent_component: object = None)

Class representing two input inverted logic gates.

@@ -676,6 +877,18 @@

Returns

str
C code description of negated logic gate's Boolean function (with bitwise shifted inputs).
+
+ +Expand source code + +
def get_function_c(self):
+    """Generates C code representing corresponding negated two input logic gate's Boolean function using bitwise operators between its bitwise shifted inputs.
+
+    Returns:
+        str: C code description of negated logic gate's Boolean function (with bitwise shifted inputs).
+    """
+    return "~("+(super().get_function_c()) + ") & 0x01"
+
def get_function_v(self) @@ -687,6 +900,18 @@

Returns

str
Verilog description of negated logic gate's Boolean function.
+
+ +Expand source code + +
def get_function_v(self):
+    """Generates Verilog code representing corresponding negated two input logic gate's Boolean function using bitwise operators between its inputs.
+
+    Returns:
+        str: Verilog description of negated logic gate's Boolean function.
+    """
+    return "~("+(super().get_function_v())+")"
+

Inherited members

@@ -730,7 +955,7 @@

Inherited members

class TwoInputLogicGate -(a: Wire, b: Wire, prefix: str = 'gate', outid: int = 0, parent_component: object = None) +(a: Wire,
b: Wire,
prefix: str = 'gate',
outid: int = 0,
parent_component: object = None)

Class representing two input logic gates.

@@ -1222,6 +1447,19 @@

Returns

str
C code library includes.
+
+ +Expand source code + +
@staticmethod
+def get_includes_c():
+    """Generates necessary C library includes for output representation.
+
+    Returns:
+        str: C code library includes.
+    """
+    return f"#include <stdio.h>\n#include <stdint.h>\n\n"
+
def get_output_cgp(out_id: int) @@ -1238,6 +1476,22 @@

Returns

str
List containing logic gate's output wire indexes (one in this case).
+
+ +Expand source code + +
@staticmethod
+def get_output_cgp(out_id: int):
+    """Generates list of output wires indexes of described two input logic gate from MSB to LSB.
+
+    Args:
+        out_id (int): Output wire index position.
+
+    Returns:
+        str: List containing logic gate's output wire indexes (one in this case).
+    """
+    return f"({out_id})"
+
def get_parameters_cgp() @@ -1251,6 +1505,22 @@

Returns

str
CGP chromosome parameters of described logic gate.
+
+ +Expand source code + +
@staticmethod
+def get_parameters_cgp():
+    """Generates CGP chromosome parameters of corresponding logic gate.
+
+    In total seven parameters represent: total inputs, total outputs, number of rows, number of columns (gates),
+    number of each gate's inputs, number of each gate's outputs, quality constant value.
+
+    Returns:
+        str: CGP chromosome parameters of described logic gate.
+    """
+    return "{2,1,1,1,2,1,0}"
+

Methods

@@ -1265,6 +1535,23 @@

Returns

str
C code invocation of logical function and assignment to output.
+
+ +Expand source code + +
def get_assign_c_flat(self):
+    """Generates C code for invocation of logical functions and subsequently provides assignment to their output.
+
+    Returns:
+        str: C code invocation of logical function and assignment to output.
+    """
+    # No gate logic is generated if one of the inputs is a wire with constant value.
+    # I.e. either the constant or the second input wire is propagated to the output for the corresponding logic gate's logic function.
+    if self.disable_generation:
+        return ""
+    else:
+        return f"  {self.out.prefix} = {self.get_function_c()};\n"
+
def get_assign_python_flat(self) @@ -1276,6 +1563,25 @@

Returns

str
Python code invocation of logical function and assignment to output.
+
+ +Expand source code + +
def get_assign_python_flat(self):
+    """Generates Python code for invocation of logical functions and subsequently provides assignment to their output.
+
+    Returns:
+        str: Python code invocation of logical function and assignment to output.
+    """
+    # No gate logic is generated if one of the inputs is a wire with constant value.
+    # I.e. either the constant or the second input wire is propagated to the output for the corresponding logic gate's logic function.
+    if self.disable_generation:
+        #return f"  {self.out.prefix} = {self.get_function_c()} # DD {self.prefix} \n"
+
+        return ""
+    else:
+        return f"  {self.out.prefix} = {self.get_function_c()}\n"
+
def get_assign_v_flat(self) @@ -1287,6 +1593,23 @@

Returns

str
Verilog code invocation of logical function and assignment to output.
+
+ +Expand source code + +
def get_assign_v_flat(self):
+    """Generates Verilog code for invocation of logical functions and subsequently provides assignment to their output.
+
+    Returns:
+        str: Verilog code invocation of logical function and assignment to output.
+    """
+    # No gate logic is generated if one of the inputs is a wire with constant value.
+    # I.e. either the constant or the second input wire is propagated to the output for the corresponding logic gate's logic function.
+    if self.disable_generation:
+        return ""
+    else:
+        return f"  assign {self.out.prefix} = {self.get_function_v()};\n"
+
def get_blif_code(self, file_object) @@ -1298,6 +1621,21 @@

Args

file_object : TextIOWrapper
Destination file object where circuit's representation will be written to.
+
+ +Expand source code + +
def get_blif_code(self, file_object):
+    """Generates flat Blif code representation of corresponding logic gate itself.
+
+    Args:
+        file_object (TextIOWrapper): Destination file object where circuit's representation will be written to.
+    """
+    file_object.write(self.get_prototype_blif_flat())
+    file_object.write(self.get_declaration_blif())
+    file_object.write(self.get_function_blif_flat(top_modul=True))
+    file_object.write(f".end\n")
+
def get_c_code(self, file_object) @@ -1309,6 +1647,20 @@

Args

file_object : TextIOWrapper
Destination file object where circuit's representation will be written to.
+
+ +Expand source code + +
def get_c_code(self, file_object):
+    """Generates flat C code representation of corresponding logic gate itself.
+
+    Args:
+        file_object (TextIOWrapper): Destination file object where circuit's representation will be written to.
+    """
+    file_object.write(self.get_includes_c())
+    file_object.write(self.get_prototype_c_flat())
+    file_object.write("  return "+(self.get_function_c())+";\n}")
+
def get_cgp_code(self, file_object) @@ -1320,6 +1672,19 @@

Args

file_object : TextIOWrapper
Destination file object where circuit's representation will be written to.
+
+ +Expand source code + +
def get_cgp_code(self, file_object):
+    """Generates flat CGP chromosome representation of corresponding logic gate itself.
+
+    Args:
+        file_object (TextIOWrapper): Destination file object where circuit's representation will be written to.
+    """
+    file_object.write(self.get_parameters_cgp())
+    file_object.write(self.get_gate_triplet_cgp())
+
def get_declaration_blif(self) @@ -1331,6 +1696,22 @@

Returns

str
Blif logic gate's wires declaration.
+
+ +Expand source code + +
def get_declaration_blif(self):
+    """Generates Blif code declaration of two input logic gate's wires.
+
+    Returns:
+        str: Blif logic gate's wires declaration.
+    """
+    return f".inputs {self.a.get_wire_declaration_blif()}{self.b.get_wire_declaration_blif()}\n" + \
+           f".outputs" + \
+           "".join([f" {self.out.name}\n" if self.disable_generation is False else f" {self.out.name}_out\n" for _ in range(1)]) + \
+           f".names vdd\n1\n" + \
+           f".names gnd\n0\n"
+
def get_declaration_c_flat(self) @@ -1342,6 +1723,23 @@

Returns

str
C code logic gate's output wire declaration.
+
+ +Expand source code + +
def get_declaration_c_flat(self):
+    """Generates C code declaration of output wire for flat representation.
+
+    Returns:
+        str: C code logic gate's output wire declaration.
+    """
+    # No gate output wire is generated if one of the inputs is a wire with constant value.
+    # I.e. either the constant or the second input wire is propagated to the output for the corresponding logic gate's logic function.
+    if self.disable_generation:
+        return ""
+    else:
+        return f"{self.out.get_declaration_c()}"
+
def get_declaration_c_hier(self) @@ -1353,6 +1751,23 @@

Returns

str
C code logic gate's output wire declaration.
+
+ +Expand source code + +
def get_declaration_c_hier(self):
+    """Generates C code declaration of output wire for hierarchical representation.
+
+    Returns:
+        str: C code logic gate's output wire declaration.
+    """
+    # No gate output wire is generated if one of the inputs is a wire with constant value.
+    # I.e. either the constant or the second input wire is propagated to the output for the corresponding logic gate's logic function.
+    if self.disable_generation:
+        return ""
+    else:
+        return f"{self.out.get_declaration_c()}"
+
def get_declaration_v_flat(self) @@ -1364,6 +1779,23 @@

Returns

str
Verilog code logic gate's output wire declaration.
+
+ +Expand source code + +
def get_declaration_v_flat(self):
+    """Generates Verilog code declaration of output wire for flat representation.
+
+    Returns:
+        str: Verilog code logic gate's output wire declaration.
+    """
+    # No gate output wire is generated if one of the inputs is a wire with constant value.
+    # I.e. either the constant or the second input wire is propagated to the output for the corresponding logic gate's logic function.
+    if self.disable_generation:
+        return ""
+    else:
+        return f"{self.out.get_declaration_v_flat()}"
+
def get_declaration_v_hier(self) @@ -1375,6 +1807,23 @@

Returns

str
Verilog code logic gate's output wire declaration.
+
+ +Expand source code + +
def get_declaration_v_hier(self):
+    """Generates Verilog code declaration of output wire for hierarchical representation.
+
+    Returns:
+        str: Verilog code logic gate's output wire declaration.
+    """
+    # No gate output wire is generated if one of the inputs is a wire with constant value.
+    # I.e. either the constant or the second input wire is propagated to the output for the corresponding logic gate's logic function.
+    if self.disable_generation:
+        return ""
+    else:
+        return f"{self.out.get_declaration_v_hier()}"
+
def get_function_blif_flat(self, top_modul: bool = False) @@ -1392,6 +1841,30 @@

Returns

str
Blif description of logic gate's Boolean function.
+
+ +Expand source code + +
def get_function_blif_flat(self, top_modul: bool = False):
+    """Generates Blif code representing corresponding two input logic gate's Boolean function between its inputs.
+
+    Invokes corresponding logic gate's `get_function_blif` method for its individual description of logic function.
+
+    Args:
+        top_modul (bool, optional): Specifies whether the described circuit has logic gate as its top modul component (used for self logic gate generation). Defaults to False.
+
+    Returns:
+        str: Blif description of logic gate's Boolean function.
+    """
+    if top_modul is True:
+        return f"{self.get_function_blif()}"
+    # No function block is generated if one of the inputs is a wire with constant value.
+    # I.e. either the constant or the second input wire is propagated to the output for the corresponding logic gate's logic function.
+    elif self.disable_generation:
+        return ""
+    else:
+        return f"{self.get_function_blif()}"
+
def get_function_block_blif(self) @@ -1403,6 +1876,22 @@

Returns

str
Blif logic gate subcomponent description.
+
+ +Expand source code + +
def get_function_block_blif(self):
+    """Generates Blif code representation of corresponding two input logic gate used as subcomponent in hierarchical circuit description.
+
+    Returns:
+        str: Blif logic gate subcomponent description.
+    """
+    gate_block = type(self)(a=Wire(name="a"), b=Wire(name="b"), prefix="out")
+    return f"{gate_block.get_prototype_blif_hier()}" + \
+           f"{gate_block.get_declaration_blif()}" + \
+           f"{gate_block.get_function_blif()}" + \
+           f".end\n"
+
def get_function_block_c(self) @@ -1414,6 +1903,20 @@

Returns

str
C code of logic gate's function block description.
+
+ +Expand source code + +
def get_function_block_c(self):
+    """Generates C code representation of corresponding logic gate used as a function block in hierarchical circuit description.
+
+    Returns:
+        str: C code of logic gate's function block description.
+    """
+    gate_block = type(self)(a=Wire(name="a"), b=Wire(name="b"))
+    return f"{gate_block.get_prototype_c_hier()}" + \
+           f"  return "+(gate_block.get_function_c())+";\n}\n\n"
+
def get_function_block_v(self) @@ -1425,6 +1928,21 @@

Returns

str
Verilog logic gate's function block description.
+
+ +Expand source code + +
def get_function_block_v(self):
+    """Generates Verilog code representation of corresponding logic gate used as function block in hierarchical circuit description.
+
+    Returns:
+        str: Verilog logic gate's function block description.
+    """
+    gate_block = type(self)(a=Wire(name="a"), b=Wire(name="b"), prefix="out")
+    return f"{gate_block.get_prototype_v_hier()}" + \
+           f"  assign {gate_block.out.name} = {gate_block.get_function_v()};\n" + \
+           f"endmodule\n\n"
+
def get_function_c(self) @@ -1436,6 +1954,20 @@

Returns

str
C code description of logic gate's Boolean function (with bitwise shifted inputs).
+
+ +Expand source code + +
def get_function_c(self):
+    """Generates C code representing corresponding two input logic gate's Boolean function using bitwise operators between its bitwise shifted inputs.
+
+    Returns:
+        str: C code description of logic gate's Boolean function (with bitwise shifted inputs).
+    """
+    if self.out.is_const():
+        return self.out.get_wire_value_c_flat()
+    return f"{self.a.get_wire_value_c_flat()} {self.operator} {self.b.get_wire_value_c_flat()}"
+
def get_function_v(self) @@ -1447,6 +1979,18 @@

Returns

str
Verilog description of logic gate's Boolean function.
+
+ +Expand source code + +
def get_function_v(self):
+    """Generates Verilog code representing corresponding two input logic gate's Boolean function using bitwise operators between its inputs.
+
+    Returns:
+        str: Verilog description of logic gate's Boolean function.
+    """
+    return f"{self.a.get_wire_value_v_flat()} {self.operator} {self.b.get_wire_value_v_flat()}"
+
def get_gate_invocation_c(self) @@ -1458,6 +2002,23 @@

Returns

str
C code of logic gate's function block invocation.
+
+ +Expand source code + +
def get_gate_invocation_c(self):
+    """Generates C code invocation of corresponding logic gate's generated function block.
+
+    Returns:
+        str: C code of logic gate's function block invocation.
+    """
+    # No function block is generated if one of the inputs is a wire with constant value.
+    # I.e. either the constant or the second input wire is propagated to the output for the corresponding logic gate's logic function.
+    if self.disable_generation:
+        return ""
+    else:
+        return f"  {self.out.name} = {self.gate_type}({self.a.get_wire_value_c_hier()}, {self.b.get_wire_value_c_hier()});\n"
+
def get_gate_invocation_v(self) @@ -1469,6 +2030,24 @@

Returns

str
Verilog code logic gate's function block invocation.
+
+ +Expand source code + +
def get_gate_invocation_v(self):
+    """Generates Verilog code invocation of corresponding logic gate's generated function block.
+
+    Returns:
+        str: Verilog code logic gate's function block invocation.
+    """
+    # No function block is generated if one of the inputs is a wire with constant value.
+    # I.e. either the constant or the second input wire is propagated to the output for the corresponding logic gate's logic function.
+    if self.disable_generation:
+        return ""
+    else:
+        gate_block = self.__class__(a=Wire(name="a"), b=Wire(name="b"), prefix="out")
+        return f"  {self.gate_type} {self.gate_type}_{self.out.prefix}(.{gate_block.a.prefix}({self.a.get_wire_value_v_hier()}), .{gate_block.b.prefix}({self.b.get_wire_value_v_hier()}), .{gate_block.out.prefix}({self.out.prefix}));\n"
+
def get_gate_triplet_cgp(self) @@ -1480,6 +2059,35 @@

Returns

str
Triplet and output lists describing function of corresponding two input logic gate.
+
+ +Expand source code + +
def get_gate_triplet_cgp(self):
+    """Generates flat CGP triplet and output representation of corresponding logic gate itself.
+
+    Returns:
+        str: Triplet and output lists describing function of corresponding two input logic gate.
+    """
+    if self.a.is_const() and self.b.is_const():
+        a_id = self.a.cgp_const
+        b_id = self.b.cgp_const
+    elif self.a.is_const():
+        a_id = self.a.cgp_const
+        b_id = 2
+    elif self.b.is_const():
+        a_id = 2
+        b_id = self.b.cgp_const
+    else:
+        a_id = 2
+        b_id = 3
+
+    if self.out.is_const():
+        out_id = self.out.cgp_const
+    else:
+        out_id = a_id+1 if a_id > b_id else b_id+1
+    return self.get_triplet_cgp(a_id=a_id, b_id=b_id, out_id=out_id) + self.get_output_cgp(out_id=out_id)
+
def get_invocation_blif_hier(self, top_modul: bool = False, *args, **kwargs) @@ -1496,6 +2104,26 @@

Returns

str
Blif logic gate subcomponent invocation.
+
+ +Expand source code + +
def get_invocation_blif_hier(self, top_modul: bool = False, *args, **kwargs):
+    """Generates Blif code invocation of corresponding two input logic gate's generated subcomponent.
+
+    Args:
+        top_modul (bool, optional): Specifies whether the described circuit has logic gate as its top modul component (used for self logic gate generation). Defaults to False.
+
+    Returns:
+        str: Blif logic gate subcomponent invocation.
+    """
+    # No function block is generated if one of the inputs is a wire with constant value.
+    # I.e. either the constant or the second input wire is propagated to the output for the corresponding logic gate's logic function.
+    if self.disable_generation and top_modul is False:
+        return ""
+    else:
+        return f".subckt {self.gate_type} a={self.a.get_wire_value_blif()} b={self.b.get_wire_value_blif()} out={self.out.get_wire_value_blif()}\n"
+
def get_output_v_flat(self) @@ -1507,6 +2135,18 @@

Returns

str
Module's output wire assignment in flat Verilog.
+
+ +Expand source code + +
def get_output_v_flat(self):
+    """Generates flat Verilog module's output wire assignment used for self logic gate circuit generation.
+
+    Returns:
+        str: Module's output wire assignment in flat Verilog.
+    """
+    return "".join([f"  assign {self.out.name} = {self.get_function_v()};\n" if self.disable_generation is False else f"  assign {self.out.name}_out = {self.get_function_v()};\n" for _ in range(1)])
+
def get_prototype_blif_flat(self) @@ -1518,6 +2158,18 @@

Returns

str
Model's name in flat Blif code.
+
+ +Expand source code + +
def get_prototype_blif_flat(self):
+    """Generates flat Blif model header to describe corresponding logic gate's interface in flat Blif.
+
+    Returns:
+        str: Model's name in flat Blif code.
+    """
+    return f".model {self.prefix}\n"
+
def get_prototype_blif_hier(self) @@ -1529,6 +2181,18 @@

Returns

str
Model's name in hierarchical Blif.
+
+ +Expand source code + +
def get_prototype_blif_hier(self):
+    """Generates hierarchical Blif model header to describe corresponding logic gate's interface in hierarchical Blif.
+
+    Returns:
+        str: Model's name in hierarchical Blif.
+    """
+    return f".model {self.gate_type}\n"
+
def get_prototype_c_flat(self) @@ -1540,6 +2204,18 @@

Returns

str
Function's name and parameters in flat C code.
+
+ +Expand source code + +
def get_prototype_c_flat(self):
+    """Generates flat C code function header to describe corresponding two input logic gate's interface in flat C code.
+
+    Returns:
+        str: Function's name and parameters in flat C code.
+    """
+    return f"uint8_t {self.prefix}(uint8_t {self.a.name}, uint8_t {self.b.name})" + "{" + "\n"
+
def get_prototype_c_hier(self) @@ -1551,6 +2227,18 @@

Returns

str
Function's name and parameters in hierarchical C code.
+
+ +Expand source code + +
def get_prototype_c_hier(self):
+    """Generates hierarchical C code function header to describe corresponding two input logic gate's interface in hierarchical C code.
+
+    Returns:
+        str: Function's name and parameters in hierarchical C code.
+    """
+    return f"uint8_t {self.gate_type}(uint8_t {self.a.name}, uint8_t {self.b.name})" + "{" + "\n"
+
def get_prototype_v_flat(self) @@ -1562,6 +2250,19 @@

Returns

str
Module's name and parameters in flat Verilog.
+
+ +Expand source code + +
def get_prototype_v_flat(self):
+    """Generates flat Verilog module header to describe corresponding two input logic gate's interface in flat Verilog.
+
+    Returns:
+        str: Module's name and parameters in flat Verilog.
+    """
+    return f"module {self.prefix}(input {self.a.name}, input {self.b.name}" + \
+           "".join([f", output {self.out.name}" if self.disable_generation is False else f", output {self.out.name}_out" for _ in range(1)]) + ");\n"
+
def get_prototype_v_hier(self) @@ -1573,6 +2274,18 @@

Returns

str
Module's name and parameters in hierarchical Verilog.
+
+ +Expand source code + +
def get_prototype_v_hier(self):
+    """Generates hierarchical Verilog module header to describe corresponding two input logic gate's interface in hierarchical Verilog.
+
+    Returns:
+        str: Module's name and parameters in hierarchical Verilog.
+    """
+    return f"module {self.gate_type}(input {self.a.name}, input {self.b.name}, output {self.out.name});\n"
+
def get_triplet_cgp(self, a_id: int, b_id: int, out_id: int) @@ -1598,6 +2311,30 @@

Returns

str
Triplet describing function of corresponding two input logic gate.
+
+ +Expand source code + +
def get_triplet_cgp(self, a_id: int, b_id: int, out_id: int):
+    """Generates logic gate triplet (first input wire, second input wire, logic gate function) using wires unique position indexes within the described circuit.
+
+    Each triplet represents unique logic gate within the described circuit. Besides the contained input wires indexes and gate's inner logic function, an output wire
+    with incremented index position is also created and remembered to be appropriately driven as an input to another logic gate or as the circuit's output.
+
+    Constant wire with value 0 has constant index of 0.
+    Constant wire with value 1 has constant index of 1.
+    Other wires indexes start counting from 2 and up.
+
+    Args:
+        a_id (int): First input wire index position.
+        b_id (int): Second input wire index position.
+        out_id (int): The output wire index position
+
+    Returns:
+        str: Triplet describing function of corresponding two input logic gate.
+    """
+    return f"([{out_id}]{a_id},{b_id},{self.cgp_function})"
+
def get_v_code(self, file_object) @@ -1609,6 +2346,20 @@

Args

file_object : TextIOWrapper
Destination file object where circuit's representation will be written to.
+
+ +Expand source code + +
def get_v_code(self, file_object):
+    """Generates flat Verilog code representation of corresponding logic gate itself.
+
+    Args:
+        file_object (TextIOWrapper): Destination file object where circuit's representation will be written to.
+    """
+    file_object.write(self.get_prototype_v_flat())
+    file_object.write(self.get_output_v_flat())
+    file_object.write(f"endmodule")
+
@@ -1699,7 +2450,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/core/one_bit_circuits/four_input_one_bit_circuit.html b/core/one_bit_circuits/four_input_one_bit_circuit.html index ec2e079..4059b11 100644 --- a/core/one_bit_circuits/four_input_one_bit_circuit.html +++ b/core/one_bit_circuits/four_input_one_bit_circuit.html @@ -3,13 +3,13 @@ - + ariths_gen.core.one_bit_circuits.four_input_one_bit_circuit API documentation - + @@ -37,7 +37,7 @@

Classes

class FourInputOneBitCircuit -(a: Wire = <ariths_gen.wire_components.wires.Wire object>, b: Wire = <ariths_gen.wire_components.wires.Wire object>, c: Wire = <ariths_gen.wire_components.wires.Wire object>, d: Wire = <ariths_gen.wire_components.wires.Wire object>, prefix: str = '', name: str = 'four_input_one_bit_circuit') +(a: Wire = <ariths_gen.wire_components.wires.Wire object>,
b: Wire = <ariths_gen.wire_components.wires.Wire object>,
c: Wire = <ariths_gen.wire_components.wires.Wire object>,
d: Wire = <ariths_gen.wire_components.wires.Wire object>,
prefix: str = '',
name: str = 'four_input_one_bit_circuit')

Class represents a general four input one bit circuit and implements their generation to various representations. It is derived from TwoInputOneBitCircuit class.

@@ -289,6 +289,27 @@

Returns

str
Blif code containing declaration of circuit's input/output wires.
+
+ +Expand source code + +
def get_declaration_blif(self):
+    """Generates Blif code declaration of four input one bit circuit's input/output wires.
+
+    It is adapted for generation of general description of four input one bit circuits as well as their modified versions when some inputs are desired as constant values.
+    In such cases the inner modul logic is also modified accordingly. It is used for self four input one bit circuit flat/hierarchical generation.
+
+    Returns:
+        str: Blif code containing declaration of circuit's input/output wires.
+    """
+    unique_out_wires = []
+    [unique_out_wires.append(o.name+"_outid"+str(self.out.bus.index(o))) if o.is_const() or o.name in [self.a.name, self.b.name, self.c.name, self.d.name] else unique_out_wires.append(o.name) for o in self.out.bus]
+    return f".inputs {self.a.get_wire_declaration_blif()}{self.b.get_wire_declaration_blif()}{self.c.get_wire_declaration_blif()}{self.d.get_wire_declaration_blif()}\n" + \
+           f".outputs" + \
+           "".join([f" {o}" for o in unique_out_wires]) + "\n" + \
+           f".names vdd\n1\n" + \
+           f".names gnd\n0\n"
+
def get_function_blif_flat(self, top_modul: bool = False) @@ -307,6 +328,31 @@

Returns

str
Flat Blif code containing invocation of inner subcomponents logic gates Boolean functions.
+
+ +Expand source code + +
def get_function_blif_flat(self, top_modul: bool = False):
+    """Generates flat Blif code with invocation of subcomponents logic gates Boolean functions via their corresponding truth tables.
+
+    It is adapted for generation of general description of four input one bit circuits as well as their modified versions when some inputs are desired as constant values.
+    In such cases the inner modul prototype is also modified accordingly. It is used for self four input one bit circuit flat generation.
+
+    Args:
+        top_modul (bool, optional): Specifies whether the described circuit represents top modul component (self one bit circuit generation). Defaults to False.
+
+    Returns:
+        str: Flat Blif code containing invocation of inner subcomponents logic gates Boolean functions.
+    """
+    if top_modul:
+        unique_out_wires = []
+        [unique_out_wires.append(o.name+"_outid"+str(self.out.bus.index(o))) if o.is_const() or o.name in [self.a.name, self.b.name, self.c.name, self.d.name] else unique_out_wires.append(o.name) for o in self.out.bus]
+        return "".join([c.get_function_blif_flat() if c.disable_generation is False else
+                       c.out.get_assign_blif(prefix=f"{unique_out_wires.pop(unique_out_wires.index(c.out.name+'_outid'+str(c.outid)))}", output=True) if f"{c.out.name+'_outid'+str(c.outid)}" in unique_out_wires else
+                       "" for c in self.components])
+    else:
+        return "".join([c.get_function_blif_flat() for c in self.components])
+
def get_invocation_blif_hier(self) @@ -318,6 +364,19 @@

Returns

str
Hierarchical Blif code subcomponent's model invocation.
+
+ +Expand source code + +
def get_invocation_blif_hier(self):
+    """Generates hierarchical Blif code invocation of corresponding four input one bit circuit's generated function block.
+
+    Returns:
+        str: Hierarchical Blif code subcomponent's model invocation.
+    """
+    circuit_block = self.__class__()
+    return f".subckt {circuit_block.prefix} {circuit_block.a.prefix}={self.a.get_wire_value_blif()} {circuit_block.b.prefix}={self.b.get_wire_value_blif()} {circuit_block.c.prefix}={self.c.get_wire_value_blif()} {circuit_block.d.prefix}={self.d.get_wire_value_blif()}{self.out.get_unique_assign_out_wires_blif(function_block_out_bus=circuit_block.out)}\n"
+
def get_invocations_blif_hier(self) @@ -331,6 +390,25 @@

Returns

str
Hierarchical Blif code containing invocation of inner subcomponents function blocks.
+
+ +Expand source code + +
def get_invocations_blif_hier(self):
+    """Generates hierarchical Blif code with invocation of subcomponents function blocks.
+
+    It is adapted for generation of general description of four input one bit circuits as well as their modified versions when some inputs are desired as constant values.
+    In such cases the inner modul prototype is also modified accordingly. It is used for self four input one bit circuit hierarchical generation.
+
+    Returns:
+        str: Hierarchical Blif code containing invocation of inner subcomponents function blocks.
+    """
+    unique_out_wires = []
+    [unique_out_wires.append(o.name+"_outid"+str(self.out.bus.index(o))) if o.is_const() or o.name in [self.a.name, self.b.name, self.c.name, self.d.name] else unique_out_wires.append(o.name) for o in self.out.bus]
+    return "".join([c.get_invocation_blif_hier() if c.disable_generation is False else
+                   c.out.get_assign_blif(prefix=f"{unique_out_wires.pop(unique_out_wires.index(c.out.name+'_outid'+str(c.outid)))}", output=True) if f"{c.out.name+'_outid'+str(c.outid)}" in unique_out_wires else
+                   "" for c in self.components])
+
def get_out_invocation_c(self) @@ -344,6 +422,25 @@

Returns

str
Hierarchical C code subcomponent's C function invocation and output assignment.
+
+ +Expand source code + +
def get_out_invocation_c(self):
+    """Generates hierarchical C code invocation of corresponding four input one bit circuit's generated function block.
+
+    Assigns output values from invocation of the corresponding function block into inner wires present inside the upper
+    component from which function block has been invoked.
+
+    Returns:
+        str: Hierarchical C code subcomponent's C function invocation and output assignment.
+    """
+    # Used to retrieve proper component's output wire offset position within the output bus
+    output_bus_wire_names = []
+    [output_bus_wire_names.append(w.prefix) for w in self.out.bus]
+    circuit_block = self.__class__()
+    return "".join([f"  {c.out.prefix} = ({circuit_block.prefix}({self.a.get_wire_value_c_hier()}, {self.b.get_wire_value_c_hier()}, {self.c.get_wire_value_c_hier()}, {self.d.get_wire_value_c_hier()}) >> {output_bus_wire_names.index(c.out.prefix)}) & 0x01;\n" for c in self.components if c.disable_generation is False and c.out.prefix in output_bus_wire_names])
+
def get_out_invocation_v(self) @@ -357,6 +454,22 @@

Returns

str
Hierarchical Verilog code subcomponent's module invocation and output assignment.
+
+ +Expand source code + +
def get_out_invocation_v(self):
+    """Generates hierarchical Verilog code invocation of corresponding four input one bit circuit's generated function block.
+
+    Assigns output values from invocation of the corresponding function block into inner wires present inside the upper
+    component from which function block has been invoked.
+
+    Returns:
+        str: Hierarchical Verilog code subcomponent's module invocation and output assignment.
+    """
+    circuit_block = self.__class__()
+    return f"  {circuit_block.prefix} {circuit_block.prefix}_{self.out.prefix}(.{circuit_block.a.prefix}({self.a.get_wire_value_v_hier()}), .{circuit_block.b.prefix}({self.b.get_wire_value_v_hier()}), .{circuit_block.c.prefix}({self.c.get_wire_value_v_hier()}), .{circuit_block.d.prefix}({self.d.get_wire_value_v_hier()}){self.out.get_unique_assign_out_wires_v(circuit_block)});\n"
+
def get_parameters_cgp(self) @@ -370,6 +483,22 @@

Returns

str
CGP chromosome parameters of described circuit.
+
+ +Expand source code + +
def get_parameters_cgp(self):
+    """Generates CGP chromosome parameters of corresponding four input one bit circuit.
+
+    In total seven parameters represent: total inputs, total outputs, number of rows, number of columns (gates),
+    number of each gate's inputs, number of each gate's outputs, quality constant value.
+
+    Returns:
+        str: CGP chromosome parameters of described circuit.
+    """
+    self.circuit_gates = self.get_circuit_gates()
+    return f"{{4,{self.out.N},1,{len(self.circuit_gates)},2,1,0}}"
+
def get_prototype_c(self) @@ -381,6 +510,18 @@

Returns

str
Function's name and parameters in C code.
+
+ +Expand source code + +
def get_prototype_c(self):
+    """Generates C code function header to describe corresponding four input one bit circuit's interface in C code.
+
+    Returns:
+        str: Function's name and parameters in C code.
+    """
+    return f"{self.c_data_type} {self.prefix}({self.c_data_type} {self.a.prefix}, {self.c_data_type} {self.b.prefix}, {self.c_data_type} {self.c.prefix}, {self.c_data_type} {self.d.prefix})" + "{" + "\n"
+
def get_prototype_v(self) @@ -394,6 +535,24 @@

Returns

str
Flat module's name and parameters in Verilog.
+
+ +Expand source code + +
def get_prototype_v(self):
+    """Generates Verilog for flat module header to describe corresponding four input one bit circuit's interface in Verilog.
+
+    It is adapted for generation of general description of four input one bit circuits as well as their modified versions when some inputs are desired as constant values.
+    In such cases the inner module logic is also modified accordingly. It is used for self four input one bit circuit flat generation.
+
+    Returns:
+        str: Flat module's name and parameters in Verilog.
+    """
+    unique_out_wires = []
+    [unique_out_wires.append(o.name+"_outid"+str(self.out.bus.index(o))) if o.is_const() or o.name in [self.a.name, self.b.name, self.c.name, self.d.name] else unique_out_wires.append(o.name) for o in self.out.bus]
+    return f"module {self.prefix}(input {self.a.name}, input {self.b.name}, input {self.c.name}, input {self.d.name}" + \
+           "".join([f", output {o}" for o in unique_out_wires]) + ");\n"
+
def get_prototype_v_hier(self) @@ -407,6 +566,24 @@

Returns

str
Hierarchical module's name and parameters in Verilog.
+
+ +Expand source code + +
def get_prototype_v_hier(self):
+    """Generates Verilog for hierarchical module header to describe corresponding four input one bit circuit's interface in Verilog.
+
+    It is adapted for generation of general description of four input one bit circuits as well as their modified versions when some inputs are desired as constant values.
+    In such cases the inner module logic is also modified accordingly. It is used for self four input one bit circuit hierarchical generation.
+
+    Returns:
+        str: Hierarchical module's name and parameters in Verilog.
+    """
+    unique_out_wires = []
+    [unique_out_wires.append(o.name+"_outid"+str(self.out.bus.index(o))) if o.is_const() or o.name in [self.a.name, self.b.name, self.c.name, self.d.name] else unique_out_wires.append(o.name) for o in self.out.bus]
+    return f"module {self.prefix}(input [0:0] {self.a.name}, input [0:0] {self.b.name}, input [0:0] {self.c.name}, input [0:0] {self.d.name}" + \
+           "".join([f", output [0:0] {o}" for o in unique_out_wires]) + ");\n"
+
def get_self_init_v_flat(self) @@ -420,6 +597,26 @@

Returns

str
Verilog flat module's inner circuit wires initialization and assignment.
+
+ +Expand source code + +
def get_self_init_v_flat(self):
+    """Generates Verilog for self flat module initialization and assignment of corresponding four input one bit circuit's input/output wires.
+
+    It is adapted for generation of general description of four input one bit circuits as well as their modified versions when some inputs are desired as constant values.
+    In such cases the inner module prototype is also modified accordingly. It is used for self four input one bit circuit flat generation.
+
+    Returns:
+        str: Verilog flat module's inner circuit wires initialization and assignment.
+    """
+    unique_out_wires = []
+    [unique_out_wires.append(o.name+"_outid"+str(self.out.bus.index(o))) if o.is_const() or o.name in [self.a.name, self.b.name, self.c.name, self.d.name] else unique_out_wires.append(o.name) for o in self.out.bus]
+    return "".join([c.get_assign_v_flat() if c.disable_generation is False else
+                    f"  assign {unique_out_wires.pop(unique_out_wires.index(c.out.name+'_outid'+str(c.outid)))} = {c.out.v_const};\n" if f"{c.out.name+'_outid'+str(c.outid)}" in unique_out_wires and c.out.is_const() else
+                    f"  assign {unique_out_wires.pop(unique_out_wires.index(c.out.name+'_outid'+str(c.outid)))} = {c.out.name};\n" if f"{c.out.name+'_outid'+str(c.outid)}" in unique_out_wires else
+                    f"" for c in self.components])
+
def get_self_init_v_hier(self) @@ -433,6 +630,26 @@

Returns

str
Verilog hierarchical module's inner circuit wires initialization and assignment.
+
+ +Expand source code + +
def get_self_init_v_hier(self):
+    """Generates Verilog for hierarchical module's inner initialization and assignment of corresponding arithmetic circuit's input/output wires.
+
+    It is adapted for generation of general description of four input one bit circuits as well as their modified versions when some inputs are desired as constant values.
+    In such cases the inner module prototype is also modified accordingly. It is used for self four input one bit circuit hierarchical generation.
+
+    Returns:
+        str: Verilog hierarchical module's inner circuit wires initialization and assignment.
+    """
+    unique_out_wires = []
+    [unique_out_wires.append(o.name+"_outid"+str(self.out.bus.index(o))) if o.is_const() or o.name in [self.a.name, self.b.name, self.c.name, self.d.name] else unique_out_wires.append(o.name) for o in self.out.bus]
+    return "".join([c.get_gate_invocation_v() if c.disable_generation is False else
+                    f"  assign {unique_out_wires.pop(unique_out_wires.index(c.out.name+'_outid'+str(c.outid)))}[0] = {c.out.v_const};\n" if f"{c.out.name+'_outid'+str(c.outid)}" in unique_out_wires and c.out.is_const() else
+                    f"  assign {unique_out_wires.pop(unique_out_wires.index(c.out.name+'_outid'+str(c.outid)))}[0] = {c.out.name}[0];\n" if f"{c.out.name+'_outid'+str(c.outid)}" in unique_out_wires else
+                    f"" for c in self.components])
+

Inherited members

@@ -534,7 +751,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/core/one_bit_circuits/index.html b/core/one_bit_circuits/index.html index 73b2e7f..35d580d 100644 --- a/core/one_bit_circuits/index.html +++ b/core/one_bit_circuits/index.html @@ -3,13 +3,13 @@ - + ariths_gen.core.one_bit_circuits API documentation - + @@ -71,7 +71,7 @@

Sub-modules

diff --git a/core/one_bit_circuits/three_input_one_bit_circuit.html b/core/one_bit_circuits/three_input_one_bit_circuit.html index 2179b2c..223f19e 100644 --- a/core/one_bit_circuits/three_input_one_bit_circuit.html +++ b/core/one_bit_circuits/three_input_one_bit_circuit.html @@ -3,13 +3,13 @@ - + ariths_gen.core.one_bit_circuits.three_input_one_bit_circuit API documentation - + @@ -37,7 +37,7 @@

Classes

class ThreeInputOneBitCircuit -(a: Wire = <ariths_gen.wire_components.wires.Wire object>, b: Wire = <ariths_gen.wire_components.wires.Wire object>, c: Wire = <ariths_gen.wire_components.wires.Wire object>, prefix: str = '', name: str = 'three_input_one_bit_circuit') +(a: Wire = <ariths_gen.wire_components.wires.Wire object>,
b: Wire = <ariths_gen.wire_components.wires.Wire object>,
c: Wire = <ariths_gen.wire_components.wires.Wire object>,
prefix: str = '',
name: str = 'three_input_one_bit_circuit')

Class represents a general three input one bit circuit and implements their generation to various representations. It is derived from TwoInputOneBitCircuit class.

@@ -292,6 +292,27 @@

Returns

str
Blif code containing declaration of circuit's input/output wires.
+
+ +Expand source code + +
def get_declaration_blif(self):
+    """Generates Blif code declaration of three input one bit circuit's input/output wires.
+
+    It is adapted for generation of general description of three input one bit circuits as well as their modified versions when some inputs are desired as constant values.
+    In such cases the inner modul logic is also modified accordingly. It is used for self three input one bit circuit flat/hierarchical generation.
+
+    Returns:
+        str: Blif code containing declaration of circuit's input/output wires.
+    """
+    unique_out_wires = []
+    [unique_out_wires.append(o.name+"_outid"+str(self.out.bus.index(o))) if o.is_const() or o.name in [self.a.name, self.b.name, self.c.name] else unique_out_wires.append(o.name) for o in self.out.bus]
+    return f".inputs {self.a.get_wire_declaration_blif()}{self.b.get_wire_declaration_blif()}{self.c.get_wire_declaration_blif()}\n" + \
+           f".outputs" + \
+           "".join([f" {o}" for o in unique_out_wires]) + "\n" + \
+           f".names vdd\n1\n" + \
+           f".names gnd\n0\n"
+
def get_function_blif_flat(self, top_modul: bool = False) @@ -310,6 +331,31 @@

Returns

str
Flat Blif code containing invocation of inner subcomponents logic gates Boolean functions.
+
+ +Expand source code + +
def get_function_blif_flat(self, top_modul: bool = False):
+    """Generates flat Blif code with invocation of subcomponents logic gates Boolean functions via their corresponding truth tables.
+
+    It is adapted for generation of general description of three input one bit circuits as well as their modified versions when some inputs are desired as constant values.
+    In such cases the inner modul prototype is also modified accordingly. It is used for self three input one bit circuit flat generation.
+
+    Args:
+        top_modul (bool, optional): Specifies whether the described circuit represents top modul component (self one bit circuit generation). Defaults to False.
+
+    Returns:
+        str: Flat Blif code containing invocation of inner subcomponents logic gates Boolean functions.
+    """
+    if top_modul:
+        unique_out_wires = []
+        [unique_out_wires.append(o.name+"_outid"+str(self.out.bus.index(o))) if o.is_const() or o.name in [self.a.name, self.b.name, self.c.name] else unique_out_wires.append(o.name) for o in self.out.bus]
+        return "".join([c.get_function_blif_flat() if c.disable_generation is False else
+                       c.out.get_assign_blif(prefix=f"{unique_out_wires.pop(unique_out_wires.index(c.out.name+'_outid'+str(c.outid)))}", output=True) if f"{c.out.name+'_outid'+str(c.outid)}" in unique_out_wires else
+                       "" for c in self.components])
+    else:
+        return "".join([c.get_function_blif_flat() for c in self.components])
+
def get_invocation_blif_hier(self) @@ -321,6 +367,19 @@

Returns

str
Hierarchical Blif code subcomponent's model invocation.
+
+ +Expand source code + +
def get_invocation_blif_hier(self):
+    """Generates hierarchical Blif code invocation of corresponding three input one bit circuit's generated function block.
+
+    Returns:
+        str: Hierarchical Blif code subcomponent's model invocation.
+    """
+    circuit_block = self.__class__()
+    return f".subckt {circuit_block.prefix} {circuit_block.a.prefix}={self.a.get_wire_value_blif()} {circuit_block.b.prefix}={self.b.get_wire_value_blif()} {circuit_block.c.prefix}={self.c.get_wire_value_blif()}{self.out.get_unique_assign_out_wires_blif(function_block_out_bus=circuit_block.out)}\n"
+
def get_invocations_blif_hier(self) @@ -334,6 +393,25 @@

Returns

str
Hierarchical Blif code containing invocation of inner subcomponents function blocks.
+
+ +Expand source code + +
def get_invocations_blif_hier(self):
+    """Generates hierarchical Blif code with invocation of subcomponents function blocks.
+
+    It is adapted for generation of general description of three input one bit circuits as well as their modified versions when some inputs are desired as constant values.
+    In such cases the inner modul prototype is also modified accordingly. It is used for self three input one bit circuit hierarchical generation.
+
+    Returns:
+        str: Hierarchical Blif code containing invocation of inner subcomponents function blocks.
+    """
+    unique_out_wires = []
+    [unique_out_wires.append(o.name+"_outid"+str(self.out.bus.index(o))) if o.is_const() or o.name in [self.a.name, self.b.name, self.c.name] else unique_out_wires.append(o.name) for o in self.out.bus]
+    return "".join([c.get_invocation_blif_hier() if c.disable_generation is False else
+                   c.out.get_assign_blif(prefix=f"{unique_out_wires.pop(unique_out_wires.index(c.out.name+'_outid'+str(c.outid)))}", output=True) if f"{c.out.name+'_outid'+str(c.outid)}" in unique_out_wires else
+                   "" for c in self.components])
+
def get_out_invocation_c(self) @@ -347,6 +425,25 @@

Returns

str
Hierarchical C code subcomponent's C function invocation and output assignment.
+
+ +Expand source code + +
def get_out_invocation_c(self):
+    """Generates hierarchical C code invocation of corresponding three input one bit circuit's generated function block.
+
+    Assigns output values from invocation of the corresponding function block into inner wires present inside the upper
+    component from which function block has been invoked.
+
+    Returns:
+        str: Hierarchical C code subcomponent's C function invocation and output assignment.
+    """
+    # Used to retrieve proper component's output wire offset position within the output bus
+    output_bus_wire_names = []
+    [output_bus_wire_names.append(w.prefix) for w in self.out.bus]
+    circuit_block = self.__class__()
+    return "".join([f"  {c.out.prefix} = ({circuit_block.prefix}({self.a.get_wire_value_c_hier()}, {self.b.get_wire_value_c_hier()}, {self.c.get_wire_value_c_hier()}) >> {output_bus_wire_names.index(c.out.prefix)}) & 0x01;\n" for c in self.components if c.disable_generation is False and c.out.prefix in output_bus_wire_names])
+
def get_out_invocation_v(self) @@ -360,6 +457,22 @@

Returns

str
Hierarchical Verilog code subcomponent's module invocation and output assignment.
+
+ +Expand source code + +
def get_out_invocation_v(self):
+    """Generates hierarchical Verilog code invocation of corresponding three input one bit circuit's generated function block.
+
+    Assigns output values from invocation of the corresponding function block into inner wires present inside the upper
+    component from which function block has been invoked.
+
+    Returns:
+        str: Hierarchical Verilog code subcomponent's module invocation and output assignment.
+    """
+    circuit_block = self.__class__()
+    return f"  {circuit_block.prefix} {circuit_block.prefix}_{self.out.prefix}(.{circuit_block.a.prefix}({self.a.get_wire_value_v_hier()}), .{circuit_block.b.prefix}({self.b.get_wire_value_v_hier()}), .{circuit_block.c.prefix}({self.c.get_wire_value_v_hier()}){self.out.get_unique_assign_out_wires_v(circuit_block)});\n"
+
def get_parameters_cgp(self) @@ -373,6 +486,22 @@

Returns

str
CGP chromosome parameters of described circuit.
+
+ +Expand source code + +
def get_parameters_cgp(self):
+    """Generates CGP chromosome parameters of corresponding three input one bit circuit.
+
+    In total seven parameters represent: total inputs, total outputs, number of rows, number of columns (gates),
+    number of each gate's inputs, number of each gate's outputs, quality constant value.
+
+    Returns:
+        str: CGP chromosome parameters of described circuit.
+    """
+    self.circuit_gates = self.get_circuit_gates()
+    return f"{{3,{self.out.N},1,{len(self.circuit_gates)},2,1,0}}"
+
def get_prototype_c(self) @@ -384,6 +513,18 @@

Returns

str
Function's name and parameters in C code.
+
+ +Expand source code + +
def get_prototype_c(self):
+    """Generates C code function header to describe corresponding three input one bit circuit's interface in C code.
+
+    Returns:
+        str: Function's name and parameters in C code.
+    """
+    return f"{self.c_data_type} {self.prefix}({self.c_data_type} {self.a.prefix}, {self.c_data_type} {self.b.prefix}, {self.c_data_type} {self.c.prefix})" + "{" + "\n"
+
def get_prototype_v(self) @@ -397,6 +538,24 @@

Returns

str
Flat module's name and parameters in Verilog.
+
+ +Expand source code + +
def get_prototype_v(self):
+    """Generates Verilog for flat module header to describe corresponding three input one bit circuit's interface in Verilog.
+
+    It is adapted for generation of general description of three input one bit circuits as well as their modified versions when some inputs are desired as constant values.
+    In such cases the inner module logic is also modified accordingly. It is used for self three input one bit circuit flat generation.
+
+    Returns:
+        str: Flat module's name and parameters in Verilog.
+    """
+    unique_out_wires = []
+    [unique_out_wires.append(o.name+"_outid"+str(self.out.bus.index(o))) if o.is_const() or o.name in [self.a.name, self.b.name, self.c.name] else unique_out_wires.append(o.name) for o in self.out.bus]
+    return f"module {self.prefix}(input {self.a.name}, input {self.b.name}, input {self.c.name}" + \
+           "".join([f", output {o}" for o in unique_out_wires]) + ");\n"
+
def get_prototype_v_hier(self) @@ -410,6 +569,24 @@

Returns

str
Hierarchical module's name and parameters in Verilog.
+
+ +Expand source code + +
def get_prototype_v_hier(self):
+    """Generates Verilog for hierarchical module header to describe corresponding three input one bit circuit's interface in Verilog.
+
+    It is adapted for generation of general description of three input one bit circuits as well as their modified versions when some inputs are desired as constant values.
+    In such cases the inner module logic is also modified accordingly. It is used for self three input one bit circuit hierarchical generation.
+
+    Returns:
+        str: Hierarchical module's name and parameters in Verilog.
+    """
+    unique_out_wires = []
+    [unique_out_wires.append(o.name+"_outid"+str(self.out.bus.index(o))) if o.is_const() or o.name in [self.a.name, self.b.name, self.c.name] else unique_out_wires.append(o.name) for o in self.out.bus]
+    return f"module {self.prefix}(input [0:0] {self.a.name}, input [0:0] {self.b.name}, input [0:0] {self.c.name}" + \
+           "".join([f", output [0:0] {o}" for o in unique_out_wires]) + ");\n"
+
def get_self_init_v_flat(self) @@ -423,6 +600,26 @@

Returns

str
Verilog flat module's inner circuit wires initialization and assignment.
+
+ +Expand source code + +
def get_self_init_v_flat(self):
+    """Generates Verilog for self flat module initialization and assignment of corresponding three input one bit circuit's input/output wires.
+
+    It is adapted for generation of general description of three input one bit circuits as well as their modified versions when some inputs are desired as constant values.
+    In such cases the inner module prototype is also modified accordingly. It is used for self three input one bit circuit flat generation.
+
+    Returns:
+        str: Verilog flat module's inner circuit wires initialization and assignment.
+    """
+    unique_out_wires = []
+    [unique_out_wires.append(o.name+"_outid"+str(self.out.bus.index(o))) if o.is_const() or o.name in [self.a.name, self.b.name, self.c.name] else unique_out_wires.append(o.name) for o in self.out.bus]
+    return "".join([c.get_assign_v_flat() if c.disable_generation is False else
+                    f"  assign {unique_out_wires.pop(unique_out_wires.index(c.out.name+'_outid'+str(c.outid)))} = {c.out.v_const};\n" if f"{c.out.name+'_outid'+str(c.outid)}" in unique_out_wires and c.out.is_const() else
+                    f"  assign {unique_out_wires.pop(unique_out_wires.index(c.out.name+'_outid'+str(c.outid)))} = {c.out.name};\n" if f"{c.out.name+'_outid'+str(c.outid)}" in unique_out_wires else
+                    f"" for c in self.components])
+
def get_self_init_v_hier(self) @@ -436,6 +633,26 @@

Returns

str
Verilog hierarchical module's inner circuit wires initialization and assignment.
+
+ +Expand source code + +
def get_self_init_v_hier(self):
+    """Generates Verilog for hierarchical module's inner initialization and assignment of corresponding arithmetic circuit's input/output wires.
+
+    It is adapted for generation of general description of three input one bit circuits as well as their modified versions when some inputs are desired as constant values.
+    In such cases the inner module prototype is also modified accordingly. It is used for self three input one bit circuit hierarchical generation.
+
+    Returns:
+        str: Verilog hierarchical module's inner circuit wires initialization and assignment.
+    """
+    unique_out_wires = []
+    [unique_out_wires.append(o.name+"_outid"+str(self.out.bus.index(o))) if o.is_const() or o.name in [self.a.name, self.b.name, self.c.name] else unique_out_wires.append(o.name) for o in self.out.bus]
+    return "".join([c.get_gate_invocation_v() if c.disable_generation is False else
+                    f"  assign {unique_out_wires.pop(unique_out_wires.index(c.out.name+'_outid'+str(c.outid)))}[0] = {c.out.v_const};\n" if f"{c.out.name+'_outid'+str(c.outid)}" in unique_out_wires and c.out.is_const() else
+                    f"  assign {unique_out_wires.pop(unique_out_wires.index(c.out.name+'_outid'+str(c.outid)))}[0] = {c.out.name}[0];\n" if f"{c.out.name+'_outid'+str(c.outid)}" in unique_out_wires else
+                    f"" for c in self.components])
+

Inherited members

@@ -537,7 +754,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/core/one_bit_circuits/two_input_one_bit_circuit.html b/core/one_bit_circuits/two_input_one_bit_circuit.html index 967615f..6fd7049 100644 --- a/core/one_bit_circuits/two_input_one_bit_circuit.html +++ b/core/one_bit_circuits/two_input_one_bit_circuit.html @@ -3,13 +3,13 @@ - + ariths_gen.core.one_bit_circuits.two_input_one_bit_circuit API documentation - + @@ -37,7 +37,7 @@

Classes

class TwoInputOneBitCircuit -(a: Wire = <ariths_gen.wire_components.wires.Wire object>, b: Wire = <ariths_gen.wire_components.wires.Wire object>, prefix: str = '', name: str = 'two_input_one_bit_circuit') +(a: Wire = <ariths_gen.wire_components.wires.Wire object>,
b: Wire = <ariths_gen.wire_components.wires.Wire object>,
prefix: str = '',
name: str = 'two_input_one_bit_circuit')

Class represents a general two input one bit circuit and implements their generation to various representations. It is derived from ArithmeticCircuit class.

@@ -426,6 +426,21 @@

Args

file_object : TextIOWrapper
Destination file object where circuit's representation will be written to.
+
+ +Expand source code + +
def get_blif_code_flat(self, file_object):
+    """Generates flat Blif code representation of corresponding one bit circuit.
+
+    Args:
+        file_object (TextIOWrapper): Destination file object where circuit's representation will be written to.
+    """
+    file_object.write(self.get_prototype_blif())
+    file_object.write(self.get_declaration_blif())
+    file_object.write(self.get_function_blif_flat(top_modul=True))
+    file_object.write(f".end\n")
+
def get_declaration_blif(self) @@ -439,6 +454,27 @@

Returns

str
Blif code containing declaration of circuit's input/output wires.
+
+ +Expand source code + +
def get_declaration_blif(self):
+    """Generates Blif code declaration of two input one bit circuit's input/output wires.
+
+    It is adapted for generation of general description of two input one bit circuits as well as their modified versions when some inputs are desired as constant values.
+    In such cases the inner modul logic is also modified accordingly. It is used for self two input one bit circuit flat/hierarchical generation.
+
+    Returns:
+        str: Blif code containing declaration of circuit's input/output wires.
+    """
+    unique_out_wires = []
+    [unique_out_wires.append(o.name+"_outid"+str(self.out.bus.index(o))) if o.is_const() or o.name in [self.a.name, self.b.name] else unique_out_wires.append(o.name) for o in self.out.bus]
+    return f".inputs {self.a.get_wire_declaration_blif()}{self.b.get_wire_declaration_blif()}\n" + \
+           f".outputs" + \
+           "".join([f" {o}" for o in unique_out_wires]) + "\n" + \
+           f".names vdd\n1\n" + \
+           f".names gnd\n0\n"
+
def get_declaration_c_flat(self) @@ -450,6 +486,19 @@

Returns

str
Flat C code containing unique declaration of circuit wires.
+
+ +Expand source code + +
def get_declaration_c_flat(self):
+    """Generates flat C code declaration of output wires.
+
+    Returns:
+        str: Flat C code containing unique declaration of circuit wires.
+    """
+    # Unique declaration of all circuit's inner components outputs
+    return "".join([c.out.get_declaration_c() for c in self.components if c.disable_generation is False])
+
def get_declaration_c_hier(self) @@ -461,6 +510,19 @@

Returns

str
Hierarchical C code containing unique declaration of circuit wires.
+
+ +Expand source code + +
def get_declaration_c_hier(self):
+    """Generates hierarchical C code declaration of output wires.
+
+    Returns:
+        str: Hierarchical C code containing unique declaration of circuit wires.
+    """
+    # Unique declaration of all circuit's inner components outputs
+    return "".join([c.out.get_declaration_c() for c in self.components if c.disable_generation is False and any(o.prefix == c.out.prefix for o in self.out.bus)])
+
def get_declaration_v_flat(self) @@ -472,6 +534,19 @@

Returns

str
Flat Verilog code containing unique declaration of one bit circuit wires.
+
+ +Expand source code + +
def get_declaration_v_flat(self):
+    """Generates flat Verilog code declaration of inner component's output wires.
+
+    Returns:
+        str: Flat Verilog code containing unique declaration of one bit circuit wires.
+    """
+    # Unique declaration of all circuit's inner components outputs
+    return "".join([c.out.get_declaration_v_flat() for c in self.components if c.disable_generation is False])
+
def get_declaration_v_hier(self) @@ -483,6 +558,19 @@

Returns

str
Hierarchical Verilog code containing unique declaration of circuit wires.
+
+ +Expand source code + +
def get_declaration_v_hier(self):
+    """Generates hierarchical Verilog code declaration of output wires.
+
+    Returns:
+        str: Hierarchical Verilog code containing unique declaration of circuit wires.
+    """
+    # Unique declaration of all circuit's inner components outputs
+    return "".join([c.out.get_declaration_v_hier() for c in self.components if c.disable_generation is False and any(o.prefix == c.out.prefix for o in self.out.bus)])
+
def get_declarations_v_flat(self) @@ -494,6 +582,19 @@

Returns

str
Flat Verilog code containing unique declaration of one bit circuit wires.
+
+ +Expand source code + +
def get_declarations_v_flat(self):
+    """Generates flat Verilog code declaration of self one bit circuit wires when described one bit circuit is a top module.
+
+    Returns:
+        str: Flat Verilog code containing unique declaration of one bit circuit wires.
+    """
+    # Unique declaration of all circuit's inner component wires
+    return "".join([c.out.get_declaration_v_flat() for c in self.components if c.disable_generation is False and not any(o.prefix == c.out.prefix for o in self.out.bus)])
+
def get_declarations_v_hier(self) @@ -505,6 +606,19 @@

Returns

str
Hierarchical Verilog code containing unique declaration of subcomponent's function block circuit wires.
+
+ +Expand source code + +
def get_declarations_v_hier(self):
+    """Generates hierarchical Verilog code declaration of input subcomponent's circuit wires.
+
+    Returns:
+        str: Hierarchical Verilog code containing unique declaration of subcomponent's function block circuit wires.
+    """
+    # Unique declaration of all circuit's inner component wires
+    return "".join([c.out.get_declaration_v_hier() for c in self.components if c.disable_generation is False and not any(o.prefix == c.out.prefix for o in self.out.bus)])
+
def get_function_blif_flat(self, top_modul: bool = False) @@ -523,6 +637,31 @@

Returns

str
Flat Blif code containing invocation of inner subcomponents logic gates Boolean functions.
+
+ +Expand source code + +
def get_function_blif_flat(self, top_modul: bool = False):
+    """Generates flat Blif code with invocation of subcomponents logic gates Boolean functions via their corresponding truth tables.
+
+    It is adapted for generation of general description of two input one bit circuits as well as their modified versions when some inputs are desired as constant values.
+    In such cases the inner modul prototype is also modified accordingly. It is used for self two input one bit circuit flat generation.
+
+    Args:
+        top_modul (bool, optional): Specifies whether the described circuit represents top modul component (self one bit circuit generation). Defaults to False.
+
+    Returns:
+        str: Flat Blif code containing invocation of inner subcomponents logic gates Boolean functions.
+    """
+    if top_modul:
+        unique_out_wires = []
+        [unique_out_wires.append(o.name+"_outid"+str(self.out.bus.index(o))) if o.is_const() or o.name in [self.a.name, self.b.name] else unique_out_wires.append(o.name) for o in self.out.bus]
+        return "".join([c.get_function_blif_flat() if c.disable_generation is False else
+                       c.out.get_assign_blif(prefix=f"{unique_out_wires.pop(unique_out_wires.index(c.out.name+'_outid'+str(c.outid)))}", output=True) if f"{c.out.name+'_outid'+str(c.outid)}" in unique_out_wires else
+                       "" for c in self.components])
+    else:
+        return "".join([c.get_function_blif_flat() for c in self.components])
+
def get_function_block_blif(self) @@ -534,6 +673,19 @@

Returns

str
Hierarchical Blif code of two input one bit circuit's function block description.
+
+ +Expand source code + +
def get_function_block_blif(self):
+    """Generates hierarchical Blif code representation of corresponding two input one bit circuit used as function block in hierarchical circuit description.
+
+    Returns:
+        str: Hierarchical Blif code of two input one bit circuit's function block description.
+    """
+    adder_block = self.__class__()
+    return f"{adder_block.get_circuit_blif()}"
+
def get_function_block_c(self) @@ -545,6 +697,19 @@

Returns

str
Hierarchical C code of two input one bit circuit's function block description.
+
+ +Expand source code + +
def get_function_block_c(self):
+    """Generates hierarchical C code representation of corresponding two input one bit circuit used as function block in hierarchical circuit description.
+
+    Returns:
+        str: Hierarchical C code of two input one bit circuit's function block description.
+    """
+    adder_block = self.__class__()
+    return f"{adder_block.get_circuit_c()}\n\n"
+
def get_function_block_v(self) @@ -556,6 +721,19 @@

Returns

str
Hierarchical Verilog code of two input one bit circuit's function block description.
+
+ +Expand source code + +
def get_function_block_v(self):
+    """Generates hierarchical Verilog code representation of corresponding two input one bit circuit used as function block in hierarchical circuit description.
+
+    Returns:
+        str: Hierarchical Verilog code of two input one bit circuit's function block description.
+    """
+    adder_block = self.__class__()
+    return f"{adder_block.get_circuit_v()}\n\n"
+
def get_function_out_c_hier(self) @@ -567,6 +745,18 @@

Returns

str
Hierarchical C code containing output bus wires assignment.
+
+ +Expand source code + +
def get_function_out_c_hier(self):
+    """Generates hierarchical C code assignment of corresponding two input one bit circuit's output wires.
+
+    Returns:
+        str: Hierarchical C code containing output bus wires assignment.
+    """
+    return self.out.return_bus_wires_values_c_flat()
+
def get_init_c_flat(self) @@ -578,6 +768,18 @@

Returns

str
Flat C code initialization of two input one bit circuit output wires.
+
+ +Expand source code + +
def get_init_c_flat(self):
+    """Generates flat C code initialization and assignment of corresponding two input one bit circuit's output wires.
+
+    Returns:
+        str: Flat C code initialization of two input one bit circuit output wires.
+    """
+    return "".join([c.get_assign_c_flat() for c in self.components])
+
def get_init_v_flat(self) @@ -589,6 +791,18 @@

Returns

str
Flat Verilog code initialization of two input one bit circuit wires.
+
+ +Expand source code + +
def get_init_v_flat(self):
+    """Generates flat Verilog code initialization and assignment of corresponding two input one bit circuit's input/output wires.
+
+    Returns:
+        str: Flat Verilog code initialization of two input one bit circuit wires.
+    """
+    return "".join([c.get_assign_v_flat() for c in self.components])
+
def get_invocation_blif_hier(self) @@ -600,6 +814,19 @@

Returns

str
Hierarchical Blif code subcomponent's model invocation.
+
+ +Expand source code + +
def get_invocation_blif_hier(self):
+    """Generates hierarchical Blif code invocation of corresponding two input one bit circuit's generated function block.
+
+    Returns:
+        str: Hierarchical Blif code subcomponent's model invocation.
+    """
+    circuit_block = self.__class__()
+    return f".subckt {circuit_block.prefix} {circuit_block.a.prefix}={self.a.get_wire_value_blif()} {circuit_block.b.prefix}={self.b.get_wire_value_blif()}{self.out.get_unique_assign_out_wires_blif(function_block_out_bus=circuit_block.out)}\n"
+
def get_invocations_blif_hier(self) @@ -613,6 +840,25 @@

Returns

str
Hierarchical Blif code containing invocation of inner subcomponents function blocks.
+
+ +Expand source code + +
def get_invocations_blif_hier(self):
+    """Generates hierarchical Blif code with invocation of subcomponents function blocks.
+
+    It is adapted for generation of general description of two input one bit circuits as well as their modified versions when some inputs are desired as constant values.
+    In such cases the inner modul prototype is also modified accordingly. It is used for self two input one bit circuit hierarchical generation.
+
+    Returns:
+        str: Hierarchical Blif code containing invocation of inner subcomponents function blocks.
+    """
+    unique_out_wires = []
+    [unique_out_wires.append(o.name+"_outid"+str(self.out.bus.index(o))) if o.is_const() or o.name in [self.a.name, self.b.name] else unique_out_wires.append(o.name) for o in self.out.bus]
+    return "".join([c.get_invocation_blif_hier() if c.disable_generation is False else
+                   c.out.get_assign_blif(prefix=f"{unique_out_wires.pop(unique_out_wires.index(c.out.name+'_outid'+str(c.outid)))}", output=True) if f"{c.out.name+'_outid'+str(c.outid)}" in unique_out_wires else
+                   "" for c in self.components])
+
def get_out_invocation_c(self) @@ -626,6 +872,25 @@

Returns

str
Hierarchical C code subcomponent's C function invocation and output assignment.
+
+ +Expand source code + +
def get_out_invocation_c(self):
+    """Generates hierarchical C code invocation of corresponding two input one bit circuit's generated function block.
+
+    Assigns output values from invocation of the corresponding function block into inner wires present inside the upper
+    component from which function block has been invoked.
+
+    Returns:
+        str: Hierarchical C code subcomponent's C function invocation and output assignment.
+    """
+    # Used to retrieve proper component's output wire offset position within the output bus
+    output_bus_wire_names = []
+    [output_bus_wire_names.append(w.prefix) for w in self.out.bus]
+    circuit_block = self.__class__()
+    return "".join([f"  {c.out.prefix} = ({circuit_block.prefix}({self.a.get_wire_value_c_hier()}, {self.b.get_wire_value_c_hier()}) >> {output_bus_wire_names.index(c.out.prefix)}) & 0x01;\n" for c in self.components if c.disable_generation is False and c.out.prefix in output_bus_wire_names])
+
def get_out_invocation_v(self) @@ -639,6 +904,22 @@

Returns

str
Hierarchical Verilog code subcomponent's module invocation and output assignment.
+
+ +Expand source code + +
def get_out_invocation_v(self):
+    """Generates hierarchical Verilog code invocation of corresponding two input one bit circuit's generated function block.
+
+    Assigns output values from invocation of the corresponding function block into inner wires present inside the upper
+    component from which function block has been invoked.
+
+    Returns:
+        str: Hierarchical Verilog code subcomponent's module invocation and output assignment.
+    """
+    circuit_block = self.__class__()
+    return f"  {circuit_block.prefix} {circuit_block.prefix}_{self.out.prefix}(.{circuit_block.a.prefix}({self.a.get_wire_value_v_hier()}), .{circuit_block.b.prefix}({self.b.get_wire_value_v_hier()}){self.out.get_unique_assign_out_wires_v(circuit_block)});\n"
+
def get_parameters_cgp(self) @@ -652,6 +933,22 @@

Returns

str
CGP chromosome parameters of described circuit.
+
+ +Expand source code + +
def get_parameters_cgp(self):
+    """Generates CGP chromosome parameters of corresponding two input one bit circuit.
+
+    In total seven parameters represent: total inputs, total outputs, number of rows, number of columns (gates),
+    number of each gate's inputs, number of each gate's outputs, quality constant value.
+
+    Returns:
+        str: CGP chromosome parameters of described circuit.
+    """
+    self.circuit_gates = self.get_circuit_gates()
+    return f"{{2,{self.out.N},1,{len(self.circuit_gates)},2,1,0}}"
+
def get_prototype_v(self) @@ -665,6 +962,24 @@

Returns

str
Flat module's name and parameters in Verilog.
+
+ +Expand source code + +
def get_prototype_v(self):
+    """Generates Verilog for flat module header to describe corresponding two input one bit circuit's interface in Verilog.
+
+    It is adapted for generation of general description of two input one bit circuits as well as their modified versions when some inputs are desired as constant values.
+    In such cases the inner module logic is also modified accordingly. It is used for self two input one bit circuit flat generation.
+
+    Returns:
+        str: Flat module's name and parameters in Verilog.
+    """
+    unique_out_wires = []
+    [unique_out_wires.append(o.name+"_outid"+str(self.out.bus.index(o))) if o.is_const() or o.name in [self.a.name, self.b.name] else unique_out_wires.append(o.name) for o in self.out.bus]
+    return f"module {self.prefix}(input {self.a.name}, input {self.b.name}" + \
+           "".join([f", output {o}" for o in unique_out_wires]) + ");\n"
+
def get_prototype_v_hier(self) @@ -678,6 +993,24 @@

Returns

str
Hierarchical module's name and parameters in Verilog.
+
+ +Expand source code + +
def get_prototype_v_hier(self):
+    """Generates Verilog for hierarchical module header to describe corresponding two input one bit circuit's interface in Verilog.
+
+    It is adapted for generation of general description of two input one bit circuits as well as their modified versions when some inputs are desired as constant values.
+    In such cases the inner module logic is also modified accordingly. It is used for self two input one bit circuit hierarchical generation.
+
+    Returns:
+        str: Hierarchical module's name and parameters in Verilog.
+    """
+    unique_out_wires = []
+    [unique_out_wires.append(o.name+"_outid"+str(self.out.bus.index(o))) if o.is_const() or o.name in [self.a.name, self.b.name] else unique_out_wires.append(o.name) for o in self.out.bus]
+    return f"module {self.prefix}(input [0:0] {self.a.name}, input [0:0] {self.b.name}" + \
+           "".join([f", output [0:0] {o}" for o in unique_out_wires]) + ");\n"
+
def get_self_init_v_flat(self) @@ -691,6 +1024,26 @@

Returns

str
Verilog flat module's inner circuit wires initialization and assignment.
+
+ +Expand source code + +
def get_self_init_v_flat(self):
+    """Generates Verilog for self flat module initialization and assignment of corresponding two input one bit circuit's input/output wires.
+
+    It is adapted for generation of general description of two input one bit circuits as well as their modified versions when some inputs are desired as constant values.
+    In such cases the inner module prototype is also modified accordingly. It is used for self two input one bit circuit flat generation.
+
+    Returns:
+        str: Verilog flat module's inner circuit wires initialization and assignment.
+    """
+    unique_out_wires = []
+    [unique_out_wires.append(o.name+"_outid"+str(self.out.bus.index(o))) if o.is_const() or o.name in [self.a.name, self.b.name] else unique_out_wires.append(o.name) for o in self.out.bus]
+    return "".join([c.get_assign_v_flat() if c.disable_generation is False else
+                    f"  assign {unique_out_wires.pop(unique_out_wires.index(c.out.name+'_outid'+str(c.outid)))} = {c.out.v_const};\n" if f"{c.out.name+'_outid'+str(c.outid)}" in unique_out_wires and c.out.is_const() else
+                    f"  assign {unique_out_wires.pop(unique_out_wires.index(c.out.name+'_outid'+str(c.outid)))} = {c.out.name};\n" if f"{c.out.name+'_outid'+str(c.outid)}" in unique_out_wires else
+                    f"" for c in self.components])
+
def get_self_init_v_hier(self) @@ -704,6 +1057,26 @@

Returns

str
Verilog hierarchical module's inner circuit wires initialization and assignment.
+
+ +Expand source code + +
def get_self_init_v_hier(self):
+    """Generates Verilog for hierarchical module's inner initialization and assignment of corresponding arithmetic circuit's input/output wires.
+
+    It is adapted for generation of general description of two input one bit circuits as well as their modified versions when some inputs are desired as constant values.
+    In such cases the inner module prototype is also modified accordingly. It is used for self two input one bit circuit hierarchical generation.
+
+    Returns:
+        str: Verilog hierarchical module's inner circuit wires initialization and assignment.
+    """
+    unique_out_wires = []
+    [unique_out_wires.append(o.name+"_outid"+str(self.out.bus.index(o))) if o.is_const() or o.name in [self.a.name, self.b.name] else unique_out_wires.append(o.name) for o in self.out.bus]
+    return "".join([c.get_gate_invocation_v() if c.disable_generation is False else
+                    f"  assign {unique_out_wires.pop(unique_out_wires.index(c.out.name+'_outid'+str(c.outid)))}[0] = {c.out.v_const};\n" if f"{c.out.name+'_outid'+str(c.outid)}" in unique_out_wires and c.out.is_const() else
+                    f"  assign {unique_out_wires.pop(unique_out_wires.index(c.out.name+'_outid'+str(c.outid)))}[0] = {c.out.name}[0];\n" if f"{c.out.name+'_outid'+str(c.outid)}" in unique_out_wires else
+                    f"" for c in self.components])
+
def get_v_code_flat(self, file_object) @@ -715,6 +1088,21 @@

Args

file_object : TextIOWrapper
Destination file object where circuit's representation will be written to.
+
+ +Expand source code + +
def get_v_code_flat(self, file_object):
+    """Generates flat Verilog code representation of corresponding one bit circuit.
+
+    Args:
+        file_object (TextIOWrapper): Destination file object where circuit's representation will be written to.
+    """
+    file_object.write(self.get_prototype_v())
+    file_object.write(self.get_declarations_v_flat())
+    file_object.write(self.get_self_init_v_flat())
+    file_object.write(f"endmodule")
+

Inherited members

@@ -816,7 +1204,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/index.html b/index.html index 9f9fe8d..fc9d141 100644 --- a/index.html +++ b/index.html @@ -3,13 +3,13 @@ - + ariths_gen API documentation - + @@ -76,7 +76,7 @@

Sub-modules

diff --git a/multi_bit_circuits/adders/brent_kung_adder.html b/multi_bit_circuits/adders/brent_kung_adder.html index 399e5cf..e3a88b4 100644 --- a/multi_bit_circuits/adders/brent_kung_adder.html +++ b/multi_bit_circuits/adders/brent_kung_adder.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.adders.brent_kung_adder API documentation - + @@ -37,7 +37,7 @@

Classes

class SignedBrentKungAdder -(a: Bus, b: Bus, prefix: str = '', name: str = 's_bka', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 's_bka',
**kwargs)

Class representing signed Brent-Kung adder (using valency-2 logic gates).

@@ -225,7 +225,7 @@

Inherited members

class UnsignedBrentKungAdder -(a: Bus, b: Bus, prefix: str = '', name: str = 'u_bka', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'u_bka',
**kwargs)

Class representing unsigned Brent-Kung adder (using valency-2 logic gates).

@@ -500,7 +500,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/adders/carry_increment_adder.html b/multi_bit_circuits/adders/carry_increment_adder.html index 606f409..2ca8846 100644 --- a/multi_bit_circuits/adders/carry_increment_adder.html +++ b/multi_bit_circuits/adders/carry_increment_adder.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.adders.carry_increment_adder API documentation - + @@ -37,7 +37,7 @@

Classes

class SignedCarryIncrementAdder -(a: Bus, b: Bus, increment_block_size: int = 4, prefix: str = '', name: str = 's_cia', **kwargs) +(a: Bus,
b: Bus,
increment_block_size: int = 4,
prefix: str = '',
name: str = 's_cia',
**kwargs)

Class representing signed carry increment adder.

@@ -217,7 +217,7 @@

Inherited members

class UnsignedCarryIncrementAdder -(a: Bus, b: Bus, increment_block_size: int = 4, prefix: str = '', name: str = 'u_cia', **kwargs) +(a: Bus,
b: Bus,
increment_block_size: int = 4,
prefix: str = '',
name: str = 'u_cia',
**kwargs)

Class representing unsigned carry increment adder.

@@ -452,7 +452,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/adders/carry_lookahead_adder.html b/multi_bit_circuits/adders/carry_lookahead_adder.html index b5b0eaf..5fbe7b0 100644 --- a/multi_bit_circuits/adders/carry_lookahead_adder.html +++ b/multi_bit_circuits/adders/carry_lookahead_adder.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.adders.carry_lookahead_adder API documentation - + @@ -37,7 +37,7 @@

Classes

class SignedCarryLookaheadAdder -(a: Bus, b: Bus, cla_block_size: int = 4, prefix: str = '', name: str = 's_cla', **kwargs) +(a: Bus,
b: Bus,
cla_block_size: int = 4,
prefix: str = '',
name: str = 's_cla',
**kwargs)

Class representing signed carry-lookahead adder.

@@ -205,7 +205,7 @@

Inherited members

class UnsignedCarryLookaheadAdder -(a: Bus, b: Bus, cla_block_size: int = 4, prefix: str = '', name: str = 'u_cla', **kwargs) +(a: Bus,
b: Bus,
cla_block_size: int = 4,
prefix: str = '',
name: str = 'u_cla',
**kwargs)

Class representing unsigned carry-lookahead adder.

@@ -451,7 +451,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/adders/carry_save_adder.html b/multi_bit_circuits/adders/carry_save_adder.html index 1ae2d35..5549b4c 100644 --- a/multi_bit_circuits/adders/carry_save_adder.html +++ b/multi_bit_circuits/adders/carry_save_adder.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.adders.carry_save_adder API documentation - + @@ -37,7 +37,7 @@

Classes

class CarrySaveAdderComponent -(a: Bus, b: Bus, c: Bus, prefix: str = '', name: str = 'csa_component', signed: bool = False, **kwargs) +(a: Bus,
b: Bus,
c: Bus,
prefix: str = '',
name: str = 'csa_component',
signed: bool = False,
**kwargs)

Class representing carry save adder component.

@@ -218,7 +218,7 @@

Inherited members

class UnsignedCarrySaveAdder -(a: Bus, b: Bus, c: Bus, prefix: str = '', name: str = 'u_csa', unsigned_adder_class_name: str = ariths_gen.multi_bit_circuits.adders.carry_lookahead_adder.UnsignedCarryLookaheadAdder, **kwargs) +(a: Bus,
b: Bus,
c: Bus,
prefix: str = '',
name: str = 'u_csa',
unsigned_adder_class_name: str = ariths_gen.multi_bit_circuits.adders.carry_lookahead_adder.UnsignedCarryLookaheadAdder,
**kwargs)

Class representing unsigned carry save adder.

@@ -420,7 +420,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/adders/carry_select_adder.html b/multi_bit_circuits/adders/carry_select_adder.html index 8eb895b..9024560 100644 --- a/multi_bit_circuits/adders/carry_select_adder.html +++ b/multi_bit_circuits/adders/carry_select_adder.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.adders.carry_select_adder API documentation - + @@ -37,7 +37,7 @@

Classes

class SignedCarrySelectAdder -(a: Bus, b: Bus, select_block_size: int = 4, prefix: str = '', name: str = 's_csla', **kwargs) +(a: Bus,
b: Bus,
select_block_size: int = 4,
prefix: str = '',
name: str = 's_csla',
**kwargs)

Class representing signed carry select adder.

@@ -219,7 +219,7 @@

Inherited members

class UnsignedCarrySelectAdder -(a: Bus, b: Bus, select_block_size: int = 4, prefix: str = '', name: str = 'u_csla', **kwargs) +(a: Bus,
b: Bus,
select_block_size: int = 4,
prefix: str = '',
name: str = 'u_csla',
**kwargs)

Class representing unsigned carry select adder.

@@ -470,7 +470,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/adders/carry_skip_adder.html b/multi_bit_circuits/adders/carry_skip_adder.html index 991968a..1026d08 100644 --- a/multi_bit_circuits/adders/carry_skip_adder.html +++ b/multi_bit_circuits/adders/carry_skip_adder.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.adders.carry_skip_adder API documentation - + @@ -37,7 +37,7 @@

Classes

class SignedCarrySkipAdder -(a: Bus, b: Bus, bypass_block_size: int = 4, prefix: str = '', name: str = 's_cska', **kwargs) +(a: Bus,
b: Bus,
bypass_block_size: int = 4,
prefix: str = '',
name: str = 's_cska',
**kwargs)

Class representing signed carry skip (bypass) adder composed of smaller carry bypass blocks of chosen size to reduce propagation delay.

@@ -216,7 +216,7 @@

Inherited members

class UnsignedCarrySkipAdder -(a: Bus, b: Bus, bypass_block_size: int = 4, prefix: str = '', name: str = 'u_cska', **kwargs) +(a: Bus,
b: Bus,
bypass_block_size: int = 4,
prefix: str = '',
name: str = 'u_cska',
**kwargs)

Class representing unsigned carry skip (bypass) adder composed of smaller carry bypass blocks of chosen size to reduce propagation delay.

@@ -459,7 +459,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/adders/conditional_sum_adder.html b/multi_bit_circuits/adders/conditional_sum_adder.html index 8e7b068..edf3b13 100644 --- a/multi_bit_circuits/adders/conditional_sum_adder.html +++ b/multi_bit_circuits/adders/conditional_sum_adder.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.adders.conditional_sum_adder API documentation - + @@ -37,7 +37,7 @@

Classes

class SignedConditionalSumAdder -(a: Bus, b: Bus, prefix: str = '', name: str = 's_cosa', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 's_cosa',
**kwargs)

Class representing signed conditional sum adder.

@@ -432,7 +432,7 @@

Inherited members

class UnsignedConditionalSumAdder -(a: Bus, b: Bus, prefix: str = '', name: str = 'u_cosa', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'u_cosa',
**kwargs)

Class representing unsigned conditional sum adder.

@@ -777,7 +777,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/adders/han_carlson_adder.html b/multi_bit_circuits/adders/han_carlson_adder.html index cb6c451..fea767b 100644 --- a/multi_bit_circuits/adders/han_carlson_adder.html +++ b/multi_bit_circuits/adders/han_carlson_adder.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.adders.han_carlson_adder API documentation - + @@ -37,7 +37,7 @@

Classes

class SignedHanCarlsonAdder -(a: Bus, b: Bus, prefix: str = '', name: str = 's_hca', config_choice: int = 1, **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 's_hca',
config_choice: int = 1,
**kwargs)

Class representing signed Han-Carlson adder (using valency-2 logic gates).

@@ -228,7 +228,7 @@

Inherited members

class UnsignedHanCarlsonAdder -(a: Bus, b: Bus, prefix: str = '', name: str = 'u_hca', config_choice: int = 1, **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'u_hca',
config_choice: int = 1,
**kwargs)

Class representing unsigned Han-Carlson adder (using valency-2 logic gates).

@@ -534,7 +534,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/adders/index.html b/multi_bit_circuits/adders/index.html index 4e7f4e5..c7630f4 100644 --- a/multi_bit_circuits/adders/index.html +++ b/multi_bit_circuits/adders/index.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.adders API documentation - + @@ -126,7 +126,7 @@

Sub-modules

diff --git a/multi_bit_circuits/adders/knowles_adder.html b/multi_bit_circuits/adders/knowles_adder.html index edfcf94..4555fd4 100644 --- a/multi_bit_circuits/adders/knowles_adder.html +++ b/multi_bit_circuits/adders/knowles_adder.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.adders.knowles_adder API documentation - + @@ -37,7 +37,7 @@

Classes

class SignedKnowlesAdder -(a: Bus, b: Bus, prefix: str = '', name: str = 's_ka', config_choice: int = 1, **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 's_ka',
config_choice: int = 1,
**kwargs)

Class representing signed Knowles adder (using valency-2 logic gates).

@@ -228,7 +228,7 @@

Inherited members

class UnsignedKnowlesAdder -(a: Bus, b: Bus, prefix: str = '', name: str = 'u_ka', config_choice: int = 1, **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'u_ka',
config_choice: int = 1,
**kwargs)

Class representing unsigned Knowles adder (using valency-2 logic gates).

@@ -493,7 +493,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/adders/kogge_stone_adder.html b/multi_bit_circuits/adders/kogge_stone_adder.html index 56ac866..21607e6 100644 --- a/multi_bit_circuits/adders/kogge_stone_adder.html +++ b/multi_bit_circuits/adders/kogge_stone_adder.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.adders.kogge_stone_adder API documentation - + @@ -37,7 +37,7 @@

Classes

class SignedKoggeStoneAdder -(a: Bus, b: Bus, prefix: str = '', name: str = 's_ksa', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 's_ksa',
**kwargs)

Class representing signed Kogge-Stone adder (using valency-2 logic gates).

@@ -223,7 +223,7 @@

Inherited members

class UnsignedKoggeStoneAdder -(a: Bus, b: Bus, prefix: str = '', name: str = 'u_ksa', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'u_ksa',
**kwargs)

Class representing unsigned Kogge-Stone adder (using valency-2 logic gates).

@@ -471,7 +471,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/adders/ladner_fischer_adder.html b/multi_bit_circuits/adders/ladner_fischer_adder.html index 7f95ab1..a1b769d 100644 --- a/multi_bit_circuits/adders/ladner_fischer_adder.html +++ b/multi_bit_circuits/adders/ladner_fischer_adder.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.adders.ladner_fischer_adder API documentation - + @@ -37,7 +37,7 @@

Classes

class SignedLadnerFischerAdder -(a: Bus, b: Bus, prefix: str = '', name: str = 's_lfa', config_choice: int = 1, **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 's_lfa',
config_choice: int = 1,
**kwargs)

Class representing signed Ladner-Fischer adder (using valency-2 logic gates).

@@ -228,7 +228,7 @@

Inherited members

class UnsignedLadnerFischerAdder -(a: Bus, b: Bus, prefix: str = '', name: str = 'u_lfa', config_choice: int = 1, **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'u_lfa',
config_choice: int = 1,
**kwargs)

Class representing unsigned Ladner-Fischer adder (using valency-2 logic gates).

@@ -538,7 +538,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/adders/pg_ripple_carry_adder.html b/multi_bit_circuits/adders/pg_ripple_carry_adder.html index 4147f04..c16e9dc 100644 --- a/multi_bit_circuits/adders/pg_ripple_carry_adder.html +++ b/multi_bit_circuits/adders/pg_ripple_carry_adder.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.adders.pg_ripple_carry_adder API documentation - + @@ -37,7 +37,7 @@

Classes

class SignedPGRippleCarryAdder -(a: Bus, b: Bus, prefix: str = '', name: str = 's_pg_rca', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 's_pg_rca',
**kwargs)

Class representing signed ripple carry adder with propagate/generate logic.

@@ -216,7 +216,7 @@

Inherited members

class UnsignedPGRippleCarryAdder -(a: Bus, b: Bus, prefix: str = '', name: str = 'u_pg_rca', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'u_pg_rca',
**kwargs)

Class representing unsigned ripple carry adder with propagate/generate logic.

@@ -438,7 +438,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/adders/ripple_carry_adder.html b/multi_bit_circuits/adders/ripple_carry_adder.html index af4f309..12c63c1 100644 --- a/multi_bit_circuits/adders/ripple_carry_adder.html +++ b/multi_bit_circuits/adders/ripple_carry_adder.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.adders.ripple_carry_adder API documentation - + @@ -37,7 +37,7 @@

Classes

class SignedRippleCarryAdder -(a: Bus, b: Bus, prefix: str = '', name: str = 's_rca', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 's_rca',
**kwargs)

Class representing signed ripple carry adder.

@@ -186,7 +186,7 @@

Inherited members

class UnsignedRippleCarryAdder -(a: Bus, b: Bus, prefix: str = '', name: str = 'u_rca', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'u_rca',
**kwargs)

Class representing unsigned ripple carry adder.

@@ -373,7 +373,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/adders/sklansky_adder.html b/multi_bit_circuits/adders/sklansky_adder.html index e366ab8..2a342f9 100644 --- a/multi_bit_circuits/adders/sklansky_adder.html +++ b/multi_bit_circuits/adders/sklansky_adder.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.adders.sklansky_adder API documentation - + @@ -37,7 +37,7 @@

Classes

class SignedSklanskyAdder -(a: Bus, b: Bus, prefix: str = '', name: str = 's_sa', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 's_sa',
**kwargs)

Class representing signed Sklansky (or divide-and-conquer) adder (using valency-2 logic gates).

@@ -223,7 +223,7 @@

Inherited members

class UnsignedSklanskyAdder -(a: Bus, b: Bus, prefix: str = '', name: str = 'u_sa', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'u_sa',
**kwargs)

Class representing unsigned Sklansky (or divide-and-conquer) adder (using valency-2 logic gates).

@@ -475,7 +475,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/approximate_adders/index.html b/multi_bit_circuits/approximate_adders/index.html index 5cc7088..425e5e7 100644 --- a/multi_bit_circuits/approximate_adders/index.html +++ b/multi_bit_circuits/approximate_adders/index.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.approximate_adders API documentation - + @@ -61,7 +61,7 @@

Sub-modules

diff --git a/multi_bit_circuits/approximate_adders/quad.html b/multi_bit_circuits/approximate_adders/quad.html index fbef710..d8d5ea6 100644 --- a/multi_bit_circuits/approximate_adders/quad.html +++ b/multi_bit_circuits/approximate_adders/quad.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.approximate_adders.quad API documentation - + @@ -262,6 +262,14 @@

Methods

+
+ +Expand source code + +
def log(self, *args):
+    if self.use_log:
+        print(*args)
+

Inherited members

@@ -360,7 +368,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/approximate_multipliers/broken_array_multiplier.html b/multi_bit_circuits/approximate_multipliers/broken_array_multiplier.html index 1007d73..8abbe29 100644 --- a/multi_bit_circuits/approximate_multipliers/broken_array_multiplier.html +++ b/multi_bit_circuits/approximate_multipliers/broken_array_multiplier.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.approximate_multipliers.broken_array_multiplier API documentation - + @@ -37,7 +37,7 @@

Classes

class UnsignedBrokenArrayMultiplier -(a: Bus, b: Bus, horizontal_cut: int = 0, vertical_cut: int = 0, prefix: str = '', name: str = 'u_bam', **kwargs) +(a: Bus,
b: Bus,
horizontal_cut: int = 0,
vertical_cut: int = 0,
prefix: str = '',
name: str = 'u_bam',
**kwargs)

Class representing unsigned broken array multiplier.

@@ -365,7 +365,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/approximate_multipliers/broken_carry_save_multiplier.html b/multi_bit_circuits/approximate_multipliers/broken_carry_save_multiplier.html index 7a79c2d..dc549f1 100644 --- a/multi_bit_circuits/approximate_multipliers/broken_carry_save_multiplier.html +++ b/multi_bit_circuits/approximate_multipliers/broken_carry_save_multiplier.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.approximate_multipliers.broken_carry_save_multiplier API documentation - + @@ -37,7 +37,7 @@

Classes

class UnsignedBrokenCarrySaveMultiplier -(a: Bus, b: Bus, horizontal_cut: int = 0, vertical_cut: int = 0, prefix: str = '', name: str = 'u_bamcsa', unsigned_adder_class_name: str = ariths_gen.multi_bit_circuits.adders.carry_lookahead_adder.UnsignedCarryLookaheadAdder, **kwargs) +(a: Bus,
b: Bus,
horizontal_cut: int = 0,
vertical_cut: int = 0,
prefix: str = '',
name: str = 'u_bamcsa',
unsigned_adder_class_name: str = ariths_gen.multi_bit_circuits.adders.carry_lookahead_adder.UnsignedCarryLookaheadAdder,
**kwargs)

Class representing unsigned broken carry save (Braun) multiplier.

@@ -415,7 +415,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/approximate_multipliers/index.html b/multi_bit_circuits/approximate_multipliers/index.html index 1beb28e..2d3769d 100644 --- a/multi_bit_circuits/approximate_multipliers/index.html +++ b/multi_bit_circuits/approximate_multipliers/index.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.approximate_multipliers API documentation - + @@ -81,7 +81,7 @@

Sub-modules

diff --git a/multi_bit_circuits/approximate_multipliers/recursive_multiplier.html b/multi_bit_circuits/approximate_multipliers/recursive_multiplier.html index ce1492a..9b070e0 100644 --- a/multi_bit_circuits/approximate_multipliers/recursive_multiplier.html +++ b/multi_bit_circuits/approximate_multipliers/recursive_multiplier.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.approximate_multipliers.recursive_multiplier API documentation - + @@ -37,7 +37,7 @@

Classes

class SignedAccurateTwoBitMultiplier -(a: Bus, b: Bus, prefix: str = '', name: str = 's_2bit_accm', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 's_2bit_accm',
**kwargs)

Class representing signed two-bit accurate multiplier.

@@ -159,7 +159,7 @@

Inherited members

class SignedApproximateTwoBitMultiplierM1 -(a: Bus, b: Bus, prefix: str = '', name: str = 's_2bit_axm1', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 's_2bit_axm1',
**kwargs)

Class representing signed two-bit approximate multiplier variant M1.

@@ -280,7 +280,7 @@

Inherited members

class SignedApproximateTwoBitMultiplierM2 -(a: Bus, b: Bus, prefix: str = '', name: str = 's_2bit_axm2', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 's_2bit_axm2',
**kwargs)

Class representing signed two-bit approximate multiplier variant M2.

@@ -401,7 +401,7 @@

Inherited members

class SignedApproximateTwoBitMultiplierM3 -(a: Bus, b: Bus, prefix: str = '', name: str = 's_2bit_axm3', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 's_2bit_axm3',
**kwargs)

Class representing signed two-bit approximate multiplier variant M3.

@@ -522,7 +522,7 @@

Inherited members

class SignedApproximateTwoBitMultiplierM4 -(a: Bus, b: Bus, prefix: str = '', name: str = 's_2bit_axm4', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 's_2bit_axm4',
**kwargs)

Class representing signed two-bit approximate multiplier variant M4.

@@ -643,7 +643,7 @@

Inherited members

class SignedRecursiveMultiplier -(a: Bus, b: Bus, prefix: str = '', name: str = 's_rm', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 's_rm',
**kwargs)

Class representing signed recursive multiplier.

@@ -766,7 +766,7 @@

Inherited members

class UnsignedAccurateTwoBitMultiplier -(a: Bus, b: Bus, prefix: str = '', name: str = 'u_2bit_accm', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'u_2bit_accm',
**kwargs)

Class representing unsigned two-bit accurate multiplier.

@@ -951,7 +951,7 @@

Inherited members

class UnsignedApproximateTwoBitMultiplierM1 -(a: Bus, b: Bus, prefix: str = '', name: str = 'u_2bit_axm1', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'u_2bit_axm1',
**kwargs)

Class representing unsigned two-bit approximate multiplier variant M1.

@@ -1124,7 +1124,7 @@

Inherited members

class UnsignedApproximateTwoBitMultiplierM2 -(a: Bus, b: Bus, prefix: str = '', name: str = 'u_2bit_axm1', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'u_2bit_axm1',
**kwargs)

Class representing unsigned two-bit approximate multiplier variant M2.

@@ -1313,7 +1313,7 @@

Inherited members

class UnsignedApproximateTwoBitMultiplierM3 -(a: Bus, b: Bus, prefix: str = '', name: str = 'u_2bit_axm3', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'u_2bit_axm3',
**kwargs)

Class representing unsigned two-bit approximate multiplier variant M3.

@@ -1512,7 +1512,7 @@

Inherited members

class UnsignedApproximateTwoBitMultiplierM4 -(a: Bus, b: Bus, prefix: str = '', name: str = 'u_2bit_axm4', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'u_2bit_axm4',
**kwargs)

Class representing unsigned two-bit approximate multiplier variant M4.

@@ -1685,7 +1685,7 @@

Inherited members

class UnsignedRecursiveMultiplier -(a: Bus, b: Bus, prefix: str = '', name: str = 'u_rm', submultipliers: list = None, unsigned_adder_class_name: str = ariths_gen.multi_bit_circuits.adders.carry_lookahead_adder.UnsignedCarryLookaheadAdder, **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'u_rm',
submultipliers: list = None,
unsigned_adder_class_name: str = ariths_gen.multi_bit_circuits.adders.carry_lookahead_adder.UnsignedCarryLookaheadAdder,
**kwargs)

Class representing unsigned recursive multiplier.

@@ -1967,7 +1967,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/approximate_multipliers/truncated_array_multiplier.html b/multi_bit_circuits/approximate_multipliers/truncated_array_multiplier.html index c6c50d8..6cd7bd5 100644 --- a/multi_bit_circuits/approximate_multipliers/truncated_array_multiplier.html +++ b/multi_bit_circuits/approximate_multipliers/truncated_array_multiplier.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.approximate_multipliers.truncated_array_multiplier API documentation - + @@ -37,7 +37,7 @@

Classes

class UnsignedTruncatedArrayMultiplier -(a: Bus, b: Bus, truncation_cut: int = 0, prefix: str = '', name: str = 'u_tm', **kwargs) +(a: Bus,
b: Bus,
truncation_cut: int = 0,
prefix: str = '',
name: str = 'u_tm',
**kwargs)

Class representing unsigned truncated array multiplier.

@@ -325,7 +325,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/approximate_multipliers/truncated_carry_save_multiplier.html b/multi_bit_circuits/approximate_multipliers/truncated_carry_save_multiplier.html index 7beadcd..2c12cdb 100644 --- a/multi_bit_circuits/approximate_multipliers/truncated_carry_save_multiplier.html +++ b/multi_bit_circuits/approximate_multipliers/truncated_carry_save_multiplier.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.approximate_multipliers.truncated_carry_save_multiplier API documentation - + @@ -37,7 +37,7 @@

Classes

class UnsignedTruncatedCarrySaveMultiplier -(a: Bus, b: Bus, truncation_cut: int = 0, prefix: str = '', name: str = 'u_tmcsa', unsigned_adder_class_name: str = ariths_gen.multi_bit_circuits.adders.carry_lookahead_adder.UnsignedCarryLookaheadAdder, **kwargs) +(a: Bus,
b: Bus,
truncation_cut: int = 0,
prefix: str = '',
name: str = 'u_tmcsa',
unsigned_adder_class_name: str = ariths_gen.multi_bit_circuits.adders.carry_lookahead_adder.UnsignedCarryLookaheadAdder,
**kwargs)

Class representing unsigned truncated carry save (Braun) multiplier.

@@ -365,7 +365,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/dividers/array_divider.html b/multi_bit_circuits/dividers/array_divider.html index 6eafe22..7fc51c5 100644 --- a/multi_bit_circuits/dividers/array_divider.html +++ b/multi_bit_circuits/dividers/array_divider.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.dividers.array_divider API documentation - + @@ -37,7 +37,7 @@

Classes

class ArrayDivider -(a: Bus, b: Bus, prefix: str = '', name: str = 'arrdiv', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'arrdiv',
**kwargs)

Class representing array divider.

@@ -310,7 +310,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/dividers/index.html b/multi_bit_circuits/dividers/index.html index bf045d3..92e28c3 100644 --- a/multi_bit_circuits/dividers/index.html +++ b/multi_bit_circuits/dividers/index.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.dividers API documentation - + @@ -61,7 +61,7 @@

Sub-modules

diff --git a/multi_bit_circuits/index.html b/multi_bit_circuits/index.html index 2252a6f..ab7d786 100644 --- a/multi_bit_circuits/index.html +++ b/multi_bit_circuits/index.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits API documentation - + @@ -91,7 +91,7 @@

Sub-modules

diff --git a/multi_bit_circuits/multipliers/array_multiplier.html b/multi_bit_circuits/multipliers/array_multiplier.html index d45418f..3b1699d 100644 --- a/multi_bit_circuits/multipliers/array_multiplier.html +++ b/multi_bit_circuits/multipliers/array_multiplier.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.multipliers.array_multiplier API documentation - + @@ -37,7 +37,7 @@

Classes

class SignedArrayMultiplier -(a: Bus, b: Bus, prefix: str = '', name: str = 's_arrmul', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 's_arrmul',
**kwargs)

Class representing signed array multiplier.

@@ -302,7 +302,7 @@

Inherited members

class UnsignedArrayMultiplier -(a: Bus, b: Bus, prefix: str = '', name: str = 'u_arrmul', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'u_arrmul',
**kwargs)

Class representing unsigned array multiplier.

@@ -583,7 +583,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/multipliers/carry_save_multiplier.html b/multi_bit_circuits/multipliers/carry_save_multiplier.html index 4e26ddb..698cbca 100644 --- a/multi_bit_circuits/multipliers/carry_save_multiplier.html +++ b/multi_bit_circuits/multipliers/carry_save_multiplier.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.multipliers.carry_save_multiplier API documentation - + @@ -37,7 +37,7 @@

Classes

class SignedCarrySaveMultiplier -(a: Bus, b: Bus, prefix: str = '', name: str = 's_csamul', unsigned_adder_class_name: str = ariths_gen.multi_bit_circuits.adders.carry_lookahead_adder.UnsignedCarryLookaheadAdder, **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 's_csamul',
unsigned_adder_class_name: str = ariths_gen.multi_bit_circuits.adders.carry_lookahead_adder.UnsignedCarryLookaheadAdder,
**kwargs)

Class representing signed carry save array multiplier.

@@ -333,7 +333,7 @@

Inherited members

class UnsignedCarrySaveMultiplier -(a: Bus, b: Bus, prefix: str = '', name: str = 'u_csamul', unsigned_adder_class_name: str = ariths_gen.multi_bit_circuits.adders.carry_lookahead_adder.UnsignedCarryLookaheadAdder, **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'u_csamul',
unsigned_adder_class_name: str = ariths_gen.multi_bit_circuits.adders.carry_lookahead_adder.UnsignedCarryLookaheadAdder,
**kwargs)

Class representing unsigned carry save array multiplier (also known as Braun multiplier).

@@ -642,7 +642,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/multipliers/dadda_multiplier.html b/multi_bit_circuits/multipliers/dadda_multiplier.html index be6a413..db8fd53 100644 --- a/multi_bit_circuits/multipliers/dadda_multiplier.html +++ b/multi_bit_circuits/multipliers/dadda_multiplier.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.multipliers.dadda_multiplier API documentation - + @@ -37,7 +37,7 @@

Classes

class SignedDaddaMultiplier -(a: Bus, b: Bus, prefix: str = '', name: str = 's_dadda_cla', unsigned_adder_class_name: str = ariths_gen.multi_bit_circuits.adders.carry_lookahead_adder.UnsignedCarryLookaheadAdder, **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 's_dadda_cla',
unsigned_adder_class_name: str = ariths_gen.multi_bit_circuits.adders.carry_lookahead_adder.UnsignedCarryLookaheadAdder,
**kwargs)

Class representing signed dadda multiplier.

@@ -271,7 +271,7 @@

Inherited members

class UnsignedDaddaMultiplier -(a: Bus, b: Bus, prefix: str = '', name: str = 'u_dadda_cla', unsigned_adder_class_name: str = ariths_gen.multi_bit_circuits.adders.carry_lookahead_adder.UnsignedCarryLookaheadAdder, **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'u_dadda_cla',
unsigned_adder_class_name: str = ariths_gen.multi_bit_circuits.adders.carry_lookahead_adder.UnsignedCarryLookaheadAdder,
**kwargs)

Class representing unsigned dadda multiplier.

@@ -514,7 +514,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/multipliers/index.html b/multi_bit_circuits/multipliers/index.html index 24b611e..69d8c2e 100644 --- a/multi_bit_circuits/multipliers/index.html +++ b/multi_bit_circuits/multipliers/index.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.multipliers API documentation - + @@ -76,7 +76,7 @@

Sub-modules

diff --git a/multi_bit_circuits/multipliers/wallace_multiplier.html b/multi_bit_circuits/multipliers/wallace_multiplier.html index ec750ad..b3d4310 100644 --- a/multi_bit_circuits/multipliers/wallace_multiplier.html +++ b/multi_bit_circuits/multipliers/wallace_multiplier.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.multipliers.wallace_multiplier API documentation - + @@ -37,7 +37,7 @@

Classes

class SignedWallaceMultiplier -(a: Bus, b: Bus, prefix: str = '', name: str = 's_wallace_cla', use_csa: bool = True, unsigned_adder_class_name: str = ariths_gen.multi_bit_circuits.adders.carry_lookahead_adder.UnsignedCarryLookaheadAdder, **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 's_wallace_cla',
use_csa: bool = True,
unsigned_adder_class_name: str = ariths_gen.multi_bit_circuits.adders.carry_lookahead_adder.UnsignedCarryLookaheadAdder,
**kwargs)

Class representing signed wallace multiplier.

@@ -338,7 +338,7 @@

Inherited members

class UnsignedWallaceMultiplier -(a: Bus, b: Bus, prefix: str = '', name: str = 'u_wallace_cla', use_csa: bool = True, unsigned_adder_class_name: str = ariths_gen.multi_bit_circuits.adders.carry_lookahead_adder.UnsignedCarryLookaheadAdder, **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'u_wallace_cla',
use_csa: bool = True,
unsigned_adder_class_name: str = ariths_gen.multi_bit_circuits.adders.carry_lookahead_adder.UnsignedCarryLookaheadAdder,
**kwargs)

Class representing unsigned wallace multiplier.

@@ -704,7 +704,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/others/bit_reduce.html b/multi_bit_circuits/others/bit_reduce.html index f51795e..0fdbb69 100644 --- a/multi_bit_circuits/others/bit_reduce.html +++ b/multi_bit_circuits/others/bit_reduce.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.others.bit_reduce API documentation - + @@ -37,7 +37,7 @@

Classes

class AndReduce -(a: Bus, prefix: str = '', name: str = 'andreduce', **kwargs) +(a: Bus,
prefix: str = '',
name: str = 'andreduce',
**kwargs)

Class representing tree reducer circuit. Doent work for NAND gate!

@@ -125,7 +125,7 @@

Inherited members

class BitReduce -(a: Bus, gate: TwoInputLogicGate, prefix: str = '', name: str = 'bitreduce', **kwargs) +(a: Bus,
gate: TwoInputLogicGate,
prefix: str = '',
name: str = 'bitreduce',
**kwargs)

Class representing tree reducer circuit. Doent work for NAND gate!

@@ -250,7 +250,7 @@

Inherited members

class OrReduce -(a: Bus, prefix: str = '', name: str = 'orreduce', **kwargs) +(a: Bus,
prefix: str = '',
name: str = 'orreduce',
**kwargs)

Class representing tree reducer circuit. Doent work for NAND gate!

@@ -366,7 +366,7 @@

diff --git a/multi_bit_circuits/others/compare.html b/multi_bit_circuits/others/compare.html index 213a26c..a823ea7 100644 --- a/multi_bit_circuits/others/compare.html +++ b/multi_bit_circuits/others/compare.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.others.compare API documentation - + @@ -37,7 +37,7 @@

Classes

class UnsignedCompareGT -(a: Bus, b: Bus, prefix: str = '', name: str = 'cmp_gt', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'cmp_gt',
**kwargs)

Class representing unsigned compare

@@ -154,7 +154,7 @@

Inherited members

class UnsignedCompareGTE -(a: Bus, b: Bus, prefix: str = '', name: str = 'cmp_gte', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'cmp_gte',
**kwargs)

Class representing unsigned compare

@@ -272,7 +272,7 @@

Inherited members

class UnsignedCompareLT -(a: Bus, b: Bus, prefix: str = '', name: str = 'cmp_lt', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'cmp_lt',
**kwargs)

Class representing unsigned compare

@@ -389,7 +389,7 @@

Inherited members

class UnsignedCompareLTE -(a: Bus, b: Bus, prefix: str = '', name: str = 'cmp_lte', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'cmp_lte',
**kwargs)

Class representing unsigned compare

@@ -538,7 +538,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/others/index.html b/multi_bit_circuits/others/index.html index 020c7f3..1bf66c3 100644 --- a/multi_bit_circuits/others/index.html +++ b/multi_bit_circuits/others/index.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.others API documentation - + @@ -76,7 +76,7 @@

Sub-modules

diff --git a/multi_bit_circuits/others/popcount.html b/multi_bit_circuits/others/popcount.html index 6920525..86781ed 100644 --- a/multi_bit_circuits/others/popcount.html +++ b/multi_bit_circuits/others/popcount.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.others.popcount API documentation - + @@ -37,7 +37,7 @@

Classes

class UnsignedPopCount -(a: Bus, adder: Optional[GeneralCircuit] = None, prefix: str = '', name: str = 'popcnt', **kwargs) +(a: Bus,
adder: GeneralCircuit | None = None,
prefix: str = '',
name: str = 'popcnt',
**kwargs)

Class representing unsigned popcount circuit.

@@ -189,7 +189,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/others/popcount_compare.html b/multi_bit_circuits/others/popcount_compare.html index 7e4dec7..3ad2968 100644 --- a/multi_bit_circuits/others/popcount_compare.html +++ b/multi_bit_circuits/others/popcount_compare.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.others.popcount_compare API documentation - + @@ -37,7 +37,7 @@

Classes

class PopCountCompare -(a: Bus, b: Bus, prefix: str = '', name: str = 'popcnt_cmp', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'popcnt_cmp',
**kwargs)

Class representing a circiut @@ -204,7 +204,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/subtractors/index.html b/multi_bit_circuits/subtractors/index.html index bdf597e..bd979c0 100644 --- a/multi_bit_circuits/subtractors/index.html +++ b/multi_bit_circuits/subtractors/index.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.subtractors API documentation - + @@ -66,7 +66,7 @@

Sub-modules

diff --git a/multi_bit_circuits/subtractors/ripple_borrow_subtractor.html b/multi_bit_circuits/subtractors/ripple_borrow_subtractor.html index 1cbc749..d9f11ce 100644 --- a/multi_bit_circuits/subtractors/ripple_borrow_subtractor.html +++ b/multi_bit_circuits/subtractors/ripple_borrow_subtractor.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.subtractors.ripple_borrow_subtractor API documentation - + @@ -37,7 +37,7 @@

Classes

class SignedRippleBorrowSubtractor -(a: Bus, b: Bus, prefix: str = '', name: str = 's_rbs', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 's_rbs',
**kwargs)

Class representing signed ripple borrow subtractor.

@@ -186,7 +186,7 @@

Inherited members

class UnsignedRippleBorrowSubtractor -(a: Bus, b: Bus, prefix: str = '', name: str = 'u_rbs', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'u_rbs',
**kwargs)

Class representing unsigned ripple borrow subtractor.

@@ -369,7 +369,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/multi_bit_circuits/subtractors/ripple_carry_subtractor.html b/multi_bit_circuits/subtractors/ripple_carry_subtractor.html index 3cb8f07..197e4da 100644 --- a/multi_bit_circuits/subtractors/ripple_carry_subtractor.html +++ b/multi_bit_circuits/subtractors/ripple_carry_subtractor.html @@ -3,13 +3,13 @@ - + ariths_gen.multi_bit_circuits.subtractors.ripple_carry_subtractor API documentation - + @@ -37,7 +37,7 @@

Classes

class SignedRippleCarrySubtractor -(a: Bus, b: Bus, prefix: str = '', name: str = 's_rcs', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 's_rcs',
**kwargs)

Class representing signed ripple carry subtractor.

@@ -189,7 +189,7 @@

Inherited members

class UnsignedRippleCarrySubtractor -(a: Bus, b: Bus, prefix: str = '', name: str = 'u_rcs', **kwargs) +(a: Bus,
b: Bus,
prefix: str = '',
name: str = 'u_rcs',
**kwargs)

Class representing unsigned ripple carry subtractor.

@@ -377,7 +377,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/one_bit_circuits/index.html b/one_bit_circuits/index.html index 7405978..a85ad78 100644 --- a/one_bit_circuits/index.html +++ b/one_bit_circuits/index.html @@ -3,13 +3,13 @@ - + ariths_gen.one_bit_circuits API documentation - + @@ -66,7 +66,7 @@

Sub-modules

diff --git a/one_bit_circuits/logic_gates/index.html b/one_bit_circuits/logic_gates/index.html index 96e0561..4e221e5 100644 --- a/one_bit_circuits/logic_gates/index.html +++ b/one_bit_circuits/logic_gates/index.html @@ -3,13 +3,13 @@ - + ariths_gen.one_bit_circuits.logic_gates API documentation - + @@ -61,7 +61,7 @@

Sub-modules

diff --git a/one_bit_circuits/logic_gates/logic_gates.html b/one_bit_circuits/logic_gates/logic_gates.html index 8c93e8b..b5ef338 100644 --- a/one_bit_circuits/logic_gates/logic_gates.html +++ b/one_bit_circuits/logic_gates/logic_gates.html @@ -3,13 +3,13 @@ - + ariths_gen.one_bit_circuits.logic_gates.logic_gates API documentation - + @@ -37,7 +37,7 @@

Classes

class AndGate -(a: Wire, b: Wire, prefix: str = '', outid: int = 0, parent_component: object = None) +(a: Wire,
b: Wire,
prefix: str = '',
outid: int = 0,
parent_component: object = None)

Class representing two input AND gate.

@@ -138,6 +138,23 @@

Returns

str
Blif description of AND gate's Boolean function.

+
+ +Expand source code + +
def get_function_blif(self):
+    """Generates Blif code representing AND gate Boolean function using its truth table.
+
+    Returns:
+        str: Blif description of AND gate's Boolean function.
+    """
+    if self.disable_generation:
+        return f".names {self.a.get_wire_value_blif()} {self.b.get_wire_value_blif()} {self.out.name}_out\n" + \
+               f"11 1\n"
+    else:
+        return f".names {self.a.get_wire_value_blif()} {self.b.get_wire_value_blif()} {self.out.get_wire_value_blif()}\n" + \
+               f"11 1\n"
+

Inherited members

@@ -183,7 +200,7 @@

Inherited members

class NandGate -(a: Wire, b: Wire, prefix: str = '', outid: int = 0, parent_component: object = None) +(a: Wire,
b: Wire,
prefix: str = '',
outid: int = 0,
parent_component: object = None)

Class representing two input NAND gate.

@@ -291,6 +308,23 @@

Returns

str
Blif description of NAND gate's Boolean function.

+
+ +Expand source code + +
def get_function_blif(self):
+    """Generates Blif code representing NAND gate Boolean function using its truth table.
+
+    Returns:
+        str: Blif description of NAND gate's Boolean function.
+    """
+    if self.disable_generation:
+        return f".names {self.a.get_wire_value_blif()} {self.b.get_wire_value_blif()} {self.out.name}_out\n" + \
+               f"0- 1\n-0 1\n"
+    else:
+        return f".names {self.a.get_wire_value_blif()} {self.b.get_wire_value_blif()} {self.out.get_wire_value_blif()}\n" + \
+               f"0- 1\n-0 1\n"
+

Inherited members

@@ -336,7 +370,7 @@

Inherited members

class NorGate -(a: Wire, b: Wire, prefix: str = '', outid: int = 0, parent_component: object = None) +(a: Wire,
b: Wire,
prefix: str = '',
outid: int = 0,
parent_component: object = None)

Class representing two input NOR gate.

@@ -444,6 +478,23 @@

Returns

str
Blif description of NOR gate's Boolean function.

+
+ +Expand source code + +
def get_function_blif(self):
+    """Generates Blif code representing NOR gate Boolean function using its truth table.
+
+    Returns:
+        str: Blif description of NOR gate's Boolean function.
+    """
+    if self.disable_generation:
+        return f".names {self.a.get_wire_value_blif()} {self.b.get_wire_value_blif()} {self.out.name}_out\n" + \
+               f"00 1\n"
+    else:
+        return f".names {self.a.get_wire_value_blif()} {self.b.get_wire_value_blif()} {self.out.get_wire_value_blif()}\n" + \
+               f"00 1\n"
+

Inherited members

@@ -489,7 +540,7 @@

Inherited members

class NotGate -(a: Wire, prefix: str = '', outid: int = 0, parent_component: object = None) +(a: Wire,
prefix: str = '',
outid: int = 0,
parent_component: object = None)

Class representing one input NOT gate.

@@ -582,6 +633,23 @@

Returns

str
Blif description of NOT gate's Boolean function.

+
+ +Expand source code + +
def get_function_blif(self):
+    """Generates Blif code representing NOT gate Boolean function using its truth table.
+
+    Returns:
+        str: Blif description of NOT gate's Boolean function.
+    """
+    if self.disable_generation:
+        return f".names {self.a.get_wire_value_blif()} {self.out.name}_out\n" + \
+               f"0 1\n"
+    else:
+        return f".names {self.a.get_wire_value_blif()} {self.out.get_wire_value_blif()}\n" + \
+               f"0 1\n"
+

Inherited members

@@ -627,7 +695,7 @@

Inherited members

class OrGate -(a: Wire, b: Wire, prefix: str = '', outid: int = 0, parent_component: object = None) +(a: Wire,
b: Wire,
prefix: str = '',
outid: int = 0,
parent_component: object = None)

Class representing two input OR gate.

@@ -728,6 +796,23 @@

Returns

str
Blif description of OR gate's Boolean function.

+
+ +Expand source code + +
def get_function_blif(self):
+    """Generates Blif code representing OR gate Boolean function using its truth table.
+
+    Returns:
+        str: Blif description of OR gate's Boolean function.
+    """
+    if self.disable_generation:
+        return f".names {self.a.get_wire_value_blif()} {self.b.get_wire_value_blif()} {self.out.name}_out\n" + \
+               f"1- 1\n-1 1\n"
+    else:
+        return f".names {self.a.get_wire_value_blif()} {self.b.get_wire_value_blif()} {self.out.get_wire_value_blif()}\n" + \
+               f"1- 1\n-1 1\n"
+

Inherited members

@@ -773,7 +858,7 @@

Inherited members

class XnorGate -(a: Wire, b: Wire, prefix: str = '', outid: int = 0, parent_component: object = None) +(a: Wire,
b: Wire,
prefix: str = '',
outid: int = 0,
parent_component: object = None)

Class representing two input XNOR gate.

@@ -881,6 +966,23 @@

Returns

str
Blif description of XNOR gate's Boolean function.

+
+ +Expand source code + +
def get_function_blif(self):
+    """Generates Blif code representing XNOR gate Boolean function using its truth table.
+
+    Returns:
+        str: Blif description of XNOR gate's Boolean function.
+    """
+    if self.disable_generation:
+        return f".names {self.a.get_wire_value_blif()} {self.b.get_wire_value_blif()} {self.out.name}_out\n" + \
+               f"00 1\n11 1\n"
+    else:
+        return f".names {self.a.get_wire_value_blif()} {self.b.get_wire_value_blif()} {self.out.get_wire_value_blif()}\n" + \
+               f"00 1\n11 1\n"
+

Inherited members

@@ -926,7 +1028,7 @@

Inherited members

class XorGate -(a: Wire, b: Wire, prefix: str = '', outid: int = 0, parent_component: object = None) +(a: Wire,
b: Wire,
prefix: str = '',
outid: int = 0,
parent_component: object = None)

Class representing two input XOR gate.

@@ -1033,6 +1135,23 @@

Returns

str
Blif description of XOR gate's Boolean function.

+
+ +Expand source code + +
def get_function_blif(self):
+    """Generates Blif code representing XOR gate Boolean function using its truth table.
+
+    Returns:
+        str: Blif description of XOR gate's Boolean function.
+    """
+    if self.disable_generation:
+        return f".names {self.a.get_wire_value_blif()} {self.b.get_wire_value_blif()} {self.out.name}_out\n" + \
+               f"01 1\n10 1\n"
+    else:
+        return f".names {self.a.get_wire_value_blif()} {self.b.get_wire_value_blif()} {self.out.get_wire_value_blif()}\n" + \
+               f"01 1\n10 1\n"
+

Inherited members

@@ -1139,7 +1258,7 @@

diff --git a/one_bit_circuits/one_bit_components/four_input_one_bit_components.html b/one_bit_circuits/one_bit_components/four_input_one_bit_components.html index b96366c..bcbc2d5 100644 --- a/one_bit_circuits/one_bit_components/four_input_one_bit_components.html +++ b/one_bit_circuits/one_bit_components/four_input_one_bit_components.html @@ -3,13 +3,13 @@ - + ariths_gen.one_bit_circuits.one_bit_components.four_input_one_bit_components API documentation - + @@ -37,7 +37,7 @@

Classes

class BlackCell -(a: Wire = <ariths_gen.wire_components.wires.Wire object>, b: Wire = <ariths_gen.wire_components.wires.Wire object>, c: Wire = <ariths_gen.wire_components.wires.Wire object>, d: Wire = <ariths_gen.wire_components.wires.Wire object>, prefix: str = '', name: str = 'bc') +(a: Wire = <ariths_gen.wire_components.wires.Wire object>,
b: Wire = <ariths_gen.wire_components.wires.Wire object>,
c: Wire = <ariths_gen.wire_components.wires.Wire object>,
d: Wire = <ariths_gen.wire_components.wires.Wire object>,
prefix: str = '',
name: str = 'bc')

Class representing four input black cell used in parallel prefix adders inside the PG (parallel prefix computation) logic.

@@ -142,6 +142,18 @@

Returns

Wire
Return generate wire.

+
+ +Expand source code + +
def get_generate_wire(self):
+    """Get output wire carrying generate signal value.
+
+    Returns:
+       Wire: Return generate wire.
+    """
+    return self.out.get_wire(0)
+
def get_propagate_wire(self) @@ -153,6 +165,18 @@

Returns

Wire
Return propagate wire.

+
+ +Expand source code + +
def get_propagate_wire(self):
+    """Get output wire carrying propagate signal value.
+
+    Returns:
+       Wire: Return propagate wire.
+    """
+    return self.out.get_wire(1)
+

Inherited members

@@ -256,7 +280,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/one_bit_circuits/one_bit_components/index.html b/one_bit_circuits/one_bit_components/index.html index e4807e1..b95ca96 100644 --- a/one_bit_circuits/one_bit_components/index.html +++ b/one_bit_circuits/one_bit_components/index.html @@ -3,13 +3,13 @@ - + ariths_gen.one_bit_circuits.one_bit_components API documentation - + @@ -71,7 +71,7 @@

Sub-modules

diff --git a/one_bit_circuits/one_bit_components/three_input_one_bit_components.html b/one_bit_circuits/one_bit_components/three_input_one_bit_components.html index 11a5e92..ccb16fc 100644 --- a/one_bit_circuits/one_bit_components/three_input_one_bit_components.html +++ b/one_bit_circuits/one_bit_components/three_input_one_bit_components.html @@ -3,13 +3,13 @@ - + ariths_gen.one_bit_circuits.one_bit_components.three_input_one_bit_components API documentation - + @@ -37,7 +37,7 @@

Classes

class FullAdder -(a: Wire = <ariths_gen.wire_components.wires.Wire object>, b: Wire = <ariths_gen.wire_components.wires.Wire object>, c: Wire = <ariths_gen.wire_components.wires.Wire object>, prefix: str = '', name: str = 'fa') +(a: Wire = <ariths_gen.wire_components.wires.Wire object>,
b: Wire = <ariths_gen.wire_components.wires.Wire object>,
c: Wire = <ariths_gen.wire_components.wires.Wire object>,
prefix: str = '',
name: str = 'fa')

Class representing three input one bit full adder.

@@ -203,24 +203,91 @@

Returns

Wire
Return carry out wire.

+
+ +Expand source code + +
def get_carry_wire(self):
+    """Get output wire carrying carry out value.
+
+    Returns:
+       Wire: Return carry out wire.
+    """
+    return self.out.get_wire(1)
+
def get_circuit_v(self)

support of custom PDK

+
+ +Expand source code + +
def get_circuit_v(self):
+    """ support of custom PDK """
+    if not self.use_verilog_instance:
+        return super().get_circuit_v()
+
+    return f"{self.get_prototype_v_hier()}" + \
+           f"{self.get_self_init_v_hier()}" + \
+           f"endmodule"
+
def get_init_v_flat(self)

support of custom PDK

+
+ +Expand source code + +
def get_init_v_flat(self):
+    """ support of custom PDK """
+    if not self.use_verilog_instance:
+        return super().get_init_v_flat()
+
+    return "  " + self.use_verilog_instance.format(
+        **{
+            "unit": self.prefix,
+            "wirea": f"1'b{self.a.value}" if self.a.is_const() else self.a.name,
+            "wireb": f"1'b{self.b.value}" if self.b.is_const() else self.b.name,
+            "wirec": f"1'b{self.c.value}" if self.c.is_const() else self.c.name,
+            "wireys": self.get_sum_wire().prefix,
+            "wireyc": self.get_carry_wire().prefix,
+        }) + ";\n"
+
def get_self_init_v_hier(self)

support of custom PDK

+
+ +Expand source code + +
def get_self_init_v_hier(self):
+    """ support of custom PDK """
+    if not self.use_verilog_instance:
+        return super().get_self_init_v_hier()
+
+    unique_out_wires = []
+    for o in self.out.bus:
+        unique_out_wires.append(o.name+"_outid"+str(self.out.bus.index(o))) if o.is_const() or o.name in [self.a.name, self.b.name] else unique_out_wires.append(o.name)
+
+    return "  " + self.use_verilog_instance.format(
+        **{
+            "unit": self.prefix,
+            "wirea": self.a.name,
+            "wireb": self.b.name,
+            "wirec": self.c.name,
+            "wireys": unique_out_wires[0],
+            "wireyc": unique_out_wires[1],
+        }) + ";\n"
+
def get_sum_wire(self) @@ -232,6 +299,18 @@

Returns

Wire
Return sum wire.

+
+ +Expand source code + +
def get_sum_wire(self):
+    """Get output wire carrying sum value.
+
+    Returns:
+       Wire: Return sum wire.
+    """
+    return self.out.get_wire(0)
+

Inherited members

@@ -306,7 +385,7 @@

Inherited members

class FullAdderP -(a: Wire = <ariths_gen.wire_components.wires.Wire object>, b: Wire = <ariths_gen.wire_components.wires.Wire object>, c: Wire = <ariths_gen.wire_components.wires.Wire object>, prefix: str = '', name: str = 'fa_p') +(a: Wire = <ariths_gen.wire_components.wires.Wire object>,
b: Wire = <ariths_gen.wire_components.wires.Wire object>,
c: Wire = <ariths_gen.wire_components.wires.Wire object>,
prefix: str = '',
name: str = 'fa_p')

Class representing three input one bit full adder with additional output wire for P signal.

@@ -387,6 +466,18 @@

Returns

Wire
Return propagate wire.

+
+ +Expand source code + +
def get_propagate_wire(self):
+    """Get output wire carrying propagate value.
+
+    Returns:
+        Wire: Return propagate wire.
+    """
+    return self.out.get_wire(2)
+

Inherited members

@@ -466,7 +557,7 @@

Inherited members

class FullAdderPG -(a: Wire = <ariths_gen.wire_components.wires.Wire object>, b: Wire = <ariths_gen.wire_components.wires.Wire object>, c: Wire = <ariths_gen.wire_components.wires.Wire object>, prefix: str = '', name: str = 'fa_pg') +(a: Wire = <ariths_gen.wire_components.wires.Wire object>,
b: Wire = <ariths_gen.wire_components.wires.Wire object>,
c: Wire = <ariths_gen.wire_components.wires.Wire object>,
prefix: str = '',
name: str = 'fa_pg')

Class representing three input one bit full adder with additional output wires for P and G signals.

@@ -558,6 +649,18 @@

Returns

Wire
Return generate wire.

+
+ +Expand source code + +
def get_generate_wire(self):
+    """Get output wire carrying generate value.
+
+    Returns:
+        Wire: Return generate wire.
+    """
+    return self.out.get_wire(3)
+
def get_propagate_wire(self) @@ -569,6 +672,18 @@

Returns

Wire
Return propagate wire.

+
+ +Expand source code + +
def get_propagate_wire(self):
+    """Get output wire carrying propagate value.
+
+    Returns:
+        Wire: Return propagate wire.
+    """
+    return self.out.get_wire(2)
+

Inherited members

@@ -648,7 +763,7 @@

Inherited members

class FullSubtractor -(a: Wire = <ariths_gen.wire_components.wires.Wire object>, b: Wire = <ariths_gen.wire_components.wires.Wire object>, c: Wire = <ariths_gen.wire_components.wires.Wire object>, prefix: str = '', name: str = 'fs') +(a: Wire = <ariths_gen.wire_components.wires.Wire object>,
b: Wire = <ariths_gen.wire_components.wires.Wire object>,
c: Wire = <ariths_gen.wire_components.wires.Wire object>,
prefix: str = '',
name: str = 'fs')

Class representing three input one bit full subtractor.

@@ -760,6 +875,18 @@

Returns

Wire
Return borrow out wire.

+
+ +Expand source code + +
def get_borrow_wire(self):
+    """Get output wire carrying borrow out value.
+
+    Returns:
+       Wire: Return borrow out wire.
+    """
+    return self.out.get_wire(1)
+
def get_difference_wire(self) @@ -771,6 +898,18 @@

Returns

Wire
Return difference wire.

+
+ +Expand source code + +
def get_difference_wire(self):
+    """Get output wire carrying difference value.
+
+    Returns:
+       Wire: Return difference wire.
+    """
+    return self.out.get_wire(0)
+

Inherited members

@@ -848,7 +987,7 @@

Inherited members

class GreyCell -(a: Wire = <ariths_gen.wire_components.wires.Wire object>, b: Wire = <ariths_gen.wire_components.wires.Wire object>, c: Wire = <ariths_gen.wire_components.wires.Wire object>, prefix: str = '', name: str = 'gc') +(a: Wire = <ariths_gen.wire_components.wires.Wire object>,
b: Wire = <ariths_gen.wire_components.wires.Wire object>,
c: Wire = <ariths_gen.wire_components.wires.Wire object>,
prefix: str = '',
name: str = 'gc')

Class representing three input grey cell used in parallel prefix adders inside the PG (parallel prefix computation) logic.

@@ -935,6 +1074,18 @@

Returns

Wire
Return generate wire.

+
+ +Expand source code + +
def get_generate_wire(self):
+    """Get output wire carrying generate value.
+
+    Returns:
+       Wire: Return generate wire.
+    """
+    return self.out.get_wire(0)
+

Inherited members

@@ -1012,7 +1163,7 @@

Inherited members

class PGSumLogic -(a: Wire = <ariths_gen.wire_components.wires.Wire object>, b: Wire = <ariths_gen.wire_components.wires.Wire object>, c: Wire = <ariths_gen.wire_components.wires.Wire object>, prefix: str = '', name: str = 'pg_sum') +(a: Wire = <ariths_gen.wire_components.wires.Wire object>,
b: Wire = <ariths_gen.wire_components.wires.Wire object>,
c: Wire = <ariths_gen.wire_components.wires.Wire object>,
prefix: str = '',
name: str = 'pg_sum')

Class represents a three input function block that contains logic for obtaining the propagate/generate/sum signals.

@@ -1121,6 +1272,18 @@

Returns

Wire
Return generate wire.

+
+ +Expand source code + +
def get_generate_wire(self):
+    """Get output wire carrying generate signal value.
+
+    Returns:
+       Wire: Return generate wire.
+    """
+    return self.out.get_wire(1)
+
def get_propagate_wire(self) @@ -1132,6 +1295,18 @@

Returns

Wire
Return propagate wire.
+
+ +Expand source code + +
def get_propagate_wire(self):
+    """Get output wire carrying propagate signal value.
+
+    Returns:
+       Wire: Return propagate wire.
+    """
+    return self.out.get_wire(0)
+
def get_sum_wire(self) @@ -1143,6 +1318,18 @@

Returns

Wire
Return sum wire.
+
+ +Expand source code + +
def get_sum_wire(self):
+    """Get output wire carrying sum value.
+
+    Returns:
+       Wire: Return sum wire.
+    """
+    return self.out.get_wire(2)
+

Inherited members

@@ -1220,7 +1407,7 @@

Inherited members

class TwoOneMultiplexer -(a: Wire = <ariths_gen.wire_components.wires.Wire object>, b: Wire = <ariths_gen.wire_components.wires.Wire object>, c: Wire = <ariths_gen.wire_components.wires.Wire object>, prefix: str = '', name: str = 'mux2to1') +(a: Wire = <ariths_gen.wire_components.wires.Wire object>,
b: Wire = <ariths_gen.wire_components.wires.Wire object>,
c: Wire = <ariths_gen.wire_components.wires.Wire object>,
prefix: str = '',
name: str = 'mux2to1')

Class representing two to one multiplexer (with select signal as its third input).

@@ -1370,12 +1557,48 @@

Methods

support of custom PDK

+
+ +Expand source code + +
def get_circuit_v(self):
+    """ support of custom PDK """
+    if not self.use_verilog_instance:
+        return super().get_circuit_v()
+
+    return f"{self.get_prototype_v_hier()}" + \
+           f"{self.get_self_init_v_hier()}" + \
+           f"endmodule"
+
def get_init_v_flat(self)

support of custom PDK

+
+ +Expand source code + +
def get_init_v_flat(self):
+    """ support of custom PDK """
+    if not self.use_verilog_instance:
+        return super().get_init_v_flat()
+
+    if self.out[0].is_const():
+        return ""
+    else:
+        # TODO - replace by one verilog_instance_format!
+        neg_out_w_name = f"neg_{self.out.get_wire(0).name}"
+        return f"  wire {neg_out_w_name};\n  " + self.use_verilog_instance.format(
+            **{
+                "unit": self.prefix,
+                "wirea": self.a.get_wire_value_v_hier(), # former version:  f"1'b{self.a.value}" if self.a.is_const() else self.a.name,
+                "wireb": self.b.get_wire_value_v_hier(), #f"1'b{self.b.value}" if self.b.is_const() else self.b.name,
+                "wires": self.c.get_wire_value_v_hier(), #f"1'b{self.c.value}" if self.c.is_const() else self.c.name,
+                "wirey": neg_out_w_name,
+            }) + ";\n" + f"  assign {self.out.get_wire(0).name} = ~{neg_out_w_name};\n"
+
def get_mux_out_wire(self) @@ -1387,12 +1610,47 @@

Returns

Wire
Return multiplexer out wire.
+
+ +Expand source code + +
def get_mux_out_wire(self):
+    """Get multiplexer output wire.
+
+    Returns:
+       Wire: Return multiplexer out wire.
+    """
+    return self.out.get_wire(0)
+
def get_self_init_v_hier(self)

support of custom PDK

+
+ +Expand source code + +
def get_self_init_v_hier(self):
+    """ support of custom PDK """
+    if not self.use_verilog_instance:
+        return super().get_self_init_v_hier()
+
+    unique_out_wires = []
+    for o in self.out.bus:
+        unique_out_wires.append(o.name+"_outid"+str(self.out.bus.index(o))) if o.is_const() or o.name in [self.a.name, self.b.name] else unique_out_wires.append(o.name)
+
+    neg_out_w_name = f"neg_{unique_out_wires[0]}"
+    return f"  wire {neg_out_w_name};\n  " + self.use_verilog_instance.format(
+        **{
+            "unit": self.prefix,
+            "wirea": self.a.name,
+            "wireb": self.b.name,
+            "wires": self.c.name,
+            "wirey": neg_out_w_name
+        }) + ";\n" + f"  assign {unique_out_wires[0]} = ~{neg_out_w_name};\n"
+

Inherited members

@@ -1541,7 +1799,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/one_bit_circuits/one_bit_components/two_input_one_bit_components.html b/one_bit_circuits/one_bit_components/two_input_one_bit_components.html index 9837a35..eff616f 100644 --- a/one_bit_circuits/one_bit_components/two_input_one_bit_components.html +++ b/one_bit_circuits/one_bit_components/two_input_one_bit_components.html @@ -3,13 +3,13 @@ - + ariths_gen.one_bit_circuits.one_bit_components.two_input_one_bit_components API documentation - + @@ -37,7 +37,7 @@

Classes

class HalfAdder -(a: Wire = <ariths_gen.wire_components.wires.Wire object>, b: Wire = <ariths_gen.wire_components.wires.Wire object>, prefix: str = '', name: str = 'ha') +(a: Wire = <ariths_gen.wire_components.wires.Wire object>,
b: Wire = <ariths_gen.wire_components.wires.Wire object>,
prefix: str = '',
name: str = 'ha')

Class representing two input one bit half adder.

@@ -182,24 +182,89 @@

Returns

Wire
Return carry out wire.
+
+ +Expand source code + +
def get_carry_wire(self):
+    """Get output wire carrying carry out value.
+
+    Returns:
+       Wire: Return carry out wire.
+    """
+    return self.out.get_wire(1)
+
def get_circuit_v(self)

support of custom PDK

+
+ +Expand source code + +
def get_circuit_v(self):
+    """ support of custom PDK """
+    if not self.use_verilog_instance:
+        return super().get_circuit_v()
+
+    return f"{self.get_prototype_v_hier()}" + \
+           f"{self.get_self_init_v_hier()}" + \
+           f"endmodule"
+
def get_init_v_flat(self)

support of custom PDK

+
+ +Expand source code + +
def get_init_v_flat(self):
+    """ support of custom PDK """
+    if not self.use_verilog_instance:
+        return super().get_init_v_flat()
+
+    return "  " + self.use_verilog_instance.format(
+        **{
+            "unit": self.prefix,
+            "wirea": f"1'b{self.a.value}" if self.a.is_const() else self.a.name,
+            "wireb": f"1'b{self.b.value}" if self.b.is_const() else self.b.name,
+            "wireys": self.get_sum_wire().prefix,
+            "wireyc": self.get_carry_wire().prefix,
+        }) + ";\n"
+
def get_self_init_v_hier(self)

support of custom PDK

+
+ +Expand source code + +
def get_self_init_v_hier(self):
+    """ support of custom PDK """
+    if not self.use_verilog_instance:
+        return super().get_self_init_v_hier()
+
+    unique_out_wires = []
+    for o in self.out.bus:
+        unique_out_wires.append(o.name+"_outid"+str(self.out.bus.index(o))) if o.is_const() or o.name in [self.a.name, self.b.name] else unique_out_wires.append(o.name)
+
+    return "  " + self.use_verilog_instance.format(
+        **{
+            "unit": self.prefix,
+            "wirea": self.a.name,
+            "wireb": self.b.name,
+            "wireys": unique_out_wires[0],
+            "wireyc": unique_out_wires[1],
+        }) + ";\n"
+
def get_sum_wire(self) @@ -211,6 +276,18 @@

Returns

Wire
Return sum wire.
+
+ +Expand source code + +
def get_sum_wire(self):
+    """Get output wire carrying sum value.
+
+    Returns:
+       Wire: Return sum wire.
+    """
+    return self.out.get_wire(0)
+

Inherited members

@@ -285,7 +362,7 @@

Inherited members

class HalfSubtractor -(a: Wire = <ariths_gen.wire_components.wires.Wire object>, b: Wire = <ariths_gen.wire_components.wires.Wire object>, prefix: str = '', name: str = 'hs') +(a: Wire = <ariths_gen.wire_components.wires.Wire object>,
b: Wire = <ariths_gen.wire_components.wires.Wire object>,
prefix: str = '',
name: str = 'hs')

Class representing two input one bit half subtractor.

@@ -383,6 +460,18 @@

Returns

Wire
Return borrow out wire.
+
+ +Expand source code + +
def get_borrow_wire(self):
+    """Get output wire carrying borrow out value.
+
+    Returns:
+       Wire: Return borrow out wire.
+    """
+    return self.out.get_wire(1)
+
def get_difference_wire(self) @@ -394,6 +483,18 @@

Returns

Wire
Return difference wire.
+
+ +Expand source code + +
def get_difference_wire(self):
+    """Get output wire carrying difference value.
+
+    Returns:
+       Wire: Return difference wire.
+    """
+    return self.out.get_wire(0)
+

Inherited members

@@ -471,7 +572,7 @@

Inherited members

class PGLogicBlock -(a: Wire = <ariths_gen.wire_components.wires.Wire object>, b: Wire = <ariths_gen.wire_components.wires.Wire object>, prefix: str = '', name: str = 'pg_logic') +(a: Wire = <ariths_gen.wire_components.wires.Wire object>,
b: Wire = <ariths_gen.wire_components.wires.Wire object>,
prefix: str = '',
name: str = 'pg_logic')

Class representing two input one bit propagate/generate logic block.

@@ -574,6 +675,18 @@

Returns

Wire
Return generate wire.
+
+ +Expand source code + +
def get_generate_wire(self):
+    """Get output wire carrying generate signal value.
+
+    Returns:
+       Wire: Return generate wire.
+    """
+    return self.out.get_wire(1)
+
def get_propagate_wire(self) @@ -585,6 +698,18 @@

Returns

Wire
Return propagate wire.
+
+ +Expand source code + +
def get_propagate_wire(self):
+    """Get output wire carrying propagate signal value.
+
+    Returns:
+       Wire: Return propagate wire.
+    """
+    return self.out.get_wire(0)
+
def get_sum_wire(self) @@ -596,6 +721,18 @@

Returns

Wire
Return sum wire.
+
+ +Expand source code + +
def get_sum_wire(self):
+    """Get output wire carrying sum value.
+
+    Returns:
+       Wire: Return sum wire.
+    """
+    return self.out.get_wire(2)
+

Inherited members

@@ -718,7 +855,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/pdk.html b/pdk.html index 58d9929..db8caf7 100644 --- a/pdk.html +++ b/pdk.html @@ -3,13 +3,13 @@ - + ariths_gen.pdk API documentation - + @@ -45,6 +45,15 @@

Functions

+
+ +Expand source code + +
def set_pdk45_library():
+    one_bit_components.FullAdder.use_verilog_instance = "FAX1 {unit} (.A({wirea}), .B({wireb}), .C({wirec}), .YS({wireys}), .YC({wireyc}))"
+    one_bit_components.HalfAdder.use_verilog_instance = "HAX1 {unit} (.A({wirea}), .B({wireb}), .YS({wireys}), .YC({wireyc}))"
+    one_bit_components.TwoOneMultiplexer.use_verilog_instance = "MUX2X1 {unit} (.A({wirea}), .B({wireb}), .S({wires}), .Y({wirey}))"
+
@@ -70,7 +79,7 @@

Functions

diff --git a/wire_components/buses.html b/wire_components/buses.html index 4192eb7..a0ba7bf 100644 --- a/wire_components/buses.html +++ b/wire_components/buses.html @@ -3,13 +3,13 @@ - + ariths_gen.wire_components.buses API documentation - + @@ -37,7 +37,7 @@

Classes

class Bus -(prefix: str = 'bus', N: int = 1, wires_list: list = None, out_bus: bool = False, signed: bool = False) +(prefix: str = 'bus',
N: int = 1,
wires_list: list = None,
out_bus: bool = False,
signed: bool = False)

Class representing bus of wires used as inputs/outputs of bigger circuits.

@@ -366,7 +366,7 @@

Args

Methods

-def bus_extend(self, N: int, prefix: str = 'bus', desired_extension_wire: Wire = <ariths_gen.wire_components.wires.ConstantWireValue0 object>) +def bus_extend(self,
N: int,
prefix: str = 'bus',
desired_extension_wire: Wire = <ariths_gen.wire_components.wires.ConstantWireValue0 object>)

Provides bus extension to contain more wires.

@@ -379,9 +379,31 @@

Args

desired_extension_wire : Wire, optional
Specifies the wire that should be connected to all of the extending bus wires. Defaults to ConstantWireValue0().
+
+ +Expand source code + +
def bus_extend(self, N: int, prefix: str = "bus", desired_extension_wire: Wire = ConstantWireValue0()):
+    """Provides bus extension to contain more wires.
+
+    Args:
+        N (int): Number of wires in the bus. Defaults to 1.
+        prefix (str, optional): Prefix name of the bus. Defaults to "bus".
+        desired_extension_wire (Wire, optional): Specifies the wire that should be connected to all of the extending bus wires. Defaults to ConstantWireValue0().
+    """
+    # Checks if any extension is neccesarry and if so, proceeds to wire extend the bus
+    if self.N < N:
+        # Adding wires into current bus's wires list (wire names are concatenated from bus prefix and their index position inside the bus in square brackets)
+        self.bus += [Wire(name=prefix+f"[{i}]", prefix=prefix, index=i, parent_bus=self) for i in range(self.N, N)]
+
+        for w_index in range(self.N, N):
+            self.connect(bus_wire_index=w_index, inner_component_out_wire=desired_extension_wire)
+
+        self.N = N
+
-def connect(self, bus_wire_index: int, inner_component_out_wire: Wire, inserted_wire_desired_index: int = -1) +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.

@@ -395,9 +417,35 @@

Args

Wire of some other component (mostly its output) to store in the bus.

inserted_wire_desired_index(int, optional): Optional desired explicit index, where 'inner_component_out_wire' value resides in the inner components's output bus. Otherwise 'inner_component_out_wire' self index value is used. Defaults to -1.

+
+ +Expand source code + +
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.
+
+    Used for connection of output wire of the inner circuit component
+    to the appropriate wire of the circuit's output bus.
+
+    Args:
+        bus_wire_index (int): Index in bus to store given wire in.
+        inner_component_out_wire (Wire): Wire of some other component (mostly its output) to store in the bus.
+        inserted_wire_desired_index(int, optional): Optional desired explicit index, where 'inner_component_out_wire' value resides in the inner components's output bus. Otherwise 'inner_component_out_wire' self index value is used. Defaults to -1.
+    """
+    inserted_wire_index = inserted_wire_desired_index if inserted_wire_desired_index != -1 else inner_component_out_wire.index
+    # Used for connection of constant wire value into a bus
+    if inner_component_out_wire.is_const():
+        self.bus[bus_wire_index] = inner_component_out_wire
+    # Proper connection of wires that themselves are not yet a member of any other bus and also those that could be part of some bus but do not have `inserted_wire_desired_index` defined
+    elif inner_component_out_wire.parent_bus is None or inserted_wire_desired_index == -1:
+        self.bus[bus_wire_index] = Wire(name=inner_component_out_wire.name, prefix=inner_component_out_wire.prefix, index=inserted_wire_index, value=inner_component_out_wire.value, parent_bus=self)
+    # Proper connection of wires that are already a member of some other bus and are desired to connect value from their previous bus to this one at desired index position
+    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 connect_bus(self, connecting_bus: object, start_connection_pos: int = 0, end_connection_pos: int = -1, offset: int = 0) +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.

@@ -414,6 +462,27 @@

Args

offset : int, optional
Specifies the offset wire index position in the self bus for proper connection (i.e. wire at index position 5 in the connecting_bus with offset set to 5 will be connected to self bus index position 0). Default to 0.
+
+ +Expand source code + +
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.
+
+    Used for connection of some inner circuit component's output bus (`connecting_bus`) wires
+    to the appropriate input bus (this `self` bus) wires of some other circuit.
+
+    Args:
+        connecting_bus (object): Specifies the connecting bus.
+        start_connection_pos (int, optional): Specifies the position from which to start interconnecting wires from the `connecting_bus` to this `self` bus. Defaults to 0.
+        end_connection_pos (int, optional): Specifies the position from which to end interconnecting wires from the `connecting_bus` to this `self` bus. Defaults to -1.
+        offset (int, optional): Specifies the offset wire index position in the `self` bus for proper connection (i.e. wire at index position 5 in the `connecting_bus` with offset set to 5 will be connected to `self` bus index position 0). Default to 0.
+    """
+    if end_connection_pos == -1:
+        end_connection_pos = self.N
+
+    [self.connect(o-offset, connecting_bus.get_wire(o), inserted_wire_desired_index=o) for o in range(start_connection_pos, end_connection_pos)]
+
def get_declaration_c(self) @@ -425,6 +494,18 @@

Returns

str
C code for declaration and initialization of bus name.
+
+ +Expand source code + +
def get_declaration_c(self):
+    """Bus declaration in C code.
+
+    Returns:
+        str: C code for declaration and initialization of bus name.
+    """
+    return f"  {self.c_type} {self.prefix} = 0;\n"
+
def get_unique_assign_out_wires_blif(self, function_block_out_bus: object) @@ -441,6 +522,23 @@

Returns

str
Blif code for proper subcomponent's function block invocation with respective output wires assignment.
+
+ +Expand source code + +
def get_unique_assign_out_wires_blif(self, function_block_out_bus: object):
+    """Assigns unique output wires to their respective outputs of subcomponent's function block modul in hierarchical Blif subcomponent's invocation.
+
+    Args:
+        function_block_out_bus (object): Specifies output bus of corresponding function block's outputs for proper subcomponent modul invocation.
+
+    Returns:
+        str: Blif code for proper subcomponent's function block invocation with respective output wires assignment.
+    """
+    unique_out_wires = []
+    [unique_out_wires.append(w.prefix) if w.prefix not in unique_out_wires else None for w in self.bus]
+    return "".join([f" {function_block_out_bus.get_wire(self.bus.index(o)).name}={unique_out_wires.pop(unique_out_wires.index(o.prefix))}" if o.prefix in unique_out_wires else "" for o in self.bus])
+
def get_unique_assign_out_wires_v(self, circuit_block: object) @@ -457,6 +555,23 @@

Returns

str
Verilog code unique bus wires for proper subcomponent's function block invocation.
+
+ +Expand source code + +
def get_unique_assign_out_wires_v(self, circuit_block: object):
+    """Returns bus's wires used for hierarchical one bit subcomponent's function block invocation and output wires assignments.
+
+    Args:
+        circuit_block (object): Object describing corresponding function block that is being invoked for proper output wires assignment during instantiation.
+
+    Returns:
+        str: Verilog code unique bus wires for proper subcomponent's function block invocation.
+    """
+    unique_out_wires = []
+    [unique_out_wires.append(w.prefix) if w.prefix not in unique_out_wires else None for w in self.bus]
+    return "".join([f", .{circuit_block.out.get_wire(self.bus.index(o)).prefix}({unique_out_wires.pop(unique_out_wires.index(o.prefix))})" if o.prefix in unique_out_wires else f", .{circuit_block.out.get_wire(self.bus.index(o)).prefix}()" for o in self.bus])
+
def get_wire(self, wire_index: int = 0) @@ -473,6 +588,22 @@

Returns

Wire
Returning wire from the bus.
+
+ +Expand source code + +
def get_wire(self, wire_index: int = 0):
+    """Retrieves a wire from the bus by a given index.
+
+    Args:
+        wire_index (int, optional): Index of wire to be retrieved from the bus. Defaults to 0.
+
+    Returns:
+        Wire: Returning wire from the bus.
+    """
+    assert wire_index < self.N, f"Wire index {wire_index} is out of bounds of the bus {self.prefix} with size {self.N}"
+    return self.bus[wire_index]
+
def get_wire_assign_blif(self, output: bool = False) @@ -489,6 +620,27 @@

Returns

str
Blif code for bus wires assignments.
+
+ +Expand source code + +
def get_wire_assign_blif(self, output: bool = False):
+    """Assign all bits from the bus as each individual wires or assign wires into the corresponding output bus position in Blif code representation.
+
+    Args:
+        output (bool, optional): Specifies whether bus wires are used as outputs (True, assigned to) or as inputs (False, assigned from). Defaults to False.
+
+    Returns:
+        str: Blif code for bus wires assignments.
+    """
+    # Ensures correct binding between the bus wire index and the wire itself
+    # It is used for the case when multiple of the same wire (e.g. `ContantWireValue0()`) are present in the bus (its id would otherwise be incorrect when using `self.bus.index(_)`)
+    mapped_positions = [(w_id, self.bus[w_id]) for w_id in range(self.N)]
+    if self.N > 1:
+        return "".join([w[1].get_assign_blif(prefix=self.prefix+f"[{w[0]}]", output=output) for w in mapped_positions])
+    else:
+        return "".join([w[1].get_assign_blif(prefix=self.prefix, output=output) for w in mapped_positions])
+
def get_wire_declaration_blif(self) @@ -500,6 +652,22 @@

Returns

str
Blif code for declaration of individual bus wires.
+
+ +Expand source code + +
def get_wire_declaration_blif(self):
+    """Declare each wire from the bus independently in Blif code representation.
+
+    Returns:
+        str: Blif code for declaration of individual bus wires.
+    """
+    # Ensures correct binding between the bus wire index and the wire itself
+    # It is used for the case when multiple of the same wire (e.g. `ContantWireValue0()`) are present in the bus (its id would otherwise be incorrect when using `self.bus.index(_)`)
+    mapped_positions = [(w_id, self.bus[w_id]) for w_id in range(self.N)]
+    array = True if self.N > 1 else False
+    return "".join([f" {w[1].get_declaration_blif(prefix=self.prefix, offset=w[0], array=array)}" for w in mapped_positions])
+
def get_wire_declaration_v(self) @@ -511,6 +679,18 @@

Returns

str
Verilog code for declaration of individual bus wires.
+
+ +Expand source code + +
def get_wire_declaration_v(self):
+    """Declare the wire in Verilog code representation.
+
+    Returns:
+        str: Verilog code for declaration of individual bus wires.
+    """
+    return f"  wire [{self.N-1}:0] {self.prefix};\n"
+
def is_output_bus(self) @@ -522,6 +702,18 @@

Returns

bool
Returns True if it is an output bus of some component.
+
+ +Expand source code + +
def is_output_bus(self):
+    """Tells whether this Bus is an output bus.
+
+    Returns:
+        bool: Returns True if it is an output bus of some component.
+    """
+    return self.out_bus
+
def return_bus_wires_sign_extend_c_flat(self) @@ -533,6 +725,22 @@

Returns

str
C code for sign extending the bus variable wire values.
+
+ +Expand source code + +
def return_bus_wires_sign_extend_c_flat(self):
+    """Sign extends the bus's corresponding C variable to ensure proper flat C code variable signedness.
+
+    Returns:
+        str: C code for sign extending the bus variable wire values.
+    """
+    if self.signed is True:
+        last_bus_wire = self.bus[-1]
+        return "".join([f"  {self.prefix} |= {last_bus_wire.return_wire_value_c_flat(offset=i)}" for i in range(len(self.bus), self.c_var_size)])
+    else:
+        return ""
+
def return_bus_wires_sign_extend_c_hier(self) @@ -544,6 +752,22 @@

Returns

str
C code for sign extending the bus variable wire values.
+
+ +Expand source code + +
def return_bus_wires_sign_extend_c_hier(self):
+    """Sign extends the bus's corresponding C variable to ensure proper hier C code variable signedness.
+
+    Returns:
+        str: C code for sign extending the bus variable wire values.
+    """
+    if self.signed is True:
+        last_bus_wire = self.bus[-1]
+        return "".join([f"  {self.prefix} |= {last_bus_wire.return_wire_value_c_hier(offset=i)}" for i in range(len(self.bus), self.c_var_size)])
+    else:
+        return ""
+
def return_bus_wires_sign_extend_python_flat(self, retype: bool = False) @@ -555,6 +779,34 @@

Returns

str
Python code for sign extending the bus variable wire values.
+
+ +Expand source code + +
  def return_bus_wires_sign_extend_python_flat(self, retype: bool = False):
+      """Sign extends the bus's corresponding Python variable (object) to ensure proper flat Python code variable signedness.
+
+      Returns:
+          str: Python code for sign extending the bus variable wire values.
+      """
+      if self.signed is True:
+          last_bus_wire = self.bus[-1]
+
+          assert self.N < 64, "Sign extension is not supported for bus with more than 64 bits"
+          if retype:
+              rewrite = f"""
+if hasattr({self.prefix}, 'astype'):
+  {self.prefix} = {self.prefix}.astype("int64")
+else:
+  from ctypes import c_int64
+  {self.prefix} = c_int64({self.prefix}).value\n"""
+          else:
+              rewrite = ""
+          
+          return "".join([f"  {self.prefix} = ({self.prefix}) | {last_bus_wire.return_wire_value_python_flat(offset=i)}" for i in range(len(self.bus), 64)]) + rewrite
+      else:
+          return ""
+
def return_bus_wires_values_c_flat(self) @@ -566,6 +818,21 @@

Returns

str
C code for assigning wire values into bus represented in C code variable.
+
+ +Expand source code + +
def return_bus_wires_values_c_flat(self):
+    """Retrieves values from bus's wires and stores them in bus's corresponding C variable at proper offset bit position in the bus for flat generation.
+
+    Returns:
+        str: C code for assigning wire values into bus represented in C code variable.
+    """
+    # Ensures correct binding between the bus wire index and the wire itself
+    # It is used for the case when multiple of the same wire (e.g. `ContantWireValue0()`) are present in the bus (its id would otherwise be incorrect when using `self.bus.index(_)`)
+    mapped_positions = [(w_id, self.bus[w_id]) for w_id in range(self.N)]
+    return "".join([f"  {self.prefix} |= {w[1].return_wire_value_c_flat(offset=w[0])}" for w in mapped_positions])
+
def return_bus_wires_values_c_hier(self) @@ -577,6 +844,21 @@

Returns

str
C code for assigning wire values into bus represented in C code variable.
+
+ +Expand source code + +
def return_bus_wires_values_c_hier(self):
+    """Retrieves values from bus's wires and stores them in bus's corresponding C variable at proper offset bit position in the bus for hierarchical generation.
+
+    Returns:
+        str: C code for assigning wire values into bus represented in C code variable.
+    """
+    # Ensures correct binding between the bus wire index and the wire itself
+    # It is used for the case when multiple of the same wire (e.g. `ContantWireValue0()`) are present in the bus (its id would otherwise be incorrect when using `self.bus.index(_)`)
+    mapped_positions = [(w_id, w) for w_id, w in enumerate(self.bus) if ((w.parent_bus is None) or (w.parent_bus is not None and w.prefix != self.prefix) or (w.is_const()))]
+    return "".join([f"  {self.prefix} |= {w[1].return_wire_value_c_hier(offset=w[0])}" for w in mapped_positions])
+
def return_bus_wires_values_python_flat(self) @@ -588,6 +870,21 @@

Returns

str
Python code for assigning wire values into bus represented in Python code variable.
+
+ +Expand source code + +
def return_bus_wires_values_python_flat(self):
+    """Retrieves values from bus's wires and stores them in bus's corresponding Python variable (object) at proper offset bit position in the bus for flat generation.
+
+    Returns:
+        str: Python code for assigning wire values into bus represented in Python code variable.
+    """
+    # Ensures correct binding between the bus wire index and the wire itself
+    # It is used for the case when multiple of the same wire (e.g. `ContantWireValue0()`) are present in the bus (its id would otherwise be incorrect when using `self.bus.index(_)`)
+    mapped_positions = [(w_id, self.bus[w_id]) for w_id in range(self.N)]
+    return "".join([f"  {self.prefix} = 0\n"] + [f"  {self.prefix} = ({self.prefix}) | {w[1].return_wire_value_python_flat(offset=w[0])}" for w in mapped_positions])
+
def return_bus_wires_values_v_flat(self) @@ -599,6 +896,21 @@

Returns

str
Verilog code for assigning wire values into bus represented in Verilog code bus variable.
+
+ +Expand source code + +
def return_bus_wires_values_v_flat(self):
+    """Retrieves values from bus's wires and stores them in bus's corresponding Verilog variable at proper offset bit position in the bus for flat generation.
+
+    Returns:
+        str: Verilog code for assigning wire values into bus represented in Verilog code bus variable.
+    """
+    # Ensures correct binding between the bus wire index and the wire itself
+    # It is used for the case when multiple of the same wire (e.g. `ContantWireValue0()`) are present in the bus (its id would otherwise be incorrect when using `self.bus.index(_)`)
+    mapped_positions = [(w_id, self.bus[w_id]) for w_id in range(self.N)]
+    return "".join([f"  assign {self.prefix}[{w[0]}] = {w[1].return_wire_value_v_flat()}" for w in mapped_positions])
+
def return_bus_wires_values_v_hier(self) @@ -610,6 +922,21 @@

Returns

str
Verilog code for assigning wire values into bus represented in Verilog code variable.
+
+ +Expand source code + +
def return_bus_wires_values_v_hier(self):
+    """Retrieves values from bus's wires and stores them in bus's corresponding Verilog variable at proper offset bit position in the bus for hierarchical generation.
+
+    Returns:
+        str: Verilog code for assigning wire values into bus represented in Verilog code variable.
+    """
+    # Ensures correct binding between the bus wire index and the wire itself
+    # It is used for the case when multiple of the same wire (e.g. `ContantWireValue0()`) are present in the bus (its id would otherwise be incorrect when using `self.bus.index(_)`)
+    mapped_positions = [(w_id, w) for w_id, w in enumerate(self.bus) if ((w.parent_bus is None) or (w.parent_bus is not None and w.prefix != self.prefix) or (w.is_const()))]
+    return "".join([f"  assign {self.prefix}[{w[0]}] = {w[1].return_wire_value_v_hier()}" for w in mapped_positions])
+
@@ -658,7 +985,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.

diff --git a/wire_components/index.html b/wire_components/index.html index 9ebdd40..1c3a836 100644 --- a/wire_components/index.html +++ b/wire_components/index.html @@ -3,13 +3,13 @@ - + ariths_gen.wire_components API documentation - + @@ -66,7 +66,7 @@

Sub-modules

diff --git a/wire_components/wires.html b/wire_components/wires.html index 801e46a..efe0de6 100644 --- a/wire_components/wires.html +++ b/wire_components/wires.html @@ -3,13 +3,13 @@ - + ariths_gen.wire_components.wires API documentation - + @@ -100,6 +100,19 @@

Returns

bool
True, because constant wire carries a constant value 0.
+
+ +Expand source code + +
@staticmethod
+def is_const():
+    """Information whether wire carries constant value.
+
+    Returns:
+        bool: True, because constant wire carries a constant value 0.
+    """
+    return True
+

Inherited members

@@ -191,6 +204,19 @@

Returns

bool
True, because constant wire carries a constant value 1.
+
+ +Expand source code + +
@staticmethod
+def is_const():
+    """Information whether wire carries constant value.
+
+    Returns:
+        bool: True, because constant wire carries a constant value 1.
+    """
+    return True
+

Inherited members

@@ -219,7 +245,7 @@

Inherited members

class Wire -(name: str, prefix: str = '', value: int = 0, index: int = 0, parent_bus: object = None) +(name: str,
prefix: str = '',
value: int = 0,
index: int = 0,
parent_bus: object = None)

Class representing basic wire used to interconnect components.

@@ -537,6 +563,19 @@

Returns

bool
False, because basic wire doesn't represent a wire with constant value.
+
+ +Expand source code + +
@staticmethod
+def is_const():
+    """Information whether wire carries constant value.
+
+    Returns:
+        bool: False, because basic wire doesn't represent a wire with constant value.
+    """
+    return False
+

Instance variables

@@ -575,6 +614,37 @@

Returns

str
Blif code for assignment of one wire to another.
+
+ +Expand source code + +
def get_assign_blif(self, prefix: str, output: bool = False):
+    """Assignment of wire value to another desired wire in Blif code.
+
+    This wire's value is either assigned to desired output bus wire (represented by `prefix` name) when `output`=True.
+    Otherwise the wire value at desired bus position (represented by `prefix` name) is assigned to this wire when `output`=False.
+
+    Args:
+        prefix (str): Name of the source/destination bus wire to be assigned from/to.
+        output (bool, optional): Whether `prefix` represents the destination or the source wire in the assignment. Defaultly it symbolizes the source. Defaults to False.
+
+    Returns:
+        str: Blif code for assignment of one wire to another.
+    """
+    if output is True:
+        if self.is_const():
+            return f".names {self.blif_const} {prefix}\n" + \
+                   f"1 1\n"
+        else:
+            return f".names {self.name} {prefix}\n" + \
+                   f"1 1\n"
+    else:
+        if self.is_const():
+            return "\n"
+        else:
+            return f".names {prefix} {self.name}\n" + \
+                   f"1 1\n"
+
def get_declaration_blif(self, prefix: str = '', offset: int = 0, array: bool = False) @@ -597,6 +667,29 @@

Returns

str
Blif code for declaration of a wire.
+
+ +Expand source code + +
def get_declaration_blif(self, prefix: str = "", offset: int = 0, array: bool = False):
+    """Declaration of wire which is part of a bus in Blif code.
+
+    Declares basic wire name if wire is not part of a bus
+    or declares wire by an offset of its position within the bus.
+
+    Args:
+        prefix (str, optional): Bus prefix of which this wire is a part off. Defaults to "".
+        offset (int, optional): Offset wire location within a bus. Defaults to 0.
+        array (bool, optional): Tells whether a basic wire or a wire from within a bus is to be declared. Defaults to False.
+
+    Returns:
+        str: Blif code for declaration of a wire.
+    """
+    if array is True:
+        return f"{prefix}[{offset}]"
+    else:
+        return f"{prefix}"
+
def get_declaration_c(self) @@ -608,6 +701,21 @@

Returns

str
Empty string if C code wire is carrying constant value (constant value is used in situ) or returns C code for declaration and initialization of wire's name.
+
+ +Expand source code + +
def get_declaration_c(self):
+    """Wire declaration in C code.
+
+    Returns:
+        str: Empty string if C code wire is carrying constant value (constant value is used in situ) or returns C code for declaration and initialization of wire's name.
+    """
+    if self.is_const():
+        return ""
+    else:
+        return f"  uint8_t {self.name} = {self.value};\n"
+
def get_declaration_v_flat(self) @@ -619,6 +727,21 @@

Returns

str
Empty string if Verilog code wire is carrying constant value (constant value is used in situ) or returns Verilog code for declaration and initialization of wire's name.
+
+ +Expand source code + +
def get_declaration_v_flat(self):
+    """Wire declaration for flat Verilog code.
+
+    Returns:
+        str: Empty string if Verilog code wire is carrying constant value (constant value is used in situ) or returns Verilog code for declaration and initialization of wire's name.
+    """
+    if self.is_const():
+        return ""
+    else:
+        return f"  wire {self.name};\n"
+
def get_declaration_v_hier(self) @@ -630,6 +753,21 @@

Returns

str
Empty string if Verilog code wire is carrying constant value (constant value is used in situ) or returns Verilog code for declaration and initialization of wire's name.
+
+ +Expand source code + +
def get_declaration_v_hier(self):
+    """Wire declaration for hierarchical Verilog code.
+
+    Returns:
+        str: Empty string if Verilog code wire is carrying constant value (constant value is used in situ) or returns Verilog code for declaration and initialization of wire's name.
+    """
+    if self.is_const():
+        return ""
+    else:
+        return f"  wire [0:0] {self.name};\n"
+
def get_wire_declaration_blif(self) @@ -642,6 +780,20 @@

Returns

str
Blif code for declaration of a wire.
+
+ +Expand source code + +
def get_wire_declaration_blif(self):
+    """Declaration of a single wire in Blif code.
+    
+    Used for declaration of modul inputs.
+    
+    Returns:
+        str: Blif code for declaration of a wire.
+    """
+    return f"{self.prefix} "
+
def get_wire_value_blif(self) @@ -655,6 +807,24 @@

Returns

str
Blif code to get bit value from this wire or to get constant wire's bit value 0/1.
+
+ +Expand source code + +
def get_wire_value_blif(self):
+    """Accesses bit value from wire represented in Blif code.
+
+    Used for assignment of specific one bit circuit/gate values to their respective parameters
+    in hierarchical Blif subcomponents generation.
+
+    Returns:
+        str: Blif code to get bit value from this wire or to get constant wire's bit value 0/1.
+    """
+    if self.is_const():
+        return self.blif_const
+    else:
+        return self.name
+
def get_wire_value_c_flat(self) @@ -666,6 +836,31 @@

Returns

str
C code bitwise shift to get desired bit value from this wire or wire variable's constant bit value 0/1.
+
+ +Expand source code + +
def get_wire_value_c_flat(self):
+    """Accesses desired bit value from wire represented in C code variable used for flat generation.
+
+    Returns:
+        str: C code bitwise shift to get desired bit value from this wire or wire variable's constant bit value 0/1.
+    """
+    if self.is_const():
+        return f"({self.c_const})"
+    # If wire is part of an input bus (where wire names are concatenated from bus prefix and their index position inside the bus in square brackets)
+    # then the wire value is obtained from bitwise shifting the required wire from the parent bus ('parent_bus.prefix' is the same value as 'self.prefix')
+    elif self.is_buswire() and self.name == f"{self.prefix}[{self.index}]":
+        return f"(({self.prefix} >> {self.index}) & 0x01)"
+    elif self.is_buswire():
+        g = re.match(r"(.*)\[(\d+)\]", self.name)
+        if g:
+            return f"(({g.group(1)} >> {g.group(2)}) & 0x01)"
+        else:
+            return f"(({self.name} >> 0) & 0x01)"
+    else:
+        return f"(({self.name} >> 0) & 0x01)"
+
def get_wire_value_c_hier(self) @@ -677,6 +872,21 @@

Returns

str
C code bitwise shift to get desired bit value position from this wire or wire variable's constant bit value 0/1.
+
+ +Expand source code + +
def get_wire_value_c_hier(self):
+    """Accesses desired bit value from wire represented in C code variable used for hierarchical generation.
+
+    Returns:
+        str: C code bitwise shift to get desired bit value position from this wire or wire variable's constant bit value 0/1.
+    """
+    if self.is_const():
+        return f"({self.c_const})"
+    else:
+        return f"(({self.prefix} >> {self.index}) & 0x01)"
+
def get_wire_value_v_flat(self) @@ -688,6 +898,21 @@

Returns

str
Verilog code to get bit value from this wire or to get constant wire's bit value 0/1.
+
+ +Expand source code + +
def get_wire_value_v_flat(self):
+    """Accesses bit value from wire represented in Verilog code variable used for flat generation.
+
+    Returns:
+        str: Verilog code to get bit value from this wire or to get constant wire's bit value 0/1.
+    """
+    if self.is_const():
+        return self.v_const
+    else:
+        return self.name
+
def get_wire_value_v_hier(self) @@ -699,12 +924,34 @@

Returns

str
Verilog code to get bit value from this wire or to get constant wire's bit value 0/1.
+
+ +Expand source code + +
def get_wire_value_v_hier(self):
+    """Accesses bit value from wire represented in Verilog code variable used for hierarchical generation.
+
+    Returns:
+        str: Verilog code to get bit value from this wire or to get constant wire's bit value 0/1.
+    """
+    if self.is_const():
+        return self.v_const
+    else:
+        return f"{self.prefix}[{self.index}]"
+
def is_buswire(self)
+
+ +Expand source code + +
def is_buswire(self):
+    return self.name.endswith("["+str(self.index)+"]") and self.parent_bus is not None
+
def return_wire_value_c_flat(self, offset: int = 0) @@ -721,6 +968,24 @@

Returns

str
C code bitwise shift for storing (constant/variable) wire value at desired offset position.
+
+ +Expand source code + +
def return_wire_value_c_flat(self, offset: int = 0):
+    """Retrieves desired bit value from wire represented in C code variable and bitwise shifts it to desired position for storing it within a bus for flat generation.
+
+    Args:
+        offset (int, optional): Used to shift wire value in order to be stored in proper location inside a bus. Defaults to 0.
+
+    Returns:
+        str: C code bitwise shift for storing (constant/variable) wire value at desired offset position.
+    """
+    if self.is_const():
+        return f"({self.c_const}) << {offset};\n"
+    else:
+        return f"(({self.name} >> 0) & 0x01ull) << {offset};\n"
+
def return_wire_value_c_hier(self, offset: int = 0) @@ -737,6 +1002,26 @@

Returns

str
C code bitwise shift for storing (constant/variable) wire value at desired offset position.
+
+ +Expand source code + +
def return_wire_value_c_hier(self, offset: int = 0):
+    """Retrieves desired bit value from wire represented in C code variable and bitwise shifts it to desired position for storing it within a bus for hierarchical generation.
+
+    Args:
+        offset (int, optional): Used to shift wire value in order to be stored in proper location inside a bus. Defaults to 0.
+
+    Returns:
+        str: C code bitwise shift for storing (constant/variable) wire value at desired offset position.
+    """
+    # If wire is part of an input bus (where wire names are concatenated from bus prefix and their index position inside the bus in square brackets)
+    # then the wire value is obtained from bitwise shifting the required wire from the parent bus ('parent_bus.prefix' is the same value as 'self.prefix')
+    if self.is_const():
+        return f"({self.c_const}) << {offset};\n"
+    else:
+        return f"(({self.prefix} >> {self.index}) & 0x01ull) << {offset};\n"
+
def return_wire_value_python_flat(self, offset: int = 0) @@ -753,6 +1038,29 @@

Returns

str
Python code bitwise shift for storing (constant/variable) wire value at desired offset position.
+
+ +Expand source code + +
def return_wire_value_python_flat(self, offset: int = 0):
+    """Retrieves desired bit value from wire represented in Python code variable (object) and bitwise shifts it to desired position for storing it within a bus for flat generation.
+
+    Args:
+        offset (int, optional): Used to shift wire value in order to be stored in proper location inside a bus. Defaults to 0.
+
+    Returns:
+        str: Python code bitwise shift for storing (constant/variable) wire value at desired offset position.
+    """
+    if self.is_const():
+        return f"(({self.c_const}) << {offset})\n"
+    # If wire is part of an input bus (where wire names are concatenated from bus prefix and their index position inside the bus in square brackets)
+    # then the wire value is obtained from bitwise shifting the required wire from the parent bus ('parent_bus.prefix' is the same value as 'self.prefix')
+    elif self.is_buswire():
+        return f"((({self.prefix} >> {self.index}) & 0x01) << {offset})\n"
+
+    else:
+        return f"((({self.name} >> 0) & 0x01) << {offset})\n"
+
def return_wire_value_v_flat(self) @@ -764,6 +1072,21 @@

Returns

str
Verilog code for retrieving (constant/variable) wire value (and assign it at desired bus offset position).
+
+ +Expand source code + +
def return_wire_value_v_flat(self):
+    """Retrieves bit value from wire represented in Verilog code variable for storing it within a bus for flat generation.
+
+    Returns:
+        str: Verilog code for retrieving (constant/variable) wire value (and assign it at desired bus offset position).
+    """
+    if self.is_const():
+        return f"{self.v_const};\n"
+    else:
+        return f"{self.name};\n"
+
def return_wire_value_v_hier(self) @@ -775,6 +1098,21 @@

Returns

str
Verilog code for retrieving (constant/variable) wire value used for assigning it into bus represented in Verilog code variable.
+
+ +Expand source code + +
def return_wire_value_v_hier(self):
+    """Retrieves bit value from bus's wires and stores them in bus's corresponding Verilog variable at proper offset bit position in the bus for hierarchical generation.
+
+    Returns:
+        str: Verilog code for retrieving (constant/variable) wire value used for assigning it into bus represented in Verilog code variable.
+    """
+    if self.is_const():
+        return f"{self.v_const};\n"
+    else:
+        return f"{self.prefix}[{self.index}];\n"
+
@@ -835,7 +1173,7 @@

-

Generated by pdoc 0.11.1.

+

Generated by pdoc 0.11.4.