@@ -198,7 +198,6 @@ def __init__(self, *, addr_width, data_width):
198
198
199
199
self ._addr_width = addr_width
200
200
self ._data_width = data_width
201
- self ._memory_map = None
202
201
203
202
members = {
204
203
"addr" : Out (self .addr_width ),
@@ -217,27 +216,6 @@ def addr_width(self):
217
216
def data_width (self ):
218
217
return self ._data_width
219
218
220
- @property
221
- def memory_map (self ):
222
- if self ._memory_map is None :
223
- raise AttributeError (f"{ self !r} does not have a memory map" )
224
- return self ._memory_map
225
-
226
- @memory_map .setter
227
- def memory_map (self , memory_map ):
228
- if self .frozen :
229
- raise ValueError (f"Signature has been frozen. Cannot set its memory map" )
230
- if memory_map is not None :
231
- if not isinstance (memory_map , MemoryMap ):
232
- raise TypeError (f"Memory map must be an instance of MemoryMap, not { memory_map !r} " )
233
- if memory_map .addr_width != self .addr_width :
234
- raise ValueError (f"Memory map has address width { memory_map .addr_width } , which is not "
235
- f"the same as bus interface address width { self .addr_width } " )
236
- if memory_map .data_width != self .data_width :
237
- raise ValueError (f"Memory map has data width { memory_map .data_width } , which is not the "
238
- f"same as bus interface data width { self .data_width } " )
239
- self ._memory_map = memory_map
240
-
241
219
@classmethod
242
220
def check_parameters (cls , * , addr_width , data_width ):
243
221
"""Validate signature parameters.
@@ -264,7 +242,6 @@ def create(self, *, path=None, src_loc_at=0):
264
242
An :class:`Interface` object using this signature.
265
243
"""
266
244
return Interface (addr_width = self .addr_width , data_width = self .data_width ,
267
- memory_map = self ._memory_map , # if None, do not raise an exception
268
245
path = path , src_loc_at = 1 + src_loc_at )
269
246
270
247
def __eq__ (self , other ):
@@ -304,19 +281,22 @@ class Interface(wiring.PureInterface):
304
281
Address width. See :class:`Signature`.
305
282
data_width : :class:`int`
306
283
Data width. See :class:`Signature`.
307
- memory_map: :class:`MemoryMap`
308
- Memory map of the bus. Optional. See :class:`Signature`.
309
284
path : iter(:class:`str`)
310
285
Path to this CSR interface. Optional. See :class:`wiring.PureInterface`.
311
286
287
+ Attributes
288
+ ----------
289
+ memory_map: :class:`MemoryMap`
290
+ Memory map of the bus. Optional.
291
+
312
292
Raises
313
293
------
314
294
See :meth:`Signature.check_parameters`.
315
295
"""
316
- def __init__ (self , * , addr_width , data_width , memory_map = None , path = None , src_loc_at = 0 ):
296
+ def __init__ (self , * , addr_width , data_width , path = None , src_loc_at = 0 ):
317
297
sig = Signature (addr_width = addr_width , data_width = data_width )
318
- sig .memory_map = memory_map
319
298
super ().__init__ (sig , path = path , src_loc_at = 1 + src_loc_at )
299
+ self ._memory_map = None
320
300
321
301
@property
322
302
def addr_width (self ):
@@ -328,7 +308,21 @@ def data_width(self):
328
308
329
309
@property
330
310
def memory_map (self ):
331
- return self .signature .memory_map
311
+ if self ._memory_map is None :
312
+ raise AttributeError (f"{ self !r} does not have a memory map" )
313
+ return self ._memory_map
314
+
315
+ @memory_map .setter
316
+ def memory_map (self , memory_map ):
317
+ if not isinstance (memory_map , MemoryMap ):
318
+ raise TypeError (f"Memory map must be an instance of MemoryMap, not { memory_map !r} " )
319
+ if memory_map .addr_width != self .addr_width :
320
+ raise ValueError (f"Memory map has address width { memory_map .addr_width } , which is not "
321
+ f"the same as bus interface address width { self .addr_width } " )
322
+ if memory_map .data_width != self .data_width :
323
+ raise ValueError (f"Memory map has data width { memory_map .data_width } , which is not the "
324
+ f"same as bus interface data width { self .data_width } " )
325
+ self ._memory_map = memory_map
332
326
333
327
def __repr__ (self ):
334
328
return f"csr.Interface({ self .signature !r} )"
@@ -561,18 +555,11 @@ def chunks(self):
561
555
CSR bus providing access to registers.
562
556
"""
563
557
def __init__ (self , * , addr_width , data_width , alignment = 0 , name = None , shadow_overlaps = None ):
564
- bus_signature = Signature (addr_width = addr_width , data_width = data_width )
565
- bus_signature .memory_map = MemoryMap (addr_width = addr_width , data_width = data_width ,
566
- alignment = alignment , name = name )
567
-
568
- self ._signature = wiring .Signature ({"bus" : In (bus_signature )})
569
- self ._r_shadow = Multiplexer ._Shadow (data_width , shadow_overlaps , name = "r_shadow" )
570
- self ._w_shadow = Multiplexer ._Shadow (data_width , shadow_overlaps , name = "w_shadow" )
571
- super ().__init__ ()
572
-
573
- @property
574
- def signature (self ):
575
- return self ._signature
558
+ super ().__init__ ({"bus" : In (Signature (addr_width = addr_width , data_width = data_width ))})
559
+ self .bus .memory_map = MemoryMap (addr_width = addr_width , data_width = data_width ,
560
+ alignment = alignment , name = name )
561
+ self ._r_shadow = Multiplexer ._Shadow (data_width , shadow_overlaps , name = "r_shadow" )
562
+ self ._w_shadow = Multiplexer ._Shadow (data_width , shadow_overlaps , name = "w_shadow" )
576
563
577
564
def align_to (self , alignment ):
578
565
"""Align the implicit address of the next register.
@@ -704,17 +691,10 @@ class Decoder(wiring.Component):
704
691
CSR bus providing access to subordinate buses.
705
692
"""
706
693
def __init__ (self , * , addr_width , data_width , alignment = 0 , name = None ):
707
- bus_signature = Signature (addr_width = addr_width , data_width = data_width )
708
- bus_signature .memory_map = MemoryMap (addr_width = addr_width , data_width = data_width ,
709
- alignment = alignment , name = name )
710
-
711
- self ._signature = wiring .Signature ({"bus" : In (bus_signature )})
712
- self ._subs = dict ()
713
- super ().__init__ ()
714
-
715
- @property
716
- def signature (self ):
717
- return self ._signature
694
+ super ().__init__ ({"bus" : In (Signature (addr_width = addr_width , data_width = data_width ))})
695
+ self .bus .memory_map = MemoryMap (addr_width = addr_width , data_width = data_width ,
696
+ alignment = alignment , name = name )
697
+ self ._subs = dict ()
718
698
719
699
def align_to (self , alignment ):
720
700
"""Align the implicit address of the next window.
0 commit comments