From 33e80b96c7aac6b93e6bee18572abf529f8cc1fa Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Mon, 16 Feb 2015 12:41:48 +0100 Subject: Added YosysJS wrapper --- .gitignore | 1 - Makefile | 8 +- kernel/driver.cc | 4 +- misc/yosys.html | 237 ----------------------------------------------- misc/yosysjs/demo01.html | 237 +++++++++++++++++++++++++++++++++++++++++++++++ misc/yosysjs/demo02.html | 102 ++++++++++++++++++++ misc/yosysjs/yosysjs.js | 159 +++++++++++++++++++++++++++++++ 7 files changed, 508 insertions(+), 240 deletions(-) delete mode 100644 misc/yosys.html create mode 100644 misc/yosysjs/demo01.html create mode 100644 misc/yosysjs/demo02.html create mode 100644 misc/yosysjs/yosysjs.js diff --git a/.gitignore b/.gitignore index 4334b3d8..2e937c73 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 a7035008..a301df2f 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 6df7cf2e..69a7b8e1 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/yosys.html deleted file mode 100644 index 264a58f9..00000000 --- a/misc/yosys.html +++ /dev/null @@ -1,237 +0,0 @@ - - yosys.js example application - -

yosys.js example application

-
[ load example ]
- - -
-

Loading...
- - - - diff --git a/misc/yosysjs/demo01.html b/misc/yosysjs/demo01.html new file mode 100644 index 00000000..e0ba0248 --- /dev/null +++ b/misc/yosysjs/demo01.html @@ -0,0 +1,237 @@ + + YosysJS Example Application #01 + +

YosysJS Example Application #01

+
[ load example ]
+ + +
+

Loading...
+ + + + diff --git a/misc/yosysjs/demo02.html b/misc/yosysjs/demo02.html new file mode 100644 index 00000000..ec33198c --- /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 00000000..ad6df348 --- /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('