Inside any electronic device, from an old television remote to a global positioning system, there will be at least one microcontroller unit (MCU) and, in many cases, several. MCUs are used in specialized end products ("appliances") and are designed to perform a specific task very well (by comparison, microprocessors are designed to perform many general functions).
Microcontrollers can be designed to minimize cost, be ruggedized for industrial and automotive applications and, when embedded in an FPGA, be reprogrammed to change functions. This flexibility allows a single appliance to be deployed in multiple products, even if interface standards vary.
What factors should be considered in choosing a microcontroller? While this article's focus is on embedded applications using FPGAs, the selection criteria for any microcontroller are essentially the same. The designer will need to determine:
- How much will the end product cost?
- How much memory is required to implement the design and to store the control program?
- What are the Input/Output requirements?
- What are the register requirements?
- How will the microcontroller integrate with other devices?
Traditionally MCUs have been off the shelf, application specific standard parts (ASSPs), with each vendor varying the feature set to differentiate the part. However, the union of MCU intellectual property (IP) cores with field programmable gate arrays (FPGAs) provides a far more flexible hardware platform than traditional MCU ASSPs, with these benefits:
- While FPGAs may be more expensive than a single MCU, their functionality, such as embedded DSP and memory blocks and a flexible I/O ring, may offset the cost of multiple devices.
- FPGAs provide a more flexible memory architecture, so as data and instruction needs vary the user can adjust the hardware design accordingly.
- Input/Output requirements can be demanding, given the variety of signal standards and interface protocols required in modern systems. FPGAs excel in this area with programmable on-chip buffers. For example, the Lattice MachXO device supports single-ended LVCMOS / LVTTL and differential LVDS / LVPECL in a variety of voltage levels.
- When considering registers and scratch pad memory resources, MCU IP cores for FPGAs often provide the flexibility to change the configuration to meet application needs.
- FPGAs are ideal solutions to device integration problems. The programmable look-up-table (LUT), register and memory resources allow for additional integration, while flexible programmable I/O and specialty interfaces such as double-data rate (DDR) make handshaking with multiple devices easier.
FPGAs are well-suited for many microcontroller applications because they are relatively inexpensive, include a wide range of embedded memory blocks, have adequate I/Os for nearly any controller function, are register rich, and support many I/O standards, ranging from LVCMOS and SSTL to differential LVDS signaling.
Examples of microcontroller applications
The flexibility of FPGAs allows for a wide range of microcontroller applications, as well as more complex designs that include microcontrollers. Products such as home electronics, appliances, industrial robots and a growing number of new automotive applications, from GPS to engine control to braking systems, include microcontrollers.
In a motor control application, the system sends and receives information to and from the microcontroller to adjust the speed and direction of a stepper motor. Inputs from the system tell the microcontroller to increase or decrease the speed of the motor and the microcontroller, in turn, tells the system the speed and direction of the motor in real time.
In a navigation system application, a microcontroller adjusts the graphical display of the system to increase or decrease resolution based upon device input. For purposes of this article, a system on chip (SoC) application is used to illustrate the design flow for a typical microcontroller implemented in an FPGA.
Fig 1 shows a block diagram of an SoC implementation in an FPGA. This system includes a microcontroller, peripheral bus and several peripheral functions, and also a HW Trace Debugger that displays Register File, Scratch Pad, Call Stack, Program Counter, Flags and a Trace Listing. It also may support Single Step, Multi-Step and Breakpoints for the microcontroller.
1. System on a Chip (SoC) implementation in an FPGA.
(Click this image to view a larger, more detailed version)
The versatility of an FPGA-based SoC solution is obvious in this example. The peripherals shown here are typical of the functions that may be found in a SoC design implemented in an FPGA:
- Pulse width modulation has applications in telecommunications, radio control, switching amplifiers, power and voltage control. By controlling the pulse width, data may be encoded and decoded in transmissions, synthesis audio signals or control motors.
- The analog to digital converter (ADC) module generates an n bit wide value representing an external analog voltage. The ADC can acquire data automatically and, in conjunction with an external comparator, be configured, for instance, to generate an interrupt and by reading a register clear an ADC sample ready flag.
- The I2C Slave interface module provides a serial communications link to an I2C master controller. Typical applications for an I2C interface are controlling color balance, audio volume, daughter card management, and display controls.