3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-22 16:45:32 +00:00

More emcc stuff

This commit is contained in:
Clifford Wolf 2015-02-15 17:14:09 +01:00
parent c2cc342e1a
commit 8d45f81046
3 changed files with 39 additions and 17 deletions

View file

@ -4,18 +4,18 @@
<h1>yosys.js example application</h1>
<div><textarea id="output" style="width: 100%" rows="30" cols="100"></textarea></div>
<div id="wait" style="display: block"><br/><b><span id="waitmsg">Loading...</span></b></div>
<div id="input" style="display: none"><form onsubmit="return run_command()"><tt><span id="prompt"><br/>yosys&gt; </span></tt><input id="command" type="text" size="100"></form></div>
<div id="input" style="display: none"><form onsubmit="window.setTimeout(run_command); return false"><tt><span id="prompt">
</span></tt><input id="command" type="text" style="font-family: monospace; font-weight: bold;" 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) {
if (!got_log_messages) {
document.getElementById('wait').style.display = 'none';
document.getElementById('input').style.display = 'block';
document.getElementById('waitmsg').innerText = 'Waiting for yosys.js...';
window.setTimeout(startup, 50);
got_log_messages = true;
}
if (element && typeof(text) != "number") {
@ -37,30 +37,42 @@
}
};
})(),
command: (function(cmd) {
Module.ccall('run', '', ['string'], [cmd])
}),
prompt: (function(cmd) {
return Module.ccall('prompt', 'string', [], [])
})
};
function startup() {
document.getElementById('wait').style.display = 'none';
document.getElementById('input').style.display = 'block';
document.getElementById('waitmsg').innerText = 'Waiting for yosys.js...';
document.getElementById('prompt').innerText = yosys_prompt();
document.getElementById('command').focus();
console.log('yosys.js loaded.');
}
function yosys_command(cmd) {
Module.ccall('run', '', ['string'], [cmd])
}
function yosys_prompt() {
return Module.ccall('prompt', 'string', [], [])
}
function run_command() {
var cmd = document.getElementById('command').value;
document.getElementById('command').value = '';
Module.print(Module.prompt() + cmd);
Module.print(yosys_prompt() + cmd);
document.getElementById('wait').style.display = 'block';
document.getElementById('input').style.display = 'none';
function run_command_bh() {
try {
Module.command(cmd);
yosys_command(cmd);
} catch (e) {
Module.print('Caught JavaScript exception. (see JavaScript console for details.)');
console.log(e);
}
document.getElementById('wait').style.display = 'none';
document.getElementById('input').style.display = 'block';
document.getElementById('prompt').innerText = Module.prompt();
document.getElementById('prompt').innerText = yosys_prompt();
document.getElementById('command').focus();
}