blob: de03be978173f962a016d40d94c1309d7abd88fa [file] [log] [blame]
lowRISC Contributors802543a2019-08-31 12:12:56 +01001// Copyright lowRISC contributors.
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4//
5// tl_${xbar.name} package generated by `tlgen.py` tool
6
7<%
Rupert Swarbricka5e687f2021-03-01 11:51:41 +00008 unames = [x.name.replace('.', '__').upper() for x in xbar.devices]
9 name_len = max([len(un) for un in unames])
lowRISC Contributors802543a2019-08-31 12:12:56 +010010%>\
11package tl_${xbar.name}_pkg;
12
Rupert Swarbricka5e687f2021-03-01 11:51:41 +000013% for uname, device in zip(unames, xbar.devices):
14<%
15 lname = uname.ljust(name_len)
16%>\
lowRISC Contributors802543a2019-08-31 12:12:56 +010017 ## Address
Eunchan Kimc7452942019-12-19 17:04:37 -080018 % if device.xbar == False:
Rupert Swarbricka5e687f2021-03-01 11:51:41 +000019 localparam logic [31:0] ADDR_SPACE_${lname} = 32'h ${"%08x" % device.addr_range[0][0]};
Eunchan Kimc7452942019-12-19 17:04:37 -080020 % else:
21 ## Xbar device
Rupert Swarbricka5e687f2021-03-01 11:51:41 +000022 localparam logic [${len(device.addr_range)-1}:0][31:0] ADDR_SPACE_${lname} = {
Timothy Chen4f276602020-08-26 17:08:14 -070023 % for addr in list(reversed(device.addr_range)):
Eunchan Kimc7452942019-12-19 17:04:37 -080024 32'h ${"%08x" % addr[0]}${"," if not loop.last else ""}
25 % endfor
26 };
27 % endif
lowRISC Contributors802543a2019-08-31 12:12:56 +010028% endfor
29
Rupert Swarbricka5e687f2021-03-01 11:51:41 +000030% for uname, device in zip(unames, xbar.devices):
31<%
32 lname = uname.ljust(name_len)
33%>\
lowRISC Contributors802543a2019-08-31 12:12:56 +010034 ## Mask
Eunchan Kimc7452942019-12-19 17:04:37 -080035 % if device.xbar == False:
Rupert Swarbricka5e687f2021-03-01 11:51:41 +000036 localparam logic [31:0] ADDR_MASK_${lname} = 32'h ${"%08x" % (device.addr_range[0][1] - device.addr_range[0][0])};
Eunchan Kimc7452942019-12-19 17:04:37 -080037 % else:
38 ## Xbar
Rupert Swarbricka5e687f2021-03-01 11:51:41 +000039 localparam logic [${len(device.addr_range)-1}:0][31:0] ADDR_MASK_${lname} = {
Timothy Chen4f276602020-08-26 17:08:14 -070040 % for addr in list(reversed(device.addr_range)):
Eunchan Kimc7452942019-12-19 17:04:37 -080041 32'h ${"%08x" % (addr[1] - addr[0])}${"," if not loop.last else ""}
42 % endfor
43 };
44 % endif
lowRISC Contributors802543a2019-08-31 12:12:56 +010045% endfor
46
47 localparam int N_HOST = ${len(xbar.hosts)};
48 localparam int N_DEVICE = ${len(xbar.devices)};
49
50 typedef enum int {
51% for device in xbar.devices:
52 ## Create enum type for hosts( or blocks) connecting to the device
53 ## Device Node has one upstream port. So tl_device_h2d can be directly used
54<%
Rupert Swarbricka5e687f2021-03-01 11:51:41 +000055 u_name = ''.join(device.name.title().replace('.', '_').split('_'));
lowRISC Contributors802543a2019-08-31 12:12:56 +010056%>\
57 % if loop.last:
58 Tl${u_name} = ${loop.index}
59 % else:
60 Tl${u_name} = ${loop.index},
61 % endif
62% endfor
63 } tl_device_e;
64
65 typedef enum int {
66% for host in xbar.hosts:
67 ## Create enum type for downstream connecting to each host
68 ## Host Node has one downstream port. so tl_host_h2d can be directly used
69<%
Rupert Swarbricka5e687f2021-03-01 11:51:41 +000070 u_name = ''.join(host.name.title().replace('.', '_').split('_'));
lowRISC Contributors802543a2019-08-31 12:12:56 +010071%>\
72 % if loop.last:
73 Tl${u_name} = ${loop.index}
74 % else:
75 Tl${u_name} = ${loop.index},
76 % endif
77% endfor
78 } tl_host_e;
79
80endpackage