-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
98 lines (85 loc) · 3.18 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/brython@3.9.6/brython.min.js">
</script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/brython@3.9.6/brython_stdlib.js">
</script>
<script src="logidiff.py" type="text/python3"></script>
<style>
html {
font-size: 20px;
height: 100%;
}
.thing {
max-width: 600px;
margin: auto;
}
.text {
width: 99%;
font-size: 20px;
font-family: monospace;
text-align: center;
}
</style>
<title>logidiff</title>
</head>
<body onload="brython()">
<script type="text/python">
from browser import bind, document
from logidiff import *
def keyevent(ev):
if ev.key == "Enter":
equivalent()
def equivalent():
try:
if document["input"].value != "":
not_eqs = evaluate(document["input"].value)
else:
raise Exception("must provide an equation to evaluate")
except Exception as e:
document["output"].html = f"Error: {str(e)}"
return
if not_eqs:
document["output"].html = "Statements are not equivalent for: <br>"
for ne in not_eqs:
document["output"].html += ", ".join(ne) + "<br>"
else:
document["output"].html = "Statements are equivalent"
document["input"].bind("keydown", keyevent)
</script>
<div class="thing">
<h1 style="text-align: center;">logidiff</h1>
<p>Input a logical equation and press enter to determine if both sides
are equivalent. Uses VHDL operators and syntax (case insensitive).
Also supports aliases for common operators, such as
'*' for 'and', '+' for 'or', '!' for 'not', and '^' for 'xor'.
These aliases do not need spaces around them.
Multiple statements can be equated on the same line
to check their total equivalency.</p>
<p>The source code for this website is available <a href="https://github.com/nobodywasishere/logidiff/">here</a>.</p>
<hr><br>
<input id="input" class="text" placeholder="(a or b) and c = a*c+b*c">
<p id="output"></p>
<br><hr><br>
<div>
<h3>Examples</h3>
<pre>(a or b) and c = a*c+b*c</pre>
<pre>(a xor b) and c = (a and c) xor (b and c)</pre>
<pre>a xor b = a^b = !(a xnor b) = !a^!b</pre>
<pre>a or b = !a nand !b = not (!a and !b)</pre>
</div>
</div>
<script>
var r = new XMLHttpRequest();
r.addEventListener('load', function() {
document.querySelector('#stats').innerText = JSON.parse(this.responseText).count_unique
})
r.open('GET', 'https://nobodywasishere.goatcounter.com/counter/' + '/{{ page.url | remove: "/" }}' + '.json')
r.send()
</script>
<script data-goatcounter="https://nobodywasishere.goatcounter.com/count"
async src="//gc.zgo.at/count.js"></script>
</body>
</html>