PriorityEncoder constructor

PriorityEncoder(
  1. Logic inp, {
  2. bool generateValid = false,
  3. String name = 'priority_encoder',
  4. bool reserveName = false,
  5. bool reserveDefinitionName = false,
  6. 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,
    {bool generateValid = false,
    super.name = 'priority_encoder',
    super.reserveName,
    super.reserveDefinitionName,
    String? definitionName})
    : super(
          definitionName: definitionName ?? 'PriorityEncoder_W${inp.width}') {
  inp = addInput('inp', inp, width: inp.width);

  if (generateValid) {
    addOutput('valid');
  }
  addOutput('out', width: log2Ceil(inp.width + 1));
}