164 lines
4.3 KiB
HTML
164 lines
4.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="UTF-8"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>Verilog Playground</title>
|
|
<style type="text/css" media="screen">
|
|
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono&display=swap');
|
|
|
|
* {
|
|
box-sizing: border-box;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
|
|
body {
|
|
padding: 3px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
#buttons {
|
|
color: white;
|
|
background-color: #2d3d40;
|
|
width: 100%;
|
|
height: 38px;
|
|
padding: 4px;
|
|
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;
|
|
height: 100%;
|
|
}
|
|
|
|
button span.text { padding: 4px; }
|
|
|
|
#text {
|
|
font-family: 'JetBrains Mono', monospace;
|
|
font-size: inherit;
|
|
}
|
|
|
|
#editor {
|
|
height: 75vh;
|
|
width: 100%;
|
|
}
|
|
|
|
#logdiv {
|
|
height: 100%;
|
|
width: 100%;
|
|
}
|
|
|
|
#logdiv {
|
|
position: relative;
|
|
overflow: scroll;
|
|
}
|
|
|
|
@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%;
|
|
}
|
|
|
|
#log {
|
|
position: absolute;
|
|
height: 100%;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div id="buttons">
|
|
<button onclick="save_code('%SAVECODEURI%')"><span class="text">Save (ctrl-s)</span></button>
|
|
<button onclick="save_code('%SAVEASURI%')"><span class="text">Save as new</span></button>
|
|
Sim:
|
|
<button onclick="send_to_icarus()"><span class="text">Icarus</span></button>
|
|
<!-- button><span class="text">Verilator</span></button -->
|
|
</div>
|
|
|
|
<div id="text">
|
|
<div id="editor">@CODE@</div>
|
|
<div id="logdiv">
|
|
<pre id="log"></pre>
|
|
</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() {
|
|
log_area.innerHTML = "Please wait...";
|
|
fetch('%IVERILOGPOSTURI%',
|
|
{
|
|
method: 'POST',
|
|
headers: {
|
|
'Accept': 'text/plain',
|
|
'Content-Type': 'text/plain'
|
|
},
|
|
body: editor.getValue()
|
|
})
|
|
.then((response) => response.text())
|
|
.then((text) => { log_area.innerHTML = text; });
|
|
};
|
|
|
|
function save_code(uri) {
|
|
fetch(uri,
|
|
{
|
|
method: 'POST',
|
|
headers: {
|
|
'Accept': 'text/plain',
|
|
'Content-Type': 'text/plain'
|
|
},
|
|
body: editor.getValue()
|
|
})
|
|
.then((response) => response.text())
|
|
.then((text) => { window.location.href = text; });
|
|
};
|
|
|
|
document.addEventListener('keydown', (e) => {
|
|
if (e.key.toLowerCase() === 's' && e.ctrlKey) {
|
|
e.preventDefault();
|
|
save_code();
|
|
}
|
|
});
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|