blob: 8b21d9cf4c54ec1763e1c70514ea04ca53cf55fc [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
Eunchan Kimcb28a172019-10-08 16:35:48 -07005from mako import exceptions
lowRISC Contributors802543a2019-08-31 12:12:56 +01006from mako.template import Template
7from pkg_resources import resource_filename
8
9from .item import NodeType
10from .xbar import Xbar
11
12
13def generate(xbar): #xbar: Xbar -> str
14 """generate uses elaborated model then creates top level Xbar module
15 with prefix.
16 """
17
18 xbar_rtl_tpl = Template(
Michael Schaffnerc7039362019-10-22 16:16:06 -070019 filename=resource_filename('tlgen', 'xbar.rtl.sv.tpl'))
lowRISC Contributors802543a2019-08-31 12:12:56 +010020 xbar_pkg_tpl = Template(
Michael Schaffnerc7039362019-10-22 16:16:06 -070021 filename=resource_filename('tlgen', 'xbar.pkg.sv.tpl'))
Eunchan Kimc6a6a3b2019-09-12 14:27:43 -070022 #xbar_dv_tpl = Template(
Michael Schaffnerc7039362019-10-22 16:16:06 -070023 # filename=resource_filename('tlgen', 'xbar.dv.sv.tpl'))
Eunchan Kimc6a6a3b2019-09-12 14:27:43 -070024 xbar_bind_tpl = Template(
Michael Schaffnerc7039362019-10-22 16:16:06 -070025 filename=resource_filename('tlgen', 'xbar.bind.sv.tpl'))
lowRISC Contributors802543a2019-08-31 12:12:56 +010026
Eunchan Kimcb28a172019-10-08 16:35:48 -070027 try:
28 out_rtl = xbar_rtl_tpl.render(xbar=xbar, ntype=NodeType)
29 out_pkg = xbar_pkg_tpl.render(xbar=xbar)
30 out_bind = xbar_bind_tpl.render(xbar=xbar, ntype=NodeType)
31 except:
32 log.error(exceptions.text_error_template().render())
33
Eunchan Kimc6a6a3b2019-09-12 14:27:43 -070034 return (out_rtl, out_pkg, out_bind)