Module ariths_gen.multi_bit_circuits.others.popcount_compare
Classes
class PopCountCompare (a: Bus,
b: Bus,
prefix: str = '',
name: str = 'popcnt_cmp',
**kwargs)-
Expand source code
class PopCountCompare(GeneralCircuit): """Class representing a circiut if number of ones in a is larger or equal than number of ones in b │ │ │ │ │ │ │ │ │ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ┌───────┐ ┌─────────┐ │ popcnt│ │ popcnt │ └──┬────┘ └─────┬───┘ │ │ └───────┐ ┌──────┘ ┌──▼───▼──┐ │ <= │ └────┬────┘ │ ▼ """ def __init__(self, a: Bus, b: Bus, prefix : str = "", name : str = "popcnt_cmp", **kwargs): super().__init__(name=name, prefix=prefix, inputs=[a, b], out_N=1, **kwargs) p1 = self.add_component(UnsignedPopCount(a=Bus(wires_list=self.a.bus, prefix=f"{prefix}_popcount1_a"), prefix=f"{prefix}_popcount1", inner_component=True)).out p2 = self.add_component(UnsignedPopCount(a=Bus(wires_list=self.b.bus, prefix=f"{prefix}_popcount2_a"), prefix=f"{prefix}_popcount2", inner_component=True)).out #N = max(p1.N, p2.N) #p1.bus_extend(N) #p2.bus_extend(N) red = self.add_component(UnsignedCompareGTE(p1, p2, prefix=f"{prefix}_cmp", inner_component = True)) self.out.connect_bus(red.out)Class representing a circiut if number of ones in a is larger or equal than number of ones in b
│ │ │ │ │ │ │ │ │ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ┌───────┐ ┌─────────┐ │ popcnt│ │ popcnt │ └──┬────┘ └─────┬───┘ │ │
└───────┐ ┌──────┘
┌──▼───▼──┐
│ <= │
└────┬────┘
│
▼Ancestors
Inherited members
GeneralCircuit:add_componentget_blif_code_flatget_blif_code_hierget_c_code_flatget_c_code_hierget_cgp_code_flatget_circuit_blifget_circuit_cget_circuit_defget_circuit_gatesget_circuit_vget_circuit_wire_indexget_circuit_wiresget_component_typesget_declaration_blifget_declaration_c_flatget_declaration_c_hierget_declaration_v_flatget_declaration_v_hierget_declarations_c_hierget_declarations_v_hierget_function_blif_flatget_function_block_blifget_function_block_cget_function_block_vget_function_blocks_blifget_function_blocks_cget_function_blocks_vget_function_out_blifget_function_out_c_flatget_function_out_c_hierget_function_out_python_flatget_function_out_v_flatget_function_out_v_hierget_hier_subcomponent_defget_includes_cget_init_c_flatget_init_c_hierget_init_python_flatget_init_v_flatget_init_v_hierget_instance_numget_invocation_blif_hierget_invocations_blif_hierget_multi_bit_componentsget_one_bit_componentsget_out_invocation_cget_out_invocation_vget_outputs_cgpget_parameters_cgpget_previous_componentget_prototype_blifget_prototype_cget_prototype_pythonget_prototype_vget_python_code_flatget_triplets_cgpget_unique_typesget_v_code_flatget_v_code_hiersave_wire_id