mirror of https://github.com/YosysHQ/yosys.git
More emscripten stuff, Added example app
This commit is contained in:
parent
86819cc9f8
commit
3216f9420e
|
@ -13,13 +13,13 @@
|
|||
/abc
|
||||
/yosys
|
||||
/yosys.exe
|
||||
/yosys.js
|
||||
/yosys.html
|
||||
/yosys-abc
|
||||
/yosys-abc.exe
|
||||
/yosys-config
|
||||
/yosys-filterlib
|
||||
/yosys-filterlib.exe
|
||||
/yosys-filterlib.html
|
||||
/kernel/version_*.cc
|
||||
/share
|
||||
/libyosys
|
||||
|
|
11
Makefile
11
Makefile
|
@ -95,9 +95,10 @@ CXXFLAGS += -std=gnu++0x -Os
|
|||
|
||||
else ifeq ($(CONFIG),emcc)
|
||||
CXX = emcc
|
||||
CXXFLAGS := -std=c++11 $(filter-out -ggdb,$(CXXFLAGS))
|
||||
CXXFLAGS := -std=c++11 $(filter-out -fPIC,$(filter-out -ggdb,$(CXXFLAGS)))
|
||||
EMCCFLAGS := -Os -Wno-warn-absolute-paths
|
||||
EMCCFLAGS += --memory-init-file 0
|
||||
EMCCFLAGS += --memory-init-file 0 -s NO_EXIT_RUNTIME=1
|
||||
EMCCFLAGS += -s EXPORTED_FUNCTIONS="['_main','_run','_prompt']"
|
||||
# https://github.com/kripken/emscripten/blob/master/src/settings.js
|
||||
# EMCCFLAGS += -s ALLOW_MEMORY_GROWTH=1
|
||||
# EMCCFLAGS += -s DISABLE_EXCEPTION_CATCHING=0
|
||||
|
@ -108,7 +109,11 @@ EMCCFLAGS += --memory-init-file 0
|
|||
CXXFLAGS += $(EMCCFLAGS)
|
||||
LDFLAGS += $(EMCCFLAGS)
|
||||
LDLIBS =
|
||||
EXE = .html
|
||||
EXE = .js
|
||||
|
||||
EXTRA_TARGETS += yosys.html
|
||||
yosys.html: misc/yosys.html
|
||||
$(P) cp misc/yosys.html yosys.html
|
||||
|
||||
else ifeq ($(CONFIG),mxe)
|
||||
CXX = /usr/local/src/mxe/usr/bin/i686-pc-mingw32-gcc
|
||||
|
|
|
@ -72,6 +72,32 @@ int getopt(int argc, char **argv, const char *optstring)
|
|||
|
||||
USING_YOSYS_NAMESPACE
|
||||
|
||||
#ifdef EMSCRIPTEN
|
||||
|
||||
extern "C" int main(int, char**);
|
||||
extern "C" void run(const char*);
|
||||
extern "C" const char *prompt();
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
log_files.push_back(stdout);
|
||||
log_error_stderr = true;
|
||||
yosys_banner();
|
||||
yosys_setup();
|
||||
}
|
||||
|
||||
void run(const char *command)
|
||||
{
|
||||
run_pass(command);
|
||||
}
|
||||
|
||||
const char *prompt()
|
||||
{
|
||||
return create_prompt(yosys_get_design(), 0);
|
||||
}
|
||||
|
||||
#else /* EMSCRIPTEN */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
std::string frontend_command = "auto";
|
||||
|
@ -440,3 +466,5 @@ int main(int argc, char **argv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#endif /* EMSCRIPTEN */
|
||||
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>yosys.js example application</title>
|
||||
</head>
|
||||
<body onload="document.getElementById('command').focus()">
|
||||
<h1>yosys.js example application</h1>
|
||||
<div><textarea id="output" style="width: 100%" rows="30" cols="100">Loading...</textarea></div>
|
||||
<div><form onsubmit="return run_command()"><tt><span id="prompt"><br/>yosys> </span></tt><input id="command" type="text" size="100"></form></div>
|
||||
<script type='text/javascript'>
|
||||
var got_log_messages = false;
|
||||
var Module = {
|
||||
print: (function() {
|
||||
var element = document.getElementById('output');
|
||||
if (element) element.value = ''; // clear browser cache
|
||||
return function(text) {
|
||||
got_log_messages = true;
|
||||
if (element && typeof(text) != "number") {
|
||||
element.value += text + "\n";
|
||||
element.scrollTop = element.scrollHeight; // focus on bottom
|
||||
}
|
||||
};
|
||||
})(),
|
||||
printErr: (function() {
|
||||
var element = document.getElementById('output');
|
||||
if (element) element.value = ''; // clear browser cache
|
||||
return function(text) {
|
||||
if (element && typeof(text) != "number") {
|
||||
console.log(text);
|
||||
if (got_log_messages) {
|
||||
element.value += text + "\n";
|
||||
element.scrollTop = element.scrollHeight; // focus on bottom
|
||||
}
|
||||
}
|
||||
};
|
||||
})(),
|
||||
command: (function(cmd) {
|
||||
Module.ccall('run', '', ['string'], [cmd])
|
||||
}),
|
||||
prompt: (function(cmd) {
|
||||
return Module.ccall('prompt', 'string', [], [])
|
||||
})
|
||||
};
|
||||
function run_command() {
|
||||
var cmd = document.getElementById('command').value;
|
||||
document.getElementById('command').value = '';
|
||||
Module.print(Module.prompt() + cmd);
|
||||
try {
|
||||
Module.command(cmd);
|
||||
} catch (e) {
|
||||
Module.print('Caught JavaScript exception. (see JavaScript console for details.)');
|
||||
console.log(e);
|
||||
}
|
||||
document.getElementById('command').focus();
|
||||
document.getElementById('prompt').innerText = Module.prompt();
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
<script async type="text/javascript" src="yosys.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -24,9 +24,11 @@ passes/techmap/techmap.inc: techlibs/common/techmap.v
|
|||
|
||||
passes/techmap/techmap.o: passes/techmap/techmap.inc
|
||||
|
||||
ifneq ($(CONFIG),emcc)
|
||||
TARGETS += yosys-filterlib$(EXE)
|
||||
EXTRA_OBJS += passes/techmap/filterlib.o
|
||||
|
||||
yosys-filterlib$(EXE): passes/techmap/filterlib.o
|
||||
$(P) $(CXX) -o yosys-filterlib$(EXE) $(LDFLAGS) $^ $(LDLIBS)
|
||||
endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue