Global Sources
EE Times-India
Stay in touch with EE Times India
EE Times-India > Embedded

Hardware, software implications of endianness

Posted: 14 Apr 2014     Print Version  Bookmark and Share

Keywords:software programmers  endianness  computing processor  compilers  CPU 

Embedded software programmers are familiar with the endianness characteristic of a computing processor, insofar as it refers to how bytes of a data word are ordered within memory.

Taking their name from Jonathan Swift's book Gulliver's Travels, big-endian systems are systems in which the most significant byte of the word is stored in the smallest address given and the least significant byte is stored in the largest. In contrast, little endian systems are those in which the least significant byte is stored in the smallest address.

So, depending on endianness, data types are stored differently in memory, which means there are considerations when accessing individual byte locations of a multi-byte data element in memory. In this article, we will review the concept of endianness from a software standpoint and then look at the implications of endianness for hardware IP block designers and device driver developers when they work with a complex system such as a modern System-on-Chip (SoC).

Today's SoCs integrate many hardware IP blocks; designers need to be aware of the order of bytes on the byte lanes of connecting buses when transferring data. In a system with several discrete hardware components—such as a host processor and external devices connected to it via a PCI bus, for example—the hardware components may support different endianness modes. Device driver developers need to make the data transfers among these hardware components endianness-proof.

Endianness effect in software
From a software standpoint, the 'endianness effect' comes into play when writing and reading data from memory. To fully understand the implications we need to explain the use of data types in embedded software.

All high-level programming languages support several data types. For example, C supports data types such as char, int, long, float, and so on, each having different memory storage length requirements for data elements of its type. The lengths of data types of C are part standard (such as defined by ANSI C) and part compiler implementation dependent. For example, one compiler may implement char data type to be one byte in length and an int to be two bytes in length. Another compiler may implement char data type to be two bytes in length and an int to be four bytes in length. To avoid confusion on lengths and to ensure portability across C compilers, embedded software programmers often define their own data types that explicitly give the number of bytes for the data type.

For example, the following may be defined:

The above definitions are specific to a C compiler/processor that implements int data type as four bytes long, short data type as two bytes long and char data type as one byte long. The software then uses these user defined types rather than C standard types. To make their software portable across different C compilers/processors, embedded programmers isolate these type definitions into a 'port' file. When the software needs to work on a new compiler/processor, only the port file needs to be redone, while the software written using the user defined data types remains unchanged.

To illustrate the 'endianness effect', consider the following section of code:

1 • 2 • 3 • 4 • 5 Next Page Last Page

Comment on "Hardware, software implications of e..."
*  You can enter [0] more charecters.
*Verify code:


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


Go to top             Connect on Facebook      Follow us on Twitter      Follow us on Orkut

Back to Top