PriorityEncoder constructor
Construct a PriorityEncoder.
- out is the number of trailing zeros or the position of first trailing
one. Will be set to one past the length of the input
inp
if there are no bits set ininp
. - Optional
valid
output is set if the output position is valid
Implementation
PriorityEncoder(Logic inp, {Logic? valid, super.name, String? definitionName})
: super(
definitionName: definitionName ?? 'PriorityEncoder_W${inp.width}') {
inp = addInput('inp', inp, width: inp.width);
if (valid != null) {
addOutput('valid');
valid <= this.valid!;
}
addOutput('out', width: log2Ceil(inp.width + 1));
}