\

I designed a nibble-oriented CPU in Verilog to build a scientific calculator

62 points - today at 5:15 PM

Source
  • drob518

    today at 6:34 PM

    My dad worked for HP from the mid-1970s through the mid-1990s. Needless to say, I used HP calculators in high school and college. The best things about having an HP calculator were the solid physical construction (the buttons on the 11C and 15C were awesome), the accuracy, and the fact that whenever your classmates asked to borrow your calculator they would recoil in horror when you asked them whether they knew RPN. Nobody borrowed my calculator. Anyway, I love this project.

      • dhosek

        today at 9:43 PM

        My biggest challenge the first time I ever used an HP calculator was less RPN than the syntax of it. I thought I had to hit enter after every token so I typed, e.g., 2⎆3⎆+⎆ rather than 2⎆3+. Needless to say, this did not work as expected, but being simultaneously vain and bashful, I was unwilling to ask for help and did almost all the arithmetic for my freshman physics class by hand.

        • phkahler

          today at 8:09 PM

          I still have my dads old HP with the glowing red letters and all the functions. Not sure if we still have the charger. Not sure the battery is any good, but the calculator worked fine last time it was turned on decades ago. Any idea if this can be made to function again?

          • bsder

            today at 9:58 PM

            > the buttons on the 11C and 15C were awesome

            What is the trick to engineering HP calculator keys? Nobody gets keys right like the old HP calculators.

            In this age of 3D printing and fast prototypes, we really ought to be able to crack this.

        • wewtyflakes

          today at 6:56 PM

          If the CPU is nibble-oriented, wouldn't that mean that that is its byte size?

            • joemi

              today at 7:53 PM

              Are you trying to make a pun with byte/bite relating to nibble? Because that's actually where the term nibble (referring to 4 bits) comes from, so I'm not sure such a pun even counts as a pun anymore. Or am I misinterpreting your comment?

                • robinsonb5

                  today at 9:04 PM

                  When did we stop spelling it "nybble"?

                    • zamadatix

                      today at 10:25 PM

                      I don't know we ever "stopped" as much as the "nibble" spelling has always existed while "nybble" did.

                      • quantified

                        today at 10:09 PM

                        I was wondering this as well. Probably when a new wave of people discovered the concept in the absence of the older wave? By contrast, "byte" has been in use continuously and widely.

                • hvs

                  today at 7:41 PM

                  A byte is always 8 bits. The word you're looking for is `word-size` which, in this case would be 4 bits.

                    • jlokier

                      today at 7:48 PM

                      A byte is not always 8 bits on old machines, though it is standardised as 8 bits nowadays.

                      This is why network RFCs talk of "octets", to avoid the ambiguity. Octets are always 8 bits.

                      https://en.wikipedia.org/wiki/Octet_(computing)

                        • djmips

                          today at 9:44 PM

                          I didn't realize that there was a 16 bit name called a 'chomp' haha. But more formally hextet.

                          • duped

                            today at 9:41 PM

                            The definition of a byte today is different than the definition of byte when those machines were manufactured. Just like how 'foot' is now standardized(*)

                            (* technically, a 'foot' is not a standard unit of measure but that's due to the long history of 'foot' not being standardized until relatively recently)

                        • quantified

                          today at 10:10 PM

                          I think you might be missing the attempt at humor.

                  • gdevic

                    today at 5:17 PM

                    The core question: how did HP's scientific calculators actually work at the gate level? That rabbit hole led to building one from scratch.

                    The architectural decision everything else follows from: a decimal calculator should store numbers as BCD — one decimal digit per 4-bit nibble. A standard byte-oriented CPU (Z80, 6502) fights that layout constantly. So I designed a small custom CPU in Verilog where 4 bits is the natural data width and memory is nibble addressable.

                    What the project covers:

                    - Custom CPU: Harvard architecture, 12-bit ISA, 8-state execution FSM, hardware stack guard with a FAULT state for microcode debugging

                    - CORDIC for trig functions, verified to 14 significant digits

                    - Two-pass assembler in Python (~700 lines)

                    - Verilator + Qt framework: same Verilog source runs in simulation, as a desktop GUI debugger, as WebAssembly, and on real hardware

                    - Scripting language on top of the microcode for adding functions without touching hardware

                    - Custom PCB (EasyEDA/JLCPCB), battery, charging circuit

                    Write-up: https://baltazarstudios.com

                    Hackaday: https://hackaday.com/2026/05/13/build-the-cpu-then-build-the...

                      • mountain_peak

                        today at 10:12 PM

                        Very impressive, and obviously a labour of love! As a calculator and SystemVerilog enthusiast, it's wonderful to see a project such as this come to fruition - congratulations!

                        I'm holding in my hand a 4-bit Von Neumann Mostek MK50310N that my father and I used to use to build calculators long ago. Although Mostek made chips for HP (such as the HP-35), they weren't commercially available, but the 50310 was. We could only dream of a project such as yours. I was happy when the "open source" NumWorks was released, but this project aligns more with my interests.

                        Will definitely install the Qt simulator - would be even better to build one IRL!

                          • kristianp

                            today at 10:16 PM

                            Re Numworks, at $125 for a calculator, you've got to really love the idea.

                              • mountain_peak

                                today at 10:24 PM

                                I didn't think it was that much, but I checked my receipt from 2017, and sure enough it was!

                                I have in my hand (I guess I like using that phase today), my father's original receipt for the HP-45 (it's with the box and manual). $299.00 in 1975, which is $1,850 today(!!!).

                                Relatively speaking, electronics are very, very cheap today compared to what they used to be. Still appreciate that my $30 CASIO does 90% of that the NumWorks can do, but I'm happy to support upstarts such as NumWorks.

                        • djmips

                          today at 9:45 PM

                          At least the 6502 has a BCD mode built in!

                            • quantified

                              today at 10:15 PM

                              I'd like to amplify this. Decimal math using nibbles containing 0 through 9 was standard operating procedure, one of the things that made the 6502 nice. Unfortunately you had to use a short loop to convert between 2s complement and BCD.

                          • VLM

                            today at 6:18 PM

                            Ironically the Z80 is a nibble ALU. That's why its so slow compared to the competition, an 8 bit add on a "2 MHz" Z80 takes as much clock time as a 8 bit add on a "1 MHz" 6809.

                        • kanswam

                          today at 8:49 PM

                          [dead]

                          • panzys00

                            today at 6:12 PM

                            [dead]