From 33e80b96c7aac6b93e6bee18572abf529f8cc1fa Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Mon, 16 Feb 2015 12:41:48 +0100 Subject: [PATCH] Added YosysJS wrapper --- .gitignore | 1 - Makefile | 8 +- kernel/driver.cc | 4 +- misc/{yosys.html => yosysjs/demo01.html} | 4 +- misc/yosysjs/demo02.html | 102 +++++++++++++++ misc/yosysjs/yosysjs.js | 159 +++++++++++++++++++++++ 6 files changed, 273 insertions(+), 5 deletions(-) rename misc/{yosys.html => yosysjs/demo01.html} (98%) create mode 100644 misc/yosysjs/demo02.html create mode 100644 misc/yosysjs/yosysjs.js diff --git a/.gitignore b/.gitignore index 4334b3d84..2e937c735 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,6 @@ /yosys /yosys.exe /yosys.js -/yosys.html /yosys-abc /yosys-abc.exe /yosys-config diff --git a/Makefile b/Makefile index a7035008c..a301df2fc 100644 --- a/Makefile +++ b/Makefile @@ -113,12 +113,18 @@ LDLIBS = EXE = .js TARGETS := $(filter-out yosys-config,$(TARGETS)) -EXTRA_TARGETS += yosys.html viz.js +EXTRA_TARGETS += yosysjs-$(YOSYS_VER).zip viz.js: wget -O viz.js.part https://github.com/mdaines/viz.js/releases/download/0.0.3/viz.js mv viz.js.part viz.js +yosysjs-$(YOSYS_VER).zip: yosys.js viz.js misc/yosysjs/* + rm -rf yosysjs-$(YOSYS_VER) yosysjs-$(YOSYS_VER).zip + mkdir -p yosysjs-$(YOSYS_VER) + cp viz.js misc/yosysjs/* yosys.js yosysjs-$(YOSYS_VER)/ + zip -r yosysjs-$(YOSYS_VER).zip yosysjs-$(YOSYS_VER) + yosys.html: misc/yosys.html $(P) cp misc/yosys.html yosys.html diff --git a/kernel/driver.cc b/kernel/driver.cc index 6df7cf2e8..69a7b8e15 100644 --- a/kernel/driver.cc +++ b/kernel/driver.cc @@ -93,7 +93,9 @@ void run(const char *command) const char *prompt() { - return create_prompt(yosys_get_design(), 0); + const char *p = create_prompt(yosys_get_design(), 0); + while (*p == '\n') p++; + return p; } #else /* EMSCRIPTEN */ diff --git a/misc/yosys.html b/misc/yosysjs/demo01.html similarity index 98% rename from misc/yosys.html rename to misc/yosysjs/demo01.html index 264a58f96..e0ba0248f 100644 --- a/misc/yosys.html +++ b/misc/yosysjs/demo01.html @@ -1,7 +1,7 @@ - yosys.js example application + YosysJS Example Application #01 -

yosys.js example application

+

YosysJS Example Application #01

[ load example ]
diff --git a/misc/yosysjs/demo02.html b/misc/yosysjs/demo02.html new file mode 100644 index 000000000..ec33198c7 --- /dev/null +++ b/misc/yosysjs/demo02.html @@ -0,0 +1,102 @@ + + YosysJS Example Application #02 + + + +

YosysJS Example Application #02

+

+

+ + + +

+ + + + diff --git a/misc/yosysjs/yosysjs.js b/misc/yosysjs/yosysjs.js new file mode 100644 index 000000000..ad6df348b --- /dev/null +++ b/misc/yosysjs/yosysjs.js @@ -0,0 +1,159 @@ +var YosysJS = new function() { + this.script_element = document.currentScript; + this.viz_element = undefined; + + this.url_prefix = this.script_element.src.replace(/[^/]+$/, '') + + this.load_viz = function() { + if (this.viz_element) + return; + + this.viz_element = document.createElement('iframe') + this.viz_element.style.display = 'none' + document.body.appendChild(this.viz_element); + + this.viz_element.contentWindow.document.open() + this.viz_element.contentWindow.document.write('