<FL4SHK>
Also, does an OR reduce translate into an OR tree?
<vup>
FL4SHK: do you just want `.any()`
<FL4SHK>
vup: `.any()`?
<vup>
some statement `.any()`
<vup>
(a + b).any()
<FL4SHK>
I need to do vector ORs
<vup>
ah
<FL4SHK>
I suppose it's still possible to use this
<FL4SHK>
No, I guess not.
<FL4SHK>
a `variable` would be helpful to have.
<FL4SHK>
As it stands, it looks like I have to use a Python `list` that I add `Signal`s representing subsequent values of the "variable" to
<FL4SHK>
then I can simply use `my_list[-1]` for the most recent value.
<d1b2>
<zyp> what are you trying to do? my_list[0] | my_list[1] | …?
<FL4SHK>
Okay so I was making two separate points.
<FL4SHK>
a value representing `my_list[0] | my_list[1] | my_list[2]` would need to use a `for` loop if I don't know how many elements are in `my_list`
<d1b2>
<zyp> I believe you can just treat it as a regular python expression and do functools.reduce(operator.or_, my_list)
<FL4SHK>
Ah, I see.
<FL4SHK>
Does it become something efficient when optimized by yosys?
<d1b2>
<zyp> I don't know, but I would expect it to be equivalent to typing out the expression for a known length of the list
<d1b2>
<zyp> I mean, functools.reduce(operator.or_, [a, b, c]) creates exactly the same expression as a | b | c as far as nmigen is concerned, they'll both invoke the OR-operator twice
<FL4SHK>
I'd prefer it generate an `or` tree
<FL4SHK>
I'm going to test it.
<d1b2>
<zyp> I figure that's an optimization yosys should do, not nmigen
<FL4SHK>
I agree.
<FL4SHK>
If yosys doesn't make that optimization, I have to do it myself.
<dragonmux>
also, if you have a list, you can pass it to Array to turn it into a nMigen object where you can then do .any() as suggested before to automate the generation of the | without having to map-reduce
<dragonmux>
this assumes a list/tuple of Signal/Array/etc but givne what you're asking, that seems like a reasonable assumption to make
<FL4SHK>
`Array` doesn't have an `any()` function.
<mwk>
what is it that you actually want?
<dragonmux>
Array() is a Value, and Value has .any()
<FL4SHK>
Array() is not a Value
<mwk>
a | b | c | d already has the right semantics, and after being put through synthesis, it will go through abc which will make it into a tree and rebalance it
<mwk>
so I don't see any actual problem here
<FL4SHK>
mwk: then that's what I need
<d1b2>
<zyp> then what I suggested should work
<mwk>
yosys itself has no pass for it, but abc is pretty good at this stuff
<dragonmux>
ohh, Array is an abc MutableSequence.. our bad
<FL4SHK>
When does it go through abc?
<mwk>
yosys calls abc as a subprocess in later stages of the synth flow
<FL4SHK>
Does it go through abc when I use Vivado for pnr?
<mwk>
if you're using the plain nmigen platform? no
<mwk>
but vivado also does its own optimizations, which should be able to optimize that stuff
<d1b2>
<zyp> in that case I'd expect vivado to do the right thing
<FL4SHK>
Okay.
<FL4SHK>
I'll just do a reduce, then.
<d1b2>
<zyp> I figure tree balancing would be among the lowest hanging fruits of optimizations
<dragonmux>
ah, if all your operands have the same shape, you can use `Operator('r|', my_list)`!!