diff --git a/_web_server/server/index.html b/_web_server/server/index.html index 2e23447..f343f9c 100644 --- a/_web_server/server/index.html +++ b/_web_server/server/index.html @@ -94,6 +94,7 @@
+ Sim: @@ -151,6 +152,10 @@ .then((text) => { window.location.href = text; }); }; + function show_help() { + alert("%HELPSTRING%"); + }; + document.addEventListener('keydown', (e) => { if (e.key.toLowerCase() === 's' && e.ctrlKey) { e.preventDefault(); diff --git a/_web_server/server/playground-server.scm b/_web_server/server/playground-server.scm index 23ecefb..d46c868 100755 --- a/_web_server/server/playground-server.scm +++ b/_web_server/server/playground-server.scm @@ -191,7 +191,7 @@ #:content-type-params content-type-params)) ;;; -;;; Execute system command and capture stdout and stderr to string list +;;; Execute system command and capture stdout and stderr to string ;;; (define* (system-to-string cmd #:key (pwd #f)) (let* ((cmd (string-append cmd " 2>&1")) @@ -201,14 +201,14 @@ (values (close-pipe p) out))) ;;; -;;; Unused +;;; Execute system command and capture stdout and stderr to string list ;;; -;; (define* (system-to-string-list cmd #:key (pwd #f)) -;; (let-values (((status out) -;; (system-to-string cmd #:pwd pwd))) -;; (values -;; status -;; (list-trim (string-split out #\newline) string-null?)))) +(define* (system-to-string-list cmd #:key (pwd #f)) + (let-values (((status out) + (system-to-string cmd #:pwd pwd))) + (values + status + (list-trim (string-split out #\newline) string-null?)))) ;;; ;;; Make pretty log from executable output @@ -328,6 +328,18 @@ (exe-log-pretty cmdline status out))) (values status (string-append compile-log execution-log))))))))))) +;;; +;;; Get iverilog version +;;; +(define (iverilog-version iverilog-exe) + (let-values (((status out) + (system-to-string-list + (format "~a -V" iverilog-exe)))) + (if (and (zero? status) + (not (null? out))) + (car out) + "Unknown"))) + ;;; ;;; Execute simulation ;;; @@ -426,9 +438,28 @@ (iverilog-post-uri (encode-and-join-uri-path iverilog-path)) (savecode-post-uri (encode-and-join-uri-path savecode-path)) (saveas-post-uri (encode-and-join-uri-path saveas-path)) - (index-html (read-template-text index-file `(("IVERILOGPOSTURI" ,iverilog-post-uri) - ("SAVECODEURI" ,savecode-post-uri) - ("SAVEASURI" ,saveas-post-uri))))) + (index-html + (read-template-text + index-file + `(("IVERILOGPOSTURI" ,iverilog-post-uri) + ("SAVECODEURI" ,savecode-post-uri) + ("SAVEASURI" ,saveas-post-uri) + ("HELPSTRING", + (string-concatenate + (insert-between + `("Verilog Playground by Punzik (c) 2022" + "" + ,(format "Icarus: ~a" + (iverilog-version iverilog-exe)) + ,(format "Verilator: ~a" "TODO") + "" + "Rules:" + "0. Don't fool around ;)" + "1. (TODO) The top module must be named 'testbench'." + "2. (TODO) The top module for the Verilator must have an input clock signal." + "3. Code size should not exceed 10000 characters." + "4. Code execution time no longer than 5 seconds.") + "\\n"))))))) (lambda (request request-body) (let (;; Requested resource path