ApbCompleter constructor

ApbCompleter({
  1. required ApbInterface apb,
  2. String name = 'apb_completer',
})

Constructor.

Implementation

ApbCompleter({required ApbInterface apb, super.name = 'apb_completer'}) {
  this.apb = apb.clone()
    ..connectIO(this, apb,
        inputTags: {
          ApbDirection.fromRequester,
          ApbDirection.fromRequesterExceptSelect,
          ApbDirection.misc
        },
        outputTags: {ApbDirection.fromCompleter},
        uniquify: (orig) => '${name}_$orig');

  downstreamValid = Logic(name: 'downstreamValid');
  upstreamValid = Logic(name: 'upstreamValid');
  fsm = FiniteStateMachine<ApbCompleterState>(
      this.apb.clk, ~this.apb.resetN, ApbCompleterState.idle, [
    // IDLE
    //    move to SELECTED when we get a SELx
    State(
      ApbCompleterState.idle,
      events: {
        this.apb.sel[0] & ~this.apb.enable: ApbCompleterState.selected,
      },
      actions: [
        downstreamValid < 0,
      ],
    ),
    // SELECTED move when we get an ENABLE if the transaction has latency,
    //    move to ACCESS state if the transaction has no latency, can move
    //    directly back to IDLE for performance
    State(
      ApbCompleterState.selected,
      events: {
        this.apb.enable & ~upstreamValid: ApbCompleterState.access,
        this.apb.enable & upstreamValid: ApbCompleterState.idle,
      },
      actions: [
        downstreamValid < this.apb.enable,
      ],
    ),
    // ACCESS
    //    move to IDLE when the transaction is done
    State(
      ApbCompleterState.access,
      events: {
        upstreamValid: ApbCompleterState.idle,
      },
      actions: [
        downstreamValid < 1,
      ],
    ),
  ]);

  _build();
}