alt.hn

5/15/2026 at 5:15:58 PM

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

https://github.com/gdevic/FPGA-Calculator

by gdevic

5/15/2026 at 6:34:36 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.

by drob518

5/15/2026 at 9:58:15 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.

by bsder

5/16/2026 at 4:50:11 PM

I was part of a group touring HP labs in the mid-1970s.

They showed us how they computed the key dimensions and typography with an (HP) minicomputer, then had it print out the commands for some kind of numerically controlled cutting machine on paper tapes using an old ASR33 teletype.

The cutting machine generated moulds for the injection moulding machines making the keys.

The keys are in two parts: light coloured digits and symbols and darker plastic forming the shape of the key itself and surrounding the lighter symbol plastic. As a result, they can be worn down but they can never wear out.

by j_not_j

5/15/2026 at 11:49:12 PM

"Can I borrow your calculator"

"Sure!" (hands over HP-25C)

<start counting seconds...>

"Hey, where's the equals key?"

by kabdib

5/15/2026 at 9:43:21 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.

by dhosek

5/15/2026 at 8:09:08 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?

by phkahler

5/16/2026 at 6:00:02 PM

Yes probably. What model is it? I repair and restore old HP calculators. One thin about all the models from 1972 through the early 1980s that use a battery pack - do not power the calculator off the adaptor alone - these models used a working battery pack as part of the adaptor voltage "regulation" - if you power off the adaptor without the battery a much higher voltage will get into the calulator and can permanently damage it. If you dont have a working battery pack, the only way to test it is with a bench power supply set to a safe voltage. For many of these models I install a lithium battery system and USB-C charge port so we no longer have to mess around with old leaky batteries and HP's poor implementation for charging them. Some of the models that are like this are: 35, 45, 55, 65, 67, the 20-series (21, 22, 25 etc) and the 30-series (31E, 32E, 33E, 33C, 34C etc). After these, the "Pioneers" came out (11C, 15C etc) which dont use a power adaptor and are safe.

by plexuss

5/16/2026 at 4:33:09 AM

One of the coolest projects I've seen in a while! Amazing work! In case anyone missed the write-up^1, it's very well-written. I really enjoyed the chapter about designing the instruction set.

1: https://baltazarstudios.com/calculator-introduction/

by ajxs

5/15/2026 at 11:20:39 PM

This is a brilliant project. (My DM42 returned 9 exactly.)

Blog post 6 had an error where the picture of a HP-71B (I have one and used its Forth/Assembler ROM manual to write the first HP-48 ROM decoder) where the caption says it is a 48GX (both used a Saturn CPU).

by NetMageSCW

5/16/2026 at 1:23:21 PM

Corrected. Thank you!

by gdevic

5/16/2026 at 1:05:18 AM

Cool project

Really hoping that ghidra can add support for non-byte aligned memory regions some day. So many cool 4-bit architectures out there and attempting to shoehorn them into ghidra produces not great results

by russdill

5/15/2026 at 6:56:34 PM

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

by wewtyflakes

5/15/2026 at 7:53:08 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?

by joemi

5/15/2026 at 9:04:35 PM

When did we stop spelling it "nybble"?

by robinsonb5

5/15/2026 at 10:25:36 PM

"Nibble" may well have always been in use by folks, and nybble may have actually come later. At the very least, references to each spelling being in use exist for the last ~60 years.

The first book match I get for "nibble" near "byte" is in the 1964 "System 360 Assembler Language" by Don H. Stabley uses nibble. The earliest match I can find for "nybble" in relation to computers was the 1968 "Encyclopedia of library and information science". Nybble (and likely nibble) itself doesn't seem to have taken off until around the mid 1970s https://books.google.com/ngrams/graph?content=nybble&year_st...

References to the coining of the term in 1958 of course don't provide a textual source.

by zamadatix

5/15/2026 at 10:09:19 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.

by quantified

5/15/2026 at 7:41:59 PM

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

by hvs

5/15/2026 at 7:48:54 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)

by jlokier

5/15/2026 at 9:41:51 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)

by duped

5/16/2026 at 12:45:33 AM

No. 8 bit bytes are the de facto standard but that is in no way official nor the definition of the word. You can find modern niche projects with non-8-bit bytes (and by extension non-32 or 64 bit words).

by fc417fc802

