From 11c1619dc849f87e9818b24e7658a34c738a7fb3 Mon Sep 17 00:00:00 2001 From: Minseong Jang Date: Wed, 20 Nov 2024 13:29:38 +0000 Subject: [PATCH] Define `transparent_fifo` with valid-ready egress interface --- doc/docs/figure/masked-merge-use-case.svg | 685 ++++++++---------- doc/docs/tutorial/custom_fifo.md | 2 +- .../src/examples/custom_fifo.rs | 2 +- .../src/std/combinators/fifo.rs | 76 ++ 4 files changed, 371 insertions(+), 394 deletions(-) diff --git a/doc/docs/figure/masked-merge-use-case.svg b/doc/docs/figure/masked-merge-use-case.svg index 611bd2b..7666ce2 100644 --- a/doc/docs/figure/masked-merge-use-case.svg +++ b/doc/docs/figure/masked-merge-use-case.svg @@ -1,585 +1,486 @@ + style="fill:none;stroke:none;stroke-linecap:square;stroke-miterlimit:10" + inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"> + + + + image/svg+xml + + + + + + id="path2" + inkscape:connector-curvature="0" + style="clip-rule:nonzero" /> + + id="path145" + inkscape:connector-curvature="0" + style="fill:#f3f3f3;fill-rule:evenodd" /> + id="path147" + inkscape:connector-curvature="0" + style="fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round" /> + id="path149" + inkscape:connector-curvature="0" + style="fill:#000000;fill-rule:nonzero" /> + id="path151" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path153" + inkscape:connector-curvature="0" + style="fill:#000000;fill-rule:nonzero" /> + id="path155" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path157" + inkscape:connector-curvature="0" + style="fill-rule:evenodd;stroke:#595959;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round" /> + id="path159" + inkscape:connector-curvature="0" + style="fill:#595959;fill-rule:evenodd;stroke:#595959;stroke-width:2;stroke-linecap:butt" /> + id="path161" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path163" + inkscape:connector-curvature="0" + style="fill-rule:evenodd;stroke:#351c75;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round" /> + id="path165" + inkscape:connector-curvature="0" + style="fill:#351c75;fill-rule:evenodd;stroke:#351c75;stroke-width:2;stroke-linecap:butt" /> + id="path167" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path169" + inkscape:connector-curvature="0" + style="fill:#000000;fill-rule:nonzero" /> + id="path171" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + d="m 321.2428,401.50647 h -0.92188 q 0,0.70312 -0.0156,1.40625 0,0.6875 0,1.45312 h 0.8125 q 0.875,0 1.28125,-0.40625 0.40625,-0.42187 0.40625,-1.0625 0,-0.67187 -0.375,-1.03125 -0.375,-0.35937 -1.1875,-0.35937 z m -2.95313,-0.0469 v -0.4375 h 2.98438 q 1.21875,0 1.90625,0.48438 0.6875,0.48437 0.6875,1.375 0,0.625 -0.45313,1.14062 -0.45312,0.5 -1.34375,0.65625 0.46875,0.0937 0.76563,0.42188 0.3125,0.3125 0.5,0.9375 l 0.45312,1.57812 0.8125,0.0937 v 0.4375 q -0.15625,0.0469 -0.35937,0.0781 -0.1875,0.0312 -0.4375,0.0312 -0.5,0 -0.75,-0.14063 -0.25,-0.15625 -0.34375,-0.54687 l -0.42188,-1.70313 q -0.0937,-0.4375 -0.28125,-0.65625 -0.1875,-0.21875 -0.46875,-0.28125 -0.28125,-0.0781 -0.71875,-0.0781 h -0.51562 q 0,0.76562 0,1.4375 0.0156,0.67187 0.0156,1.3125 l 0.98438,0.10937 v 0.4375 h -3.01563 v -0.4375 l 0.98438,-0.10937 q 0.0156,-0.67188 0.0156,-1.35938 0,-0.70312 0,-1.39062 v -0.53125 q 0,-0.6875 0,-1.375 0,-0.6875 -0.0156,-1.375 z m 9.22126,1.98438 q -0.29688,0 -0.60938,0.17187 -0.29687,0.15625 -0.51562,0.53125 -0.20313,0.375 -0.28125,1 h 1.95312 q 0.375,0 0.5,-0.15625 0.125,-0.17187 0.125,-0.40625 0,-0.3125 -0.15625,-0.5625 -0.15625,-0.26562 -0.42187,-0.42187 -0.25,-0.15625 -0.59375,-0.15625 z m 0,4.84375 q -1.07813,0 -1.73438,-0.6875 -0.64062,-0.70313 -0.64062,-1.9375 0,-0.8125 0.32812,-1.42188 0.34375,-0.60937 0.89063,-0.95312 0.5625,-0.34375 1.23437,-0.34375 0.54688,0 0.98438,0.25 0.45312,0.25 0.71875,0.70312 0.26562,0.45313 0.26562,1.09375 0,0.1875 -0.0156,0.34375 -0.0156,0.14063 -0.0469,0.25 h -3.40625 q 0.0156,0.98438 0.48438,1.5 0.46875,0.51563 1.25,0.51563 0.5,0 0.84375,-0.20313 0.34375,-0.21875 0.625,-0.54687 l 0.26562,0.20312 q -0.29687,0.5625 -0.8125,0.90625 -0.51562,0.32813 -1.23437,0.32813 z m 6.90619,-0.0312 q -0.39063,0 -0.65625,-0.21875 -0.25,-0.23438 -0.3125,-0.60938 -0.4375,0.4375 -0.76563,0.65625 -0.32812,0.20313 -0.79687,0.20313 -0.57813,0 -1,-0.32813 -0.42188,-0.34375 -0.42188,-1 0,-0.3125 0.14063,-0.57812 0.14062,-0.26563 0.51562,-0.51563 0.39063,-0.26562 1.10938,-0.51562 0.25,-0.0937 0.5625,-0.1875 0.32812,-0.0937 0.64062,-0.17188 v -0.26562 q 0,-0.78125 -0.23437,-1.03125 -0.23438,-0.25 -0.76563,-0.25 -0.125,0 -0.26562,0.0156 -0.14063,0 -0.3125,0.0469 l -0.20313,0.6875 q -0.14062,0.51562 -0.54687,0.51562 -0.45313,0 -0.5,-0.4375 0.14062,-0.60937 0.70312,-0.96875 0.5625,-0.35937 1.375,-0.35937 0.82813,0 1.23438,0.42187 0.40625,0.42188 0.40625,1.4375 v 2.26563 q 0,0.34375 0.10937,0.48437 0.10938,0.14063 0.28125,0.14063 0.14063,0 0.23438,-0.0625 0.0937,-0.0625 0.17187,-0.17188 l 0.21875,0.23438 q -0.1875,0.3125 -0.42187,0.4375 -0.23438,0.125 -0.5,0.125 z m -3.01563,-1.46875 q 0,0.4375 0.25,0.625 0.25,0.17187 0.60938,0.17187 0.15625,0 0.29687,-0.0469 0.15625,-0.0469 0.35938,-0.15625 0.20312,-0.125 0.51562,-0.35938 v -1.64062 q -0.28125,0.0781 -0.54687,0.17187 -0.26563,0.0937 -0.4375,0.15625 -0.45313,0.17188 -0.6875,0.375 -0.21875,0.1875 -0.29688,0.375 -0.0625,0.17188 -0.0625,0.32813 z m 5.43973,-1.14063 q 0,1.04688 0.42187,1.54688 0.42188,0.48437 1.0625,0.48437 0.34375,0 0.60938,-0.14062 0.28125,-0.14063 0.57812,-0.48438 v -2.9375 q -0.35937,-0.32812 -0.65625,-0.4375 -0.28125,-0.125 -0.54687,-0.125 -0.39063,0 -0.73438,0.21875 -0.32812,0.21875 -0.53125,0.6875 -0.20312,0.45313 -0.20312,1.1875 z m 2.78125,2.60938 -0.0781,-0.73438 q -0.26562,0.35938 -0.625,0.5625 -0.35937,0.20313 -0.85937,0.20313 -0.65625,0 -1.15625,-0.32813 -0.48438,-0.32812 -0.75,-0.92187 -0.26563,-0.59375 -0.26563,-1.375 0,-0.8125 0.29688,-1.42188 0.29687,-0.60937 0.79687,-0.95312 0.51563,-0.34375 1.17188,-0.34375 0.375,0 0.71875,0.15625 0.34375,0.14062 0.67187,0.54687 v -2.42187 l -0.90625,-0.0937 v -0.375 l 1.67188,-0.48438 0.14062,0.0781 -0.0312,1.51562 v 5.76563 l 0.85938,0.125 v 0.39062 z m 5.09173,-4.78125 v -0.39063 h 2.07813 v 0.39063 l -0.57813,0.10937 -1.70312,4.53125 q -0.54688,1.42188 -1.04688,2.04688 -0.48437,0.64062 -1.14062,0.64062 -0.39063,0 -0.6875,-0.20312 -0.29688,-0.1875 -0.29688,-0.5 0.0469,-0.23438 0.25,-0.35938 0.21875,-0.10937 0.46875,-0.10937 0.20313,0 0.39063,0.0781 0.1875,0.0937 0.39062,0.32813 l 0.0625,0.0469 q 0.32813,-0.28125 0.5625,-0.70312 0.23438,-0.40625 0.39063,-0.82813 l 0.0469,-0.125 -1.9375,-4.875 -0.57812,-0.0781 v -0.39063 h 2.54687 v 0.39063 l -0.9375,0.10937 1.34375,3.64063 1.3125,-3.625 z m 2.69043,1.40625 v -0.5 l 4.125,-2.39063 0.3125,0.57813 -3.6875,2.0625 3.6875,2.07812 -0.3125,0.57813 z m 5.51792,-3.42188 v -0.4375 h 5.3125 l 0.0625,1.875 h -0.59375 l -0.23438,-1.34375 h -2.51562 q 0,0.67188 -0.0156,1.35938 0,0.6875 0,1.34375 h 1.65625 l 0.14063,-1.01563 h 0.5 v 2.625 h -0.5 l -0.14063,-1.10937 h -1.65625 q 0,0.79687 0,1.48437 0.0156,0.6875 0.0156,1.35938 l 1,0.10937 v 0.4375 h -3.03125 v -0.4375 l 0.98437,-0.10937 q 0.0156,-0.67188 0.0156,-1.35938 0,-0.70312 0,-1.39062 V 404.319 q 0,-0.6875 0,-1.375 0,-0.6875 -0.0156,-1.375 z m 5.95892,6.6875 v -0.39062 l 0.79688,-0.14063 q 0.0156,-0.40625 0.0156,-0.875 0,-0.48437 0,-0.82812 v -0.5 q 0,-0.4375 0,-0.73438 0,-0.29687 -0.0312,-0.60937 l -0.84375,-0.0937 v -0.375 l 1.64063,-0.65625 0.15625,0.10937 -0.0312,1.45313 v 1.40625 q 0,0.34375 0,0.82812 0.0156,0.46875 0.0156,0.875 l 0.75,0.14063 v 0.39062 z m 1.25,-6.375 q -0.29687,0 -0.5,-0.1875 -0.20312,-0.1875 -0.20312,-0.48437 0,-0.3125 0.20312,-0.5 0.20313,-0.1875 0.5,-0.1875 0.29688,0 0.5,0.1875 0.21875,0.1875 0.21875,0.5 0,0.29687 -0.21875,0.48437 -0.20312,0.1875 -0.5,0.1875 z m 1.94123,6.375 v -0.39062 l 0.82812,-0.14063 q 0.0156,-0.42187 0.0156,-0.84375 0.0156,-0.4375 0.0156,-0.85937 v -2.26563 h -0.89062 v -0.46875 l 0.90625,-0.10937 q 0.0781,-0.85938 0.23437,-1.375 0.17188,-0.53125 0.5625,-0.9375 0.34375,-0.32813 0.71875,-0.45313 0.375,-0.14062 0.73438,-0.14062 0.375,0 0.65625,0.14062 0.29687,0.125 0.375,0.4375 -0.0156,0.20313 -0.1875,0.34375 -0.17188,0.14063 -0.46875,0.14063 -0.39063,0 -0.76563,-0.32813 l -0.29687,-0.23437 q -0.0469,0.0312 -0.0937,0.0625 -0.0312,0.0312 -0.0625,0.0625 -0.28125,0.28125 -0.42188,0.84375 -0.14062,0.5625 -0.125,1.45312 h 1.48438 v 0.5625 h -1.45313 v 2.26563 q 0,0.42187 0,0.84375 0,0.42187 0.0156,0.84375 l 0.96875,0.15625 v 0.39062 z m 6.14361,0.14063 q -0.625,0 -1.1875,-0.29688 -0.54687,-0.29687 -0.90625,-0.875 -0.34375,-0.59375 -0.34375,-1.46875 0,-0.89062 0.34375,-1.48437 0.35938,-0.60938 0.90625,-0.90625 0.5625,-0.3125 1.1875,-0.3125 0.60938,0 1.17188,0.3125 0.5625,0.29687 0.92187,0.90625 0.35938,0.59375 0.35938,1.48437 0,0.875 -0.35938,1.46875 -0.35937,0.57813 -0.92187,0.875 -0.5625,0.29688 -1.17188,0.29688 z m 0,-0.48438 q 0.6875,0 1.0625,-0.54687 0.375,-0.54688 0.375,-1.60938 0,-1.07812 -0.375,-1.64062 -0.375,-0.5625 -1.0625,-0.5625 -0.6875,0 -1.0625,0.5625 -0.375,0.5625 -0.375,1.64062 0,1.0625 0.375,1.60938 0.375,0.54687 1.0625,0.54687 z m 5.32181,0.5 q -0.59375,0 -1.15625,-0.15625 -0.54688,-0.17187 -0.92188,-0.40625 l 0.0625,-1.48437 h 0.67188 l 0.20312,1.25 q 0.25,0.14062 0.5,0.20312 0.26563,0.0625 0.60938,0.0625 0.76562,0 1.20312,-0.32812 0.45313,-0.34375 0.45313,-0.95313 0,-0.51562 -0.3125,-0.79687 -0.3125,-0.28125 -1,-0.54688 l -0.42188,-0.17187 q -0.8125,-0.32813 -1.32812,-0.82813 -0.5,-0.5 -0.5,-1.3125 0,-0.625 0.3125,-1.0625 0.3125,-0.4375 0.85937,-0.67187 0.54688,-0.23438 1.23438,-0.23438 0.53125,0 0.96875,0.15625 0.4375,0.14063 0.76562,0.39063 l -0.0625,1.39062 h -0.64062 l -0.23438,-1.20312 q -0.39062,-0.20313 -0.85937,-0.20313 -0.60938,0 -1.03125,0.29688 -0.42188,0.29687 -0.42188,0.90625 0,0.48437 0.3125,0.8125 0.32813,0.3125 0.90625,0.53125 l 0.42188,0.17187 q 1.04687,0.39063 1.48437,0.90625 0.45313,0.5 0.45313,1.26563 0,0.625 -0.32813,1.07812 -0.32812,0.45313 -0.89062,0.70313 -0.5625,0.23437 -1.3125,0.23437 z m 8.00293,-3.92187 v 0.5 l -4.125,2.40625 -0.3125,-0.57813 3.70312,-2.07812 -3.70312,-2.0625 0.3125,-0.57813 z" + id="path173" + inkscape:connector-curvature="0" + style="fill:#000000;fill-rule:nonzero" /> + id="path175" + inkscape:connector-curvature="0" + style="fill:#f3f3f3;fill-rule:evenodd" /> + id="path177" + inkscape:connector-curvature="0" + style="fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round" /> + id="path179" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path181" + inkscape:connector-curvature="0" + style="fill:#000000;fill-rule:nonzero" /> + id="path183" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path185" + inkscape:connector-curvature="0" + style="fill:#000000;fill-rule:nonzero" /> + id="path187" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path189" + inkscape:connector-curvature="0" + style="fill-rule:evenodd;stroke:#595959;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round" /> + id="path191" + inkscape:connector-curvature="0" + style="fill:#595959;fill-rule:evenodd;stroke:#595959;stroke-width:2;stroke-linecap:butt" /> + id="path193" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path195" + inkscape:connector-curvature="0" + style="fill-rule:evenodd;stroke:#351c75;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round" /> + id="path197" + inkscape:connector-curvature="0" + style="fill:#351c75;fill-rule:evenodd;stroke:#351c75;stroke-width:2;stroke-linecap:butt" /> + id="path199" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path201" + inkscape:connector-curvature="0" + style="fill:#000000;fill-rule:nonzero" /> + id="path203" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path205" + inkscape:connector-curvature="0" + style="fill:#000000;fill-rule:nonzero" /> + id="path207" + inkscape:connector-curvature="0" + style="fill:#f3f3f3;fill-rule:evenodd" /> + id="path209" + inkscape:connector-curvature="0" + style="fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round" /> + id="path211" + inkscape:connector-curvature="0" + style="fill:#000000;fill-rule:nonzero" /> + id="path213" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path215" + inkscape:connector-curvature="0" + style="fill:#000000;fill-rule:nonzero" /> + id="path217" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path219" + inkscape:connector-curvature="0" + style="fill-rule:evenodd;stroke:#595959;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round" /> + id="path221" + inkscape:connector-curvature="0" + style="fill:#595959;fill-rule:evenodd;stroke:#595959;stroke-width:2;stroke-linecap:butt" /> + id="path223" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path225" + inkscape:connector-curvature="0" + style="fill-rule:evenodd;stroke:#351c75;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round" /> + id="path227" + inkscape:connector-curvature="0" + style="fill:#351c75;fill-rule:evenodd;stroke:#351c75;stroke-width:2;stroke-linecap:butt" /> + id="path229" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path231" + inkscape:connector-curvature="0" + style="fill:#000000;fill-rule:nonzero" /> + id="path233" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path235" + inkscape:connector-curvature="0" + style="fill:#000000;fill-rule:nonzero" /> + id="path237" + inkscape:connector-curvature="0" + style="fill:#f3f3f3;fill-rule:evenodd" /> + id="path239" + inkscape:connector-curvature="0" + style="fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round" /> + id="path241" + inkscape:connector-curvature="0" + style="fill:#000000;fill-rule:nonzero" /> + id="path243" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path245" + inkscape:connector-curvature="0" + style="fill:#000000;fill-rule:nonzero" /> + id="path247" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path249" + inkscape:connector-curvature="0" + style="fill-rule:evenodd;stroke:#595959;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round" /> + id="path251" + inkscape:connector-curvature="0" + style="fill:#595959;fill-rule:evenodd;stroke:#595959;stroke-width:2;stroke-linecap:butt" /> + id="path253" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path255" + inkscape:connector-curvature="0" + style="fill-rule:evenodd;stroke:#351c75;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round" /> + id="path257" + inkscape:connector-curvature="0" + style="fill:#351c75;fill-rule:evenodd;stroke:#351c75;stroke-width:2;stroke-linecap:butt" /> + id="path259" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path261" + inkscape:connector-curvature="0" + style="fill:#000000;fill-rule:nonzero" /> + id="path263" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path265" + inkscape:connector-curvature="0" + style="fill:#000000;fill-rule:nonzero" /> + id="path267" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path269" + inkscape:connector-curvature="0" + style="fill-rule:evenodd;stroke:#595959;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round" /> + id="path271" + inkscape:connector-curvature="0" + style="fill:#595959;fill-rule:evenodd;stroke:#595959;stroke-width:2;stroke-linecap:butt" /> + id="path273" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path275" + inkscape:connector-curvature="0" + style="fill-rule:evenodd;stroke:#351c75;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round" /> + id="path277" + inkscape:connector-curvature="0" + style="fill:#351c75;fill-rule:evenodd;stroke:#351c75;stroke-width:2;stroke-linecap:butt" /> + id="path279" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path281" + inkscape:connector-curvature="0" + style="fill:#000000;fill-rule:nonzero" /> + id="path283" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path285" + inkscape:connector-curvature="0" + style="fill:#000000;fill-rule:nonzero" /> + id="path287" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path289" + inkscape:connector-curvature="0" + style="fill-rule:evenodd;stroke:#595959;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round" /> + id="path291" + inkscape:connector-curvature="0" + style="fill:#595959;fill-rule:evenodd;stroke:#595959;stroke-width:2;stroke-linecap:butt" /> + id="path293" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path295" + inkscape:connector-curvature="0" + style="fill-rule:evenodd;stroke:#351c75;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round" /> + id="path297" + inkscape:connector-curvature="0" + style="fill:#351c75;fill-rule:evenodd;stroke:#351c75;stroke-width:2;stroke-linecap:butt" /> + id="path299" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path301" + inkscape:connector-curvature="0" + style="fill:#000000;fill-rule:nonzero" /> + id="path303" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> + id="path305" + inkscape:connector-curvature="0" + style="fill:#000000;fill-rule:nonzero" /> + id="path307" + inkscape:connector-curvature="0" + style="fill:#000000;fill-opacity:0;fill-rule:evenodd" /> - + id="path309" + inkscape:connector-curvature="0" + style="fill:#202122;fill-rule:nonzero" /> diff --git a/doc/docs/tutorial/custom_fifo.md b/doc/docs/tutorial/custom_fifo.md index 5f35630..17fb956 100644 --- a/doc/docs/tutorial/custom_fifo.md +++ b/doc/docs/tutorial/custom_fifo.md @@ -109,7 +109,7 @@ Based on the above submodules, we can implement the custom FIFO in a concise and fn custom_fifo(ingress: [Vr; N]) -> Vr { ingress .masked_merge() - .map_resolver_inner::<((), FifoS<(u32, U<{ clog2(N) }>), M>)>(|(_, fifo_s)| { + .map_resolver_inner::), M>>(|fifo_s| { fifo_s.inner_with_valid().fold(false.repeat::(), |acc, i| { if let Some((_, idx)) = i { acc.set(idx, true) diff --git a/hazardflow-designs/src/examples/custom_fifo.rs b/hazardflow-designs/src/examples/custom_fifo.rs index 601c0fc..5628c6e 100644 --- a/hazardflow-designs/src/examples/custom_fifo.rs +++ b/hazardflow-designs/src/examples/custom_fifo.rs @@ -46,7 +46,7 @@ where [(); clog2(N)]: pub fn custom_fifo(ingress: [Vr; N]) -> Vr { ingress .masked_merge() - .map_resolver_inner::<((), FifoS<(u32, U<{ clog2(N) }>), M>)>(|(_, fifo_s)| { + .map_resolver_inner::), M>>(|fifo_s| { fifo_s.inner_with_valid().fold(false.repeat::(), |acc, i| { if let Some((_, idx)) = i { acc.set(idx, true) diff --git a/hazardflow-designs/src/std/combinators/fifo.rs b/hazardflow-designs/src/std/combinators/fifo.rs index 90cf123..7cc8339 100644 --- a/hazardflow-designs/src/std/combinators/fifo.rs +++ b/hazardflow-designs/src/std/combinators/fifo.rs @@ -161,3 +161,79 @@ where } } } + +impl I>, D> +where + [(); clog2(N)]:, + [(); clog2(N + 1)]:, +{ + /// A variation of [`I::transparent_fifo`] that has valid-ready egress interface. + /// + /// - Payload: The same behavior as [`I::transparent_fifo`]. + /// - Resolver: The same behavior as [`I::transparent_fifo`], but unnecessary unit type is removed in the ingress + /// resolver signal. + /// + /// | Interface | Ingress | Egress | + /// | :-------: | -------------------- | ------------ | + /// | **Fwd** | `HOption

