aboutsummaryrefslogtreecommitdiffstats
path: root/gui/ice40/worker.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gui/ice40/worker.cc')
-rw-r--r--gui/ice40/worker.cc58
1 files changed, 58 insertions, 0 deletions
diff --git a/gui/ice40/worker.cc b/gui/ice40/worker.cc
new file mode 100644
index 00000000..5a8ff0e9
--- /dev/null
+++ b/gui/ice40/worker.cc
@@ -0,0 +1,58 @@
+#include "worker.h"
+#include <fstream>
+#include "jsonparse.h"
+#include "log.h"
+#include "pack.h"
+#include "pcf.h"
+#include "place_sa.h"
+#include "route.h"
+#include "bitstream.h"
+#include "design_utils.h"
+#include "timing.h"
+
+Worker::Worker(Context *_ctx) : ctx(_ctx)
+{
+ log_write_function = [this](std::string text) { Q_EMIT log(text); };
+}
+
+void Worker::parsejson(const std::string &filename)
+{
+ std::string fn = filename;
+ std::istream *f = new std::ifstream(fn);
+
+ parse_json_file(f, fn, ctx);
+ if (!pack_design(ctx))
+ log_error("Packing design failed.\n");
+ double freq = 50e6;
+ assign_budget(ctx, freq);
+ print_utilisation(ctx);
+
+ if (!place_design_sa(ctx))
+ log_error("Placing design failed.\n");
+ if (!route_design(ctx))
+ log_error("Routing design failed.\n");
+ print_utilisation(ctx);
+ Q_EMIT log("done");
+}
+
+
+TaskManager::TaskManager(Context *ctx)
+{
+ Worker *worker = new Worker(ctx);
+ worker->moveToThread(&workerThread);
+ connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater);
+ connect(this, &TaskManager::parsejson, worker, &Worker::parsejson);
+ connect(worker, &Worker::log, this, &TaskManager::info);
+ workerThread.start();
+}
+
+TaskManager::~TaskManager()
+{
+ workerThread.quit();
+ workerThread.wait();
+}
+
+void TaskManager::info(const std::string &result)
+{
+ Q_EMIT log(result);
+} \ No newline at end of file