Skip to content
Snippets Groups Projects
Commit 5d954037 authored by Yaman Umuroglu's avatar Yaman Umuroglu
Browse files

[FIFO] better documentation for SplitLargeFIFOs, FIFO in caps

parent bce67e95
No related branches found
No related tags found
No related merge requests found
......@@ -98,7 +98,7 @@ from finn.transformation.fpgadataflow.set_exec_mode import SetExecMode
from finn.transformation.fpgadataflow.set_fifo_depths import (
InsertAndSetFIFODepths,
RemoveShallowFIFOs,
SplitLargeFifos,
SplitLargeFIFOs,
)
from finn.transformation.fpgadataflow.set_folding import SetFolding
from finn.transformation.fpgadataflow.synth_ooc import SynthOutOfContext
......@@ -572,7 +572,7 @@ def step_set_fifo_depths(model: ModelWrapper, cfg: DataflowBuildConfig):
# json file has been written. otherwise, since these transforms may add/remove
# FIFOs, we get name mismatch problems when trying to reuse the final config.
if cfg.split_large_fifos:
model = model.transform(SplitLargeFifos())
model = model.transform(SplitLargeFIFOs())
model = model.transform(RemoveShallowFIFOs())
# after FIFOs are ready to go, call PrepareIP and HLSSynthIP again
......
......@@ -422,20 +422,23 @@ class InsertAndSetFIFODepths(Transformation):
return (model, False)
class SplitLargeFifos(Transformation):
"""Split FIFOs with a depth larger than 32768 into smaller ones
to ensure that they can be correctly generated."""
class SplitLargeFIFOs(Transformation):
"""Split large FIFOs before implementation, for two reasons:
- impl_style="vivado" supports a max depth of 32k. Any larger
FIFOs must be implemented as a sequence of smaller FIFOs.
- impl_style="vivado" requires power-of-two depths, which is
normally handled by rounding up to the nearest power-of-two.
So a FIFO of size 8196 normally gets rounded-up to a depth of
16384 and wastes a lot of resources. Here, instead, we split
this up into two FIFOs of depth 8192 + 4.
"""
def __init__(
self,
max_qsrl_depth=256,
):
def __init__(self, max_qsrl_depth=256, max_vivado_depth=32768):
super().__init__()
self.max_qsrl_depth = max_qsrl_depth
self.max_vivado_depth = max_vivado_depth
def get_split_configs(self, depth):
max_size = 32768
def floor_pow2(x):
if (x & (x - 1) == 0) and x != 0:
return x
......@@ -446,14 +449,13 @@ class SplitLargeFifos(Transformation):
# trivial case: for small FIFOs, return as-is with rtl style
if depth <= self.max_qsrl_depth:
return [(depth, "rtl")]
# first pass: ensure max depth of 32k is respected
# first pass: ensure max depth is respected
# (restricted by Vivado AXIS infra IP)
remainder = depth
while remainder != 0:
if remainder > max_size:
ret.append(max_size)
remainder -= max_size
if remainder > self.max_vivado_depth:
ret.append(self.max_vivado_depth)
remainder -= self.max_vivado_depth
else:
ret.append(remainder)
remainder = 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment