OneHotToBinary.base constructor

  1. @protected
OneHotToBinary.base(
  1. Logic onehot, {
  2. bool generateError = false,
  3. String name = 'one_hot_to_binary',
  4. bool reserveName = false,
  5. bool reserveDefinitionName = false,
  6. String? definitionName,
})

Constructs a Module which decodes a one-hot number onehot into a 2s complement number binary by encoding the position of the '1'.

Implementation

@protected
OneHotToBinary.base(Logic onehot,
    {this.generateError = false,
    super.name = 'one_hot_to_binary',
    super.reserveName,
    super.reserveDefinitionName,
    String? definitionName})
    : super(
          definitionName:
              definitionName ?? 'OneHotToBinary_W${onehot.width}') {
  onehot = addInput('onehot', onehot, width: onehot.width);
  addOutput('binary', width: max(log2Ceil(onehot.width), 1));

  if (generateError) {
    addOutput('error');
  }
}