r/ComputerEngineering • • 19d ago

[Software] A 16-bit computer made from ~900k NAND gates that runs its own OS with a file system, text editor and assembler

This is a computer built entirely from NAND gates in Gate Singular, a logic simulator game. In the video it assembles a Hello World on the machine itself, and then runs it.

Specs:

- 16-bit CPU with 24-bit instructions (8-bit opcode + 16-bit data)

- 30 instructions (206 if you count the variants of where operands come from and where the result goes)

- 1 KB of RAM and 24 KB of ROM in a shared address space, 2 registers, a 16-level stack, an 8-entry keyboard event queue, and a 64x64 screen with write-only VRAM

- Every instruction, including multiplication and division, runs in one clock

- Everything is made from 909191 NANDs. On top of that there are only buttons/toggles/LEDs and clock sources for temporal completeness. Nothing else is used.

The OS lives in the 24 KB ROM. It has a file system (in RAM), a text editor, memory management, an assembler to build new programs, and an OS API that those programs can use: text printing, memory allocation, file system access, keyboard input, etc.

By the way, I made the simulator game too (link in the comments).

I made it because I wanted one without the "1-tick delay per gate", and with full support for feedback between gates (e.g. so you can build proper D-latches from NANDs).

I'm happy to answer any questions about the CPU or the simulator.

92 Upvotes

8 comments sorted by

6

u/mosesenjoyer 18d ago • Bravo

Wait it’s all NAND gates?
πŸŒŽπŸ§‘β€πŸš€πŸ”«πŸ‘¨β€πŸš€

2

u/Ehizia 18d ago

Yes, it's all NAND gates, there is no other logic gates in the game. But once I made other parts (latches, multiplexers etc) from NANDs, I could copy these chunks. Most of NANDs (~760k) are coming from for ROM and RAM.

4

u/Dxrk_Playa_98 18d ago

Always has been.

1

u/Ehizia 19d ago

Steam page, if you're interested: https://store.steampowered.com/app/5402950/?utm_source=p1

The game also has tutorial challenges that go from a single NAND gate to a working 4-bit processor, and co-op if you'd rather wire a CPU with friends.

1

u/Cobalt_027 19d ago

great work, one question tho whats the difference between this game and logism?

1

u/Ehizia 19d ago

Thank you! Gate Singular has a number of features:
* Co-op
* In general, Logisim operates with higher level of abstractions (multiplexers, registers, adders etc). In Gate Singular the only gate you have is NAND, but it can simulate a lot of them.
* Very high performance (dont know if logisim can handle millions of individual object placed on the scheme, I dont have data on that).
* In Gate Singular its very easy to place and scale logic. The above 16-bit pc took for me about ~20 hours only.
* All logic correctly settles every tick (every clock level), including any feedback loops (even complex ones). Latches and flip-flops built from NANDs work with no glitches/oscillations.
* In addition to sandbox, there are tutorial challenges, from a single NAND up to a 4-bit processor.

1

u/Cobalt_027 19d ago

quite impressive really, might get this someday

1

u/TheAceRedBarron 18d ago

That one fcker on minecraft started this shit and now it's a base level engineering game........ I FUCKING LOVE IT !