-
Notifications
You must be signed in to change notification settings - Fork 1
[rdl2ot] Make the tool a peakrdl pluggin #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,31 @@ | ||||
| #!/usr/bin/env python3 | ||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line shouldn't be required, as the entry point script will automatically be created.
Suggested change
Same goes for the |
||||
| # Copyright lowRISC contributors. | ||||
| # Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||||
| # SPDX-License-Identifier: Apache-2.0 | ||||
|
|
||||
| """Generates Opentitan regblock RTL.""" | ||||
|
|
||||
| from pathlib import Path | ||||
| from typing import TYPE_CHECKING | ||||
|
|
||||
| from peakrdl.plugins.exporter import ExporterSubcommandPlugin # pylint: disable=import-error | ||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What import error is being disabled here? Also this is a |
||||
|
|
||||
| from rdl2ot import rtl_exporter | ||||
|
|
||||
| if TYPE_CHECKING: | ||||
| import argparse | ||||
|
|
||||
| from systemrdl.node import AddrmapNode | ||||
|
|
||||
|
|
||||
| class Exporter(ExporterSubcommandPlugin): | ||||
| """Generates Opentitan regblock RTL.""" | ||||
|
|
||||
| short_desc = "Generates Opentitan register block RTL." | ||||
|
|
||||
| def add_exporter_arguments(self, arg_group: "argparse.ArgumentParser") -> None: | ||||
| """No extra arguments.""" | ||||
|
|
||||
| def do_export(self, top_node: "AddrmapNode", options: "argparse.Namespace") -> None: | ||||
| """Plugin entry function.""" | ||||
| rtl_exporter.run(top_node, Path(options.output)) | ||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I learnt something new today... https://setuptools.pypa.io/en/latest/userguide/entry_point.html#entry-points-for-plugins
Didn't realise such a neat mechanism for plugin discovery was available. In the past I've only used entry-points for scripts.