Close
0%
0%

Pineapple ONE

32 bit RISC-V homemade CPU out of discrete components

Public Chat
Similar projects worth following
In this article I will describe how I designed and made a functional 32 bit RISC-V CPU at home.

Specifications:
"Max" clock speed: 500 kHz
Program memory: 512 kB
RAM size: 512 kB
VGA Output: 200x150 px (black and white)
2x 8-bit Input ports
2x 8-bit output ports


This is basically a "modern" CPU made out of hardware, that was available in the early days of semiconductors (This means that there is no FPGA or any microcontroller on board, apart from this, I could use whatever integrated circuits I could find)




Almost every electronics device uses some kind of a microcontroller nowadays. The thing is, that these chips can be very complicated, and even though you can buy them very inexpensively (like Arduino for example), I've still wanted to take a deeper look into them and understand their inner workings. I soon realised, that I have only a few options to do that: 

  1. Study an existing microcontroller from a datasheet
  2. Make some kind of a emulator (C / Python)
  3. Build my own CPU from scratch 

You can already guess which path I took.

1. Designing my own CPU:

I discovered Ben Eater's homemade CPU on Youtube and I was so mesmerised and almost immediately got to work. I've improved his design and built myself an 8 bit CPU too. This article is not about that one though. If you want to, you can check out my photos in this Twitter post. I may write another article about that someday. 

At this point, I had a pretty good understanding of a really basic CPU, but for some reason, this wasn't enough for me. Shortly after that, I've stumbled across Robert Baruch's Youtube channel and he started working on a 32 bit RISC-V CPU, which also used just a basic logic components. I have done some research about RISC-V and found out, that it is completely open-source and well documented.

Me being me, I started making my own RISC-V CPU implementation in a program called Logisim-Evolution. Again I set my goal not use ANY microcontrollers or FPGAs in my build - just basic discrete logic components. So, what exactly am I going to build? I needed to NOT set too a high goal for myself, so I would be able to finish this project in *relatively* short time (Is 2yrs short enough? :-) ). The most basic RISC-V CPU, that is supported by compilers, must include the extension "I" (Integer) and it must be at least 32 bit. So now I had all the information I'm going to need, so it was time to start building. Oh, and did I mentioned that I was going to put a VGA output card on as well? (VGA card inspired by Ben Eater; https://eater.net/vga)

