ColumnCompressor constructor
Initialize a ColumnCompressor for a set of partial products.
If clk
is not null then a set of flops are used to latch the output
after compression (see _extractRow
). reset
and enable
are optional
inputs to control these flops when clk
is provided. If clk
is null,
the ColumnCompressor is built as a combinational tree of
compressors.
Implementation
ColumnCompressor(List<Logic> inRows, this._rowShift,
{Logic? clk,
Logic? reset,
Logic? enable,
@visibleForTesting bool dontCompress = false,
super.name = 'column_compressor',
super.reserveName,
super.reserveDefinitionName,
String? definitionName})
: super(
definitionName: definitionName ??
'ColumnCompressor_L${inRows.length}_W${inRows[0].width}') {
this.clk = (clk != null) ? addInput('clk', clk) : null;
this.reset = (reset != null) ? addInput('reset', reset) : null;
this.enable = (enable != null) ? addInput('enable', enable) : null;
_rows = [
for (var row = 0; row < inRows.length; row++)
addInput('row_$row', inRows[row], width: inRows[row].width)
];
// pp = PartialProductMatrixStore(inputRows, rowShift);
columns = List.generate(maxWidth(), (i) => ColumnQueue());
for (var row = 0; row < _rows.length; row++) {
for (var col = 0; col < _rows[row].width; col++) {
final trueColumn = _rowShift[row] + col;
final term = CompressTerm(
CompressTermType.pp,
_rows[row][col].named('pp_${row}_$col', naming: Naming.mergeable),
[],
row,
trueColumn);
columns[trueColumn].add(term);
}
}
addOutput('add0', width: maxWidth());
addOutput('add1', width: maxWidth());
if (!dontCompress) {
compress();
}
}