From 1dcc2f777d644e1013a89da521f5d4c0d909e486 Mon Sep 17 00:00:00 2001 From: gatecat Date: Tue, 28 Feb 2023 18:27:13 +0100 Subject: ice40: Add python binding for write_bitstream Signed-off-by: gatecat --- ice40/arch_pybindings.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 + 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, "HierarchyMap"); + + m.def("write_bitstream", &write_bitstream); } NEXTPNR_NAMESPACE_END -- cgit v1.2.3