Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

Embedded Systems

Programming High-Performance DSPs: Part 3


In programs where the stack is being used, there are other questions that must be answered. The compiler must decide what variables to put on the stack (which take longer to access) and which variables to put in the fast on chip registers. Sometimes the compiler cannot tell which variables should go where. The compiler will decide to not even bother trying to pipeline loops that contain too many variables. In cases like that, it may make sense to break up the loop into smaller loops that will enable the compiler to pipeline each of the smaller loops (Figure 14).


Figure 14. Breaking up larger loops into smaller loops may enable each loop to be pipelined more efficiently.

Software pipelining does not happen with careful analysis and structuring of the code. For example, loops that do not have enough processing will not be pipelined. On the other hand, loops that have too much processing will not be pipelined because the loop body will exhaust the available registers! Also, function calls within a loop will not be pipelined. Instead, if you want a pipelined loop, replace the function call with an inline expansion of the function.

One of the drawbacks of pipelining is the disabling of interrupts. An interrupt in the middle of a fully primed pipe destroys the synergy in instruction execution. The compiler will protect a software pipelining operation by disabling interrupts before entering the pipelined section and enabling interrupts on the way out (Figure 15). This means that the price you pay for the efficiency in software pipelining is paid for in a non-preemptible section of code. The programmer must be able to determine the impact of sections of non-preemptible code on real time performance.


Figure 15. Interrupts are disabled during a software pipelined section of code

Embedded CPU Power Consumption
Given the proliferation of portable embedded devices, power consumption has become almost as important as execution time and memory use, and in some cases, the most important parameter to optimize in an embedded system. Most modern CPUs are designed with power consumption in mind to some degree. Many embedded processors now include features such as run-time power modes that are used to scale power consumption. One of these modes is referred to as the "idle mode". In idle mode the instruction-executing portion of the processor effectively powers down. Other parts of the processor including the peripherals and interrupt logic remain powered on. While the processor is waiting for something to happen as opposed to the processor actively executing instructions [1].

Speaking of power, it is important to distinguish between power and energy. Roughly speaking, heat depends on power consumption, while battery life depends on energy consumption. Power is energy consumption per unit of time. In processor design, power consumption is proportional to the square of the supply voltage, so the lower the supply voltage the better from a power perspective. More toggling means more activity which means more power. The goal of low power design and programming is to minimize this activity whenever possible. Another form of power consumption, leakage, deals with basic circuit characteristics, and can be eliminated by disconnecting power [2].

There are several CPU power saving strategies available to the embedded system designer. These include [2]:

  • Reducing the power supply voltage.
  • Running at a lower clock frequency.
  • Disabling functional units with control signals when not in use.
  • Disconnect parts from power supply when not in use.

There are two main power management styles used by embedded programmers:

  • Static power management: this approach does not depend on CPU activity. An example of this style is user-activated power-down modes.
  • Dynamic power management: this approach is based on CPU activity. An example of this approach is disabling functional units

The embedded designer must keep in mind that there are also power down costs. Power down costs include factors such as the time to enter and exit the mode and the energy consumed by doing this. The designer must determine if going into a power-down mode is worthwhile. One way to make this determination is to model the CPU power states with power state machine.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.