36 #include <pybind11/detail/internals.h>
37 #include <pybind11/pytypes.h>
50 #ifdef PYBIND11_MODULE
51 PYBIND11_MODULE( clock_tree_viewer, m )
53 m.doc() =
"A plugin to interactively view clock trees extracted by the clock_tree_extractor plugin.";
58 "A plugin to interactively view clock trees extracted by the clock_tree_extractor plugin." );
61 py::class_<ClockTreeViewerPlugin, RawPtrWrapper<ClockTreeViewerPlugin>,
BasePluginInterface>
62 py_clock_tree_viewer_plugin(
64 "ClockTreeViewerPlugin",
65 R
"(This class provides an interface to integrate the clock tree viewer as a plugin within the HAL framework.)" );
68 The name of the plugin.
74 Get the name of the plugin.
76 :returns: The name of the plugin.
81 The version of the plugin.
87 Get the version of the plugin.
89 :returns: The version of the plugin.
94 The description of the plugin.
100 Get the description of the plugin.
102 :returns: The description of the plugin.
107 A set of plugin names that this plugin depends on.
113 Get a set of plugin names that this plugin depends on.
115 :returns: A set of plugin names that this plugin depends on.
122 const std::optional<double> node_radius,
123 const std::optional<double> edge_width,
124 const std::optional<double> picture_margin,
125 const std::optional<double> pixels_per_unit,
126 const std::optional<std::string> &x_key,
127 const std::optional<std::string> &y_key ) ->
bool {
130 py::gil_scoped_release release;
138 py::arg(
"clock_tree" ),
139 py::arg(
"node_radius" ) = py::none(),
140 py::arg(
"edge_width" ) = py::none(),
141 py::arg(
"picture_margin" ) = py::none(),
142 py::arg(
"pixels_per_unit" ) = py::none(),
146 Plot a clock tree in the clock tree viewer of the GUI.
148 The coordinates of the gates are read from the gate parameters ``X`` and ``Y``, e.g., from Verilog instance parameters, unless the keys of other parameters are given. Pass ``None`` for both keys to draw the gates at their location in the layout instead. If no gate has coordinates, nothing is drawn and an error is shown. If only some gates have none, those are left out of the plot and a warning is shown. A clock tree of another netlist than the one that is open in the GUI is not drawn either, since its gates cannot be matched to the gates in HAL.
150 The sizes and coordinate keys are kept: extracting a clock tree with the button in the toolbar of the viewer uses them again.
152 The plot is in the colors of HAL's graph view. The background and the connections follow the theme. A gate has the color of the module it belongs to, the color of its grouping if it is in one, or the orange of a selected item if it is selected, and the plot follows all of them when they change.
154 The sizes of the drawing follow from the coordinates, from the length of a typical connection in the clock tree. Provide any of them to choose it yourself. All lengths are in the unit of the coordinates.
156 :param clock_tree_extractor.ClockTree clock_tree: The clock tree to plot.
157 :param float node_radius: The radius of the dot that represents a gate. Defaults to ``None``, which derives it from the coordinates.
158 :param float edge_width: The width of the lines that represent connections. Defaults to ``None``, which derives it from the coordinates.
159 :param float picture_margin: The empty border around the tree in a saved picture. Defaults to ``None``, which derives it from the coordinates.
160 :param float pixels_per_unit: The resolution of a saved picture. Defaults to ``None``, which derives it from the coordinates and lowers it for a large tree, so that a picture stays within 10000 pixels per side. A resolution given here is kept, and a picture that would exceed the limit is not saved.
161 :param str x_key: The name of the parameter that holds the x-coordinate, ``None`` to use the location. Defaults to ``"X"``.
162 :param str y_key: The name of the parameter that holds the y-coordinate, ``None`` to use the location. Defaults to ``"Y"``.
163 :returns: ``True`` if the clock tree is plotted, ``False`` otherwise.
169 [](
const std::vector<Gate *> &gates ) -> std::size_t {
171 std::vector<u32> gate_ids;
172 gate_ids.reserve( gates.size() );
173 for(
const Gate *gate : gates )
175 if( gate ==
nullptr )
184 "Gate with ID {} is not part of the netlist that is open, ignored.",
189 gate_ids.push_back( gate->get_id() );
193 py::gil_scoped_release release;
199 Highlight gates in the clock tree viewer of the GUI, instead of the ones that were highlighted before.
201 A highlighted gate has the color of a selected item and a ring around it that is the same size on the screen at every zoom, so it can be found in a plot of the whole chip. Only gates that are plotted can be highlighted. Gates that are not part of the clock tree are ignored, and so are those of the clock tree that have no coordinates and are therefore not plotted. Nothing is selected in HAL by this.
203 The gates that are selected in HAL are highlighted without any call to this function, e.g., after ``gui.select(gates)`` in the Python console of the GUI. The last of the two, a selection in HAL and a call to this function, decides which gates are highlighted.
205 :param list[hal_py.Gate] gates: The gates to highlight. An empty list removes the highlight.
206 :returns: The number of gates that are highlighted, i.e., those of ``gates`` that are plotted. ``0`` if there is no clock tree viewer or no clock tree is plotted.
210 #ifndef PYBIND11_MODULE
static std::size_t highlightGates(const std::vector< u32 > &gateIds)
static bool setClockTree(const cte::ClockTree &tree, const ctv::StyleOverrides &overrides=ctv::StyleOverrides(), const std::optional< std::string > &x_key=ctv::DEFAULT_X_KEY, const std::optional< std::string > &y_key=ctv::DEFAULT_Y_KEY)
std::string get_name() const override
std::string get_description() const override
std::string get_version() const override
std::set< std::string > get_dependencies() const override
#define log_warning(channel,...)
const Module * module(const Gate *g, const NodeBoxes &boxes)
const std::string DEFAULT_Y_KEY
const std::string DEFAULT_X_KEY