Compare commits
39 Commits
5a23aa8e0f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3aee2d2f38 | ||
|
|
b84ec9a1c5 | ||
|
|
1e0bfb58cf | ||
|
|
e67558de14 | ||
|
|
54f7e2be54 | ||
|
|
cc605cce85 | ||
|
|
2f9f5b6dd1 | ||
|
|
cb8bc37dfe | ||
|
|
1e12d5d3e2 | ||
|
|
1bc6ec544d | ||
|
|
d04282e1c7 | ||
|
|
664b7b1f5c | ||
|
|
37b7a54d3b | ||
|
|
01c982fada | ||
|
|
931f4d8aa4 | ||
|
|
90905544d4 | ||
|
|
ab5db7f6e8 | ||
|
|
e8ba09ecab | ||
|
|
daa744f8b2 | ||
|
|
c91003e34b | ||
|
|
53412381fb | ||
|
|
536bde92df | ||
|
|
b9cd29ad87 | ||
|
|
c6c6744b22 | ||
|
|
42f22147ea | ||
|
|
b4507004b8 | ||
|
|
74e76d8131 | ||
|
|
058191de55 | ||
|
|
f61bb7b980 | ||
|
|
9939a226c8 | ||
|
|
185dcb350d | ||
|
|
28d86fb98d | ||
|
|
680e9f3aa5 | ||
|
|
ec02787747 | ||
|
|
b87a7e0c97 | ||
|
|
6a9959f98d | ||
|
|
61a16ad2cd | ||
|
|
9f4fbe2499 | ||
|
|
347dfa0af6 |
@@ -10,4 +10,11 @@ module testbench;
|
|||||||
initial begin
|
initial begin
|
||||||
$finish;
|
$finish;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
`ifdef DUMP
|
||||||
|
initial begin
|
||||||
|
$dumpfile("testbench.fst");
|
||||||
|
$dumpvars(0, testbench);
|
||||||
|
end
|
||||||
|
`endif
|
||||||
endmodule
|
endmodule
|
||||||
|
|||||||
52
_web_server/Dockerfile
Normal file
52
_web_server/Dockerfile
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
FROM ubuntu:22.10
|
||||||
|
LABEL description="Verilog playground"
|
||||||
|
|
||||||
|
# Prepare OS
|
||||||
|
RUN sed -i 's/^# *deb-src/deb-src/g' /etc/apt/sources.list
|
||||||
|
RUN apt-get -y update \
|
||||||
|
&& apt-get -y install guile-3.0 locales git
|
||||||
|
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen \
|
||||||
|
&& locale-gen
|
||||||
|
RUN apt-get build-dep -y iverilog verilator
|
||||||
|
|
||||||
|
# Build latest Icarus Veriolog
|
||||||
|
WORKDIR /build
|
||||||
|
RUN git clone --depth 1 https://github.com/steveicarus/iverilog.git
|
||||||
|
WORKDIR /build/iverilog
|
||||||
|
RUN sh ./autoconf.sh && ./configure --prefix=/usr && make -j2 && make install
|
||||||
|
|
||||||
|
# Build latest Verilator
|
||||||
|
WORKDIR /build
|
||||||
|
RUN git clone --depth 1 https://github.com/verilator/verilator.git
|
||||||
|
WORKDIR /build/verilator
|
||||||
|
RUN autoconf && ./configure --prefix=/usr && make -j2 && make install
|
||||||
|
|
||||||
|
# Environment
|
||||||
|
ENV GIT_SSL_NO_VERIFY=1
|
||||||
|
ENV GUILE_LOAD_PATH=/server/embddr-scheme-library
|
||||||
|
ENV LANG=en_US.UTF-8
|
||||||
|
ENV DONOTUSEFIREJAIL=1
|
||||||
|
|
||||||
|
# Copy server files
|
||||||
|
WORKDIR /server
|
||||||
|
COPY server/* ./
|
||||||
|
RUN git clone https://git.embddr.com/np/embddr-scheme-library.git
|
||||||
|
RUN mkdir play-work /verilog-playground-store
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
VOLUME /verilog-playground-store
|
||||||
|
|
||||||
|
CMD [ "guile", "-e", "main", \
|
||||||
|
"./playground-server.scm", \
|
||||||
|
"--port=8080", \
|
||||||
|
"--addr=0.0.0.0", \
|
||||||
|
"--host=https://play.embddr.com", \
|
||||||
|
"--iverilog-wrap=./restrict", \
|
||||||
|
"--vvp-wrap=./restrict", \
|
||||||
|
"--verilator-sim-wrap=./restrict", \
|
||||||
|
"--verilator-build-jobs=2", \
|
||||||
|
"--max-len=10000", \
|
||||||
|
"--work-base=play-work", \
|
||||||
|
"--stor-base=/verilog-playground-store", \
|
||||||
|
"--log-level=2" ]
|
||||||
3
_web_server/container-create.sh
Executable file
3
_web_server/container-create.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
docker build -t playground .
|
||||||
45
_web_server/container-run.sh
Executable file
45
_web_server/container-run.sh
Executable file
@@ -0,0 +1,45 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [ 0 -eq "$#" ]; then
|
||||||
|
echo "Usage $0 start/stop/status"
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
action=$1
|
||||||
|
container=playground
|
||||||
|
|
||||||
|
case $action in
|
||||||
|
"start")
|
||||||
|
cid=$(docker container ls -q -a -f name=$container)
|
||||||
|
|
||||||
|
if [ -z "$cid" ]; then
|
||||||
|
docker run -d --name $container \
|
||||||
|
-p 127.0.0.1:8089:8080 \
|
||||||
|
-v /srv/playground/storage:/verilog-playground-store \
|
||||||
|
--cpus=1 --memory=16g --memory-swap=16g \
|
||||||
|
$container
|
||||||
|
else
|
||||||
|
docker start $container
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
"stop")
|
||||||
|
# Press twice CRTL-C
|
||||||
|
docker kill -s SIGINT $container
|
||||||
|
docker kill -s SIGINT $container
|
||||||
|
;;
|
||||||
|
|
||||||
|
"status")
|
||||||
|
cid=$(docker container ls -q -f name=$container)
|
||||||
|
|
||||||
|
if [ -z "$cid" ]; then
|
||||||
|
echo "Stopped"
|
||||||
|
else
|
||||||
|
echo "Started"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
"*")
|
||||||
|
echo "Unknown action $action. Actions start, stop and status are allowed"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
BIN
_web_server/server/favicon.png
Normal file
BIN
_web_server/server/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
@@ -1,9 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
exe=$(basename $0)
|
|
||||||
|
|
||||||
exec firejail --noprofile --quiet \
|
|
||||||
--rlimit-cpu=1 \
|
|
||||||
--rlimit-as=100m \
|
|
||||||
--rlimit-fsize=1m \
|
|
||||||
"$exe" "$@"
|
|
||||||
@@ -1,57 +1,149 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<meta charset="UTF-8"/>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||||
<title>Verilog Playground</title>
|
<title>Verilog Playground</title>
|
||||||
<style type="text/css" media="screen">
|
<style type="text/css" media="screen">
|
||||||
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono&display=swap');
|
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono&display=swap');
|
||||||
|
|
||||||
.container {
|
* {
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
margin: 5px;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
background: white;
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
font-variant-ligatures: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
padding: 3px;
|
||||||
font-family: 'JetBrains Mono', monospace;
|
font-family: 'JetBrains Mono', monospace;
|
||||||
font-size: 14px;
|
font-size: 10pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
.panel {
|
pre {
|
||||||
float: left;
|
font-family: 'JetBrains Mono', monospace;
|
||||||
position: relative;
|
font-size: 10pt;
|
||||||
height: 100%;
|
|
||||||
padding: 4px;
|
|
||||||
border: 1px solid #008899;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.ctrl-panel { width: 10%; }
|
#buttons {
|
||||||
.editor { width: 45%; }
|
color: white;
|
||||||
.log-panel { width: 45%; }
|
background-color: #2d3d40;
|
||||||
|
|
||||||
#log {
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
padding: 3px;
|
||||||
border: 0px;
|
|
||||||
font-size: inherit;
|
font-size: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#logdiv, #editor, #buttons {
|
||||||
|
border-width: 1px;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: #505050;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
color: black;
|
||||||
|
background-color: #dbdbdb;
|
||||||
|
margin-left: 1px;
|
||||||
|
margin-right: 1px;
|
||||||
|
margin-top: 2px;
|
||||||
|
margin-bottom: 2px;
|
||||||
|
height: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
button span.text { padding: 4px; }
|
||||||
|
|
||||||
|
#editor {
|
||||||
|
height: 75vh;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#logdiv {
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#logdiv {
|
||||||
|
position: relative;
|
||||||
|
overflow: scroll;
|
||||||
|
}
|
||||||
|
|
||||||
|
svg {
|
||||||
|
fill: none;
|
||||||
|
stroke: white;
|
||||||
|
stroke-width: 0;
|
||||||
|
shape-rendering: crispEdges;
|
||||||
|
}
|
||||||
|
|
||||||
|
svg text {
|
||||||
|
font-family: 'JetBrains Mono', monospace;
|
||||||
|
font-size: 10pt;
|
||||||
|
fill: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
svg #wave-signals {
|
||||||
|
stroke: #00fcff;
|
||||||
|
stroke-width: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
svg #wave-clock {
|
||||||
|
stroke: #fffe9a;
|
||||||
|
font-size: 8pt;
|
||||||
|
stroke-width: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
svg #wave-signals text { font-size: 8pt; }
|
||||||
|
svg #wave-clock text { font-size: 8pt; }
|
||||||
|
|
||||||
|
svg #wave-delim {
|
||||||
|
stroke: #d0d0d0;
|
||||||
|
stroke-width: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
svg #wave-background { fill: #1e2426; }
|
||||||
|
|
||||||
|
@media (orientation: landscape) and (not (pointer: coarse)) {
|
||||||
|
body {
|
||||||
|
display: flex;
|
||||||
|
flex-flow: column;
|
||||||
|
height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
#text { flex-grow: 1; }
|
||||||
|
|
||||||
|
#editor {
|
||||||
|
float: left;
|
||||||
|
width: 50%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#logdiv {
|
||||||
|
float: left;
|
||||||
|
width: 50%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#logdiv pre {
|
||||||
|
position: absolute;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div id="buttons">
|
||||||
<div class="panel ctrl-panel">
|
<button onclick="show_help()"><span class="text">?</span></button>
|
||||||
<button style="width:100%" onclick="save_code()">Save (ctrl+s)</button>
|
<button onclick="save_code('%SAVECODEURI%')"><span class="text">Save</span></button>
|
||||||
<button style="width:100%" onclick="send_to_icarus()">Run Icarus Verilog</button>
|
Sim:
|
||||||
</div>
|
<button onclick="send_to_sim('%IVERILOGPOSTURI%')"><span class="text">Icarus</span></button>
|
||||||
<div class="panel editor" id="editor">@CODE@</div>
|
<button onclick="send_to_sim('%VERILATORPOSTURI%')"><span class="text">Verilator</span></button>
|
||||||
<div class="panel log-panel">
|
|
||||||
<textarea id="log" readonly="readonly"></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="text">
|
||||||
|
<div id="editor">@CODE@</div>
|
||||||
|
<div id="logdiv"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.13.1/ace.js" type="text/javascript" charset="utf-8"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.13.1/ace.js" type="text/javascript" charset="utf-8"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.13.1/ext-language_tools.js" type="text/javascript" charset="utf-8"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.13.1/ext-language_tools.js" type="text/javascript" charset="utf-8"></script>
|
||||||
<script type="text/javascript" charset="utf-8">
|
<script type="text/javascript" charset="utf-8">
|
||||||
@@ -65,10 +157,11 @@
|
|||||||
enableBasicAutocompletion : true,
|
enableBasicAutocompletion : true,
|
||||||
enableLiveAutocompletion : true
|
enableLiveAutocompletion : true
|
||||||
});
|
});
|
||||||
const log_area = document.getElementById('log');
|
const log_area = document.getElementById('logdiv');
|
||||||
function send_to_icarus() {
|
function send_to_sim(uri) {
|
||||||
log_area.value = "Please wait...";
|
query = uri + "?width=" + log_area.clientWidth;
|
||||||
fetch('%IVERILOGPOSTURI%',
|
log_area.innerHTML = "Please wait...";
|
||||||
|
fetch(query,
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@@ -78,11 +171,11 @@
|
|||||||
body: editor.getValue()
|
body: editor.getValue()
|
||||||
})
|
})
|
||||||
.then((response) => response.text())
|
.then((response) => response.text())
|
||||||
.then((text) => { log_area.value = text; });
|
.then((text) => { log_area.innerHTML = text; });
|
||||||
};
|
};
|
||||||
|
|
||||||
function save_code() {
|
function save_code(uri) {
|
||||||
fetch('%SAVECODEURI%',
|
fetch(uri,
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@@ -95,12 +188,9 @@
|
|||||||
.then((text) => { window.location.href = text; });
|
.then((text) => { window.location.href = text; });
|
||||||
};
|
};
|
||||||
|
|
||||||
document.addEventListener('keydown', (e) => {
|
function show_help() {
|
||||||
if (e.key.toLowerCase() === 's' && e.ctrlKey) {
|
alert("%HELPSTRING%");
|
||||||
e.preventDefault();
|
};
|
||||||
save_code();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
./firejailed.sh
|
|
||||||
File diff suppressed because it is too large
Load Diff
12
_web_server/server/restrict
Executable file
12
_web_server/server/restrict
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [ -z "$DONOTUSEFIREJAIL" ]; then
|
||||||
|
exec firejail \
|
||||||
|
--quiet --noprofile \
|
||||||
|
--rlimit-cpu=5 \
|
||||||
|
--rlimit-as=250m \
|
||||||
|
--rlimit-fsize=250k \
|
||||||
|
"$@"
|
||||||
|
else
|
||||||
|
exec timeout -v -s KILL 5 "$@"
|
||||||
|
fi
|
||||||
11
_web_server/server/top_iverilog.sv
Normal file
11
_web_server/server/top_iverilog.sv
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
`timescale 1ps/1ps
|
||||||
|
|
||||||
|
module __@TOPMODULE@__;
|
||||||
|
@TOPMODULE@ @TOPMODULE@ ();
|
||||||
|
|
||||||
|
initial begin
|
||||||
|
$dumpfile("@WORKDIR@/@TOPMODULE@.vcd");
|
||||||
|
$dumpvars(1, @TOPMODULE@);
|
||||||
|
$dumplimit(100000);
|
||||||
|
end
|
||||||
|
endmodule
|
||||||
43
_web_server/server/top_verilator.cpp
Normal file
43
_web_server/server/top_verilator.cpp
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#include "verilated.h"
|
||||||
|
#include "verilated_vcd_c.h"
|
||||||
|
#include "V@TOPMODULE@.h"
|
||||||
|
|
||||||
|
#define DUMPFILE "@WORKDIR@/@TOPMODULE@.vcd"
|
||||||
|
|
||||||
|
int main(int argc, char** argv, char**) {
|
||||||
|
// Setup context, defaults, and parse command line
|
||||||
|
Verilated::debug(0);
|
||||||
|
const std::unique_ptr<VerilatedContext> contextp{new VerilatedContext};
|
||||||
|
contextp->traceEverOn(true);
|
||||||
|
contextp->commandArgs(argc, argv);
|
||||||
|
|
||||||
|
// Construct the Verilated model, from Vtop.h generated from Verilating
|
||||||
|
const std::unique_ptr<V@TOPMODULE@> topp{new V@TOPMODULE@{contextp.get()}};
|
||||||
|
|
||||||
|
VerilatedVcdC *vcd = new VerilatedVcdC;
|
||||||
|
topp->trace(vcd, 99);
|
||||||
|
vcd->open(DUMPFILE);
|
||||||
|
|
||||||
|
// Simulate until $finish
|
||||||
|
while (!contextp->gotFinish()) {
|
||||||
|
// Evaluate model
|
||||||
|
topp->eval();
|
||||||
|
vcd->dump(contextp->time());
|
||||||
|
// Advance time
|
||||||
|
if (!topp->eventsPending()) break;
|
||||||
|
contextp->time(topp->nextTimeSlot());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!contextp->gotFinish()) {
|
||||||
|
VL_DEBUG_IF(VL_PRINTF("+ Exiting without $finish; no events left\n"););
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute 'final' processes
|
||||||
|
topp->final();
|
||||||
|
|
||||||
|
// Print statistical summary report
|
||||||
|
contextp->statsPrintSummary();
|
||||||
|
vcd->close();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
./firejailed.sh
|
|
||||||
Reference in New Issue
Block a user