` | `HOption

` | + /// | **Bwd** | `Ready>` | `Ready<()>` | + pub fn transparent_fifo(self) -> Vr

+ where + [(); clog2(N) + 1]:, + [(); clog2(N + 1) + 1]:, + { + self.multi_headed_transparent_fifo().map_resolver_inner(|_| U::from(1)).filter_map(|s| { + if s.len == 0.into_u() { + None + } else { + Some(s.inner[s.raddr]) + } + }) + } + + /// A variation of [`I::multi_headed_transparent_fifo`] that has valid-ready egress interface. + /// + /// - Payload: The same behavior as [`I::multi_headed_transparent_fifo`]. + /// - Resolver: The same behavior as [`I::multi_headed_transparent_fifo`], but unnecessary unit type is removed in + /// the ingress resolver signal. + /// + /// | Interface | Ingress | Egress | + /// | :-------: | --------------------- | ---------------------------- | + /// | **Fwd** | `HOption

` | `HOption>` | + /// | **Bwd** | `Ready>` | `Ready>` | + #[allow(clippy::type_complexity)] + pub fn multi_headed_transparent_fifo(self) -> I, U<{ clog2(N + 1) }>>, { Dep::Helpful }> + where + [(); clog2(N) + 1]:, + [(); clog2(N + 1) + 1]:, + { + unsafe { + self.fsm::, { Dep::Helpful }, VrH, U<{ clog2(N + 1) }>>>( + FifoS::default(), + |ip, er, s| { + let FifoS { inner, raddr, waddr, len } = s; + let pop = er.inner; + + let empty = len == U::from(0); + let full = len == U::from(N); + + let enq = ip.is_some() && !full; + let deq = er.ready && !empty; + + let ep = Some(s); + let ir = Ready::new(!full, s); + + let inner_next = if enq { inner.set(waddr, ip.unwrap()) } else { inner }; + let len_next = (len + U::from(enq).resize() - if deq { pop.resize() } else { 0.into_u() }).resize(); + let raddr_next = + if deq { wrapping_add::<{ clog2(N) }>(raddr, pop.resize(), N.into_u()) } else { raddr }; + let waddr_next = if enq { wrapping_inc::<{ clog2(N) }>(waddr, N.into_u()) } else { waddr }; + + let s_next = FifoS { inner: inner_next, raddr: raddr_next, waddr: waddr_next, len: len_next }; + + (ep, ir, s_next) + }, + ) + } + } +}