Tiny chips with some big ideasthat's what you can expect to see this summer.
Two new microprocessors are coming out this summer and they couldn't be more different. One's an inexpensive fly-speck of a microcontroller and the other's a high-end chip that modifies its own performance based on your C code. They highlight the terrific number of choices available to embedded systems programmers and the remarkable diversity in the chip business.
Thin is in this year. Lots of embedded systems designers are trying to save space in their systems to make them either small or light. To serve this niche, a handful of CPU makers are trying to make their chips as tiny as possible. The current record holder in my book is Microchip and its new PIC10F processor.
This tiny mite is about the size of the capital T at the beginning of this sentence. With only six pins on the packagetwo of which are for power and groundthere ain't much to see on this chip. In fact, it's hard to see at all. Yet inside is a good little 8-bit microcontroller that runs at 4MHz and comes with 256 bytes of flash memory and 16 bytes of SRAM. That's bytes, not kilobytes. This chip won't calculate real-time missile trajectories but hey, it only costs 49¢.
That's the low-end version of the chip. The deluxe model comes with double the amount of flash memory, an extra 8 bytes of SRAM, and an analog comparator (poor cousin to an analog-to-digital converter). It costs a princely 65¢. Not so many years ago DEC's VAX 11/780 was reckoned the first computer to execute 1 million instructions per second. Now a 4MIPS microcontroller costs less than a cup of coffee and is so small you might accidentally inhale it.
Which isn't such a crazy idea. One of the applications Microchip envisions for this little device is in, er, disposable one-time-use medical devices. A PIC10F processor and a few sensors would easily fit into a pill you could swallow to diagnose all kinds of internal ailments. I don't suppose many of DEC's engineers imagined swallowing the equivalent of four VAXs during their development projects.
Let's get small
Four I/O pins on the processor doesn't leave a lot of room for peripheral functions. Basically, PIC10F programmers can “bit twiddle” the four pins to their hearts' content, producing pulse-width-modulation pulse trains, for example, or toggling low-speed devices. The pins can source and sink 25mA of current, so they're able to drive LEDs, relays, and other mechanical devices that need a fair amount of grunt. There's no room for a crystal input, so the chip creates its own 4MHz oscillator without any external reference. Interestingly, the oscillator is the biggest part of the silicon; the chip is basically an RF circuit with some SRAM, flash memory, and a tiny microprocessor stuck onto the side.
Your total program size is limited to just 256 instructions, or 512 instructions on the “big” version. With no memory bus there's no means for expansion. But Microchip figures that the PIC10F is so cheap at 49¢ a pop you could use it instead of PLDs, or in place of generic 7400-series logic gates. Okay, so a 74LS03 is still about half the price of a PIC10F, but the processor is also more capable than a handful of NAND gates. Instead of running a blue wire across your printed circuit board to fix the latest “oops,” you might be able to program the PIC10F to generate the handshake signal you forgot.
It's hard not to use the word cute when discussing the PIC10F processors. They're just so . . . wee. It's pretty cool when multimillion-instruction processors are so cheap they're not worth the postage.
Everyone's a processor designer
At the other end of the performance spectrum is a new 32-bit processor from startup company Stretch. This chip, called the S5400, makes every C programmer into a microprocessor architect. Always wanted a chip with a foobar instruction? Now's your chance.
Stretch's trick is to combine a fairly standard 32-bit processor with some special FPGA-like programmable logic that can hold your own custom instructions. The custom additions become part of the CPU's assembly-level instruction set, just as if the chip had been created with those instructions all along. But because the custom instructions are held in programmable logic, you can erase and reprogram them as often as you want. Result: you get your own custom microprocessor.
Other companies have done things sort of like this before, but those attempts never caught on in a big way. Mostly that was because you had to license the processor and build your own ASIC around it. A multimillion-dollar hurdle, that. You also needed first-rate hardware engineers on staff to design your custom instructions and integrate them into the rest of the processor core; another tricky hurdle. Finally, most people wouldn't know what custom instructions to ask formuch less how to make them workso the whole ordeal was too much effort for the average embedded systems developer.
Stretch's chip is just thata normal chipso it appeals to mainstream engineers who can't invest time and money on their own ASIC. It's still not cheap, though. Prices start at $35 and rapidly head north to $100 per chip for the all-singing, all-dancing version with PCI-X, 64-bit buses, and four Ethernet interfaces. That puts the S5400 toward the high end of the 32-bit price range, but it's not unreasonable for a 300MHz processor with some interesting do-it-yourself features.
Stretch gets around the whole “what-instruction-should-I-make” question by avoiding it entirely. Instead of asking hardware engineers to think up (and then implement) custom instructions, Stretch hands the problem to the programmers. Instead of designing instructions and then integrating them into the compiler, Stretch's compiler creates the instructions and then adds them to the chip.
Let the code do the work
Here's how it works. You start with normal C code and then mark a few functions with a special compiler directive. The compiler collapses each marked function, producing a single custom instruction along with the hardware to implement it. The custom hardware gets loaded into the S5400 chip at run time. You can tag as many C functions as you like, and the compiler will generate one custom instruction for each one.
Essentially, programmers can point to a section of code and say, “make that part go faster.” Stretch's compiler goes to work flattening or unrolling the function as best it can and converting it into hardware. Users never see what actually comes out. In fact, you can't design a Stretch instruction even if you wanted to; there's no hardware design tool, no schematics, and no Verilog.
You can tag every C function in your whole program if you want to, but it's not a good idea. The S5400 chip can hold several custom instructions, but the exact total depends on their relative complexity. The chip might hold a dozen simple instructions or just a few elaborate ones. The chip can swap instructions in and out, but it's a slow process, so you're better off creating just enough custom instructions to fill the chip one time.
When is an FPGA not an FPGA?
Stretch's chip is a bit like the Altera Nios and the Xilinx MicroBlaze processors, which are “soft” processors you load into an otherwise generic FPGA. Since they're soft designs in soft logic, you can modify them and even create your own in-house instructions and coprocessors. That, however, is about as far as the similarities go.
First, Nios and MicroBlaze are both slow compared with the 300MHz Stretch S5400. FPGAs are designed to be generic and multipurpose, so they're not good at hosting microprocessors. That's why Altera and Xilinx both designed their own processors (as opposed to using, say, PowerPC or MIPS) and why both companies give the design away for free. Plain-vanilla FPGAs just don't have the kind of data paths, buses, logic, and feedback mechanisms that microprocessors need.
On the plus side, MicroBlaze and Nios are both freeif you're buying FPGA chips anyway. The downside is that Nios and MicroBlaze both require hardware expertise, but again, that's probably not an issue if you're buying FPGAs in the first place. Stretch's S5400, on the other hand, doesn't require (or permit) any hardware skills to customize the processor. It's a pure software play.
Although Stretch allows you to extend the processor, you can't extend anything else. If your system needs some programmable logic for special peripherals or system functions, ironically, you'd have to add a separate FPGA chip. Xilinx and Altera chips, of course, are made for just that kind of thing.
Another company, Triscend (which is now part of Xilinx), has a chip that's just the opposite of Stretch's. You can customize the peripherals on Triscend's chip but not the processor. This lets you swap out or rearrange UARTs, direct memory access controllers, and other features while leaving the processor intact. It's a nice idea if you have a lot of different products with similar software needs but different hardware features.
One drawback to Stretch's processor is software compatibility: there isn't any. The S5400 is based on Tensilica's Xtensa processor core, so it's compatible with other Tensilica-based chips, but there aren't many of those around. Operating systems, middleware, and programmers with Tensilica experience are scarce. Stretch's compiler is obviously unique, so there's only one source for that. And, of course, any custom instructions you create will be yours and yours alone. No one will have any software support for those.
On the bright side, a one-of-a-kind microprocessor is a great way to protect your code. It's pretty hard to reverse engineer a chip with a nonstandard instruction set. A few well-placed foobar instructions can do wonders for obfuscating code.
I think the number of different embedded processors will grow in the coming years, not shrink. There's no big shakeout coming. On the contrary, new processors come along all the time to handle new and different embedded applications, while existing processors like the 8051 and 6805 last almost forever. Processor designs accumulate, like layers of geologic strata. Although that makes choosing a processor even harder, choice is a good thing. Now it looks like we're getting to the point where every programmer can have a custom processor du jour . That's real choice.