After 6 months of fiddling with Logisim, I had a working "simulation". The next step would be to create schematics for all of the modules, design all PCBs and order them from JLCPCB. But, as this would be my first time ordering PCBs, I didn't want to screw up everything - so I separated the design into modules, and chose few at a time, so as to not overwhelm myself. JLCPCB had a discount for a 2 layer PCB with dimensions < 100mm x 100mm, and I've tried my best to fit into these dimensions to keep the lower cost (and I've managed to fit it in!).

So, now I have a working simulation and my plan is to take few modules at a time, turn them into proper schematics, make a boards and order them. This isn't the best way to do things, but otherwise it would be too much for me. (foreshadowing) 

Photo of my Logisim-Evolution simulation

After 2 batches, all that remained were a few modules and one of them is called immediate generator. When I was looking into ways I could turn it from my simulation into proper schematic, I realised that I made a fatal mistake and that I had absolutely no idea how the simulation could have worked. Luckily, the repairs weren't that hard and I was able to easily retrofit one of already made PCBs to completely repair it. 

2. Prototype

I knew that this project would be large and I would almost certainly make some mistakes (we are talking about 230+ ICs), so I've decided to start with a prototype, where I have access to all signals and can easily debug the whole thing - I'm not (yet) an electrical engineer and I'm only 19, so this seemed to be a good idea (and it really was). 

After I received my PCBs, I've tested each and every one of them by connecting an Arduino to its inputs and simultaneously monitoring its outputs and comparing it to a prediction. Once I've set it up, it was all automatic and to test as much possibilities each...

Read more »

Adobe Portable Document Format - 104.73 kB - 04/28/2021 at 20:38

Preview
Download

Adobe Portable Document Format - 65.77 kB - 04/28/2021 at 20:38

Preview
Download

Adobe Portable Document Format - 115.92 kB - 04/28/2021 at 20:38

Preview
Download

Adobe Portable Document Format - 87.08 kB - 04/28/2021 at 20:38

Preview
Download

Adobe Portable Document Format - 96.80 kB - 04/28/2021 at 20:38

Preview
Download

View all 9 files

  • 2 × 4067 Integrated Circuit
  • 6 × 4161D
  • 4 × 71321L Memory ICs / Static RAM (SRAM)
  • 9 × 74HCT04 Electronic Components / Misc. Electronic Components
  • 88 × 74HCT245 Electronic Components / Misc. Electronic Components

View all 37 components

  • Schematics

    filip.szkandera04/23/2021 at 15:20 4 comments

    Here are all the schematics for my CPU - just please keep in mind that Im not (yet) an engineer and there are many things that could be done better, for example the shifter. I would love to turn this into an open-source project and maybe design a do-it-yourself "kit", so everybody could make their own 32-bit RISC-V CPU at home.

    For this to happen, some things would need to be redesigned, so the CPU could be "useful" and run much more complex programs, or be even faster.

    This is where I need your help. These improvements are too much for one person to do alone and I'm doing these things in my free time only (because of school), so if you think you could help in any way, please, write a comment, contact me on my twitter (https://twitter.com/ten_filip), or drop me an email (filip.szkandera@gmail.com). 

    Thank you.

    I could't get PDFs here, so JPGs must do for now, sorry!


    Those aren't all of my PCBs as I cannot upload more images into one project log it seems. For complete schematics I've added PDF files that you can download.

View project log

Enjoy this project?

Share

Discussions

dhruv wadhwa wrote 04/29/2021 at 09:09 point

Wowww thats sooo impressive!!!!😱😱🔥🔥

Amazing work 👍

  Are you sure? yes | no

john wrote 04/28/2021 at 21:36 point

Wow I like good job!

  Are you sure? yes | no

Steve wrote 04/28/2021 at 16:26 point

This is an amazing accomplishment!  From a fellow ben heck fan who would never have been so bold as to attempt this, I'm amazed, and as for it "only" running at 500k, remember the old TRS80-coco only ran at 890khz and it had a "real" CPU and budget behind it.  I think 500k is amazing!   I'd love to see you release this as a kit.. it might be fun to assemble!!

  Are you sure? yes | no

Cristian Bourceanu wrote 04/28/2021 at 16:25 point

Wow! Very impressive! This looks like a complex design even for a nearly graduated engineer.

What is the bottleneck for the frequency? Is it the gates specifications? 

  Are you sure? yes | no

filip.szkandera wrote 04/28/2021 at 20:35 point

Thank you! 

I'm not really sure, there could be several issues; the tower-like structure introduced a lot of parasitic inductance and capacitance, or there may be a timing issue. I've also fixed some glitches by a 10p cap, but there may be some others that are still waiting for me to find. The gates should be capable of operating at much higher frequencies, so this should't be an issue.

  Are you sure? yes | no

Cristian Bourceanu wrote 04/28/2021 at 20:52 point

You might be able to do some transient analysis with Eagle and optimise some paths, if you haven't done so already. In FPGA designs, timing is usually the issue that limits frequency, but I imagine that would being such a pain to debug for your design compared to only defining constraints in the case of FPGAs. However as Steve said, 500k is actually really good. 

Keep up the good work, I hope to see more amazing projects from you!

  Are you sure? yes | no

Henrik Sorensen wrote 04/26/2021 at 14:13 point

Looking GOOD!!!! Impressive work

You've got a new follower :-)

  Are you sure? yes | no

Ray wrote 04/25/2021 at 18:36 point

Interesting name choice. Maybe it should be "Pineapple TWO." Some history in Apple Computer, Inc. v. Formula Intern., Inc., 562 F. Supp. 775 (C.D. Cal. 1983), where Apple did not like having a clone named "Pineapple." One of the attorneys on that case went on to become my favorite law school professor.

As for the hardware here -- Wow, getting 230 ICs working together is impressive.

  Are you sure? yes | no

filip.szkandera wrote 04/25/2021 at 18:51 point

Thank you! 

The name was chosen even before I've ordered my first batch of PCBs (about 5 months into development), I didn't even knew if its going to work or not at that time.

  Are you sure? yes | no

Alexey Vazhnov wrote 04/14/2021 at 07:54 point

Whoa! Great!

@filip.szkandera, could you please add information about license of this project — is it allowed to copy, change and use the schematic and pictures in any purpose?

It would be great to see any popular open source license.

  Are you sure? yes | no

filip.szkandera wrote 04/14/2021 at 08:54 point

I would love to make it an open-source project, but I'm not quite sure about Autodesk Eagle's licensing and if I'm "legally" allowed to do that under student license.

  Are you sure? yes | no

Gravis wrote 04/15/2021 at 15:19 point

There aren't any programs (Eagle or otherwise) that restrict you from freely distributing your work.  There are only restrictions from selling your work.  You can make this open source without worry.

  Are you sure? yes | no

69K-ram wrote 04/14/2021 at 03:07 point

This is an incredibly impressive project! Nice work. Especially as you're 19. I'm 16, I doubt I'll be doing stuff like that when I'm 19.

  Are you sure? yes | no

Yann Guidon / YGDES wrote 04/28/2021 at 17:47 point

you have 3 years to learn and try :-)

  Are you sure? yes | no

Gravis wrote 04/13/2021 at 21:08 point

You should consider putting FreeRTOS on Pineapple One because it supports RV32I.  Doing so could really show off what an impressive feat this was and turn it into a useful computer that will "never" fail.

  Are you sure? yes | no

filip.szkandera wrote 04/14/2021 at 04:38 point

This would be super cool, but there are some reliability issues, that I need to solve first

  Are you sure? yes | no

Gravis wrote 04/15/2021 at 15:13 point

Please post an update on what you need to fix because inquiring minds and all.  Is it timing issues?  Those are the worst.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates