aboutsummaryrefslogtreecommitdiffstats
path: root/ice40/arch_pybindings.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ice40/arch_pybindings.cc')
-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