| #!/usr/bin/env python3 |
| # Copyright lowRISC contributors. |
| # Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| # SPDX-License-Identifier: Apache-2.0 |
| r"""Convert mako template to Hjson register description |
| """ |
| import argparse |
| import sys |
| from io import StringIO |
| |
| from mako.template import Template |
| |
| |
| def main(): |
| parser = argparse.ArgumentParser(prog="reg_pwrmgr") |
| parser.add_argument('input', |
| nargs='?', |
| metavar='file', |
| type=argparse.FileType('r'), |
| default=sys.stdin, |
| help='input template file') |
| parser.add_argument('--n_wkups', |
| type=int, |
| default=16, |
| help='Number of Wakeup sources') |
| |
| args = parser.parse_args() |
| |
| # Determine output: if stdin then stdout if not then ?? |
| out = StringIO() |
| |
| reg_tpl = Template(args.input.read()) |
| out.write( |
| reg_tpl.render(NumWkups=args.n_wkups)) |
| |
| print(out.getvalue()) |
| |
| out.close() |
| |
| |
| if __name__ == "__main__": |
| main() |