Building a Calculator From Scratch
Goran Devic built a custom scientific calculator from scratch, designing everything from the PCB to the BCD-oriented CPU.
When you need to make a quick calculation, chances are that you’d reach for your phone or open an application on your desktop computer. In this day and age, it’s less likely that you’d use a dedicated calculator. And there is almost no chance that you’d design your own calculator hardware to have on hand for these situations.
But that’s exactly what hardware hacker Goran Devic did. That is certainly not the most efficient way to calculate a sum, but that’s not the point of a project like this. Devic’s goal was to design and build a calculator that operates in a similar way to those produced by HP in the 1970s for educational purposes. He built it completely from scratch, designing even the CPU that the calculator runs on. And fortunately for us, Devic documented the entire build in great detail.
An unusual aspect of the project is that the calculator does not rely on conventional floating-point math. Instead, it uses binary-coded decimal, or BCD, the same representation used in many classic scientific calculators. In this format, every decimal digit is stored as its own 4-bit nibble, allowing the machine to avoid floating-point rounding errors and maintain exact decimal precision across calculations.
That initial design choice shaped nearly every aspect of the system. Rather than adapting an existing processor architecture, Devic created a custom nibble-oriented CPU specifically optimized for BCD arithmetic. The processor uses a 12-bit instruction format and a Harvard architecture with separate instruction and data memory spaces. Its arithmetic logic unit operates directly on 4-bit decimal digits, complete with decimal-adjust instructions similar to those found in early Intel processors.
This CPU was implemented on an Altera Cyclone II FPGA. Devic also built a Qt-based desktop prototype of the calculator software that can be compiled to WebAssembly for browser-based testing. The project grew iteratively, with every new instruction added to the processor first implemented in Verilog, then integrated into a custom Python assembler and tested through simulation before being committed to hardware.
Custom PCBs were designed to create a 35-key keypad matrix and connect it with the FPGA and an OLED character display. Devic used EasyEDA for the PCB layout and ordered prototype boards from JLCPCB before hand-soldering the switches and display components himself.
Devic’s calculator may not be something you really need in your daily life, but there is a lot that can be learned by digging into a project like this. When you’ve got some free time, I’d highly recommend reading through the project’s extensive documentation.
R&D, creativity, and building the next big thing you never knew you wanted are my specialties.