BinaryToOneHot constructor
Constructs a Module which encodes a 2's complement number binary
into a one-hot, or thermometer code
Implementation
BinaryToOneHot(Logic binary,
{super.name = 'binary_to_one_hot',
super.reserveName,
super.reserveDefinitionName,
String? definitionName})
: super(
definitionName:
definitionName ?? 'BinaryToOneHot_W${binary.width}') {
binary = addInput('binary', binary, width: binary.width);
addOutput('encoded', width: pow(2, binary.width).toInt());
encoded <= Const(1, width: encoded.width) << binary;
}