27
27
28
28
29
29
class WBMemory (Component ):
30
- @property
31
- def signature (self ):
32
- return self ._signature
33
-
34
30
def __init__ (self , * , sim = False , num_bytes = 0x400 ):
35
31
bus_signature = wishbone .Signature (addr_width = 23 , data_width = 32 ,
36
32
granularity = 8 )
37
- bus_signature .memory_map = MemoryMap (addr_width = 25 , data_width = 8 )
38
- self ._signature = Signature ({
33
+ sig = {
39
34
"bus" : In (bus_signature )
40
- })
35
+ }
41
36
42
37
if sim :
43
- self . _signature . members ["ctrl" ] = Out (Signature ({
38
+ sig ["ctrl" ] = Out (Signature ({
44
39
"force_ws" : Out (1 ) # noqa: F821
45
40
}))
46
41
47
42
self .sim = sim
48
43
self .num_bytes = num_bytes
49
44
50
- super ().__init__ ()
51
- bus_signature .memory_map .add_resource (self .bus , name = "ram" ,
52
- size = num_bytes )
45
+ super ().__init__ (sig )
46
+
47
+ # Allocate a bunch of address space for RAM
48
+ self .bus .memory_map = MemoryMap (addr_width = 25 , data_width = 8 )
49
+ # But only actually _use_ a small chunk of it.
50
+ self .bus .memory_map .add_resource (self .bus , name = "ram" ,
51
+ size = num_bytes )
53
52
54
53
@property
55
54
def init_mem (self ):
@@ -92,16 +91,11 @@ def elaborate(self, plat):
92
91
93
92
94
93
class WBLeds (Component ):
95
- @property
96
- def signature (self ):
97
- return self ._signature
98
-
99
94
def __init__ (self ):
100
95
bus_signature = wishbone .Signature (addr_width = 25 , data_width = 8 ,
101
96
granularity = 8 )
102
- bus_signature .memory_map = MemoryMap (addr_width = 25 , data_width = 8 ,
103
- name = "leds" )
104
- self ._signature = Signature ({
97
+
98
+ super ().__init__ ({
105
99
"bus" : In (bus_signature ),
106
100
"leds" : Out (8 ),
107
101
"gpio" : In (Signature ({
@@ -111,14 +105,14 @@ def __init__(self):
111
105
})).array (8 )
112
106
})
113
107
114
- super (). __init__ ()
115
- bus_signature . memory_map . add_resource ( self . leds ,
116
- name = "leds" , size = 1 )
117
- bus_signature .memory_map .add_resource (((g .o for g in self .gpio ),
118
- (g .i for g in self .gpio )),
119
- name = "inout" , size = 1 )
120
- bus_signature .memory_map .add_resource ((g .oe for g in self .gpio ),
121
- name = "oe" , size = 1 )
108
+ self . bus . memory_map = MemoryMap ( addr_width = 25 , data_width = 8 ,
109
+ name = " leds" )
110
+ self . bus . memory_map . add_resource ( self . leds , name = "leds" , size = 1 )
111
+ self . bus .memory_map .add_resource (((g .o for g in self .gpio ),
112
+ (g .i for g in self .gpio )),
113
+ name = "inout" , size = 1 )
114
+ self . bus .memory_map .add_resource ((g .oe for g in self .gpio ),
115
+ name = "oe" , size = 1 )
122
116
123
117
def elaborate (self , plat ):
124
118
m = Module ()
@@ -150,14 +144,10 @@ def elaborate(self, plat):
150
144
151
145
152
146
class CSRLeds (Component ):
153
- @property
154
- def signature (self ):
155
- return self ._signature
156
-
157
147
def __init__ (self ):
158
148
self .mux = csr .bus .Multiplexer (addr_width = 4 , data_width = 8 , name = "gpio" )
159
- self . _signature = self . mux . signature
160
- self ._signature . members += {
149
+ sig = {
150
+ "bus" : Out ( self .mux . signature . members [ "bus" ]. signature ),
161
151
"leds" : Out (8 ),
162
152
"gpio" : In (Signature ({
163
153
"i" : In (1 ),
@@ -173,7 +163,8 @@ def __init__(self):
173
163
self .mux .add (self .inout_reg , name = "inout" , addr = 4 )
174
164
self .mux .add (self .oe_reg , name = "oe" , addr = 8 )
175
165
176
- super ().__init__ ()
166
+ super ().__init__ (sig )
167
+ self .bus .memory_map = self .mux .bus .memory_map
177
168
178
169
def elaborate (self , plat ):
179
170
m = Module ()
@@ -199,22 +190,18 @@ def elaborate(self, plat):
199
190
200
191
201
192
class WBTimer (Component ):
202
- @property
203
- def signature (self ):
204
- return self ._signature
205
-
206
193
def __init__ (self ):
207
194
bus_signature = wishbone .Signature (addr_width = 30 , data_width = 8 ,
208
195
granularity = 8 )
209
- bus_signature .memory_map = MemoryMap (addr_width = 30 , data_width = 8 ,
210
- name = "timer" )
211
- self ._signature = Signature ({
196
+
197
+ super ().__init__ ({
212
198
"bus" : In (bus_signature ),
213
199
"irq" : Out (1 ),
214
200
})
215
201
216
- super ().__init__ ()
217
- bus_signature .memory_map .add_resource (self .irq , name = "irq" , size = 1 )
202
+ self .bus .memory_map = MemoryMap (addr_width = 30 , data_width = 8 ,
203
+ name = "timer" )
204
+ self .bus .memory_map .add_resource (self .irq , name = "irq" , size = 1 )
218
205
219
206
def elaborate (self , plat ):
220
207
m = Module ()
@@ -247,15 +234,16 @@ def signature(self):
247
234
def __init__ (self ):
248
235
self .mux = csr .bus .Multiplexer (addr_width = 3 , data_width = 8 ,
249
236
name = "timer" )
250
- self . _signature = self . mux . signature
251
- self ._signature . members += {
237
+ sig = {
238
+ "bus" : Out ( self .mux . signature . members [ "bus" ]. signature ),
252
239
"irq" : Out (1 )
253
240
}
254
241
255
242
self .irq_reg = csr .Element (8 , "r" , path = ("irq" ,))
256
243
self .mux .add (self .irq_reg , name = "irq" )
257
244
258
- super ().__init__ ()
245
+ super ().__init__ (sig )
246
+ self .bus .memory_map = self .mux .bus .memory_map
259
247
260
248
def elaborate (self , plat ):
261
249
m = Module ()
@@ -367,26 +355,21 @@ def elaborate(self, platform):
367
355
368
356
369
357
class WBSerial (Component ):
370
- @property
371
- def signature (self ):
372
- return self ._signature
373
-
374
358
def __init__ (self ):
375
359
bus_signature = wishbone .Signature (addr_width = 30 , data_width = 8 ,
376
360
granularity = 8 )
377
- bus_signature .memory_map = MemoryMap (addr_width = 30 , data_width = 8 ,
378
- name = "serial" )
379
- self ._signature = Signature ({
361
+
362
+ super ().__init__ ({
380
363
"bus" : In (bus_signature ),
381
364
"rx" : In (1 ),
382
365
"tx" : Out (1 ),
383
366
"irq" : Out (1 ),
384
367
})
385
-
386
- super (). __init__ ( )
387
- bus_signature .memory_map .add_resource ((self .tx , self .rx ), name = "rxtx" ,
388
- size = 1 )
389
- bus_signature .memory_map .add_resource (self .irq , name = "irq" , size = 1 )
368
+ self . bus . memory_map = MemoryMap ( addr_width = 30 , data_width = 8 ,
369
+ name = "serial" )
370
+ self . bus .memory_map .add_resource ((self .tx , self .rx ), name = "rxtx" ,
371
+ size = 1 )
372
+ self . bus .memory_map .add_resource (self .irq , name = "irq" , size = 1 )
390
373
self .serial = UART (divisor = 12000000 // 9600 )
391
374
392
375
def elaborate (self , plat ):
@@ -446,15 +429,11 @@ def elaborate(self, plat):
446
429
447
430
448
431
class CSRSerial (Component ):
449
- @property
450
- def signature (self ):
451
- return self ._signature
452
-
453
432
def __init__ (self ):
454
433
self .mux = csr .bus .Multiplexer (addr_width = 3 , data_width = 8 , alignment = 0 ,
455
434
name = "serial" )
456
- self . _signature = self . mux . signature
457
- self ._signature . members += {
435
+ sig = {
436
+ "bus" : Out ( self .mux . signature . members [ "bus" ]. signature ),
458
437
"rx" : In (1 ),
459
438
"tx" : Out (1 ),
460
439
"irq" : Out (1 )
@@ -465,8 +444,9 @@ def __init__(self):
465
444
self .irq_reg = csr .Element (8 , "r" , path = ("irq" ,))
466
445
self .mux .add (self .irq_reg , name = "irq" , addr = 4 )
467
446
468
- super ().__init__ ()
447
+ super ().__init__ (sig )
469
448
self .serial = UART (divisor = 12000000 // 9600 )
449
+ self .bus .memory_map = self .mux .bus .memory_map
470
450
471
451
def elaborate (self , plat ):
472
452
m = Module ()
0 commit comments