??? ???? ????
Login |
  • Why Register?
  • Download development tools
  • Create and track support tickets
  • Subscribe to resource updates
  • Access latest developer news
Register

XMOS Timing Analyzer Whitepaper

Development Tools:

XMOS Timing Analyzer Whitepaper
Version 1.0
This document explains how static timing analysis can be
used to determine whether timing-critical sections of code
when compiled and run on XMOS devices are guaranteed to
complete within their deadlines. It introduces the XMOS
Timing Analyzer tool, which can help you automate this task.
Publication Date: 2010/05/18
Copyright © 2010 XMOS Ltd. All Rights Reserved.

XMOS Timing Analyzer Whitepaper (1.0)
2/9
1
Introduction
To guarantee the correct behavior of real-time software running on embedded
processors can pose a significant challenge. Data-dependent control flow, where
execution times of many functions are dependent on the data inputs, means that
instruction sequences are hard to predict. In many systems, the presence of a
memory hierarchy complicates this problem further, requiring the state of all caches
and the system bus to be accurately modeled in order to predict the time of load and
store operations. Interrupt-driven I/O processing, in which external events can alter
execution flow at any time, can make it impossible to predict all possible states of
the machine and thus accurately time a section of code.
The traditional approach to verifying timing involves writing test benches to exericse
each function, for example by observing pin activity or counting instructions to
determine execution time. However, creating stimuli that cover all timing corner
cases may not be possible until the whole of the system is built, or even after the
product is deployed. This can significantly increase time-to-market and in the worst
case lead to a product recall.
XMOS devices can be programmed to respond to events instead of interrupts: event
handlers exist in the current context, which means no time is spent context switching.
As a result, response times are virtually zero, enabling many real-time interfaces to
be implemented. Events steer the execution through the code along well-defined
paths, and no uncertainty is introduced due to caches, buses or interrupts.
I/O
I/O
Interrupts
RAM
GPIO
INTC
CPU
CPU
Events
PORT
CACHE
RAM
Typical bus-based system
XMOS device
Figure 1: A typical bus-based system compared to an XMOS device.
The XMOS Timing Analyzer (XTA) allows you to determine the performance of code
compiled for any XMOS device. Using either the interactive GUI or a script, you can
specify the time in which sections of source code must be executed, for example the
time taken to handle an event. The tool identifies all corresponding paths through
the object and times them, using the worst-case time to determine a pass or fail
result. If the tool detects a timing failure, it produces feedback that helps you
optimize parts of your program until timing closure is achieved.
www.xmos.com

XMOS Timing Analyzer Whitepaper (1.0)
3/9
2
Ethernet MII Receive Specification
The Ethernet MII interface is an example of where it is advantageous to implement a
real-time interface in software. Using software allows early adoption of new hardware
standards and allows custom protocols to be implemented.
The waveform diagram below illustrates the operation of the MII receive protocol.
RXCLK
RXDV
SFD
SFD
RXD
SFD
SFD
preamble (5...5)
preamble (5...5)
(5)
(D)
DATA
DATA
CRC
(5)
(D)
1
-T
T
8
1
2
64 - 1500 bytes
4 bytes
Figure 2: Ethernet MII Receive Waveform Diagram
The signals are as follows:
· RXCLK is a free running clock generated by the Ethernet PHY.
· RXDV is a data valid signal driven high by the PHY during frame transmission.
· RXD carries a nibble of data per clock period from the PHY to the receiver.
The receiver is required to wait for a preamble of nibbles of values 0x5, followed by
two nibbles with values 0x5 and 0xD. It then inputs the actual data, which is in the
range of 64 to 1500 bytes, followed by four bytes containing a CRC.
When run at a rate of 100Mbps:
· The value of T1 is 320ns.
· The value of T2 is 1520ns.
www.xmos.com

