login join help ad

June 09, 2020

Memoir 8 - Emulators

I tasted the power of emulators for the first time in 1986. At the time, a possibility of porting MISS to PDP-11 was floated, but our group did not have the hardware. So, I started working on an emulator. It ran very slowly, taking about 200 host instructions per 1 target instruction. So, late Mikahil Flerov taught me how to use profiler[1], and the main offender turned out to be the virtual memory facility. But I'm not talking about an MMU here. Both the target PDP-11 and the Mitra-15/ES-1010 hosts were 16-bit systems, so it wasn't possible for the emulator just allocate a large array. Instead, a layer was used that paged parts of PDP-11 memory image. By profiling and some re-architecting, I managed to speed up the emulator so it only was 30-50 times slower than the real system. I also found paper tapes of CPU and RAM tests for PDP-11, and used those to catch bugs. The source of the emulator survived, although it was written in a long-forgotten language.

In 1992, the hyper-inflation turned my university salary into zero, so I left the glories of do-it-alone systems programming behind and I found a job at a company known as "Moscow Center for SPARC Technologies", or MCST. It was based at a storied establishment, Institute of Precision Mechanics and Computer Equipment (IPMCE) and basically employeed the scientists and engineers of the institute, who would otherwise go as hungry as I did.

A large chunk of MCST's business was to act as a research arm of Sun Microsystems, under the umbrella of SunLabs. IPMCE was known for making CPUs, so that's what we did for Sun.

My first real task was to help Michael Yaroslavtsev with a gate-level CPU emulator. Rather than just throwing together a few C++ classes, Mike developed a framework first. It included a domain-specific language, which described the CPU blocks according to the design of the hardware, and an interpreter with pre-translation for DSL.

The whole thing was running at a SPARCstation 1+ and basically was too slow to be useful for anything. Hardware engineers and architects were not happy with our efforts, even though it was them who asked for a clock-precise sim.

After the failure of that effort, I ended at a competing group, led by V. Tikhorsky and his right hand, Boris Fomichev (who later became known for STLport.org). The dynamic duo's emulator was roughly clock-precise, although its internal design in no way matched the CPU that it emulated. As a result, was was significantly faster, almost fast enuogh to boot an OS. They implemented what their customers really wanted, instead of what they said they wanted.

In 1996 I partook in yet another emulation effort for MCST, which probably was the coolest of them all. I didn't write the emulator though. The emulator was an actual Verilog runner, executing a real CPU model, which could otherwise be routed and taped out. The environment allowed certain hooks into C, which could drive or report CPU pins. So, a guy on the CPU design team wrote those hooks down to ioctl(2), and I wrote a driver for Solaris that managed a bi-directional parallel port on SPARCstation 10 (bpp). In order to do that, I reverse-engineered the bpp driver of Solaris first. A little FPGA board adapterd CPU socket to the parallel port with some buffers and latches. Then, we booted the Solaris on the Verilog, but using the actual hardware for all the DRAM and peripherals. The technique of "in-circuit emulator" wasn't particularly groundbreaking, but it was impressive nonethless. I touted that driver in my resume for years afterward.

[1] Flerov was colorful character. I still have his whitepaper about a new OS to replace both MISS and UNIX. Back then it was seen as perhaps ambitious, but not downright crazy idea. He killed himself in 1988.

Next: Memoir 9.

Posted by: Pete Zaitcev at 02:59 PM | No Comments | Add Comment
Post contains 650 words, total size 4 kb.

Comments are disabled.
9kb generated in CPU 0.02, elapsed 0.043 seconds.
23 queries taking 0.0284 seconds, 28 records returned.
Powered by Minx 1.1.6c-pink.