From e0e6d130cd083a8285ea2991629e0049023da234 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Thu, 19 Feb 2015 13:36:54 +0100 Subject: YosysJS stuff --- misc/yosysjs/demo03.html | 103 +++++++++++++++++++++++++++++++++++++++++++++++ misc/yosysjs/yosysjs.js | 19 ++++++++- 2 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 misc/yosysjs/demo03.html (limited to 'misc/yosysjs') diff --git a/misc/yosysjs/demo03.html b/misc/yosysjs/demo03.html new file mode 100644 index 000000000..720b82e90 --- /dev/null +++ b/misc/yosysjs/demo03.html @@ -0,0 +1,103 @@ + +YosysJS Example Application #02 + + + + + + + +

YosysJS Example Application #03

+ Your mission: Create a behavioral Verilog model for the following circuit: +

+ +

+

module top(input clk, reset, input [7:0] A, output reg [7:0] Y);
+  always @(posedge clock) begin
+    Y <= A | {4{reset}};
+  end
+endmodule

+ +

+

 

+ + diff --git a/misc/yosysjs/yosysjs.js b/misc/yosysjs/yosysjs.js index 87c951183..a1181493e 100644 --- a/misc/yosysjs/yosysjs.js +++ b/misc/yosysjs/yosysjs.js @@ -45,6 +45,7 @@ var YosysJS = new function() { ys.verbose = false; ys.logprint = false; ys.echo = false; + ys.errmsg = ""; if (typeof(reference_element) == 'string' && reference_element != "") reference_element = document.getElementById(reference_element); @@ -151,12 +152,20 @@ var YosysJS = new function() { ys.write(""); ys.write(ys.prompt() + cmd); } - mod.ccall('run', '', ['string'], [cmd]); + try { + mod.ccall('run', '', ['string'], [cmd]); + } catch (e) { + ys.errmsg = mod.ccall('errmsg', 'string', [], []);; + } return ys.print_buffer; } ys.read_file = function(filename) { - return ys.window.FS.readFile(filename, {encoding: 'utf8'}); + try { + return ys.window.FS.readFile(filename, {encoding: 'utf8'}); + } catch (e) { + return ""; + } } ys.write_file = function(filename, text) { @@ -167,6 +176,12 @@ var YosysJS = new function() { return ys.window.FS.readdir(dirname); } + ys.remove_file = function(filename) { + try { + ys.window.FS.unlink(filename); + } catch (e) { } + } + doc.open() doc.write('