[Libre-soc-bugs] [Bug 713] PartitionedSignal enhancement to add partition-context-aware lengths

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Thu Oct 7 06:45:39 BST 2021


--- Comment #25 from Jacob Lifshay <programmerjake at gmail.com> ---
(In reply to Luke Kenneth Casson Leighton from comment #22)
> (In reply to Jacob Lifshay from comment #20)
> >     if not isinstance(lane_shapes, Mapping):
> >         lane_shapes = {i: lane_shapes for i in part_counts}
> >     lane_shapes = {i: Shape.cast(lane_shapes[i]) for i in part_counts}
> >     signed = lane_shapes[0].signed
> >     assert all(i.signed == signed for i in lane_shapes.values())
> by removing signed all of these lines can go.  this reduces the function
> by 25%.   lane_shapes can become a straight dict containing
> numbers, Shape can dral with the signed argument.

I think we should keep those lines, since it allows us to completely specify
all aspects of a PartitionedSignal's shape/layout/etc. by giving it one Python
value, lane_shapes. elwid and part_counts are retrieved from a global, they're
the equivalent of SimdPartMode. The idea is that code will look kinda like
self.elwid = Signal(ElWid)
with set_global_in_scope(self.elwid, ElWid.PART_COUNTS):
    self.a = PartitionedSignal(3) # all lanes are unsigned(3)
    self.b = PartitionedSignal(signed(5)) # all lanes are signed(5)
    # all lanes are whatever shape StateEnum is
    self.state = PartitionedSignal(StateEnum)

    # same shape as self.state, could use .like() or StateEnum directly
    self.state2 = PartitionedSignal(self.state.layout)
    self.mantissa = PartitionedSignal({
        ElWid.F16: 5, # from memory, probably off
        ElWid.BF16: 8,
        ElWid.F32: 8,
        ElWid.F64: 11,

In particular, notice that you can use nmigen Shapes without needing to write a
dict everywhere, greatly reducing the modifications needed to our existing

You are receiving this mail because:
You are on the CC list for the bug.

More information about the libre-soc-bugs mailing list