3

(coco) #1
SPARK

There’s another way to build your own CPU, though,
and with FPGAs ticked off his to-do list Daniel has
created a third machine: the Mini C88. Inspired by a
clone of the C88 built onto an Espruino microcontroller
for his younger brother to take to his school’s show-
and-tell event, the Mini C88 swaps the relatively
expensive FPGA which powers the original design for
an Arduino Zero.
Typically, the way to run software written for one
computer on a different computer is to use emulation,
a software trick which requires significantly more
processing power than the original design and which is
often less than perfect. For Daniel, “less than perfect”
isn’t something worth aiming for, so he took a different
approach: Dynamic Binary Translation (DBT), a clever
technique for running software from one architecture
on hardware using another, to which he was introduced
while working at Arm.


GETTING RIGHT TO THE CORE
“Instead of simulating every state change that a real
C88 would encounter as it executes a program, we
translate – convert – the program from C88 machine
code and execute it directly on the Arduino’s Arm
Cortex-M0+ processor,” he explains of the technical
trickery required to build the Mini C88. “This means we
can make better use of the hardware. Instead of storing
the current C88 register value in memory somewhere,
like an emulator would, we just use the Arm R0 register
to store the register value. We don’t need to store
the program counter anywhere either, since the Arm
architecture has is own program counter to keep track
of where it is in the program.
“We are, in essence, hijacking the hardware built
into the M0+ for fetching, decoding, and executing
a program by giving it a program in the format that it
expects but which happens to be equivalent to the C
program we want to run.” A neat trick, but one with
its own particular challenges – including handling C
instructions for which the Arm instruction set has no
equivalent and introducing the ability to alter the speed
of execution so you can actually see the program being
run step-by-step.
The result is a machine which is as close to the
original C88 as possible, yet costs less to build. Built
into a smaller, laser-cut acrylic housing – the original
C88 being built into the largest project box available at
Daniel’s nearest high-street hobbyist electronics outlet,
having “bought the biggest project box that I could
find and thought ‘right, I’ll make it fit in there,’ then
just drilled a few holes and thought ‘that actually looks
pretty good!’” – the major features are still there: the
8 × 8 matrix display is present and correct, as are the


toggle switches which allow the user to program the
Mini C88 and switch it between program entry, display,
and runtime modes. Only the GPIO port is missing, a
sacrifice of the shift to the Arduino microcontroller.
For Daniel, the C88 began as a simple experiment
in building a simple CPU on an FPGA. Its concepts,
though, could help bridge the gap between modern,
abstract, high-level computing and its increasingly
opaque low-level underpinnings. While toggling a
program in by hand is tiresome work – especially on
the C3232, which requires 1,056 individual switch
activations for a program which fills its memory – it
makes the way in which any binary computer of any age
operates at the very lowest levels painfully obvious, in a
way simply reading about transistors can never do.
“Not everyone will be interested in the low-level
stuff,” Daniel admits. “There are plenty of people who
just want a Raspberry Pi, but for all the people who
want to get right down to the lowest level, as I did when
I started learning programming and things, this sort of
thing would be great, I think. I wish I’d had something
like this when I started learning all this stuff!”
Daniel has considered turning the Mini C88 into a
built-it-yourself kit, but at present the easiest way to
play with his creation is to either find a Maker Faire or
similar event to which the C88 and C3232 are being
exhibited or play with the simulated version at
hsmag.cc/QXPCjQ.
Those interested in its inner workings, meanwhile,
can find the VHDL code which turns an FPGA into the
C88 processor on hsmag.cc/oTpVBy.

Below
“I was inspired by the
Manchester Baby,”
explains creator
Daniel Bailey

Above
The Mini C88 is
compatible with its bigger
brother, but smaller and
cheaper to make
Free download pdf