Fifo constructor

Fifo(
  1. Logic clk,
  2. Logic reset, {
  3. required Logic writeEnable,
  4. required Logic writeData,
  5. required Logic readEnable,
  6. required int depth,
  7. bool generateError = false,
  8. bool generateOccupancy = false,
  9. bool generateBypass = false,
  10. String name = 'fifo',
})

Constructs a FIFO with RF-based storage.

Implementation

Fifo(Logic clk, Logic reset,
    {required Logic writeEnable,
    required Logic writeData,
    required Logic readEnable,
    required this.depth,
    this.generateError = false,
    this.generateOccupancy = false,
    this.generateBypass = false,
    super.name = 'fifo'})
    : dataWidth = writeData.width,
      _addrWidth = max(1, log2Ceil(depth)) {
  if (depth <= 0) {
    throw RohdHclException('Depth must be at least 1.');
  }
  if (_addrWidth <= 0) {
    throw RohdHclException(
        'Assumption that address width is non-zero in implementation');
  }

  addInput('clk', clk);
  addInput('reset', reset);

  // set up read/write ports
  addInput('writeEnable', writeEnable);
  addInput('writeData', writeData, width: dataWidth);
  addInput('readEnable', readEnable);
  addOutput('readData', width: dataWidth);

  // set up info ports
  addOutput('full');
  addOutput('empty');

  if (generateError) {
    addOutput('error');
  }

  if (generateOccupancy) {
    addOutput('occupancy', width: log2Ceil(depth));
  }

  _buildLogic();
}