Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/interface/python/py_ircx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ add_library(py_ircx ${PY_IRCX_SRC})
target_link_libraries(py_ircx
PUBLIC
ircx_api
ircx_ics55
pybind11::pybind11
)
target_include_directories(py_ircx
Expand Down
69 changes: 67 additions & 2 deletions src/interface/python/py_ircx/py_ircx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,86 @@
#include "py_ircx.h"

#include "RCXAPI.hh"
#include "ircx_ics55.h"

namespace python_interface {

bool init_rcx(const std::string& config)
namespace {

enum class RcxBackend
{
kUninitialized,
kNative,
kIcs55,
};

RcxBackend active_backend = RcxBackend::kUninitialized;

bool is_native_pdk(const std::optional<std::string>& pdk)
{
return !pdk.has_value() || pdk->empty();
}

bool is_ics55_pdk(const std::optional<std::string>& pdk)
{
return pdk.has_value() && *pdk == "ics55";
}

bool validate_pdk(const std::optional<std::string>& pdk)
{
return RCX_API_INST.init(config);
return is_native_pdk(pdk) || is_ics55_pdk(pdk);
}

} // namespace

bool init_rcx(const std::string& config, const std::optional<std::string>& pdk)
{
active_backend = RcxBackend::kUninitialized;

if (!validate_pdk(pdk)) {
return false;
}

if (is_ics55_pdk(pdk)) {
if (ircx_ics55_init(config.c_str()) != 0) {
active_backend = RcxBackend::kIcs55;
return true;
}

return false;
}

if (RCX_API_INST.init(config)) {
active_backend = RcxBackend::kNative;
return true;
}

return false;
}

bool run_rcx()
{
if (active_backend == RcxBackend::kIcs55) {
return ircx_ics55_run() != 0;
}

if (active_backend != RcxBackend::kNative) {
return false;
}

return RCX_API_INST.run();
}

bool report_rcx()
{
if (active_backend == RcxBackend::kIcs55) {
return ircx_ics55_report() != 0;
}

if (active_backend != RcxBackend::kNative) {
return false;
}

return RCX_API_INST.report();
}

Expand Down
3 changes: 2 additions & 1 deletion src/interface/python/py_ircx/py_ircx.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
// ***************************************************************************************
#pragma once

#include <optional>
#include <string>

#include "RCXAPI.hh"

namespace python_interface {

bool init_rcx(const std::string& config);
bool init_rcx(const std::string& config, const std::optional<std::string>& pdk = std::nullopt);
bool run_rcx();
bool report_rcx();

Expand Down
2 changes: 1 addition & 1 deletion src/interface/python/py_ircx/py_register_ircx.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace py = pybind11;

void register_ircx(py::module& m)
{
m.def("init_rcx", init_rcx, py::arg("config"));
m.def("init_rcx", init_rcx, py::arg("config"), py::arg("pdk") = py::none());
m.def("run_rcx", run_rcx);
m.def("report_rcx", report_rcx);
}
Expand Down
Binary file modified src/operation/iRCX/ics55/lib/libgcc_s.so.1
Binary file not shown.
Binary file modified src/operation/iRCX/ics55/lib/libgflags.so.2.2
Binary file not shown.
Binary file modified src/operation/iRCX/ics55/lib/libglog.so.1
Binary file not shown.
Binary file modified src/operation/iRCX/ics55/lib/libgomp.so.1
Binary file not shown.
Binary file modified src/operation/iRCX/ics55/lib/libircx_ics55.so
Binary file not shown.
Binary file modified src/operation/iRCX/ics55/lib/liblzma.so.5
Binary file not shown.
Binary file modified src/operation/iRCX/ics55/lib/libstdc++.so.6
Binary file not shown.
Binary file modified src/operation/iRCX/ics55/lib/libunwind.so.8
Binary file not shown.
Loading