You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
demux component bargraph mode never turns on highest output #3519
With personality=8, you get pins out-00 through out-07, which are 8 pins. It should read (MM=00..personality-1) in the man-page.
That the last bit is not turned on is a logic error in the code.
The bargraph has personality+1 states ("0=all off" through "personality=all on") whereas the demux version only has personality states. In your test case: 0 for none activated and 8 for all activated, thus 0...8 and that equals 9 possible values.
That also makes the use of sel-bit-XX problematic with personality=32 because it cannot represent that case. You can use the sel-u32 pin to set the value.
This is the snippet:
if (bit >= personality) bit=personality-1;
for (i=0; i<personality ; i++) {
out(i) = (bargraph) ? (bit>i) : (bit==i);
}
It may be changed into:
if(bargraph) {
for (i=0; i<personality; i++) {
out(i) =bit>i;
}
} else {
if (bit >= personality) bit=personality-1;
for (i=0; i<personality; i++) {
out(i) =bit==i;
}
}
Another reason for removing the ternary inner test on bargraph is because it is a shared memory variable (parameter), which must be physically read each time in the loop. But that 1) creates a race because the variable can change in the execution of the loop and 2) if it doesn't change, it is ineffective because it cannot be optimized by the compiler.
Fixing the manpage is a no-brainer. The question is: can something go wrong if we fix the bargraph mode? Or leave it like that and just document the shortcoming?
I think it is probably safe to change it. Whilst we can't know what the component is being used for (ie, can't assume that it only drives LEDs and not guillotines, for example) allowing the (presumably unused in existing systems) top output to set is unlikely to have any affect at all.
What I'd like to mention here is that the name doesn't really match the function.
It is more a bit shift than a demultiplexer.
It could be interpreted as bit demultiplexer with fixed input.
I would like to rename this component but this will probably break a lot of configs.
We could add an optional input pin, so that it is a real demultiplexer but stays compatible. But a bit demultiplexer makes not much sense compared to the current function. Hmm...
Activity
BsAtHome commentedon Jul 19, 2025
With personality=8, you get pins
out-00throughout-07, which are 8 pins. It should read(MM=00..personality-1)in the man-page.That the last bit is not turned on is a logic error in the code.
The bargraph has
personality+1states ("0=all off" through "personality=all on") whereas the demux version only haspersonalitystates. In your test case:0for none activated and8for all activated, thus 0...8 and that equals 9 possible values.That also makes the use of
sel-bit-XXproblematic with personality=32 because it cannot represent that case. You can use thesel-u32pin to set the value.This is the snippet:
It may be changed into:
Another reason for removing the ternary inner test on
bargraphis because it is a shared memory variable (parameter), which must be physically read each time in the loop. But that 1) creates a race because the variable can change in the execution of the loop and 2) if it doesn't change, it is ineffective because it cannot be optimized by the compiler.rmu75 commentedon Jan 23, 2026
Fixing the manpage is a no-brainer. The question is: can something go wrong if we fix the bargraph mode? Or leave it like that and just document the shortcoming?
andypugh commentedon Jan 23, 2026
I think it is probably safe to change it. Whilst we can't know what the component is being used for (ie, can't assume that it only drives LEDs and not guillotines, for example) allowing the (presumably unused in existing systems) top output to set is unlikely to have any affect at all.
hansu commentedon Apr 11, 2026
What I'd like to mention here is that the name doesn't really match the function.
It is more a bit shift than a demultiplexer.
It could be interpreted as bit demultiplexer with fixed input.
I would like to rename this component but this will probably break a lot of configs.
We could add an optional input pin, so that it is a real demultiplexer but stays compatible. But a bit demultiplexer makes not much sense compared to the current function. Hmm...
demux: bargraph turns on its highest output; selection cannot wrap (L…
demux: bargraph turns on its highest output; selection cannot wrap (L…
demux: bargraph turns on its highest output; selection cannot wrap (L…