Explore the Guts of Computing With Arith-matic’s S1-AU Kit

This 4-bit arithmetic logic unit looks great and teaches important lessons about computing

Advertisement

I don’t normally review Kickstarter projects that haven’t reached the verified shipping stage. Even when they manage to hit their targets, too many times I’ve seen crowd-funded projects flame out for various reasons. Such causes might be a high-minded concept that pushes the available technology beyond feasibility, problems with the harsh realities of manufacturing, or occasional outright malfeasance, where money is taken for projects that exist only as vaporware.

But I made an exception for Arith-Matic’s S1-AU 4-bit arithmetic logic unit (ALU) kit. Since the 7400 series of integrated circuits upon which the kit is based has been around since the 1960s, I felt that the enabling tech fell safely into the category of “mature technology, low risk.” And Arith-Matic was willing to send me a sample from a beta production run that was very real and fully functional.

I was attracted to the S1-AU because I like kits that expose important elements of electrical engineering normally hidden away in little black boxes. Such kits are the equivalents of the gleaming metal models of engines that mechanical engineers get to decorate their spaces with, and which are instructional and iconic in equal measure. In S1-AU’s case what’s being exposed is an essential part of every processor: the ALU, which does the real work of computation by performing mathematical operations on data.

We’ve gotten so used to CPUs as single-chip devices—where an entire processor core may be treated as just another plug-and-play component—that it’s easy to forget that a CPU is made up of distinct subsystems. These include the ALU, registers to store working data, and the control unit, which decodes incoming machine code instructions. The S1-AU puts the user in the role of the control unit, sending data to the ALU and selecting what mathematical operation it should perform.

The S1-AU is of course very simple, capable of performing just two operations—addition and subtraction—on two 4-bit operands. But to be fair, that’s not much less than the capability offered by the ALU in the 4004, the 4-bit CPU that launched the microprocessor revolution (the 4004’s ALU was also capable of rotating the bits in a binary number left and right). In addition, the S1-AU allows you to accumulate results, so that you can repeatedly increment or decrement one operand by the other. The S1-AU also tests and sets several status flags, which can indicate if the result of an operation is zero, whether the two operands are equal, or which operand is greater than the other.

Building the S1-AU was a straightforward job of soldering components into a PCB that took about two and half hours. The kit has a few nice aesthetic touches: The PCB comes in a stylish black, and a second, blank PCB board is provided to mount below the functional PCB. This second PCB means you can hold the S1-AU in one hand as you play with it, without getting stabbed by the sharp protruding stubs of component leads. Arith-Matic even took care to supply all but one of the capacitors in rectangular casings, rather than the usual cylindrical or disk shapes, which gives the kit a neat, squared-off look. The whole thing is powered by a USB mini connection.

Playing with the S1-AU is great way to understand some quirks of machine code or assembly-level programming of processors. A key quirk relates to how branching is done on many processors. In higher-level language code, branching usually happens by performing some arithmetic operation, explicitly comparing the result to some test value, and then continuing to the next instruction or jumping to some other part of the program, depending on the result. In machine code, you can often set things up to take advantage of the fact that a typical ALU automatically tests the results of every arithmetic operation for certain properties, in particular whether or not the result is equal to zero. The true or false values of these tests are indicated by flag bits in a processor’s status register, and these bits dictate the consequences of machine-code branch instructions.

So, for example, you might have a loop in which the value of a counter variable starts out as some positive integer and is decremented by one each time the computer goes through the loop. As long as the counter is greater than zero, the computer should branch back to the top of the loop. At the bottom of the loop, then, just after the computer subtracts one from the counter to decrement it, you can code a “branch if not zero” instruction. This will either send the program back to the top of the loop or direct it to carry on with the next instruction after the loop, with no separate comparison instruction required.

Understanding flag bits, and how they are silently updated as a side effect of ALU operations, is critical to learning how to program “on the metal.” Another quirk of programming on the metal that the S1-AU can help clarify is the representation of negative numbers in binary. Generally, this is done using a bit of mathematical magic called “two’s complement.” Two’s complement is great in that negative numbers are handled in the same way as positive numbers by the ALU’s circuitry. Two’s complement is also one of those things that I can review, understand, do a test exercise by hand—and then completely lose the thread of how it works by the end of the day, my understanding disappearing like water poured onto sand. The S1-AU is a great way to experiment with, and reinforce your understanding of, two’s complement.

All in all, S1-AU is a lovely kit. It’s functional enough to be educational and pretty enough to display. Unfortunately, just as this article was going to press, it missed its Kickstarter target. However, Arith-Matic emailed me to announce that it will make the kit available through a series of microrun releases instead, albeit at a higher price than what would have been possible through Kickstarter.

This article appears in the August 2018 print issue as “4-Bit Wonder.”

Advertisement