buildFlops method

  1. @protected
  2. @override
void buildFlops()
override

Builds the flops that store the count.

Implementation

@protected
@override
void buildFlops() {
  clkGatePartitionIndex =
      _providedClkGateParitionIndex ?? _pickPartitionIndex();

  if (clkGatePartitionIndex >= width || clkGatePartitionIndex < 0) {
    // just gate the whole thing together
    final clkGate = ClockGate(clk,
        enable: _lowerEnable | _upperEnable,
        reset: reset,
        controlIntf: _clockGateControlInterface);

    lowerGatedClock = clkGate.gatedClk;
    upperGatedClock = clkGate.gatedClk;

    count <=
        flop(
          clkGate.gatedClk,
          summer.sum,
          reset: reset,
          resetValue: initialValueLogic,
        );
  } else {
    final lowerClkGate = ClockGate(clk,
        enable: _lowerEnable,
        reset: reset,
        controlIntf: _clockGateControlInterface,
        name: 'lower_clock_gate');

    final upperClkGate = ClockGate(clk,
        enable: _upperEnable,
        reset: reset,
        controlIntf: _clockGateControlInterface,
        name: 'upper_clock_gate');

    final lowerCount = flop(
      lowerClkGate.gatedClk,
      summer.sum.getRange(0, clkGatePartitionIndex),
      reset: reset,
      resetValue: initialValueLogic.getRange(0, clkGatePartitionIndex),
    );

    final upperCount = flop(
      upperClkGate.gatedClk,
      summer.sum.getRange(clkGatePartitionIndex),
      reset: reset,
      resetValue: initialValueLogic.getRange(clkGatePartitionIndex),
    );

    lowerGatedClock = lowerClkGate.gatedClk;
    upperGatedClock = upperClkGate.gatedClk;

    count <= [upperCount, lowerCount].swizzle();
  }
}