aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgatecat <gatecat@ds0.me>2023-02-28 18:27:13 +0100
committermyrtle <gatecat@ds0.me>2023-02-28 18:46:35 +0100
commit1dcc2f777d644e1013a89da521f5d4c0d909e486 (patch)
tree55623a8b49feb0872cff9592cb41302386048b38
parent5d0aa7786173d698433c2b89634156e2c3928923 (diff)
downloadnextpnr-1dcc2f777d644e1013a89da521f5d4c0d909e486.tar.gz
nextpnr-1dcc2f777d644e1013a89da521f5d4c0d909e486.tar.bz2
nextpnr-1dcc2f777d644e1013a89da521f5d4c0d909e486.zip
ice40: Add python binding for write_bitstream
Signed-off-by: gatecat <gatecat@ds0.me>
-rw-r--r--ice40/arch_pybindings.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/ice40/arch_pybindings.cc b/ice40/arch_pybindings.cc
index 24e90132..09fcff3c 100644
--- a/ice40/arch_pybindings.cc
+++ b/ice40/arch_pybindings.cc
@@ -21,11 +21,23 @@
#ifndef NO_PYTHON
#include "arch_pybindings.h"
+#include "bitstream.h"
+#include "log.h"
#include "nextpnr.h"
#include "pybindings.h"
+#include <fstream>
+
NEXTPNR_NAMESPACE_BEGIN
+static void write_bitstream(const Context *ctx, std::string asc_file)
+{
+ std::ofstream out(asc_file);
+ if (!out)
+ log_error("Failed to open output file %s\n", asc_file.c_str());
+ write_asc(ctx, out);
+}
+
void arch_wrap_python(py::module &m)
{
using namespace PythonConversion;
@@ -85,6 +97,8 @@ void arch_wrap_python(py::module &m)
WRAP_MAP_UPTR(m, CellMap, "IdCellMap");
WRAP_MAP_UPTR(m, NetMap, "IdNetMap");
WRAP_MAP(m, HierarchyMap, wrap_context<HierarchicalCell &>, "HierarchyMap");
+
+ m.def("write_bitstream", &write_bitstream);
}
NEXTPNR_NAMESPACE_END