Skip to content

Instantly share code, notes, and snippets.

@devyn
Created October 29, 2014 06:52
Show Gist options
  • Select an option

  • Save devyn/d9ff282df07a27b50325 to your computer and use it in GitHub Desktop.

Select an option

Save devyn/d9ff282df07a27b50325 to your computer and use it in GitHub Desktop.
Textual redstone
nor(out, A, B) {
out !- A + B;
}
nand(out, A, B) {
notA !- A;
notB !- B;
out <- notA + notB;
}
and(out, A, B) {
nand(notOut, A, B);
out !- notOut;
}
// Translation of design F from Wikia.
xor(out, A, B) {
notA !- A;
notB !- B;
both !- notA + notB;
onlyA !- notA + both;
onlyB !- notB + both;
out <- onlyA + onlyB;
}
// Translation (and slight simplification) of design A from Wikia.
xnor(out, A, B) {
notA !- A;
notB !- B;
neither !- A + B;
both !- notA + notB;
out <- neither + both;
}
implies(out, A, B) {
notA !- A;
out <- notA + B;
}
srnor(q, ~q, Set, Reset) {
nor( q, ~q, Reset);
nor(~q, q, Reset);
}
// Transparent when clock is low.
dlatch(q, ~q, Clock, Data) {
set !- Clock + reset;
reset !- Clock + Data;
srnor(q, ~q, set, reset);
}
dflop(q, ~q, Clock, Data) {
dlatch(q1, _, Clock, Data);
notClock !- Clock;
dlatch(q, ~q, notClock, q1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment