Skip to content

Commit 617fc9a

Browse files
committed
lib.fifo: annotate for use with CLI. (WIP)
1 parent b0e43eb commit 617fc9a

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

amaranth/lib/fifo.py

+16-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from .. import *
44
from ..asserts import *
55
from .._utils import log2_int
6+
from .wiring import Signature, In, Out
67
from .coding import GrayEncoder, GrayDecoder
78
from .cdc import FFSynchronizer, AsyncFFSynchronizer
89

@@ -64,7 +65,7 @@ class FIFOInterface:
6465
w_attributes="",
6566
r_attributes="")
6667

67-
def __init__(self, *, width, depth, fwft):
68+
def __init__(self, *, width: int, depth: int, fwft):
6869
if not isinstance(width, int) or width < 0:
6970
raise TypeError("FIFO width must be a non-negative integer, not {!r}"
7071
.format(width))
@@ -85,6 +86,17 @@ def __init__(self, *, width, depth, fwft):
8586
self.r_en = Signal()
8687
self.r_level = Signal(range(depth + 1))
8788

89+
@property
90+
def signature(self):
91+
return Signature({
92+
"w_data": In(self.width),
93+
"w_rdy": Out(1),
94+
"w_en": In(1),
95+
"r_data": Out(self.width),
96+
"r_rdy": Out(1),
97+
"w_en": In(1),
98+
})
99+
88100

89101
def _incr(signal, modulo):
90102
if modulo == 2 ** len(signal):
@@ -116,7 +128,7 @@ class SyncFIFO(Elaboratable, FIFOInterface):
116128
r_attributes="",
117129
w_attributes="")
118130

119-
def __init__(self, *, width, depth, fwft=True):
131+
def __init__(self, *, width: int, depth: int, fwft=True):
120132
super().__init__(width=width, depth=depth, fwft=fwft)
121133

122134
self.level = Signal(range(depth + 1))
@@ -220,7 +232,7 @@ class SyncFIFOBuffered(Elaboratable, FIFOInterface):
220232
r_attributes="",
221233
w_attributes="")
222234

223-
def __init__(self, *, width, depth):
235+
def __init__(self, *, width: int, depth: int):
224236
super().__init__(width=width, depth=depth, fwft=True)
225237

226238
self.level = Signal(range(depth + 1))
@@ -295,7 +307,7 @@ class AsyncFIFO(Elaboratable, FIFOInterface):
295307
""".strip(),
296308
w_attributes="")
297309

298-
def __init__(self, *, width, depth, r_domain="read", w_domain="write", exact_depth=False):
310+
def __init__(self, *, width: int, depth: int, r_domain="read", w_domain="write", exact_depth=False):
299311
if depth != 0:
300312
try:
301313
depth_bits = log2_int(depth, need_pow2=exact_depth)

0 commit comments

Comments
 (0)