1 # SPDX-License-Identifier: LGPL-2.1-or-later
2 # See Notices.txt for copyright information
3 """Integer Multiplication."""
5 from typing import Any, NewType, Union, List, Dict, Iterable, Mapping, Optional
6 from typing_extensions import final
8 PartitionPointsIn = Mapping[int, Union[Value, bool, int]]
10 class PartitionPoints(Dict[int, Value]):
11 def __init__(self, partition_points: Optional[PartitionPointsIn] = None):
15 name: Optional[str] = None,
16 src_loc_at: int = 0) -> 'PartitionPoints':
19 def eq(self, rhs: 'PartitionPoints') -> Iterable[Assign]:
22 def as_mask(self, width: int) -> Value:
23 bits: List[Union[Value, bool]]
25 def get_max_partition_count(self, width: int) -> int:
28 def fits_in_width(self, width: int) -> bool:
33 class FullAdder(Elaboratable):
34 def __init__(self, width: int):
37 def elaborate(self, platform: Any) -> Module:
42 class PartitionedAdder(Elaboratable):
43 def __init__(self, width: int, partition_points: PartitionPointsIn):
46 def elaborate(self, platform: Any) -> Module:
51 class AddReduce(Elaboratable):
56 def get_max_level(input_count: int) -> int:
59 def next_register_levels(self) -> Iterable[int]:
63 def full_adder_groups(input_count: int) -> range:
66 def elaborate(self, platform: Any) -> Module:
67 intermediate_terms: List[Signal]
68 def add_intermediate_term(value: Value) -> None:
72 class Mul8_16_32_64(Elaboratable):
73 def __init__(self, register_levels: Iterable[int] = ()):
76 def _part_byte(self, index: int) -> Value:
79 def elaborate(self, platform: Any) -> Module:
82 def add_term(value: Value,
84 enabled: Optional[Value] = None) -> None: