OneHotToBinary.base constructor

OneHotToBinary.base(
  1. Logic onehot, {
  2. bool generateError = false,
  3. String name = 'one_hot_to_binary',
})

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

Implementation

OneHotToBinary.base(Logic onehot,
    {this.generateError = false, super.name = 'one_hot_to_binary'}) {
  onehot = addInput('onehot', onehot, width: onehot.width);
  addOutput('binary', width: max(log2Ceil(onehot.width), 1));

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