Module ariths_gen.multi_bit_circuits.others.bit_reduce
Classes
class AndReduce (a: Bus,
prefix: str = '',
name: str = 'andreduce',
**kwargs)-
Class representing tree reducer circuit. Doent work for NAND gate!
Expand source code
class AndReduce(BitReduce): def __init__(self, a: Bus, prefix: str = "", name: str = "andreduce", **kwargs): super().__init__(a=a, gate=AndGate, prefix=prefix, name=name, **kwargs)
Ancestors
Inherited members
BitReduce
:add_component
get_blif_code_flat
get_blif_code_hier
get_c_code_flat
get_c_code_hier
get_cgp_code_flat
get_circuit_blif
get_circuit_c
get_circuit_def
get_circuit_gates
get_circuit_v
get_circuit_wire_index
get_circuit_wires
get_component_types
get_declaration_blif
get_declaration_c_flat
get_declaration_c_hier
get_declaration_v_flat
get_declaration_v_hier
get_declarations_c_hier
get_declarations_v_hier
get_function_blif_flat
get_function_block_blif
get_function_block_c
get_function_block_v
get_function_blocks_blif
get_function_blocks_c
get_function_blocks_v
get_function_out_blif
get_function_out_c_flat
get_function_out_c_hier
get_function_out_python_flat
get_function_out_v_flat
get_function_out_v_hier
get_hier_subcomponent_def
get_includes_c
get_init_c_flat
get_init_c_hier
get_init_python_flat
get_init_v_flat
get_init_v_hier
get_instance_num
get_invocation_blif_hier
get_invocations_blif_hier
get_multi_bit_components
get_one_bit_components
get_out_invocation_c
get_out_invocation_v
get_outputs_cgp
get_parameters_cgp
get_previous_component
get_prototype_blif
get_prototype_c
get_prototype_python
get_prototype_v
get_python_code_flat
get_triplets_cgp
get_unique_types
get_v_code_flat
get_v_code_hier
save_wire_id
class BitReduce (a: Bus,
gate: TwoInputLogicGate,
prefix: str = '',
name: str = 'bitreduce',
**kwargs)-
Class representing tree reducer circuit. Doent work for NAND gate!
Expand source code
class BitReduce(GeneralCircuit): """Class representing tree reducer circuit. Doent work for NAND gate! """ def __init__(self, a: Bus, gate: TwoInputLogicGate, prefix: str = "", name: str = "bitreduce", **kwargs): self.N = a.N super().__init__(name=name, prefix=prefix, inputs=[a], out_N=1, **kwargs) # tree reduction def create_tree(a: Bus, depth: int, branch="A"): #print(a) if a.N == 1: return a[0] else: half = a.N // 2 b_in = Bus(N=half, prefix=f"b_inn{depth}A") c_in = Bus(N=a.N - half, prefix=f"b_inn{depth}B") #print(a, half, a.N) for i, j in enumerate(range(half)): b_in[i] = a[j] for i, j in enumerate(range(half, a.N)): c_in[i] = a[j] b = create_tree(b_in, depth=depth + 1, branch = branch + "A") c = create_tree(c_in, depth= depth + 1, branch = branch + "B") d = gate(a=b, b=c, prefix = f"{self.prefix}_red_{branch}_{depth}") self.add_component(d) return d.out sumwire = create_tree(self.a, 0, "X") #print(sumbus) self.out[0] = sumwire
Ancestors
Subclasses
Inherited members
GeneralCircuit
:add_component
get_blif_code_flat
get_blif_code_hier
get_c_code_flat
get_c_code_hier
get_cgp_code_flat
get_circuit_blif
get_circuit_c
get_circuit_def
get_circuit_gates
get_circuit_v
get_circuit_wire_index
get_circuit_wires
get_component_types
get_declaration_blif
get_declaration_c_flat
get_declaration_c_hier
get_declaration_v_flat
get_declaration_v_hier
get_declarations_c_hier
get_declarations_v_hier
get_function_blif_flat
get_function_block_blif
get_function_block_c
get_function_block_v
get_function_blocks_blif
get_function_blocks_c
get_function_blocks_v
get_function_out_blif
get_function_out_c_flat
get_function_out_c_hier
get_function_out_python_flat
get_function_out_v_flat
get_function_out_v_hier
get_hier_subcomponent_def
get_includes_c
get_init_c_flat
get_init_c_hier
get_init_python_flat
get_init_v_flat
get_init_v_hier
get_instance_num
get_invocation_blif_hier
get_invocations_blif_hier
get_multi_bit_components
get_one_bit_components
get_out_invocation_c
get_out_invocation_v
get_outputs_cgp
get_parameters_cgp
get_previous_component
get_prototype_blif
get_prototype_c
get_prototype_python
get_prototype_v
get_python_code_flat
get_triplets_cgp
get_unique_types
get_v_code_flat
get_v_code_hier
save_wire_id
class OrReduce (a: Bus,
prefix: str = '',
name: str = 'orreduce',
**kwargs)-
Class representing tree reducer circuit. Doent work for NAND gate!
Expand source code
class OrReduce(BitReduce): def __init__(self, a: Bus, prefix: str = "", name: str = "orreduce", **kwargs): super().__init__(a=a, gate=OrGate, prefix=prefix, name=name, **kwargs)
Ancestors
Inherited members
BitReduce
:add_component
get_blif_code_flat
get_blif_code_hier
get_c_code_flat
get_c_code_hier
get_cgp_code_flat
get_circuit_blif
get_circuit_c
get_circuit_def
get_circuit_gates
get_circuit_v
get_circuit_wire_index
get_circuit_wires
get_component_types
get_declaration_blif
get_declaration_c_flat
get_declaration_c_hier
get_declaration_v_flat
get_declaration_v_hier
get_declarations_c_hier
get_declarations_v_hier
get_function_blif_flat
get_function_block_blif
get_function_block_c
get_function_block_v
get_function_blocks_blif
get_function_blocks_c
get_function_blocks_v
get_function_out_blif
get_function_out_c_flat
get_function_out_c_hier
get_function_out_python_flat
get_function_out_v_flat
get_function_out_v_hier
get_hier_subcomponent_def
get_includes_c
get_init_c_flat
get_init_c_hier
get_init_python_flat
get_init_v_flat
get_init_v_hier
get_instance_num
get_invocation_blif_hier
get_invocations_blif_hier
get_multi_bit_components
get_one_bit_components
get_out_invocation_c
get_out_invocation_v
get_outputs_cgp
get_parameters_cgp
get_previous_component
get_prototype_blif
get_prototype_c
get_prototype_python
get_prototype_v
get_python_code_flat
get_triplets_cgp
get_unique_types
get_v_code_flat
get_v_code_hier
save_wire_id