mirror of https://github.com/YosysHQ/yosys.git
103 lines
3.8 KiB
HTML
103 lines
3.8 KiB
HTML
|
<html><head>
|
||
|
<title>YosysJS Example Application #02</title>
|
||
|
<script type="text/javascript" src="yosysjs.js"></script>
|
||
|
</head><body>
|
||
|
<div id="popup" style="position: fixed; left: 0; top: 0; width:100%; height:100%; text-align:center; z-index: 1000;"><div
|
||
|
style="width:300px; margin: 200px auto; background-color: #88f; border:3px dashed #000;
|
||
|
padding:15px; text-align:center;"><span id="popupmsg">Loading...</span></div>
|
||
|
</div>
|
||
|
<h1>YosysJS Example Application #02</h1>
|
||
|
<iframe id="ys" style="width: 800px; height: 100px;"></iframe><p/>
|
||
|
<textarea id="code" style="width: 800px; height: 300px;">
|
||
|
// borrowed with some modifications from
|
||
|
// http://www.ee.ed.ac.uk/~gerard/Teach/Verilog/manual/Example/lrgeEx2/cooley.html
|
||
|
module up3down5(clock, data_in, up, down, carry_out, borrow_out, count_out, parity_out);
|
||
|
|
||
|
input [8:0] data_in;
|
||
|
input clock, up, down;
|
||
|
|
||
|
output reg [8:0] count_out;
|
||
|
output reg carry_out, borrow_out, parity_out;
|
||
|
|
||
|
reg [9:0] cnt_up, cnt_dn;
|
||
|
reg [8:0] count_nxt;
|
||
|
|
||
|
always @(posedge clock)
|
||
|
begin
|
||
|
cnt_dn = count_out - 3'b 101;
|
||
|
cnt_up = count_out + 2'b 11;
|
||
|
|
||
|
case ({up,down})
|
||
|
2'b 00 : count_nxt = data_in;
|
||
|
2'b 01 : count_nxt = cnt_dn;
|
||
|
2'b 10 : count_nxt = cnt_up;
|
||
|
2'b 11 : count_nxt = count_out;
|
||
|
default : count_nxt = 9'bX;
|
||
|
endcase
|
||
|
|
||
|
parity_out <= ^count_nxt;
|
||
|
carry_out <= up & cnt_up[9];
|
||
|
borrow_out <= down & cnt_dn[9];
|
||
|
count_out <= count_nxt;
|
||
|
end
|
||
|
|
||
|
endmodule
|
||
|
</textarea><p/>
|
||
|
<input type="button" value="Before Behavioral Synth" onclick="synth1()">
|
||
|
<input type="button" value="After Behavioral Synth" onclick="synth2()">
|
||
|
<input type="button" value="After RTL Synth" onclick="synth3()">
|
||
|
<input type="button" value="After Gate-Level Synth" onclick="synth4()"><p/>
|
||
|
<svg id="svg" width="800"></svg>
|
||
|
</td></tr></table>
|
||
|
<script type="text/javascript">
|
||
|
YosysJS.load_viz();
|
||
|
function on_ys_ready() {
|
||
|
document.getElementById('popup').style.visibility = 'hidden';
|
||
|
document.getElementById('popupmsg').textContent = 'Please wait..';
|
||
|
}
|
||
|
function synth1() {
|
||
|
function work() {
|
||
|
ys.write_file("input.v", document.getElementById('code').value);
|
||
|
ys.run('design -reset; read_verilog input.v; show -stretch');
|
||
|
YosysJS.dot_into_svg(ys.read_file('show.dot'), document.getElementById('svg'));
|
||
|
document.getElementById('popup').style.visibility = 'hidden';
|
||
|
}
|
||
|
document.getElementById('popup').style.visibility = 'visible';
|
||
|
window.setTimeout(work, 100);
|
||
|
}
|
||
|
function synth2() {
|
||
|
function work() {
|
||
|
ys.write_file("input.v", document.getElementById('code').value);
|
||
|
ys.run('design -reset; read_verilog input.v; proc; opt_clean; show -stretch');
|
||
|
YosysJS.dot_into_svg(ys.read_file('show.dot'), document.getElementById('svg'));
|
||
|
document.getElementById('popup').style.visibility = 'hidden';
|
||
|
}
|
||
|
document.getElementById('popup').style.visibility = 'visible';
|
||
|
window.setTimeout(work, 100);
|
||
|
}
|
||
|
function synth3() {
|
||
|
function work() {
|
||
|
ys.write_file("input.v", document.getElementById('code').value);
|
||
|
ys.run('design -reset; read_verilog input.v; synth -run coarse; show -stretch');
|
||
|
YosysJS.dot_into_svg(ys.read_file('show.dot'), document.getElementById('svg'));
|
||
|
document.getElementById('popup').style.visibility = 'hidden';
|
||
|
}
|
||
|
document.getElementById('popup').style.visibility = 'visible';
|
||
|
window.setTimeout(work, 100);
|
||
|
}
|
||
|
function synth4() {
|
||
|
function work() {
|
||
|
ys.write_file("input.v", document.getElementById('code').value);
|
||
|
ys.run('design -reset; read_verilog input.v; synth -run coarse; synth -run fine; show -stretch');
|
||
|
YosysJS.dot_into_svg(ys.read_file('show.dot'), document.getElementById('svg'));
|
||
|
document.getElementById('popup').style.visibility = 'hidden';
|
||
|
}
|
||
|
document.getElementById('popup').style.visibility = 'visible';
|
||
|
window.setTimeout(work, 100);
|
||
|
}
|
||
|
var ys = YosysJS.create('ys', on_ys_ready);
|
||
|
ys.verbose = true;
|
||
|
ys.echo = true;
|
||
|
</script>
|
||
|
</body></html>
|