Shifter

January 15, 2025 ยท View on GitHub

ROHD-HCL provides a component to perform shifting of a Logic based on an input Logic treated as signed.

SignedShifter

The SignedShifter takes as input a Logic shiftshift and interprets shift>0shift > 0 as left-shift by the magnitude of shiftshift and right-shift by the magnitude of shiftshift if shift<0shift < 0.

   final bits = Const(16, width: 8);
   print(bits.value.toRadixString());
   // Produces: 16'b1_0000
   final shift = Logic(width: 3);
   final shifter = SignedShifter(bits, shift);

   shift.put(-1);
   print(shifter.shifted.value.toRadixString());
   // Produces:   16'b1000