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

Commit 8ef3aba

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

File tree

2 files changed

+38
-13
lines changed

2 files changed

+38
-13
lines changed

axi_intercon_gen.py

Lines changed: 37 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,12 @@ 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+
if s[0] in ['awid']:
105+
_w = max_idw
106+
else:
107+
_w = max(1,s[2])
108+
src = "{}'d0".format(_w)
95109
raw += " assign slave_{}[{}] = {};\n".format(s[0], i, src)
96110
raw += " assign connectivity_map[{}] = {}'b{};\n".format(i, len(slaves), '1'*len(slaves))
97111
i += 1
@@ -146,29 +160,34 @@ def instance_ports(w, id_width, masters, slaves):
146160
ports.append(Port('cfg_connectivity_map_i', "connectivity_map"))
147161
return ports
148162

149-
def template_ports(w, name, id_width, is_input):
163+
def template_ports(w, intf, id_width, is_input):
150164
ports = []
151165
for s in axi_signals(w, id_width):
152166
if s[0].endswith('user') and not w.user:
153167
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])
155171
prefix = 'o' if is_input == s[1] else 'i'
156172
ports.append(Port("{}_{}".format(prefix, port_name), port_name))
157173
return ports
158174

159-
def template_wires(w, name, id_width):
175+
def template_wires(w, intf, id_width):
160176
wires = []
161177
for s in axi_signals(w, id_width):
162178
if s[0].endswith('user') and not w.user:
163179
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]))
165183
return wires
166184

167185
class Master:
168186
def __init__(self, name, d=None):
169187
self.name = name
170188
self.slaves = []
171189
self.idw = 1
190+
self.read_only = False
172191
if d:
173192
self.load_dict(d)
174193

@@ -179,7 +198,10 @@ def load_dict(self, d):
179198
continue
180199
if key == 'id_width':
181200
self.idw = value
201+
elif key == 'read_only':
202+
self.read_only = value
182203
else:
204+
print(key)
183205
raise UnknownPropertyError(
184206
"Unknown property '%s' in master section '%s'" % (
185207
key, self.name))
@@ -191,6 +213,7 @@ def __init__(self, name, d=None):
191213
self.offset = 0
192214
self.size = 0
193215
self.mask = 0
216+
self.read_only = False
194217
if d:
195218
self.load_dict(d)
196219

@@ -201,6 +224,8 @@ def load_dict(self, d):
201224
elif key == 'size':
202225
self.size = value
203226
self.mask = ~(self.size-1) & 0xffffffff
227+
elif key == 'read_only':
228+
self.read_only = value
204229
else:
205230
raise UnknownPropertyError(
206231
"Unknown property '%s' in slave section '%s'" % (
@@ -288,18 +313,18 @@ def write(self):
288313
self.verilog_writer.add(ModulePort('clk' , 'input'))
289314
self.verilog_writer.add(ModulePort('rst_n', 'input'))
290315
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):
292317
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):
294319
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)
296321

297322
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):
299324
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):
301326
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)
303328

304329
raw = ""
305330

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)