blob: 911b65d96419605b16db68ef3ee3bbc148684b3f [file] [log] [blame]
#!/usr/bin/env python3
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# 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()