XMOS Timing Analyzer Whitepaper (1.0)
4/9
3
Ethernet MII Receive XC Implementation
The XC language [1] provides extensions to C that simplify control over I/O and the
processing of events. An XC program that implements the MII receive interface is
shown below.
Program 1 XC Implementation of MII Receive Protocol
1
b u f f e r e d in p o r t :32 RXD
= X S 1 _ P O R T _ 4 A ;
2
in p o r t
R X D V = X S 1 _ P O R T _ 1 I ;
3
4
v o i d m i i R e c () {
5
6
R X D V w h e n p i n s e q (0) : > v o i d ;
7
w h i l e (1) {
8
int eop = 0;
9
10
# p r a g m a xta l a b e l " w a i t _ f o r _ s f d "
11
RXD w h e n p i n s e q (0 xD ) : > v o i d ;
12
...
13
do {
14
s e l e c t {
15
# p r a g m a xta l a b e l " w o r d _ r e c e i v e "
16
c a s e RXD : > w o r d :
17
// p r o c e s s w o r d
18
b r e a k ;
19
# p r a g m a xta l a b e l " r x _ d v _ l o w "
20
c a s e R X D V w h e n p i n s e q (0) : > v o i d :
21
eop = 1;
22
// i n p u t and p r o c e s s part - w o r d
23
s w i t c h (part word size ) { compute crc and error condition
}
24
s w i t c h (error condition ) { handle error
}
25
b r e a k ;
26
}
27
} w h i l e (! eop );
28
}
29
}
The main operations performed by this program are described by their line numbers
in the paragraphs below:
1, 2
The pins are mapped to the ports RXD and RXDV, and the data port RXD is
configured to convert a stream of data nibbles from the PHY into a stream of
words for input by the processor.
www.xmos.com

XMOS Timing Analyzer Whitepaper (1.0)
5/9
In main (not shown), the port RXD is synchronized to the clock signal RXCLK
and is configured to use a 1-bit port RXDV as a ready-in strobe signal that
causes data to be sampled only when the signal is high.
6
The program initializes itself by performing a conditional input that waits for
the signal RXDV to be low.
11
The program waits for the start of the next frame by conditionally inputting
the last nibble of the preamble (0xD).
14
The select statement is used to wait for an event on one of a set of ports
and respond to it. In this example, the processor waits for either the next
word of data from RXD (line 16) or for the data valid signal RXDV to go low
(line 20).
4
Timing the Ethernet MII Implementation
When compiled and run on an XMOS device, the Ethernet MII implementation must
execute fast enough to meet the MII timing specification. For 100Mbs Ethernet, the
following two timing requirements must be met:
· The processor must always be ready to input a word of data every 320ns (T1
in Figure 2), which means that the time to execute the innermost loop (lines
1618, 27, 1314) must be executed within this time.
· After detecting the data-valid signal going low, the processor must process the
last packet of data and be ready to detect the next packet's SFD nibble with
value 0xD (lines 2025, 2728, 711) within 1520ns (T2 in Figure 2).
Using the XTA GUI, shown on the following page, you can view the source code and
select which endpoints to time between. The XTA analyzes all paths between the
endpoints in the object code and displays them visually.
www.xmos.com

XMOS Timing Analyzer Whitepaper (1.0)
6/9
Figure 3: The XTA GUI
Analyzing the first route bewteen the endpoint labeled word_receive (line 15 in
Program 1) and itself identifies a single path. In the GUI, you can specify a timing
requirement of 320ns for this route, which the tool indicates is met with a green tick
next the the route name.
Analyzing the second route between the endpoints labeled rd_dv_low (line 19 in
Program 1) and wait_for_sfd (line 11) identifies more than one path. These paths
are due to branching within the body of the case statements (lines 23-24) that deal
with the CRC calculation and error cases. In Figure 3, these multiple paths are shown
graphically in the bottom panel of the GUI. The path with the best-case time is shown
in green, the worst-case time in red. In the GUI, you can specify a timing requirement
of 1520ns for this route, which the tool indicates is met with a green tick. Note that
the tool finds all possible paths and times them, providing 100% functional coverage
on timing.
The XTA tool can be used for more than just pass/fail testing. Structural code
views highlight timing hot-spots, and instruction-level views and traces can highlight
www.xmos.com

