ReadyValidLifo<LogicType extends Logic> constructor
- required Logic clk,
- required Logic reset,
- required ReadyValidInterface<
LogicType> upstream, - required ReadyValidInterface<
LogicType> downstream, - required int depth,
- String name = 'ready_valid_lifo',
Creates a ready/valid LIFO.
Implementation
ReadyValidLifo(
{required Logic clk,
required Logic reset,
required ReadyValidInterface<LogicType> upstream,
required ReadyValidInterface<LogicType> downstream,
required this.depth,
String name = 'ready_valid_lifo'})
: super(
definitionName: 'ReadyValidLifo_D${depth}_'
'${payloadShapesIdentity([upstream.data, downstream.data])}',
name: name) {
downstream.validatePayloadCompatibility(upstream.data);
final localClk = addInput('clk', clk);
final localReset = addInput('reset', reset);
this.upstream = addPairInterface(upstream, PairRole.consumer,
uniquify: (original) => 'upstream_$original');
this.downstream = addPairInterfaceFrom(
IrrevocableReadyValidInterface<LogicType>(downstream.data.cloneTyped()),
downstream,
PairRole.provider,
uniquify: (original) => 'downstream_$original',
);
final lifo = Lifo<LogicType>(localClk, localReset,
pushEnable: this.upstream.valid,
pushData: this.upstream.data,
popEnable: this.downstream.ready,
replaceTopEnable: Const(0),
replaceTopData: this.upstream.data,
depth: depth,
name: '${name}_storage');
addOutput('occupancy', width: lifo.occupancy.width) <= lifo.occupancy;
addOutput('empty') <= lifo.empty;
addOutput('full') <= lifo.full;
addOutput('operationError') <= lifo.operationError;
this.upstream.ready <= ~lifo.full | this.downstream.ready;
this.downstream.valid <= ~lifo.empty;
this.downstream.data <= lifo.topData;
}