Skip to the content
PCBKitNew board
2 layers68 × 98 mmKim uno rev1, the printed circuit board in 3D

A portable, software defined dev kit for (retro) microprocessors.

Size
68 × 98 mm
Copper layers
2
Thickness
1.6 mm
Parts
36
Nets
48
Pads
161
Tracks, vias
407, 32
Pours
2
Routed
Yes
KiCad
KiCad 5 (file 20171130)
Created
22 Jan 2019
Updated
26 May 2019

Overview

Kim uno rev1 is an open-source printed circuit board by maxstrauch, from the maxstrauch/kim-uno repository on GitHub. It is a 2-layer board of 68 × 98 mm with 36 parts on 48 nets, routed with 407 tracks and 32 vias.

It is built around the ATMEGA328P-PU. Its parts include 21 switches, 8 resistors, 1 capacitor, 1 IC and 1 connector. It belongs with the retro computing and games boards and the AVR (ATmega, ATtiny) boards of this library.

Main components

1

README

README.md

KIM Uno

A portable, software defined dev kit for (retro) microprocessors

KIM Uno

Back in late 2018 it came to my mind, that I wanted to build a small portable microprocessor dev kit, just like the famous KIM-1 from MOS Technology, Inc. and designed by Chuck Peddle who was also involved in creating the 6502 CPU.

Therefore, I designed the KIM Uno as a portable device, which fits in one hand and is powered by two CR2032 batteries. It uses the ATMega328p ("Arduino") microcontroller running at 8 MHz to emulate (or simulate) a desired CPU. This architecture also makes sure, that the emulated CPUs are interchangeable to anything which fits inside the microcontroller's flash memory. So it is a multi-purpose device.

Currently this project emulates an OISC with just one instruction subleq. The idea came to me when I watched The Ultimate Apollo Guidance Computer Talk and then discovered this GitHub repo.

There is another pretty interesting project, called the same (KIM Uno), which does a real replica of the 6502 KIM Uno. Check it out here. The creator even sells the kit. So if you are interested in 6502 and like this project, you should take a look there!

Links

You can find:

Contents of this repository

