peepsalot has quit [Remote host closed the connection]
peepsalot has joined #amaranth-lang
notgull has quit [Ping timeout: 260 seconds]
nelgau has quit [Ping timeout: 276 seconds]
vegard_e[m] has quit [Quit: Idle timeout reached: 172800s]
cr1901 has quit [Quit: Leaving]
cr1901 has joined #amaranth-lang
<vup>
Is `Signal(range(0))` intended to raise `SyntaxWarning: Reset value 0 equals the non-inclusive end of the signal shape range(0, 0); this is likely an off-by-one error` ?
<vup>
The direct equivalent of `Signal(unsigned(0))` doesn't raise that warning
Wanda[cis] has joined #amaranth-lang
<Wanda[cis]>
it's not a direct equivalent; Signal(unsigned(0)) is equivalent to Signal(range(1))
<Hoernchen>
but range(0) has a length of 0 so this is not the same at all
<Wanda[cis]>
they both have one valid value (which is 0)
<Wanda[cis]>
however, Signal(range(0)) nominally has no valid values at all, ie. is a never type
<vup>
not sure I follow
<vup>
```
<vup>
```
<vup>
unsigned(0)
<vup>
>>> Shape.cast(range(0))
<Wanda[cis]>
yeah, it gets converted up to a 0-width value
<Wanda[cis]>
because Amaranth doesn't have actual never types
<Wanda[cis]>
(and it'd be quite hard to figure out sensible semantics for those in a HDL)
<Wanda[cis]>
which... well, is actually why this warning happens
<Wanda[cis]>
you're effectively asking for a signal with no valid values at all; shape-wise it gets upconverted to unsigned(0) which has one valid value, but the validity check still triggers with the original specification of range(0) for the default initial value of 0
<Wanda[cis]>
but, back to the original question
<Wanda[cis]>
I'd say this is... a fairly confusing message
<vup>
right, to me the warning is quite confusing, because I did not understand that `range(0)` is interpreted as a never type, especially as amaranth doesn't really suport never types and implicitly converts them to 0-width values
<vup>
yeah ^^
<Wanda[cis]>
so... what's your use case for a Signal(range(0)) in the first place?
<Wanda[cis]>
I have honestly no idea what should happen here
<vup>
just generic code, that happens to have `range(0)` as an edgecase
<Hoernchen>
it should not be just a warning
<Wanda[cis]>
vup: yeah, figured, but... what do you expect this signal to do in that edge case?
<Wanda[cis]>
I suppose the only valid use case for something that is effectively the never type in a HDL would be when the signal is always gated off to be effectively don't care?
<Wanda[cis]>
hm
<Wanda[cis]>
yeah I can see something like that
<Wanda[cis]>
I do think it'd be useful to just be able to say Signal(range(0)) without triggering a warning about the init value
<Wanda[cis]>
... as long as that value is not explicitly chosen, at least? hm.
<Wanda[cis]>
unsure about that part
<Wanda[cis]>
either way
<Wanda[cis]>
I'd say file a bug, we can talk about it at the meeting tomorrow
<vup>
Wanda[cis]: yep, the signal is used in some comparisons, which I would expect to never evaluate to true