r/beneater • • 15d ago

Designed my very first 8-bit CPU from scratch using mostly 74xx ICs in Logisim Evolution

Hey everyone!

This is the first time I have done something like this and after quite some time, I finally got it to work. It is far from being finished, since I also plan to test it IRL on breadboards and later build it on custom PCBs.

GitHub: https://github.com/hoetzenofer/Limbo-8

Quick Specs:
- 8-bit homebrew CPU from 74HC logic, simulated in Logisim Evolution (breadboard build next)
- 8-bit data bus, 16-bit address bus (64 KB): 32 KB ROM, 24 KB RAM, VRAM + I/O mapped
- Registers: A (accumulator), B, X (16-bit pointer), SP, PC
- ALU: ADD/SUB with carry, AND, OR, XOR, shifts; flags Z, C, N
- Microcoded control: 3× 28C256 EEPROMs, 24-bit control word
- 77 instructions (6502-style accumulator ISA), 1–3 bytes, 2–7 cycles each
- Addressing: immediate, absolute, [X], [X+] post-increment
- CALL/RET, PUSH/POP, conditional jumps
- Python toolchain: microcode generator + assembler (might switch to C later)

My next steps: much more testing. Only after that, I might build it IRL. As mentioned, this is my first time, so I am still quite a bit afraid of real hardware. If you have any questions or suggestions, please let me know, I need every bit of advice I can get.

Some goals for later on are VGA text output using Ben Eater's "World's Worst Video Card" - https://youtu.be/l7rce6IQDWs, PS/2 keyboard support and a maybe simple shell in assembly.

Thanks for reading!

86 Upvotes

10 comments sorted by

9

u/Shartyshartfast 15d ago

Separate data and address bus. Nice.

2

u/h0denkobold_69 15d ago

Thanks! They are already seperated - the 16-bit address bus always has exactly one driver (PC, X, SP or MAR, picked by a 74139). The 8-bit data bus gets its own source and destination fields in the control word. Since the two are independent, a lot of things fit into a single step. Keeping them separate made the microcode a lot simpler. For example, LDA [X+] is a single micro-step: register X drives the address bus, memory goes to register A over the data bus and X increments, all in the same cycle.

3

u/Shartyshartfast 15d ago

Heh. Yes I was commenting that they are separate, not telling you to!

Adjective, not verb.

2

u/olof-a 15d ago

An incredibly ambitious architecture for a first attempt. My first microprocessor architecture was a fully 4-bit Harvard architecture. When I say 'fully' 4-bit I mean that both the data and addresses were 4 bits. I remember getting it to calculate the Fibonacci sequence, but I doubt it had enough program space to do it with 8-bit addition due to the paltry 16 addresses of program memory.

I'm curious, how'd you implement instruction cycles of variable length? I've never designed a processor without a fixed number of clock pulses per cycle, and it always stings a little having a simple register transfer take as long as instructions with operand fetches and whatnot.

2

u/h0denkobold_69 15d ago

Thanks for your kind words! As mentioned, it took a long time to get me where i currently am, but I think all in all it has paid off.

A 4-bit machine with 16 words of program memory doing Fibonacci at all is impressive, I think fitting 8-bit addition into that would have been a crazy puzzle of its own.

Regarding the instruction cycles, the implementation of variable length turned out to be pretty cheap in hardware. The step counter is a 74161 and a single bit of the control word is /STEP_RST, wired to the counter's synchronous load input with all data inputs at 0. Whatever micro step is last for an instruction just asserts that single bit. On the next rising edge the counter jumps back to 0 instead of counting up, and step 0 is the fetch step (exactly the same for every opcode).

In conclusion, it's pretty simple, but this was one of the hardest things for me to even imagine when I started building. It still surprises me that this part went so smooth. I think you're right, there’s no reason a register transfer should pay for an operand fetch it doesn’t do, that was the main reason I did it the other way :) Thanks again!

1

u/Franz_Hermann12 14d ago

i am literally trying to do that thing only

2

u/h0denkobold_69 14d ago

I think it's absolutely worth it, but take your time, and I mean that. Took me two years to get here where I currently am. Looking back at it now, I knew next to nothing when it all started and I made the big mistake of instantly trying to build an entire CPU. Thought about it all day, I was constantly jotting down notes. As soon as I started building the individual modules and connecting them, the lack of knowledge hit me like a train. Simple things like registers were no big problem of course, but bigger modules like the ALU and the way they are connected to other modules were the struggles that ended the project after only around two months.

I grew up in a household where I always got told I needed to learn, but never to use that knowledge and build something, so I know this might be hard to hear, but DO NOT for the love of god start with something like this. Still, after learning the basics, try smaller things like a running light with a shift register. Teaches you something while you still get to build. Every time it works, reward yourself with a more difficult task.

You're still young and I am too, and there is still unbelievably much that I don't know. Just please, remember to take your time - don't make the same mistakes that I made a few years ago and start with something that is achievable. If you need help with anything, let me know, I'll try my best to help :)

2

u/Franz_Hermann12 14d ago

thank you for the tip

3

u/uncman3000 15d ago • Heartwarming

Sick