ReadyValidFrameLockingRoundRobinMux<LogicType extends Logic> constructor
- required Logic clk,
- required Logic reset,
- required List<
ReadyValidInterface< upstreams,Frame< >LogicType> > - required ReadyValidInterface<
Frame< downstream,LogicType> > - String name = 'ready_valid_frame_locking_round_robin_mux',
Creates a frame-locking round-robin mux.
Implementation
ReadyValidFrameLockingRoundRobinMux({
required Logic clk,
required Logic reset,
required List<ReadyValidInterface<Frame<LogicType>>> upstreams,
required ReadyValidInterface<Frame<LogicType>> downstream,
String name = 'ready_valid_frame_locking_round_robin_mux',
}) : inputCount = upstreams.length,
super(definitionName: _definitionName(upstreams), name: name) {
if (upstreams.isEmpty) {
throw ArgumentError.value(upstreams, 'upstreams', 'Must not be empty.');
}
for (var index = 0; index < upstreams.length; index++) {
upstreams[index].requireProviderComposableWith(
ReadyValidContract.validThenReady,
consumerName: '$name upstream $index',
);
}
downstream.requireConsumerComposableWith(
ReadyValidContract.readyAndValid,
providerName: name,
);
final localClk = addInput('clk', clk);
final localReset = addInput('reset', reset);
_upstreams = UnmodifiableListView([
for (var index = 0; index < inputCount; index++)
addPairInterface(
upstreams[index],
PairRole.consumer,
uniquify: (original) => 'upstream_${index}_$original',
),
]);
_downstream = addPairInterface(
downstream,
PairRole.provider,
uniquify: (original) => 'downstream_$original',
);
addOutput('selection', width: inputCount);
addOutput('grant', width: inputCount);
addOutput('locked');
final policyMux = ReadyValidPolicyMux<Frame<LogicType>>(
clk: localClk,
reset: localReset,
upstreams: _upstreams,
downstream: _downstream,
policy: roundRobinArbitrationPolicy,
advanceMode: ArbitrationAdvanceMode.onCompletion,
retentionPolicy: ArbitrationRetentionPolicy.lockUntilRelease,
complete: _downstream.accepted & _downstream.data.last,
captureOwner: _downstream.accepted & ~_downstream.data.last,
releaseOwner: _downstream.accepted & _downstream.data.last,
name: '${name}_policy_mux',
);
selection <= policyMux.selection;
grant <= policyMux.grant;
locked <= policyMux.locked;
}