0
$\begingroup$

If a NAND gate can be used to construct all other of the basic logic gates, then I'm wondering why you don't/can't have a purely NAND-based One Instruction Set Computer (OISC). All the OISC single instructions are complicated like "addleq, add and branch if less than or equal to zero", but I don't see why you can't just have an OISC be "nand, perform nand operation". Wondering what I am missing.

asked Mar 3, 2019 at 23:20
$\endgroup$
4
  • $\begingroup$ Without branching, the best you can do is a very long sequence of nand operations. Doesn't sound very general to me. $\endgroup$ Commented Mar 4, 2019 at 0:46
  • $\begingroup$ @gnasher729 most likely the following works: Define $ip := \texttt{Mem[}0\texttt{]}$ and transpile each addleq instruction using $\big[\texttt{Mem[}1\texttt{]},\dots,\texttt{Mem[}N\texttt{]}\big]$ as scratch space into a (very) long nand-sequence. $N$ depends on word size, but fix and therefore you can use the remaining memory for programming. $\endgroup$ Commented Mar 4, 2019 at 0:58
  • $\begingroup$ (even if $N$ wasn't fix, you could use even/odd indexing or the like) $\endgroup$ Commented Mar 4, 2019 at 1:01
  • $\begingroup$ Actually, not sure if this works since nand is not able to propagate bits, more trickery is needed (defining nand to work on $\texttt{Mem[}a\texttt{]}_i$ and $\texttt{Mem[}b\texttt{]}_{i+1}$ could work?). $\endgroup$ Commented Mar 4, 2019 at 1:08

2 Answers 2

1
$\begingroup$

The NAND gate is "universal" in that a network of NAND gates can implement any combinational or sequential logic function.

So to construct a "program" out of NANDs all you need is a way of specifying the network that interconnects them.

So if every NAND gate in your "computer" has a address, and the list of instructions is of the form inputA,inputB you might have a start on a "computer" with one instruction that's a NAND. (I think you'll have to come up with a parallel semantics, no instruction pointer.)

answered Mar 4, 2019 at 2:44
$\endgroup$
3
$\begingroup$

With such an instruction set, all you could express are straight-line programs. Without branches, you can't have loops. Thus, the program would not be able to handle arbitrary-length inputs: it would be limited to dealing with fixed-size inputs (or inputs with a fixed known upper bound on the size of the input). So, that wouldn't be very satisfactory.

answered Mar 4, 2019 at 1:20
$\endgroup$
3
  • $\begingroup$ What prevents us to modify the instruction pointer in case it's stored at memory location 0ドル$? $\endgroup$ Commented Mar 4, 2019 at 1:28
  • $\begingroup$ Different (even more interesting, but more tricky to get right) idea: Initially $\texttt{Mem[}0\texttt{]}$ is non-zero, the program will loop indefinitely until said memory location is zero. Pretty sure this will work too. $\endgroup$ Commented Mar 4, 2019 at 1:31
  • $\begingroup$ @KVN, performing an arbitrary operation on the instruction pointer (such as an increment, or a compare-and-set branch) requires multiple NAND operations, i.e., multiple instructions. That's trouble. After you perform the first instruction (the first NAND operation on the instruction pointer), the IP gets updated, and you jump off somewhere strange (not the end result of the multi-NAND computation, but to a program location based on some intermediate result). It might be possible to deal with this somehow, but it's not entirely clear how, and the programming model sounds horrifying. $\endgroup$ Commented Mar 4, 2019 at 21:50

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.