Skip to content

Commit

Permalink
improved import of original netlist, gui selection for modifier, ini …
Browse files Browse the repository at this point in the history
…with settings, dynamic import/export with out hard coded paths
  • Loading branch information
oleeng committed Jun 21, 2024
1 parent aab833a commit 588aa95
Show file tree
Hide file tree
Showing 6 changed files with 288 additions and 181 deletions.
1 change: 1 addition & 0 deletions plugins/netlist_modifier/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ if(PL_NETLIST_MODIFIER OR BUILD_ALL_PLUGINS)
SHARED
HEADER ${NETLIST_MODIFIER_INC}
SOURCES ${NETLIST_MODIFIER_SRC} ${NETLIST_MODIFIER_PYTHON_SRC}
LINK_LIBRARIES PUBLIC gui netlist_simulator_controller
PYDOC SPHINX_DOC_INDEX_FILE ${CMAKE_CURRENT_SOURCE_DIR}/documentation/netlist_modifier.rst
)
endif()
Original file line number Diff line number Diff line change
@@ -1,41 +1,35 @@
#pragma once
#include "hal_core/defines.h"
#include "hal_core/plugin_system/plugin_interface_base.h"
#pragma once
#include "hal_core/defines.h"
#include "hal_core/netlist/netlist.h"
#include "hal_core/plugin_system/gui_extension_interface.h"
#include "hal_core/utilities/result.h"
#include "hal_core/netlist/netlist.h"
#include "hal_core/plugin_system/plugin_interface_base.h"
#include "hal_core/utilities/result.h"

namespace hal
namespace hal
{
class GuiExtensionNetlistModifier;

class PLUGIN_API NetlistModifierPlugin : public BasePluginInterface
{
GuiExtensionNetlistModifier* m_gui_extension;

public:
std::string get_name() const override;
std::string get_version() const override;
void initialize() override;

void on_load() override;
void on_unload() override;
class GuiExtensionNetlistModifier;

std::set<std::string> get_dependencies() const override;
class PLUGIN_API NetlistModifierPlugin : public BasePluginInterface
{
GuiExtensionNetlistModifier* m_gui_extension;

NetlistModifierPlugin();
public:
std::string get_name() const override;
std::string get_version() const override;
void initialize() override;

bool create_modified_netlist();
void on_load() override;
void on_unload() override;

static Netlist* modified_netlist_pointer;
private:

bool replace_gates();
};
std::set<std::string> get_dependencies() const override;

NetlistModifierPlugin();

bool modify_in_place();
bool save();
};

class GuiExtensionNetlistModifier : public GuiExtensionInterface
class GuiExtensionNetlistModifier : public GuiExtensionInterface
{
std::vector<PluginParameter> m_parameter;

Expand All @@ -47,6 +41,5 @@ namespace hal
std::vector<PluginParameter> get_parameter() const override;

void set_parameter(const std::vector<PluginParameter>& params) override;

};
} // namespace hal
} // namespace hal
40 changes: 19 additions & 21 deletions plugins/netlist_modifier/python/python_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,28 @@ namespace hal
// the name in PYBIND11_MODULE/PYBIND11_PLUGIN *MUST* match the filename of the output library (without extension),
// otherwise you will get "ImportError: dynamic module does not define module export function" when importing the module

#ifdef PYBIND11_MODULE
PYBIND11_MODULE(netlist_modifier, m)
{
m.doc() = "hal netlist modifier python bindings";
#else
PYBIND11_PLUGIN(netlist_modifier)
{
py::module m("netlist_modifier", "hal netlist modifier python bindings");
#endif
// define all exposed functions
py::class_<NetlistModifierPlugin, RawPtrWrapper<NetlistModifierPlugin>, BasePluginInterface>(m, "NetlistModifierPlugin")
#ifdef PYBIND11_MODULE
PYBIND11_MODULE(netlist_modifier, m)
{
m.doc() = "hal netlist modifier python bindings";
#else
PYBIND11_PLUGIN(netlist_modifier)
{
py::module m("netlist_modifier", "hal netlist modifier python bindings");
#endif

// define all exposed functions
py::class_<NetlistModifierPlugin, RawPtrWrapper<NetlistModifierPlugin>, BasePluginInterface>(m, "NetlistModifierPlugin")
.def_property_readonly("name", &NetlistModifierPlugin::get_name)
.def("get_name", &NetlistModifierPlugin::get_name)
.def_property_readonly("version", &NetlistModifierPlugin::get_version)
.def("get_version", &NetlistModifierPlugin::get_version)
.def(py::init<>())
.def(
"create_modified_netlist",
&NetlistModifierPlugin::create_modified_netlist
);
.def("modify_in_place", &NetlistModifierPlugin::modify_in_place)
.def("save", &NetlistModifierPlugin::save);

#ifndef PYBIND11_MODULE
return m.ptr();
#endif
}
} // namespace hal
#ifndef PYBIND11_MODULE
return m.ptr();
#endif
}
} // namespace hal
Loading

0 comments on commit 588aa95

Please sign in to comment.