5/15/2026 at 9:44:23 PM

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

by djmips

5/15/2026 at 10:10:01 PM

I think you might be missing the attempt at humor.

by quantified

5/16/2026 at 12:49:20 AM

[dead]

by fc417fc802

5/16/2026 at 4:03:05 AM

It's actually "nybble."

by VerifiedReports

5/15/2026 at 11:01:50 PM

Love this and love seeing people building their own hardware/software tools. I hope to carve out the time soon to be one. Calculators are a perfect project

are there videos available?

by fitsumbelay

5/16/2026 at 5:31:26 AM

It is... Unbelievably exciting project. There's a lot and lot learn and explore. I'll be reading all of it.

by wg0

5/16/2026 at 3:02:29 AM

I wish I could give this project more respect than simply saying it is awesome and contraz.

Also, let us all hate on denomals! :)

by random__duck

5/15/2026 at 5:17:47 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...

by gdevic

5/15/2026 at 6:18:22 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.

by VLM

5/16/2026 at 5:10:54 AM

The Z80 is pipelined and thus has a higher latency but also higher throughput. Besides, memory was the bottleneck, in particular instruction fetches, so multicycle instructions made more sense. Related article: https://news.ycombinator.com/item?id=6341137

by userbinator

5/15/2026 at 10:12:52 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!

by mountain_peak

5/15/2026 at 10:16:50 PM

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

by kristianp

5/15/2026 at 10:24:30 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.

by mountain_peak

5/15/2026 at 9:45:40 PM

At least the 6502 has a BCD mode built in!

by djmips

5/16/2026 at 1:51:37 AM

The Z80 does have a DAA (decimal adjust arithmetic) instruction to facilitate BCD arithmetic. I don't think I ever used it in my Z80 years and I'm not familiar with the details. Sadly I have much less experience with the 6502, I didn't even know it had a BCD mode.

by billforsternz

5/16/2026 at 10:29:10 AM

Intel 8080 already had DAA, so it could add BCD numbers. Because there was no BCD subtraction, that had to be done by an indirect method, e.g. by doing a nines' complement before a BCD addition.

Zilog Z80 improved this, so that on it DAA could also be used after a subtraction, when it would correctly adjust the result for implementing BCD subtraction.

This was one of the Z80 improvements that were considered important at the time of its launch.

While I have never considered worthwhile to do BCD arithmetic instead of converting the decimal numbers to binary numbers, the DAA instruction on all Intel 8080 successors, including on IBM PC compatible computers, was very convenient for converting binary numbers to their ASCII character string hexadecimal representation, for printing or display purposes (because the decimal adjusting happens to add the correct ASCII offset between '0' ... '9' and 'A' ... 'F', so the conversion to ASCII can be done branchless).

by adrian_b

5/16/2026 at 11:33:57 AM

Slight correction, the correct offset is 7, and DAA only adds 6. But the trick is also adding the carry bit. This works on the 6502 in decimal mode too, e.g. https://news.ycombinator.com/item?id=6342286

On the Z80 and 8086, the code can be made one byte shorter by taking advantage of adjust-after-subtraction, which the 8080 didn't have (and on 6502 worked differently):

    CP   10      / CMP  AL,10      ;set carry if valid decimal digit
    SBC  A,69H   / SBB  AL,69H     ;0..9 => 96h..9Fh (auxC=1), 10..15 => A1h..A6h (auxC=0)
    DAA          / DAS             ;subtract 66h if auxC set, 60h if clear

by rep_lodsb

5/17/2026 at 12:52:34 PM

That. I blatantly "stole" those from Z80 since they are elegant and effective. I have BF (flag) that gets set in ALU when the result is > 9, then DAA/DAS that add 6 or 10 (the latter wraps around as -6 since registers are 4-bit wide).

     12'b0000_0000_001?: begin : instr_daas    // DAA, DAS
       if (flags[BF_BIT])
         rx[0] <= rx[0] + (op_is_daa ? 4'd6 : 4'd10);
       flags[CF_BIT] <= flags[BF_BIT];
       state <= FETCH;
     end : instr_daas

by gdevic

5/15/2026 at 10:15:39 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.

by quantified

5/15/2026 at 8:49:58 PM

[dead]

by kanswam

5/15/2026 at 6:12:06 PM

[dead]

by panzys00