ScheduledDeserializerEngine<LogicType extends Logic> constructor
Creates a scheduled typed-array collector.
Implementation
ScheduledDeserializerEngine({
required Logic clk,
required Logic reset,
required LogicType element,
required Logic write,
required Logic last,
required Logic clear,
required this.length,
String name = 'scheduled_deserializer_engine',
String? definitionName,
}) : super(
definitionName: definitionName ??
'ScheduledDeserializerEngine_L${length}_W${element.width}_'
'${payloadShapeIdentity(element)}',
name: name,
) {
if (length < 1) {
throw ArgumentError.value(length, 'length', 'Must be at least one.');
}
this.clk = addInput('clk', clk);
this.reset = addInput('reset', reset);
element = addTypedInput<LogicType>('element', element);
write = addInput('write', write);
last = addInput('last', last);
clear = addInput('clear', clear);
final localIndex = Logic(
name: '${name}_index',
width: widthFor(length),
);
final localComplete = Logic(name: '${name}_complete');
LogicType elementClone({String? name}) => element.cloneTyped(name: name);
TypedLogicArray<LogicType, LogicValue> dataClone({String? name}) =>
TypedLogicArray<LogicType, LogicValue>(
[length],
elementClone,
name: name ?? '${this.name}_data',
);
data = addTypedOutput<TypedLogicArray<LogicType, LogicValue>>(
'data',
dataClone,
);
addOutput('index', width: localIndex.width) <= localIndex;
addOutput('complete') <= localComplete;
Sequential(this.clk, reset: this.reset, resetValues: {
localIndex: 0,
localComplete: 0,
}, [
localComplete < 0,
If(clear, then: [
localIndex < 0,
], orElse: [
If(write, then: [
for (var slot = 0; slot < length; slot++)
If(localIndex.eq(slot), then: [
data.arrayElements[slot] < element,
]),
If(last | localIndex.eq(length - 1), then: [
localIndex < 0,
localComplete < 1,
], orElse: [
localIndex < localIndex + 1,
]),
]),
]),
]);
}