Global Sources
EE Times-Asia
Stay in touch with EE Times Asia
EE Times-Asia > Controls/MCUs

The MCU guy's guide to FPGAs: The software

Posted: 08 May 2015 ?? ?Print Version ?Bookmark and Share

Keywords:microcontroller? MCU? FPGA? multiplexers? digital signal processing?

Now, as promised, let's return to the simulator. When you come to think about it, the simulator is a program that is itself written in a sequential language like C or C++. The simulator's task is to "fake concurrency" in its sequential world. It does this by keeping track of queues of pending events and future events, which is why this type of tool is formally known as an "event-driven simulator."

In the case of our example circuit shown above, when the original triggering event (a rising edge on the clock signal) occurs, the simulator will look at whatever value is currently being presented to the inputs of regA (the current output from regB) and will schedule an event to load this value into regA and change the value on its outputs at some future time (the actual time depends on the delays the designer has associated with the register). Similarly, the simulator will look at whatever value is currently being presented to the inputs of regB (the current output from regA) and will schedule an event to load this value into regB and change the value on its outputs at some future time. The point is that these changes now form their own events that will be actioned at the appropriate time(s) in the future.

Software functions/procedures versus hardware blocks/modules
As we've just discussed, programming languages like C and C++ are very different in nature to hardware description languages (HDLs) like Verilog and VHDL. Let's explore these differences in a little more detail...

Let's begin by noting that!if we wished!on the software side of things we could simply create a single, honking big program. By this, I mean a single file containing line-after-line of code that may include loops and if-then-else type statements, but that doesn't make any use of procedure or function calls.

Figure 6: A honking big program (software) and a honking big circuit (hardware).

Similarly, on the hardware side of the fence, we could use our HDL to describe a single honking big circuit/design. In reality, of course, we tend not to do this sort of thing on either side of the fence, because it makes life difficult in so many ways...

Taking a stroll on the software side...
Just one more point before we really plunge into the mire!we are going to keep things as simple as possible. On this basis, we will consider only a single-threaded program running on a single processor core!we are not going to worry about multi-core systems, threaded applications, operating systems time-sharing multiple programs, or any other weird and wonderful scenarios.

The term "subroutine" is used to refer to a small portion of code that performs a specific task and that is relatively independent of the main body of code. The main routine (program) calls the subroutine as and when it is required. These days, the term "subroutine" is now predominantly associated with assembly languages and languages like BASIC. In the case of languages like C and C++, it is more common to use the terms "procedure" and "function" (we don't need to worry about the differences between these constructs here). Older programmers often think "subroutine" but say "procedure" and "function," while younger programmers typically view the world only in terms of procedures and functions. Having said this... these days, for a number of folks, even the terms "procedure" and "function" are going by the wayside, being replaced by "object," but we digress...

Consider a program that makes use of four procedures that we will call pA, pB, pC, and pD. A very simplistic way of viewing things (ignoring loops and suchlike) is that the "arrow of time"!by which I mean the order of program execution!points from top to bottom as illustrated below:

Figure 7: A software program in C/C++ boasting four procedures.

?First Page?Previous Page 1???2???3???4???5?Next Page?Last Page

Article Comments - The MCU guy's guide to FPGAs: The so...
*? You can enter [0] more charecters.
*Verify code:


Visit Asia Webinars to learn about the latest in technology and get practical design tips.

Back to Top