BinaryToOneHot constructor

BinaryToOneHot(
  1. Logic binary, {
  2. String name = 'binary_to_one_hot',
})

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'}) {
  binary = addInput('binary', binary, width: binary.width);
  addOutput('encoded', width: pow(2, binary.width).toInt());
  encoded <= Const(1, width: encoded.width) << binary;
}