|
1 | | -<h1>Welcome to Logicode!</h1> |
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en-us"> |
| 3 | + <head> |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <title>Logicode by testitem</title> |
| 6 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 7 | + <link rel="stylesheet" type="text/css" href="stylesheets/normalize.css" media="screen"> |
| 8 | + <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'> |
| 9 | + <link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" media="screen"> |
| 10 | + <link rel="stylesheet" type="text/css" href="stylesheets/github-light.css" media="screen"> |
| 11 | + </head> |
| 12 | + <body> |
| 13 | + <section class="page-header"> |
| 14 | + <h1 class="project-name">Logicode</h1> |
| 15 | + <h2 class="project-tagline">An esoteric language based on logic gates.</h2> |
| 16 | + <a href="https://github.com/testitem/Logicode" class="btn">View on GitHub</a> |
| 17 | + <a href="https://github.com/testitem/Logicode/zipball/master" class="btn">Download .zip</a> |
| 18 | + <a href="https://github.com/testitem/Logicode/tarball/master" class="btn">Download .tar.gz</a> |
| 19 | + </section> |
| 20 | + |
| 21 | + <section class="main-content"> |
| 22 | + <h1> |
| 23 | +<a id="logicode" class="anchor" href="#logicode" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Logicode</h1> |
| 24 | + |
| 25 | +<p>Welcome to Logicode!</p> |
| 26 | + |
| 27 | +<p>Logicode is a minimalistic language that is mainly based on Logisim.</p> |
| 28 | + |
| 29 | +<p>Because of that, the only built-in commands are AND, OR and NOT, and you make the rest.</p> |
| 30 | + |
| 31 | +<p>The three logic gates are represented like so:</p> |
| 32 | + |
| 33 | +<ul> |
| 34 | +<li> |
| 35 | +<code>a&b</code>: AND of <code>a</code> and <code>b</code>.</li> |
| 36 | +<li> |
| 37 | +<code>a|b</code>: OR of <code>a</code> and <code>b</code>.</li> |
| 38 | +<li> |
| 39 | +<code>!a</code>: NOT of <code>a</code>.</li> |
| 40 | +</ul> |
| 41 | + |
| 42 | +<p>There are more built-ins:</p> |
| 43 | + |
| 44 | +<ul> |
| 45 | +<li> |
| 46 | +<code>?</code>: Random bit, either <code>0</code> or <code>1</code>.</li> |
| 47 | +<li> |
| 48 | +<code>#</code>: Begins a line for comments.</li> |
| 49 | +</ul> |
| 50 | + |
| 51 | +<p>You can make extra things from these commands, like circuits and variables.</p> |
| 52 | + |
| 53 | +<h2> |
| 54 | +<a id="make-your-own-things" class="anchor" href="#make-your-own-things" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Make-your-own Things</h2> |
| 55 | + |
| 56 | +<h3> |
| 57 | +<a id="circuits" class="anchor" href="#circuits" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Circuits</h3> |
| 58 | + |
| 59 | +<p>To create a circuit, you have to do this:</p> |
| 60 | + |
| 61 | +<p><code>circ circuit_name(arg1, arg2...)->{what the function does}</code></p> |
| 62 | + |
| 63 | +<p><code>circ</code> is the circuit "declaration", and everything after the <code>-></code> is interpreted as code. </p> |
| 64 | + |
| 65 | +<p>Normal circuits have 1 bit as output, but if more bits are required, use the <code>+</code> symbol to separate bits.</p> |
| 66 | + |
| 67 | +<p>Like this:</p> |
| 68 | + |
| 69 | +<p><code>circ circuit_name(arg1, arg2...)->{1st bit}+{2nd bit}+...</code></p> |
| 70 | + |
| 71 | +<h3> |
| 72 | +<a id="variables" class="anchor" href="#variables" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Variables</h3> |
| 73 | + |
| 74 | +<p>To create a variable:</p> |
| 75 | + |
| 76 | +<p><code>var var_name=value</code></p> |
| 77 | + |
| 78 | +<p><code>var</code> is the variable declaration.</p> |
| 79 | + |
| 80 | +<h3> |
| 81 | +<a id="conditions" class="anchor" href="#conditions" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Conditions</h3> |
| 82 | + |
| 83 | +<p>To create a condition:</p> |
| 84 | + |
| 85 | +<p><code>cond arg->{executed if arg = 1}/{executed if arg = 0}</code></p> |
| 86 | + |
| 87 | +<p><code>cond</code> is the variable declaration, <code>arg</code> is either a value of <code>0</code> or <code>1</code>, and the <code>/</code> is the separator of the two executing strings.</p> |
| 88 | + |
| 89 | +<h2> |
| 90 | +<a id="io" class="anchor" href="#io" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>I/O</h2> |
| 91 | + |
| 92 | +<h3> |
| 93 | +<a id="output" class="anchor" href="#output" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Output</h3> |
| 94 | + |
| 95 | +<p>There is also output as well:</p> |
| 96 | + |
| 97 | +<p><code>out out_value</code></p> |
| 98 | + |
| 99 | +<p><code>out</code> is the output declaration, and you can include the built-in commands, as well as self-made circuits, into the output to be processed.</p> |
| 100 | + |
| 101 | +<h2> |
| 102 | +<a id="example-code" class="anchor" href="#example-code" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Example code:</h2> |
| 103 | + |
| 104 | +<pre><code>circ xor(a,b)->(!(a&b))&(a|b) |
| 105 | +var test=xor(1,1) |
| 106 | +out !(test) |
| 107 | + |
| 108 | +Output: 1 |
| 109 | +</code></pre> |
| 110 | + |
| 111 | +<p>The circuit <code>xor</code> calculates the XOR of two bits, and <code>test</code> is declared as the XOR of 1 and 1 (which is 0). </p> |
| 112 | + |
| 113 | +<p>Then, the <code>out</code> outputs the NOT of <code>test</code>, which is <code>1</code>.</p> |
| 114 | + |
| 115 | +<p>Expanding on the previous example:</p> |
| 116 | + |
| 117 | +<pre><code>circ xor(a,b)->(!(a&b))&(a|b) |
| 118 | +circ ha(a,b)->(a&b)+(xor(a,b)) |
| 119 | +out ha(1,?) |
| 120 | + |
| 121 | +Output: 10 |
| 122 | +</code></pre> |
| 123 | + |
| 124 | +<p>The circuit <code>xor</code> is the same as before, and the circuit <code>ha</code> is a half-adder of two bits (so it takes two arguments), and outputs two bits.</p> |
| 125 | + |
| 126 | +<p>The <code>out</code> outputs the half-adding of <code>1</code> and <code>?</code>, which is either <code>01</code> or <code>10</code> (depending on what the <code>?</code> gives).</p> |
| 127 | + |
| 128 | + <footer class="site-footer"> |
| 129 | + <span class="site-footer-owner"><a href="https://github.com/testitem/Logicode">Logicode</a> is maintained by <a href="https://github.com/testitem">testitem</a>.</span> |
| 130 | + |
| 131 | + <span class="site-footer-credits">This page was generated by <a href="https://pages.github.com">GitHub Pages</a> using the <a href="https://github.com/jasonlong/cayman-theme">Cayman theme</a> by <a href="https://twitter.com/jasonlong">Jason Long</a>.</span> |
| 132 | + </footer> |
| 133 | + |
| 134 | + </section> |
| 135 | + |
| 136 | + |
| 137 | + </body> |
| 138 | +</html> |
0 commit comments