XMOS Timing Analyzer Whitepaper (1.0)
7/9
hardware resource contention. This information helps you focus on optimizing code
where it has the greatest impact. If a degree of slack is present when meeting the
timing requirements, you can use the XTA to determine how much the processor
frequency can be reduced, thereby saving power.
5
Closing Timing At Compile-Time
Having interactively specified the timing requirements for pairs of endpoints in the
program that need to execute in real-time, you can instruct the tool to generate a
script that automatically checks these requirements are met at compile-time. The
script generated for the MII code looks as follows:
a n a l y z e e n d p o i n t s w o r d _ r e c e i v e w o r d _ r e c e i v e
set r e q u i r e d - 320 ns
a n a l y z e e n d p o i n t s r x _ d v _ l o w w a i t _ f o r _ s f d
set r e q u i r e d - 1 5 2 0 ns
p r i n t s u m m a r y
The XTA reports the worst-case time for all routes as well as the slack or violation. In
the MII example, the output at compile-time is as follows:
P A S S ( r e q u i r e d 3 2 0 . 0 ns , worst - c a s e 1 8 0 . 0 ns , s l a c k 1 4 0 . 0 ns )
P A S S ( r e q u i r e d 1 5 2 0 . 0 ns , worst - c a s e 1 2 0 0 . 0 ns , s l a c k 3 2 0 . 0 ns )
6
Conclusion
This document has shown how static timing analysis can be used to time sections
of code that have real-time requirements. It introduced the XMOS Timing Analyzer,
which identifies the execution paths through a program and times them for a target
XMOS device. Timing requirements are specified either interactively using a GUI or
as a script. The XTA determines worst-case execution time, reporting timing failures
as compilation errors, or providing a guarantee that all requirements are met.
7
What to Read Next
This document provides only an introduction to the concept of static timing analysis
and the XTA tool. The following documents provide more in-depth information:
· Validating Timing Constraints with the XMOS Tools [2]: Provides a "hands-
on" tutorial that involves timing a UART implementation using the XTA.
www.xmos.com

XMOS Timing Analyzer Whitepaper (1.0)
8/9
An interactive version of this tutorial is also available in the XMOS Development
Environment (Version 10.4+).
· The XMOS Tools User Guide [3]: Includes a chapter on how to use many
features of the XTA GUI, which is released as part of the XMOS Development
Environment.
· Taking the guesswork out of timing in real-time software systems [4]: Pro-
vides background information on static timing analysis, an overview of the XTA
tool, and outlines future possibilities for the XTA technology.
You may also find information from the following online resources useful:
· The XMOS Corporate Website: http://www.xmos.com/
· The XMOS Community Website: http://www.xcore.com/
Bibliography
[1] Douglas Watt. Programming XC on XMOS Devices. XMOS Limited, Sep 2009.
http://www.xmos.com/published/xc_en.
[2] Douglas Watt. Validating Timing Constraints with the XMOS Tools. Website, 2010.
http://www.xmos.com/published/timingtut.
[3] Douglas Watt and Huw Geddes. The XMOS Tools User Guide. XMOS Limited, 2009.
http://www.xmos.com/published/xtools_en.
[4] Peter Hedinger and Edward Clarke. Taking the guesswork out of timing in
real-time software systems. Website, 2010. http://www.xmos.com/published/
xta-article.

www.xmos.com

XMOS Timing Analyzer Whitepaper (1.0)
9/9
Disclaimer
XMOS Ltd. is the owner or licensee of this design, code, or Information (collectively, the
"Information") and is providing it to you "AS IS" with no warranty of any kind, express or
implied and shall have no liability in relation to its use. XMOS Ltd. makes no representation
that the Information, or any particular implementation thereof, is or will be free from any
claims of infringement and again, shall have no liability in relation to any such claims.
Copyright © 2010 XMOS Ltd. All Rights Reserved. XMOS and the XMOS logo are registered
trademarks of XMOS Ltd in the United Kingdom and other countries, and may not be used
without written permission. Company and product names mentioned in this document are the
trademarks or registered trademarks of their respective owners. Where those designations
appear in this document, and XMOS was aware of a trademark claim, the designations have
been printed with initial capital letters or in all capitals.
www.xmos.com

Document Outline

  • Introduction
  • Ethernet MII Receive Specification
  • Ethernet MII Receive XC Implementation
  • Timing the Ethernet MII Implementation
  • Closing Timing At

Revision History

Revision Released Formats Supported Tools
Version: 1.0 September 15, 2010 download N/A