document.getElementById('popup').style.visibility = 'hidden';
document.getElementById('popupmsg').textContent = 'Please wait..';
}
+ function handle_run_errors(logmsg, errmsg) {
+ if (errmsg != "") {
+ window.alert(errmsg);
+ document.getElementById('popup').style.visibility = 'hidden';
+ }
+ }
function synth1() {
document.getElementById('popup').style.visibility = 'visible';
ys.write_file("input.v", document.getElementById('code').value);
- ys.run('design -reset; read_verilog input.v; show -stretch');
+ ys.run('design -reset; read_verilog input.v; show -stretch', handle_run_errors);
ys.read_file('show.dot', (function(text){
- YosysJS.dot_into_svg(text, 'svg');
+ console.log(ys.errmsg);
+ if (ys.errmsg == "") YosysJS.dot_into_svg(text, 'svg');
document.getElementById('popup').style.visibility = 'hidden';
}));
}
function synth2() {
document.getElementById('popup').style.visibility = 'visible';
ys.write_file("input.v", document.getElementById('code').value);
- ys.run('design -reset; read_verilog input.v; proc; opt_clean; show -stretch');
+ ys.run('design -reset; read_verilog input.v; proc; opt_clean; show -stretch', handle_run_errors);
ys.read_file('show.dot', (function(text){
- YosysJS.dot_into_svg(text, 'svg');
+ if (ys.errmsg == "") YosysJS.dot_into_svg(text, 'svg');
document.getElementById('popup').style.visibility = 'hidden';
}));
}
function synth3() {
document.getElementById('popup').style.visibility = 'visible';
ys.write_file("input.v", document.getElementById('code').value);
- ys.run('design -reset; read_verilog input.v; synth -run coarse; show -stretch');
+ ys.run('design -reset; read_verilog input.v; synth -run coarse; show -stretch', handle_run_errors);
ys.read_file('show.dot', (function(text){
- YosysJS.dot_into_svg(text, 'svg');
+ if (ys.errmsg == "") YosysJS.dot_into_svg(text, 'svg');
document.getElementById('popup').style.visibility = 'hidden';
}));
}
function synth4() {
document.getElementById('popup').style.visibility = 'visible';
ys.write_file("input.v", document.getElementById('code').value);
- ys.run('design -reset; read_verilog input.v; synth -run coarse; synth -run fine; show -stretch');
+ ys.run('design -reset; read_verilog input.v; synth -run coarse; synth -run fine; show -stretch', handle_run_errors);
ys.read_file('show.dot', (function(text){
- YosysJS.dot_into_svg(text, 'svg');
+ if (ys.errmsg == "") YosysJS.dot_into_svg(text, 'svg');
document.getElementById('popup').style.visibility = 'hidden';
}));
}
var ys = YosysJS.create_worker(on_ys_ready);
+ ys.verbose(true);
</script>
</body></html>
ys.worker = new Worker('yosyswrk.js');
ys.callback_idx = 1;
ys.callback_cache = {};
+ ys.errmsg = "";
ys.callback_cache[0] = on_ready;
on_ready = null;
var response = e.data[0];
var callback = ys.callback_cache[response.idx];
delete ys.callback_cache[response.idx];
+ if ("errmsg" in response) ys.errmsg = response.errmsg;
if (callback) callback.apply(null, response.args);
}
ys.worker.postMessage([request]);
}
+ ys.verbose = function(value, callback) {
+ var request = {
+ "idx": ys.callback_idx,
+ "mode": "verbose",
+ "value": value
+ };
+
+ ys.callback_cache[ys.callback_idx++] = callback;
+ ys.worker.postMessage([request]);
+ }
+
return ys;
}
}
+var Module = {};
+var verbose_mode = false;
+var text_buffer = "";
+
+Module["printErr"] = Module["print"] = function(text) {
+ if (verbose_mode)
+ console.log(text);
+ text_buffer += text + "\n";
+}
+
importScripts('yosys.js');
onmessage = function(e) {
var response = { "idx": request.idx, "args": [] };
if (request.mode == "run") {
+ response["errmsg"] = "";
try {
+ text_buffer = "";
Module.ccall('run', '', ['string'], [request.cmd]);
- response.args.push("");
} catch (e) {
- response.args.push(mod.ccall('errmsg', 'string', [], []));
+ response.errmsg = Module.ccall('errmsg', 'string', [], []);
}
+ response.args.push(text_buffer);
+ response.args.push(response.errmsg);
+ text_buffer = "";
}
if (request.mode == "read_file") {
} catch (e) { }
}
+ if (request.mode == "verbose") {
+ if (request.value)
+ console.log(text_buffer);
+ verbose_mode = request.value;
+ }
+
postMessage([response]);
}