SignedShifter constructor

SignedShifter(
  1. Logic bits,
  2. Logic shift, {
  3. String name = 'shifter',
  4. bool reserveName = false,
  5. bool reserveDefinitionName = false,
  6. String? definitionName,
})

Create a SignedShifter that treats shift as signed

  • bits is the input to be shifted
  • shift is the signed amount to be shifted

Implementation

SignedShifter(Logic bits, Logic shift,
    {super.name = 'shifter',
    super.reserveName,
    super.reserveDefinitionName,
    String? definitionName})
    : super(
          definitionName: definitionName ?? 'SignedShifter_W${bits.width}') {
  bits = addInput('bits', bits, width: bits.width);
  shift = addInput('shift', shift, width: shift.width);

  addOutput('shifted', width: bits.width);
  shifted <= mux(shift[-1], bits >>> shift.abs(), bits << shift);
}