phanrahan / magma

magma circuits
Other
251 stars 23 forks source link

Add `m.reduce` function #544

Closed leonardt closed 4 years ago

leonardt commented 4 years ago

Right now you can use Python's built-in reduce function to generate a reduction tree, however in most cases, you'd rather target coreir's reduce primitive and have the downstream tool handle the synthesis of the reduction.

For example, functors.reduce(operator.and_, some_bits) will produce some_bits[0] & some_bits[1] & .... Instead, we would be able to say m.reduce(operator.and_, some_bits) and that would target the coreir reduce primitives, which would then generate code such as & some_bits. This would still allow the user to manually construct the reduction tree if desired, but also allow users to target the reduction primitives.

leonardt commented 4 years ago

Done