ColumnCompressor constructor

ColumnCompressor(
  1. List<Logic> inRows,
  2. List<int> _rowShift, {
  3. Logic? clk,
  4. Logic? reset,
  5. Logic? enable,
  6. @visibleForTesting bool dontCompress = false,
  7. String name = 'column_compressor',
  8. bool reserveName = false,
  9. bool reserveDefinitionName = false,
  10. String? definitionName,
})

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();
  }
}