OneHotToBinary.base constructor
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');
}
}