Skip to content
This repository was archived by the owner on Jan 16, 2020. It is now read-only.

Commit 3452516

Browse files
committed
Add support for read-only AXI ports
1 parent a07b0fc commit 3452516

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

axi_intercon_gen.py

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,19 @@ def axi_signals(w, id_width):
6565
]
6666
return signals
6767

68-
def module_ports(w, name, id_width, is_input):
68+
def module_ports(w, intf, id_width, is_input):
6969
ports = []
7070
for s in axi_signals(w, id_width):
7171
if s[0].endswith('user') and not w.user:
7272
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
7379
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]),
7581
'output' if is_input == s[1] else 'input',
7682
s[2]))
7783
return ports
@@ -84,6 +90,8 @@ def assigns(w, max_idw, masters, slaves):
8490
if s[0].endswith('user') and not w.user:
8591
continue
8692
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
8795
src = "slave_{}[{}]".format(s[0], i)
8896
if s[0] in ['bid', 'rid'] and m.idw < max_idw:
8997
src = src+'[{}:0]'.format(m.idw-1)
@@ -92,6 +100,8 @@ def assigns(w, max_idw, masters, slaves):
92100
src = "i_{}_{}".format(m.name, s[0])
93101
if s[0] in ['arid', 'awid'] and m.idw < max_idw:
94102
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+
src = "{}'d0".format(max(1,s[2]))
95105
raw += " assign slave_{}[{}] = {};\n".format(s[0], i, src)
96106
raw += " assign connectivity_map[{}] = {}'b{};\n".format(i, len(slaves), '1'*len(slaves))
97107
i += 1
@@ -146,29 +156,34 @@ def instance_ports(w, id_width, masters, slaves):
146156
ports.append(Port('cfg_connectivity_map_i', "connectivity_map"))
147157
return ports
148158

149-
def template_ports(w, name, id_width, is_input):
159+
def template_ports(w, intf, id_width, is_input):
150160
ports = []
151161
for s in axi_signals(w, id_width):
152162
if s[0].endswith('user') and not w.user:
153163
continue
154-
port_name = "{}_{}".format(name, s[0])
164+
if intf.read_only and (s[0].startswith('aw') or s[0].startswith('w') or s[0].startswith('b')):
165+
continue
166+
port_name = "{}_{}".format(intf.name, s[0])
155167
prefix = 'o' if is_input == s[1] else 'i'
156168
ports.append(Port("{}_{}".format(prefix, port_name), port_name))
157169
return ports
158170

159-
def template_wires(w, name, id_width):
171+
def template_wires(w, intf, id_width):
160172
wires = []
161173
for s in axi_signals(w, id_width):
162174
if s[0].endswith('user') and not w.user:
163175
continue
164-
wires.append(Wire("{}_{}".format(name, s[0]), s[2]))
176+
if intf.read_only and (s[0].startswith('aw') or s[0].startswith('w') or s[0].startswith('b')):
177+
continue
178+
wires.append(Wire("{}_{}".format(intf.name, s[0]), s[2]))
165179
return wires
166180

167181
class Master:
168182
def __init__(self, name, d=None):
169183
self.name = name
170184
self.slaves = []
171185
self.idw = 1
186+
self.read_only = False
172187
if d:
173188
self.load_dict(d)
174189

@@ -179,7 +194,10 @@ def load_dict(self, d):
179194
continue
180195
if key == 'id_width':
181196
self.idw = value
197+
elif key == 'read_only':
198+
self.read_only = value
182199
else:
200+
print(key)
183201
raise UnknownPropertyError(
184202
"Unknown property '%s' in master section '%s'" % (
185203
key, self.name))
@@ -191,6 +209,7 @@ def __init__(self, name, d=None):
191209
self.offset = 0
192210
self.size = 0
193211
self.mask = 0
212+
self.read_only = False
194213
if d:
195214
self.load_dict(d)
196215

@@ -201,6 +220,8 @@ def load_dict(self, d):
201220
elif key == 'size':
202221
self.size = value
203222
self.mask = ~(self.size-1) & 0xffffffff
223+
elif key == 'read_only':
224+
self.read_only = value
204225
else:
205226
raise UnknownPropertyError(
206227
"Unknown property '%s' in slave section '%s'" % (
@@ -288,18 +309,18 @@ def write(self):
288309
self.verilog_writer.add(ModulePort('clk' , 'input'))
289310
self.verilog_writer.add(ModulePort('rst_n', 'input'))
290311
for master in self.masters:
291-
for port in module_ports(w, master.name, master.idw, True):
312+
for port in module_ports(w, master, master.idw, True):
292313
self.verilog_writer.add(port)
293-
for wire in template_wires(w, master.name, master.idw):
314+
for wire in template_wires(w, master, master.idw):
294315
self.template_writer.add(wire)
295-
_template_ports += template_ports(w, master.name, master.idw, True)
316+
_template_ports += template_ports(w, master, master.idw, True)
296317

297318
for slave in self.slaves:
298-
for port in module_ports(w, slave.name, max_sidw, False):
319+
for port in module_ports(w, slave, max_sidw, False):
299320
self.verilog_writer.add(port)
300-
for wire in template_wires(w, slave.name, max_sidw):
321+
for wire in template_wires(w, slave, max_sidw):
301322
self.template_writer.add(wire)
302-
_template_ports += template_ports(w, slave.name, max_sidw, False)
323+
_template_ports += template_ports(w, slave, max_sidw, False)
303324

304325
raw = ""
305326

axi_node.core

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CAPI=2:
22

3-
name : pulp-platform.org::axi_node:1.1.1-r2
3+
name : pulp-platform.org::axi_node:1.1.1-r3
44

55
filesets:
66
core:

0 commit comments

Comments
 (0)