1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3# 4# Copyright (C) 2024 Antmicro 5# 6# Licensed under the Apache License, Version 2.0 (the "License"); 7# you may not use this file except in compliance with the License. 8# You may obtain a copy of the License at 9# 10# http://www.apache.org/licenses/LICENSE-2.0 11# 12# Unless required by applicable law or agreed to in writing, software 13# distributed under the License is distributed on an "AS IS" BASIS, 14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15# See the License for the specific language governing permissions and 16# limitations under the License. 17# 18# SPDX-License-Identifier: Apache-2.0 19 20from typing import TYPE_CHECKING 21 22from peakrdl.plugins.exporter import ExporterSubcommandPlugin #pylint: disable=import-error 23from peakrdl.config import schema #pylint: disable=import-error 24 25if TYPE_CHECKING: 26 import argparse 27 from systemrdl.node import AddrmapNode 28 29 30from . import cs_exporter 31 32class Exporter(ExporterSubcommandPlugin): 33 short_desc = 'Renode C# interface exporter' 34 35 def add_exporter_arguments(self, arg_group: 'argparse._ActionsContainer') -> None: 36 arg_group.add_argument('-N', '--namespace', help='Peripheral namespace', 37 required=True) 38 arg_group.add_argument('-n', '--name', help='Peripheral name') 39 arg_group.add_argument('--all-public', help='Make all field public', 40 action='store_true') 41 return 42 43 def do_export(self, top_node: 'AddrmapNode', options: 'argparse.Namespace') -> None: 44 cs_exporter.CSharpExporter().export( 45 top_node, 46 path = options.output, 47 name = options.name, 48 namespace = options.namespace, 49 all_public=options.all_public 50 ) 51