This repository contains all needed documents, to create your own KIM Uno. In the root of the repository you can find the following important documents:

  • bom_kim-uno-rev1.ods - A bill of materials and rough calculation of the material cost (it's about 4,75 € as of 2018) and links to the components on Ebay. The offers on Ebay might be closed (depends on when you read this here) but this might be a good starting point for sourcing the components.
  • kim-uno-rev1_2018-12-12_gerbers.zip - A zip file containing the latest Gerber and drill files for production. I send exactly those files out to PCBWay to produce the PCBs. The files are exported to the specifications of PCBWay (see https://www.pcbway.com/blog/help_center/Generate_Gerber_file_from_Kicad.html) but might work also for another manufacturer.
  • kim-uno-rev1-schematic.pdf - The schematic of the project. Show schematics.
  • arduino-isp.ino - An Arduino sketch of the ISP code I use on my Arduino UNO to program the microcontrollers

This are the essential three documents you'll need to reproduce my KIM Uno. Furthermore, the following directories can be found in the repository:

  • images - Just images of the project
  • kicad - The original KiCad files, so that you can make modifications as you like (see also the License section at the end)
  • src - The source code for the microcontroller firmware; you can either use src/main.hex and burn it onto your ATMega328p or you can modify src/main.c, recompile it (see src/Makefile) and then burn it with your own changes
  • tools - A little NodeJS based assembler and simulator of the KIM Uno

Flashing the firmware

In the directory src/ you can find the source code for the emulator along with an already compiled src/main.hex which you can directly upload to the microcontroller.

Before you can actually use it, you need to set the fuse bits of the microcontroller, so that it uses the internal 8 MHz clock without dividing it in half. You can get the job done with the following command:

text
avrdude -c stk500v1 -b 9600 -v -v -P /dev/cu.usbmodem1421 -p m328p -U lfuse:w:0xe2:m -U hfuse:w:0xd9:m -U efuse:w:0xff:m

After this you can flash the firmware onto the microcontroller with this command:

text
avrdude -c stk500v1 -b 9600 -v -v -P /dev/cu.usbmodem1421 -p m328p -U flash:w:main.hex

Maybe you need to change the argument for -P.

You can also use the src/Makefile to do this tasks. Run make all to compile (GNU AVR toolchain required to be installed) and make install to flash it. You can use make fuse to set the fuses correctly.

Theory of operation

Basics

The KIM Uno does emulate a One Instruction Set Computer (OISC) and provides the subleq instruction to perform computation.

The subleq instruction stands for subtract and branch if less than or equal to zero. In pseudo-code this looks like the following:

text
subleq A B C: mem[B] = mem [B] - mem[A]; 
              if (mem[B] <= 0) goto C;

Since the KIM Uno emulates a 8-bit machine, all arguments A, B and C are 8 bit values and therefore it can address a total main memory of 256 byte. Obviously this can be extended, by making A, B and C multi-byte values. But for now let's keep it simple.

The KIM Uno has also "peripherals": the display and keyboard. It uses a memory mapped architecture to interface those peripherals, although the memory map is very simple:

  • 0x00 = the Z register (zero) and should be kept zero.
  • 0x01 - 0x06 = six bytes which represent the value of every of the display segments (from right to left). A value <= 0xf (16) can be placed in one of this memory locations and it will appear on the seven segment display. There are some special characters to show which can be displayed setting a value > 0xf - see the source code (main.c) for more details.
  • 0x07, 0x08, 0x09 = three bytes where every byte represents two seven segment displays (from right to left). This memory locations allow simply displaying a result without splitting up the result into two nibbles to place it in the single digit memory locations 0x01 - 0x06.
  • 0x0a+ = A program starts at 0x0a. Currently the "Go" key executes from 0x0a fixed.

Pseudo instructions

There are three "pseudo instructions" which make life easier when programming for the KIM Uno. They are composed of multiple subleq instructions:

MOV a, b - copy data at location a to b can be composed of:

text
subleq b, b, 2 (next instruction)
subleq a, Z, 3 (next instruction)
subleq Z, b, 4 (next instruction)
subleq Z, Z, e.g. 5 (next instruction)

Using the subtraction feature of subleq, which does mem[b] - mem[a] and overwrites mem[b] with the result, the value is copied using the zero register. And subleq Z, Z, ... simply resets the zero register to 0, regardless of the value of Z.

ADD a, b - adds the values a + b and stores the sum in b can be composed of:

text
subleq a, Z, 2 (next instruction)
subleq Z, b, 3 (next instruction)
subleq Z, Z, e.g. 4 (next instruction)

This instruction simply calculates mem[b] - (- mem[a]) which is mem[b] + mem[a] by also using the subtraction feature.

HLT - halts the CPU and ends the execution:

By definition the emulator knows that the CPU wants to terminate if it jumps to 0xff (or -1 if singed). So a simple

text
subleq Z, Z, -1

does the job and indicates to the emulator, that it should end emulation.

Fibonacci example program

With this information one can now write a program in assembler, for example Fibonacci's algorithm:

text
.def n   0xfa 6             ; Input n for fibonacci
.def a   0xfc 0
.def b   0xfd 1
.def out 0x07 0             ; Output register for display

; Temp registeres, needed since the subleq instructions modify the original
; registers (the program might be optimized to use only one tmp register)
.def tmp1 0xfe 0
.def tmp2 0xff 0

; Constant values. Since subleq has no immediate instructions we store
; those values in a register
.def Z   0x00 0
.def one 0xfb 1
.def two 0xf9 2

    mov n, tmp1             ; Copy n to tmp1 to perform calculation on it
    subleq two, tmp1, done  ; If n <= 2, we're done and goto the end
    subleq one, n, loop     ; Start computation with n := n-1

loop:
    mov a, tmp1             ; Save a and ...
    mov b, tmp2             ; ... b to perform the addition on it
    add tmp1, tmp2          ; Save the sum of a and b on tmp2

This is basically the content of tools/fibonacci/fibonacci.s. This program can now be turned into subleq CPU instructions and entered into the memory of the KIM Uno and then executed. Since there is only one instruction, only the arguments (A, B and C) are entered. So after three memory locations the next instruction arguments begin and so forth.

But there is a faster way, shown in the next section.

Further tools

The tools/ directory contains some basic assembler and simulator for the KIM Uno. They are written in NodeJS - make sure that you have installed it.

Assembling programs

If you take a look at "tools/fibonacci/fibonacci.s" you'll find that it is the source code for the discussed fibonacci implementation. To assemble it and make a program out of it, that the KIM Uno can run, you enter the following command (in tools/):

text
node assemble.js fibonacci/fibonacci.s

and it will either print an error if you made a mistake or spill out the resulting program. To save it, you can copy the output and save it to a file or simply run this command:

text
node assemble.js fibonacci/fibonacci.s > yourfile.h

The output is formatted in a way that it can be directly included in the KIM Uno firmware as a C header file, but the simulator can also use it to simulate. Simply enter:

text
node sim.js yourfile.h

And you will be presented with the simulation result and the output expected from the KIM Uno on the display.

Conclusion

Design flaws in the PCB design

After completing this project I found a couple of points which are noteworthy and should be addressed in a new revision of the PCB board:

  • the ATMega328p's silk screen has not the usual notch where the first pin is located. The DIP-28 footprint does not even have a square pad where the first pin is located. This should definitely be improved with a more detailed silkscreen to prevent confusion
  • the ISP header has no connection labels on the silk screen. This makes it difficult to recognize how to connect it to the ISP
  • the ISP header could be changed into a 2x6 pin header with a standard pin layout to prevent any confusion

Apart from those points I'm pretty happy how it turned out and worked on the first try.

Further uses

But the journey does not end here - there are an infinite number of options how you could modify the KIM Uno and customize it to your needs and liking.

For example the KIM Uno could be equipped with a "real" retro CPU emulator which might emulate the famous MOS 6502 or Intel 8085, 8086 or 8088. Then it would go the way to my initial vision, before I learned about OISCs.

But there are possible other uses, since the hardware design is pretty generic. The KIM Uno could be used as:

  • a remote controller e.g. for CNCs or other devices. Maybe wired or equipped with an IR diode or any other wireless sender
  • a (hexadecimal) pocket calculator. The firmware can be adapted very easily and the board design does not need to be changed very much. Maybe the silkscreen can be adapted with math operations and the gap between the segments can be removed. Apart from this, it is already ready for this transformation

Have fun with it. Cheers!

License

Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0). Click here for details. The license applies to the entire source code.

This program is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Parts

36
QtyValueFootprintReferences
20SW_Push_Dualcustom:SMD_Tact_Switch_6x6x6_Big_PadsSW1, SW2, SW3, SW4, SW5, SW10, SW11, SW12, SW13, SW14, SW15, SW16, SW17, SW18, SW19, SW20 +4
71KResistors_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P7.62mm_HorizontalR1, R2, R3, R4, R5, R6, R7
2Battery_Cellcustom:CR2032SMDBT1, BT2
110KResistors_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P7.62mm_HorizontalR8
12_DIGIT_CAcustom:7_Segment_2_Digit7SEG2
14_DIGIT_CAcustom:7_Segment_4_Digit7SEG1
1ATMEGA328P-PUHousings_DIP:DIP-28_W7.62mmU1
1CONN_01X06Pin_Headers:Pin_Header_Straight_1x06_Pitch2.54mmJ1
1C_SmallCapacitors_THT:C_Disc_D5.0mm_W2.5mm_P2.50mmC1
1SW_SPDTcustom:Switch_SPDT_3mmSW21

Questions

How big is the Kim uno rev1 PCB?

It measures 68 × 98 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Kim uno rev1 use?

36 parts, built around the ATMEGA328P-PU. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Kim uno rev1 KiCad files?

From the maxstrauch/kim-uno repository on GitHub, at the commit this page was made from: the board is kicad/kim-uno-rev1.kicad_pcb. PCBKit opens the board in the browser, with nothing to install.

Can I use the Kim uno rev1 design in my own project?

Its repository states no licence, so its author keeps all rights: ask maxstrauch before reusing the design.

Similar boards

  • 2 layers68.8 × 53.6 mmZArduino, the printed circuit board in 3D

    ZArduino

    zmaker/arduino_cookbook

    gli sketch del nuovo progetto Arduino Cookbook e dei video di YouTube

    46 parts269
  • 2 layers76.3 × 122.8 mmDiscipad pcb, the printed circuit board in 3D

    Discipad pcb

    coseyfannitutti/discipad

    17-key numpad assembled with only through hole components, including usb type-c

    63 parts221GPL-3.0
  • 2 layers111.3 × 106.4 mmSuper Sixteen v1, the printed circuit board in 3D

    Super Sixteen v1

    matthewcieplak/super-sixteen

    Code and schematics for the Super Sixteen Eurorack sequencer

    141 parts171
  • 2 layers247.6 × 99.2 mmRomeo pcb, the printed circuit board in 3D

    Romeo pcb

    coseyfannitutti/romeo

    Staggered 40% keyboard pcb that can be assembled with only through hole components, including USB Type-C

    138 parts148GPL-3.0
  • 2 layers90 × 140 mmDrumkid, the printed circuit board in 3D

    Drumkid

    mattybrad/drumkid

    Version 4 was the first successful working design, with full code, schematics, Gerbers, etc available on GitHub.

    70 parts137
  • 2 layers238.1 × 375.5 mmFramework, the printed circuit board in 3D

    Framework

    stevennguyen/framework

    Ortholinear keyboard with a knob

    197 parts131
  • 2 layersLM80C R6, the printed circuit board in 3D

    LM80C R6

    leomil72/LM80C

    A Z80-based homebrew computer withTMS9918, AY-3-8910, Z80 CTC, Z80 PIO, and Z80 SIO

    153 parts123GPL-3.0
  • 2 layers145.3 × 44.5 mmScout, the printed circuit board in 3D

    Scout

    oskitone/scout

    3D-printed, Arduino-compatible, 17-key mono synth. Squeeeee!

    48 parts114