2022-11-30 13:10:58 +03:00

92 lines
2.5 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Verilog Playground</title>
<style type="text/css" media="screen">
@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;
background: white;
font-family: 'JetBrains Mono', monospace;
font-size: 14px;
}
.panel {
float: left;
position: relative;
height: 100%;
padding: 4px;
border: 1px solid #008899;
box-sizing: border-box;
}
.ctrl-panel { width: 10%; }
.editor { width: 45%; }
.log-panel { width: 45%; }
#log {
width: 100%;
height: 100%;
border: 0px;
font-size: inherit;
}
</style>
</head>
<body>
<div class="container">
<div class="panel ctrl-panel">
<button onclick="send_to_icarus()">Run Icarus Verilog</button>
</div>
<div class="panel editor" id="editor">`timescale 10ps/10ps
module test;
initial begin
$display("Hello world!");
$finish();
end
endmodule
</div>
<div class="panel log-panel">
<textarea id="log" readonly="readonly">LOG</textarea>
</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/ext-language_tools.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
var editor = ace.edit('editor');
editor.setTheme('ace/theme/chrome');
editor.session.setMode('ace/mode/verilog');
editor.setOptions({
tabSize : 2,
fontSize : 14,
fontFamily : 'JetBrains Mono, monospace',
enableBasicAutocompletion : true,
enableLiveAutocompletion : true
});
const log_area = document.getElementById('log');
function send_to_icarus() {
fetch('%POSTURI%',
{
method: 'POST',
headers: {
'Accept': 'text/plain',
'Content-Type': 'text/plain'
},
body: editor.getValue()
})
.then((response) => response.text())
.then((text) => { log_area.value = text; });
};
</script>
</body>
</html>