Deserializer constructor
Build a Deserializer that takes serialized input serialized
and aggregates it into one wide output deserialized of length length.
Updates one element per clock while enable
(if connected) is high,
emitting done when completing the filling of wide output LogicArray
deserialized.
Implementation
Deserializer(Logic serialized, this.length,
{required Logic clk,
required Logic reset,
Logic? enable,
super.name = 'deserializer'}) {
clk = addInput('clk', clk);
reset = addInput('reset', reset);
if (enable != null) {
enable = addInput('enable', enable);
}
serialized = (serialized is LogicArray)
? addInputArray('serialized', serialized,
dimensions: serialized.dimensions,
elementWidth: serialized.elementWidth)
: addInput('serialized', serialized, width: serialized.width);
final cnt = Counter.simple(
clk: clk, reset: reset, enable: enable, maxValue: length - 1);
addOutput('count', width: cnt.width) <= cnt.count;
addOutput('done') <= cnt.overflowed;
addOutputArray('deserialized',
dimensions: (serialized is LogicArray)
? ([length, ...serialized.dimensions])
: [length],
elementWidth: (serialized is LogicArray)
? serialized.elementWidth
: serialized.width)
.elements
.forEachIndexed((i, d) =>
d <=
flop(
clk,
reset: reset,
en: (enable ?? Const(1)) & count.eq(i),
serialized));
}