close-circle
Close
0%
0%

Custom 8-bit CPU and Computer (on an Arduino)

A custom 8-bit CPU implemented in Logisim, then on PC as a VM, then on hardware using an Arduino as a host.

Similar projects worth following
close
My objective is to build a very simple 8-bit computer, with a custom CPU instruction set. It will be designed in Logisim, tools and a VM written for Windows/Linux. Finally, hardware implementation will be done on the cheap by using an Arduino.

Over the last few years, I've been getting back into programming (probably since the 90's) creating 'virtual' CPUs on a PC, then writing little test programs etc.  I've also been adapting those to be 'hosted' on an Arduino, as the devices are cheap and I have quite a few of them, maybe one day I will move onto FPGAs.  

When I was a kid in the 80's, of all the popular home computers I had, my favourite was a 'Science Fair Microcomputer Trainer' kit from our local Tandy store. Little more than a TMS-1000 microprocessor and some LEDs and a hex keypad, I learned so much from it and later in life, long after I'd broken it in other 'projects' I wanted something like that again.

Recently, I became aware I had a limited understanding of what was going on at a lower level in a CPU, how the instruction set was related to the underlying hardware, how the control lines, registers and ALU worked.  I became aware of some free software called Logisim and decided to renew my project by designing my CPU and computer from a 'simulated' lower level.

  • The computer and CPU will be designed in Logisim.
  • Tools and a VM will be created for PC (Linux/Windows).
  • The CPU will 'hosted' on an Arduino and put in a case as a standalone working computer.

  • It's alive!

    Martian6 days ago 0 comments

    Addendum to last project note.

    CPU working, the multiplexer which shunts data to RAM to be written or the screen was taking it's input from the wrong place.

    The microcode ROM is now complete, the instruction set is as follows:

    Sample program:

    $0000	LDW R0, $0010	80 00 10
    $0003	LDW R1, $0011	84 00 11
    $0006	ADD R0, R1	01
    $0007	STW R0, $0012	90 00 12
    $000A	JMP $000A	FF 00 0A
    $0010	#02
    $0011	#08
    $0012	#00

    Loads 02 from $0010 into R0, loads 08 into R1, adds them (R0=R0+R1), stores the result (0A) into $0012.

    The program 'ends' by looping at $000A. 

  • Things fall apart, the centre cannot hold

    Martian7 days ago 0 comments

    All of my testing, debugging etc has been done in Logisim with all the parts of the CPU on a single layout, so I can see all the parts working at once:

    I am fairly convinced I've done the microcoded ROM, the system above is running a program which is printing out some poetry by WB Yeats.   Lots of cool binary and hex LEDs blinking away too for added goodness.

    I started copying and pasting all the parts into separate layouts, weaving the control lines etc together. Came up with this:

    Something has broken in the process, no doubt I've connected something wrong. Do I get Yeats on the display?

    "A gaze blank and pitiless as the sun"

  • Project Update: September 1st

    Martian09/02/2017 at 01:04 0 comments

    First I have to say how much I've learned and been inspired by this site:

    http://minnie.tuhs.org/CompArch/Tutes/week03.html

    I have a 'working'* CPU in Logisim!  It is an 8-bit CPU with a 16bit address bus, with a maximum RAM of 64K.  There are 4 general purpose registers and a 4-function ALU.

    The ALU and 'register file' was quite straightforward to do, based on the tutorial noted above, but from there it became a nightmare.  I could not find any examples of an 8-bit CPU WITH 64k of RAM, they all seemed to max out at 256 bytes which is too small for a 'useful' machine.  I also had great difficulty understanding how an instruction on the IR register is actually turned into something useful.  I read various articles and chapters of books on hardwired and microcoded CPUs until my brain started to turn to mush.

    The Control Unit, which takes the data in the IR and actually switches the control lines on and off to actually make the computer work, is a messy kludge.  It is -currently- microcoded and is not completely finished, but enough is implemented for a few test programs to run.

    • FINISH IMPLEMENTING MICROCODE
    • TEST PROGRAMS!
    • OPTIMISE, REFINE!!

  • August 2017 Update

    Martian08/16/2017 at 15:14 0 comments

      PROJECT REBOOTED - PREVIOUS LOGS ETC. DELETED.

      I recently discovered Logisim. So, after a long hiatus due to other commitments, I decided to 'reboot' the project.  

      I wanted to take a new approach by designing the machine from a lower level using Logisim. This is basically so I can learn more, filling in some gaps in my knowledge and get a better feel for building a CPU from the ground up.  

      So the project will be in three stages:

      1. Develop computer from logic circuits in Logisim, to a working model.
      2. Create an assembler and a VM in Python for Windows and Linux.
      3. Implement in hardware using an Arduino as a 'host' for my CPU.

View all 4 project logs

Enjoy this project?

Share

Discussions

Hacker404 wrote 5 days ago point

Who could resist a computer that had Bacon Lettuce and Tomato (BLT) :)

I haven't used Logisim but just looking at it, I would like to mention that most FPGA/CPLD IDE environments have schematic entry which is very much like what I see of Logisim. Schematic entry isn't very practical for large FPGAs but it's a good start to get used to the IDE. If you are going to try this then I recommend starting with Altera Quartus as it's easy to install and it's easy to find cheap CPLD breakouts with programmers cheep on ebay. Just use ebay to search for Altera CPLD and look for kits with a programmer.

  Are you sure? yes | no

Martian wrote 4 days ago point

Hi, thanks for the info.   I've not really much first-hand experience with FPGA, I worked for an optical networking firm that designed chips (on Xilinx?) about 15 years ago with Sun workstations, but I was busy running their UNIX network and never got to explore it properly.  I've only seen a few development boards in the past and they were a bit out of my price range (which is next to zero).  Arduino's have become a bit of a pooman's alternative for me to create stuff and flash it over.  I appreciate the info, I'll look into that Altera CPLD kit and read up on what's involved.

  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