PriorityEncoder constructor

PriorityEncoder(
  1. Logic inp, {
  2. Logic? valid,
  3. String name = 'unnamed_module',
  4. String? definitionName,
})

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 in inp.
  • 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));
}