3
3
from .. import *
4
4
from ..asserts import *
5
5
from .._utils import log2_int
6
+ from .wiring import Signature , In , Out
6
7
from .coding import GrayEncoder , GrayDecoder
7
8
from .cdc import FFSynchronizer , AsyncFFSynchronizer
8
9
@@ -64,7 +65,7 @@ class FIFOInterface:
64
65
w_attributes = "" ,
65
66
r_attributes = "" )
66
67
67
- def __init__ (self , * , width , depth , fwft ):
68
+ def __init__ (self , * , width : int , depth : int , fwft ):
68
69
if not isinstance (width , int ) or width < 0 :
69
70
raise TypeError ("FIFO width must be a non-negative integer, not {!r}"
70
71
.format (width ))
@@ -85,6 +86,17 @@ def __init__(self, *, width, depth, fwft):
85
86
self .r_en = Signal ()
86
87
self .r_level = Signal (range (depth + 1 ))
87
88
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
+
88
100
89
101
def _incr (signal , modulo ):
90
102
if modulo == 2 ** len (signal ):
@@ -116,7 +128,7 @@ class SyncFIFO(Elaboratable, FIFOInterface):
116
128
r_attributes = "" ,
117
129
w_attributes = "" )
118
130
119
- def __init__ (self , * , width , depth , fwft = True ):
131
+ def __init__ (self , * , width : int , depth : int , fwft = True ):
120
132
super ().__init__ (width = width , depth = depth , fwft = fwft )
121
133
122
134
self .level = Signal (range (depth + 1 ))
@@ -220,7 +232,7 @@ class SyncFIFOBuffered(Elaboratable, FIFOInterface):
220
232
r_attributes = "" ,
221
233
w_attributes = "" )
222
234
223
- def __init__ (self , * , width , depth ):
235
+ def __init__ (self , * , width : int , depth : int ):
224
236
super ().__init__ (width = width , depth = depth , fwft = True )
225
237
226
238
self .level = Signal (range (depth + 1 ))
@@ -295,7 +307,7 @@ class AsyncFIFO(Elaboratable, FIFOInterface):
295
307
""" .strip (),
296
308
w_attributes = "" )
297
309
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 ):
299
311
if depth != 0 :
300
312
try :
301
313
depth_bits = log2_int (depth , need_pow2 = exact_depth )
0 commit comments