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