31 #include "pybind11/pybind11.h"
33 #include <igraph/igraph.h>
34 #include <pybind11/detail/descr.h>
35 #include <pybind11/pytypes.h>
42 class BasePluginInterface;
58 #ifdef PYBIND11_MODULE
59 PYBIND11_MODULE( clock_tree_extractor, m )
68 py::class_<ClockTreeExtractorPlugin, RawPtrWrapper<ClockTreeExtractorPlugin>,
BasePluginInterface>
69 py_clock_tree_extractor_plugin( m,
"ClockTreeExtractorPlugin",
"" );
72 The name of the plugin.
78 Get the name of the plugin.
80 :returns: The name of the plugin.
85 The version of the plugin.
91 Get the version of the plugin.
93 :returns: The version of the plugin.
97 py_clock_tree_extractor_plugin.def_property_readonly(
99 The description of the plugin.
105 Get the description of the plugin.
107 :returns: The description of the plugin.
111 py_clock_tree_extractor_plugin.def_property_readonly(
113 A set of plugin names that this plugin depends on.
119 Get a set of plugin names that this plugin depends on.
121 :returns: A set of plugin names that this plugin depends on.
125 py::class_<cte::ClockTree>( m, "ClockTree", R
"()" )
128 [](
const Netlist *netlist ) -> std::unique_ptr<cte::ClockTree> {
135 log_error(
"clock_tree_extractor",
"{}", result.get_error().get() );
138 py::arg(
"netlist" ),
139 py::return_value_policy::move,
143 [](
const cte::ClockTree &
self,
const std::string &pathname ) ->
bool {
144 auto result =
self.export_dot( pathname );
150 log_error(
"clock_tree_extractor",
"{}", result.get_error().get() );
153 py::arg(
"pathname" ),
159 const bool parent ) -> std::unique_ptr<cte::ClockTree> {
160 auto result =
self.get_subtree( ptr, parent );
166 log_error(
"clock_tree_extractor",
"{}", result.get_error().get() );
170 py::arg(
"parent" ) =
false,
171 py::return_value_policy::move,
177 const auto &map =
self.get_all();
178 for(
auto &[ptr,
type] : map )
182 result.append( py::cast( (
const Gate *) ptr ) );
186 result.append( py::cast( (
const Net *) ptr ) );
194 "get_vertex_from_ptr",
196 auto result =
self.get_vertex_from_ptr( ptr );
199 return py::int_( result.get() );
201 log_error(
"clock_tree_extractor",
"{}", result.get_error().get() );
207 "get_ptr_from_vertex",
208 [](
const cte::ClockTree &
self,
const igraph_integer_t vertex ) -> py::object {
209 auto result =
self.get_ptr_from_vertex( vertex );
212 auto [ptr,
type] = result.get();
215 return py::cast( (
const Gate *) ptr );
219 return py::cast( (
const Net *) ptr );
223 log_error(
"clock_tree_extractor",
"{}", result.get_error().get() );
230 "get_vertices_from_ptrs",
231 [](
const cte::ClockTree &
self,
const std::vector<const void *> &ptrs ) -> py::list {
232 auto result =
self.get_vertices_from_ptrs( ptrs );
235 return py::cast( result.get() );
237 log_error(
"clock_tree_extractor",
"{}", result.get_error().get() );
243 "get_ptrs_from_vertices",
244 [](
const cte::ClockTree &
self,
const std::vector<igraph_integer_t> &vertices ) -> py::list {
245 auto res =
self.get_ptrs_from_vertices( vertices );
249 for(
const auto &[ptr,
type] : res.get() )
253 result.append( py::cast( (
const Gate *) ptr ) );
257 result.append( py::cast( (
const Net *) ptr ) );
261 log_error(
"clock_tree_extractor",
"unknown ptr type" );
267 log_error(
"clock_tree_extractor",
"{}", res.get_error().get() );
270 py::arg(
"vertices" ),
275 auto res =
self.get_neighbors( ptr, IGRAPH_IN );
279 for(
const auto &[ptr,
type] : res.get() )
283 result.append( py::cast( (
const Gate *) ptr ) );
287 result.append( py::cast( (
const Net *) ptr ) );
291 log_error(
"clock_tree_extractor",
"unknown ptr type" );
297 log_error(
"clock_tree_extractor",
"{}", res.get_error().get() );
306 auto res =
self.get_neighbors( ptr, IGRAPH_OUT );
310 for(
const auto &[ptr,
type] : res.get() )
314 result.append( py::cast( (
const Gate *) ptr ) );
318 result.append( py::cast( (
const Net *) ptr ) );
322 log_error(
"clock_tree_extractor",
"unknown ptr type" );
328 log_error(
"clock_tree_extractor",
"{}", res.get_error().get() );
338 #ifndef PYBIND11_MODULE
const Netlist * get_netlist() const
const std::vector< const Gate * > get_gates() const
const std::vector< const Net * > get_nets() const
static Result< std::unique_ptr< ClockTree > > from_netlist(const Netlist *netlist)
#define log_error(channel,...)
const Module * module(const Gate *g, const NodeBoxes &boxes)