@@ -198,7 +198,6 @@ def __init__(self, *, addr_width, data_width):
198198
199199 self ._addr_width = addr_width
200200 self ._data_width = data_width
201- self ._memory_map = None
202201
203202 members = {
204203 "addr" : Out (self .addr_width ),
@@ -217,27 +216,6 @@ def addr_width(self):
217216 def data_width (self ):
218217 return self ._data_width
219218
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-
241219 @classmethod
242220 def check_parameters (cls , * , addr_width , data_width ):
243221 """Validate signature parameters.
@@ -264,7 +242,6 @@ def create(self, *, path=None, src_loc_at=0):
264242 An :class:`Interface` object using this signature.
265243 """
266244 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
268245 path = path , src_loc_at = 1 + src_loc_at )
269246
270247 def __eq__ (self , other ):
@@ -304,19 +281,22 @@ class Interface(wiring.PureInterface):
304281 Address width. See :class:`Signature`.
305282 data_width : :class:`int`
306283 Data width. See :class:`Signature`.
307- memory_map: :class:`MemoryMap`
308- Memory map of the bus. Optional. See :class:`Signature`.
309284 path : iter(:class:`str`)
310285 Path to this CSR interface. Optional. See :class:`wiring.PureInterface`.
311286
287+ Attributes
288+ ----------
289+ memory_map: :class:`MemoryMap`
290+ Memory map of the bus. Optional.
291+
312292 Raises
313293 ------
314294 See :meth:`Signature.check_parameters`.
315295 """
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 ):
317297 sig = Signature (addr_width = addr_width , data_width = data_width )
318- sig .memory_map = memory_map
319298 super ().__init__ (sig , path = path , src_loc_at = 1 + src_loc_at )
299+ self ._memory_map = None
320300
321301 @property
322302 def addr_width (self ):
@@ -328,7 +308,21 @@ def data_width(self):
328308
329309 @property
330310 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
332326
333327 def __repr__ (self ):
334328 return f"csr.Interface({ self .signature !r} )"
@@ -561,18 +555,11 @@ def chunks(self):
561555 CSR bus providing access to registers.
562556 """
563557 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" )
576563
577564 def align_to (self , alignment ):
578565 """Align the implicit address of the next register.
@@ -704,17 +691,10 @@ class Decoder(wiring.Component):
704691 CSR bus providing access to subordinate buses.
705692 """
706693 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 ()
718698
719699 def align_to (self , alignment ):
720700 """Align the implicit address of the next window.
0 commit comments