Skip to content
Tech News
← Back to articles

Designing an FPGA Calculator from Scratch

read original get FPGA Development Board → more articles
Why This Matters

This article highlights the process of designing a custom FPGA-based calculator that ensures perfect decimal accuracy using binary-coded decimals and a self-designed CPU. It demonstrates the intricate engineering and layered development involved, emphasizing the importance of precision and understanding the inner workings of computational devices, which can inspire innovation in digital design and educational tools for the tech industry and consumers alike.

Key Takeaways

This is a scientific BCD calculator that uses binary-coded decimals, the same internal number format HP used in its scientific calculators going back to the 1970s. It represents every decimal digit as a 4-bit nibble, which means perfect decimal accuracy, no floating-point conversion errors, and an architecture that is genuinely shaped by the problem it solves. To make that work cleanly, we also design a custom CPU that thinks in nibbles too. It runs on an Altera Cyclone II FPGA, synthesized with Quartus, simulated with Verilator and ModelSim, and debugged through a Qt-based desktop prototype that also compiles to WebAssembly if you want to run it in a browser. Several tools, several moving parts – all built in stages and tested at each one.

Across ten chapters, you will follow full arc: the architectural decisions and tradeoffs, the numerical algorithms (addition, multiplication, CORDIC for trig, logarithms), the custom CPU design and its 12-bit instruction set, a hand-written two-pass assembler in Python, the microcode that runs on that CPU, a scripting layer for high-level key functions, and finally the physical board with its battery, display, and keyboard. Each piece depends on the last, so we build them in order and test them before moving on because a calculator that returns wrong answers is considerably worse than a calculator that returns no answers at all.

The joy here is not in the finished device, though that does appear at the end. It is in each layer becoming real: the moment algorithms verified in C++ begin running on a processor you designed yourself, and the result is correct to 14 decimal digits. If you have ever wondered what actually happens inside that little machine when you press a key, this series is written for you. Hope you find something of value here.