Flylib.com

Books Software

 
 
 

C Language for FPGA-Based Hardware Design?


C Language for FPGA-Based Hardware Design?

Let's think a bit more about the role of Cor lack of a role, as the case may bein hardware design. Why is standard C not appropriate as a replacement for existing hardware design languages? Because any good programming language provides one important thing: a useful abstraction of its target. VHDL and Verilog (or, more precisely, the synthesizable subsets of these languages) succeed very well because they provide a rational, efficient abstraction of a certain class of hardware: level- and edge-sensitive registers with reset and clock logic, arbitrary logic gates, and somewhat larger clocked logic elements arranged in a highly parallel manner. All of today's FPGAs fit this pattern, and it is the pattern also found in the vast majority of today's ASIC designs, no matter how complex.

The standard C language does not provide that level of abstraction (which we call register transfer level, or RTL), so "C-based" languages for hardware could add RTL-like constructs in the form of syntax decorations, extra functions or keywords, compiler hints, and more to create some meaningful way of expressing parallelism and describing low-level hardware structures such as clocks and resets. But in this case we would just have another HDL with new syntax. On the other hand, without the benefit of RTL constructs such as these, the developers of C compilers for FPGAs and other nontraditional targets would face a nearly impossible problem: how to efficiently map algorithms and applications written for one class of processing target (the traditional microprocessor) to something entirely different (arbitrary logic gates and registers combined with somewhat higher-level logic structures). Nobody has yet figured out how to do that mapping from a pure software application with a reasonable level of efficiency, although we are getting better at it.

So why use C at all for FPGA design? There are significant advantages, including the potential for hardware-software codesign, for the creation of test benches written in C, and (if the modified C language supports it) the ability to compile and debug an FPGA application using a standard C development environment. And if a mid-level approach to hardware abstraction is takenone that does not require that the programmer understand all the details of the hardware target, and yet is guided by the programming model toward more appropriate methods of codingyou can strike a balance between software design productivity and hardware design results, as measured in system performance and size .


Compelling Platforms for Software Acceleration

Here's where software developers come in. On the applications side there is an increasing trend toward using FPGAs as hardware accelerators for high-performance computing. Applications that demand such performance exist in many domains, including communications, image processing, streaming media, and other general-purpose signal processing. Many of these applications are in the embedded software space, while others represent scientific, biomedical, financial, and other larger-scale computing solutions.

When acceleration is required, these applications typically begin their lives as software models, often in C language, and are then manually rewritten and implemented in hardware using VHDL or Verilog. This manual conversion of software algorithms to hardware is a process that can be long and tedious in the extreme; hence, there is a strong demand for more rapid paths to working hardware. There is also a strong desire to avoid later redesigns of that hardware to reflect software algorithm updates. Automating the process of software-to-hardware conversionat the very least for the purpose of creating hardware prototypesis therefore highly compelling. This automation also brings hardware acceleration within reach of design teams and developers who do not have vast hardware design expertise, or where hardware design might be cost-prohibitive using traditional approaches. C-to-hardware compilation is an enabling technology that has the potential to open up hardware acceleration for a whole new class of applications and developers.

On the hardware side, there have been recent advances in FPGA-based programmable platforms that make FPGAs even more practical for use as application accelerators. In fact, FPGAs with embedded processor cores have now become cost-effective as replacements for entire embedded systems. The concept of building a complete "system on an FPGA" is finally a reality, thanks to the continued efforts of the major FPGA providers and third-party intellectual property (IP) suppliers. What is common about these new FPGA-based platforms is that they combine one or more general-purpose processor cores with a large amount of programmable logic. Just as significantly, they come equipped with substantial amounts of royalty-free , pretested components and an ever-growing collection of licensable third-party and open-source components that can be assembled on-chip in a matter of hours to create an amazingly diverse set of potential hardware/software processing platforms.

From a tools perspective, what is interesting about these new devicesand the new computing platforms they representis that they are flexible enough to support the use of methods and tools from the software development world, including traditional software debuggers . Using languages such as C and C++ in conjunction with software-to-hardware compilers makes it practical to implement software applications directly onto a mixed hardware/software platform.

It is here that FPGA designers who are questioning the use of software design languages and methods for FPGAs may be missing the point. C is not likely to replace HDLs such as VHDL and Verilog for traditional, general-purpose hardware design. C will, however, play a strong role in the kind of mixed hardware/software applications that are emerging todayapplications in which the line between what is software and what is hardware is becoming increasingly blurred, and where the ability to rapidly prototype and experiment with implementation alternatives is critical.

In addition, because of the prevalence of embedded FPGA processors, the C language is already being used for FPGAs by thousands of software engineers. The problem is that the vast majority of these software engineers are only able to program for the embedded microprocessor within the FPGA. Our goal in this book is to make C-language programming applicable to the entire FPGA, not just the embedded microprocessor within it.