lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 1 | // 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 Swarbrick | a5e687f | 2021-03-01 11:51:41 +0000 | [diff] [blame] | 8 | unames = [x.name.replace('.', '__').upper() for x in xbar.devices] |
| 9 | name_len = max([len(un) for un in unames]) |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 10 | %>\ |
| 11 | package tl_${xbar.name}_pkg; |
| 12 | |
Rupert Swarbrick | a5e687f | 2021-03-01 11:51:41 +0000 | [diff] [blame] | 13 | % for uname, device in zip(unames, xbar.devices): |
| 14 | <% |
| 15 | lname = uname.ljust(name_len) |
| 16 | %>\ |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 17 | ## Address |
Eunchan Kim | c745294 | 2019-12-19 17:04:37 -0800 | [diff] [blame] | 18 | % if device.xbar == False: |
Rupert Swarbrick | a5e687f | 2021-03-01 11:51:41 +0000 | [diff] [blame] | 19 | localparam logic [31:0] ADDR_SPACE_${lname} = 32'h ${"%08x" % device.addr_range[0][0]}; |
Eunchan Kim | c745294 | 2019-12-19 17:04:37 -0800 | [diff] [blame] | 20 | % else: |
| 21 | ## Xbar device |
Rupert Swarbrick | a5e687f | 2021-03-01 11:51:41 +0000 | [diff] [blame] | 22 | localparam logic [${len(device.addr_range)-1}:0][31:0] ADDR_SPACE_${lname} = { |
Timothy Chen | 4f27660 | 2020-08-26 17:08:14 -0700 | [diff] [blame] | 23 | % for addr in list(reversed(device.addr_range)): |
Eunchan Kim | c745294 | 2019-12-19 17:04:37 -0800 | [diff] [blame] | 24 | 32'h ${"%08x" % addr[0]}${"," if not loop.last else ""} |
| 25 | % endfor |
| 26 | }; |
| 27 | % endif |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 28 | % endfor |
| 29 | |
Rupert Swarbrick | a5e687f | 2021-03-01 11:51:41 +0000 | [diff] [blame] | 30 | % for uname, device in zip(unames, xbar.devices): |
| 31 | <% |
| 32 | lname = uname.ljust(name_len) |
| 33 | %>\ |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 34 | ## Mask |
Eunchan Kim | c745294 | 2019-12-19 17:04:37 -0800 | [diff] [blame] | 35 | % if device.xbar == False: |
Rupert Swarbrick | a5e687f | 2021-03-01 11:51:41 +0000 | [diff] [blame] | 36 | localparam logic [31:0] ADDR_MASK_${lname} = 32'h ${"%08x" % (device.addr_range[0][1] - device.addr_range[0][0])}; |
Eunchan Kim | c745294 | 2019-12-19 17:04:37 -0800 | [diff] [blame] | 37 | % else: |
| 38 | ## Xbar |
Rupert Swarbrick | a5e687f | 2021-03-01 11:51:41 +0000 | [diff] [blame] | 39 | localparam logic [${len(device.addr_range)-1}:0][31:0] ADDR_MASK_${lname} = { |
Timothy Chen | 4f27660 | 2020-08-26 17:08:14 -0700 | [diff] [blame] | 40 | % for addr in list(reversed(device.addr_range)): |
Eunchan Kim | c745294 | 2019-12-19 17:04:37 -0800 | [diff] [blame] | 41 | 32'h ${"%08x" % (addr[1] - addr[0])}${"," if not loop.last else ""} |
| 42 | % endfor |
| 43 | }; |
| 44 | % endif |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 45 | % 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 Swarbrick | a5e687f | 2021-03-01 11:51:41 +0000 | [diff] [blame] | 55 | u_name = ''.join(device.name.title().replace('.', '_').split('_')); |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 56 | %>\ |
| 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 Swarbrick | a5e687f | 2021-03-01 11:51:41 +0000 | [diff] [blame] | 70 | u_name = ''.join(host.name.title().replace('.', '_').split('_')); |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 71 | %>\ |
| 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 | |
| 80 | endpackage |