@@ -65,13 +65,19 @@ def axi_signals(w, id_width):
65
65
]
66
66
return signals
67
67
68
- def module_ports (w , name , id_width , is_input ):
68
+ def module_ports (w , intf , id_width , is_input ):
69
69
ports = []
70
70
for s in axi_signals (w , id_width ):
71
71
if s [0 ].endswith ('user' ) and not w .user :
72
72
continue
73
+ if s [0 ].startswith ('aw' ) and intf .read_only :
74
+ continue
75
+ if s [0 ].startswith ('w' ) and intf .read_only :
76
+ continue
77
+ if s [0 ].startswith ('b' ) and intf .read_only :
78
+ continue
73
79
prefix = 'o' if is_input == s [1 ] else 'i'
74
- ports .append (ModulePort ("{}_{}_{}" .format (prefix , name , s [0 ]),
80
+ ports .append (ModulePort ("{}_{}_{}" .format (prefix , intf . name , s [0 ]),
75
81
'output' if is_input == s [1 ] else 'input' ,
76
82
s [2 ]))
77
83
return ports
@@ -84,6 +90,8 @@ def assigns(w, max_idw, masters, slaves):
84
90
if s [0 ].endswith ('user' ) and not w .user :
85
91
continue
86
92
if s [1 ]:
93
+ if m .read_only and (s [0 ].startswith ('aw' ) or s [0 ].startswith ('w' ) or s [0 ].startswith ('b' )):
94
+ continue
87
95
src = "slave_{}[{}]" .format (s [0 ], i )
88
96
if s [0 ] in ['bid' , 'rid' ] and m .idw < max_idw :
89
97
src = src + '[{}:0]' .format (m .idw - 1 )
@@ -92,6 +100,12 @@ def assigns(w, max_idw, masters, slaves):
92
100
src = "i_{}_{}" .format (m .name , s [0 ])
93
101
if s [0 ] in ['arid' , 'awid' ] and m .idw < max_idw :
94
102
src = "{" + str (max_idw - m .idw )+ "'d0," + src + "}"
103
+ if m .read_only and (s [0 ].startswith ('aw' ) or s [0 ].startswith ('w' ) or s [0 ].startswith ('b' )):
104
+ if s [0 ] in ['awid' ]:
105
+ _w = max_idw
106
+ else :
107
+ _w = max (1 ,s [2 ])
108
+ src = "{}'d0" .format (_w )
95
109
raw += " assign slave_{}[{}] = {};\n " .format (s [0 ], i , src )
96
110
raw += " assign connectivity_map[{}] = {}'b{};\n " .format (i , len (slaves ), '1' * len (slaves ))
97
111
i += 1
@@ -146,29 +160,34 @@ def instance_ports(w, id_width, masters, slaves):
146
160
ports .append (Port ('cfg_connectivity_map_i' , "connectivity_map" ))
147
161
return ports
148
162
149
- def template_ports (w , name , id_width , is_input ):
163
+ def template_ports (w , intf , id_width , is_input ):
150
164
ports = []
151
165
for s in axi_signals (w , id_width ):
152
166
if s [0 ].endswith ('user' ) and not w .user :
153
167
continue
154
- port_name = "{}_{}" .format (name , s [0 ])
168
+ if intf .read_only and (s [0 ].startswith ('aw' ) or s [0 ].startswith ('w' ) or s [0 ].startswith ('b' )):
169
+ continue
170
+ port_name = "{}_{}" .format (intf .name , s [0 ])
155
171
prefix = 'o' if is_input == s [1 ] else 'i'
156
172
ports .append (Port ("{}_{}" .format (prefix , port_name ), port_name ))
157
173
return ports
158
174
159
- def template_wires (w , name , id_width ):
175
+ def template_wires (w , intf , id_width ):
160
176
wires = []
161
177
for s in axi_signals (w , id_width ):
162
178
if s [0 ].endswith ('user' ) and not w .user :
163
179
continue
164
- wires .append (Wire ("{}_{}" .format (name , s [0 ]), s [2 ]))
180
+ if intf .read_only and (s [0 ].startswith ('aw' ) or s [0 ].startswith ('w' ) or s [0 ].startswith ('b' )):
181
+ continue
182
+ wires .append (Wire ("{}_{}" .format (intf .name , s [0 ]), s [2 ]))
165
183
return wires
166
184
167
185
class Master :
168
186
def __init__ (self , name , d = None ):
169
187
self .name = name
170
188
self .slaves = []
171
189
self .idw = 1
190
+ self .read_only = False
172
191
if d :
173
192
self .load_dict (d )
174
193
@@ -179,7 +198,10 @@ def load_dict(self, d):
179
198
continue
180
199
if key == 'id_width' :
181
200
self .idw = value
201
+ elif key == 'read_only' :
202
+ self .read_only = value
182
203
else :
204
+ print (key )
183
205
raise UnknownPropertyError (
184
206
"Unknown property '%s' in master section '%s'" % (
185
207
key , self .name ))
@@ -191,6 +213,7 @@ def __init__(self, name, d=None):
191
213
self .offset = 0
192
214
self .size = 0
193
215
self .mask = 0
216
+ self .read_only = False
194
217
if d :
195
218
self .load_dict (d )
196
219
@@ -201,6 +224,8 @@ def load_dict(self, d):
201
224
elif key == 'size' :
202
225
self .size = value
203
226
self .mask = ~ (self .size - 1 ) & 0xffffffff
227
+ elif key == 'read_only' :
228
+ self .read_only = value
204
229
else :
205
230
raise UnknownPropertyError (
206
231
"Unknown property '%s' in slave section '%s'" % (
@@ -288,18 +313,18 @@ def write(self):
288
313
self .verilog_writer .add (ModulePort ('clk' , 'input' ))
289
314
self .verilog_writer .add (ModulePort ('rst_n' , 'input' ))
290
315
for master in self .masters :
291
- for port in module_ports (w , master . name , master .idw , True ):
316
+ for port in module_ports (w , master , master .idw , True ):
292
317
self .verilog_writer .add (port )
293
- for wire in template_wires (w , master . name , master .idw ):
318
+ for wire in template_wires (w , master , master .idw ):
294
319
self .template_writer .add (wire )
295
- _template_ports += template_ports (w , master . name , master .idw , True )
320
+ _template_ports += template_ports (w , master , master .idw , True )
296
321
297
322
for slave in self .slaves :
298
- for port in module_ports (w , slave . name , max_sidw , False ):
323
+ for port in module_ports (w , slave , max_sidw , False ):
299
324
self .verilog_writer .add (port )
300
- for wire in template_wires (w , slave . name , max_sidw ):
325
+ for wire in template_wires (w , slave , max_sidw ):
301
326
self .template_writer .add (wire )
302
- _template_ports += template_ports (w , slave . name , max_sidw , False )
327
+ _template_ports += template_ports (w , slave , max_sidw , False )
303
328
304
329
raw = ""
305
330
0 commit comments