Académique Documents
Professionnel Documents
Culture Documents
Board Emulator
Project Proposal
University of Essex
SURNAME : Paul Bedford
Emulator
Abstract
The paper describes in detail the various steps involved in designing and building an
ARM main board emulator as a M.Sc. project. The aim of the project was to design
and build a software emulator that would emulate all the functions of the ARM board
that is being used as a teaching aid in the laboratories. The project began with a
carefully thought out plan according to which it was divided into three sections, the
emulator GUI, the library functions and the communication system between the user
program and the emulator. The project has been completed using Winsock TCP
sockets for the communication and Qt Creator to build the emulator GUI and has
This project dissertation is in accordance with Examination Regulations 6.12 and 6.13.
Contents
ABSTRACT ........................................................................................................................ 1
CONTENTS ....................................................................................................................... 2
1. INTRODUCTION......................................................................................................... 5
1.1 OVERVIEW............................................................................................................................. 5
1.3 OVERVIEW............................................................................................................................. 5
2.4.1 Eclipse........................................................................................................................ 12
2.4.2 Qt Creator ................................................................................................................. 12
3.1.3 Design........................................................................................................................ 16
6. TESTING .................................................................................................................. 29
8. CONCLUSION .......................................................................................................... 32
9. REFERENCES ............................................................................................................ 33
1.1 Overview
The project began with the aim to build a graphical emulator of a custom ARM board
teaching aid for both students as well as staff. The ARM board consists of eight
LEDs, eight buttons and an OLED display that can be configured as a seven
with a motor may be attached to the board. The emulator would have to be able to
mimic the functions of the LEDS, buttons and LCD display exactly as on the actual
board. This has been achieved using C++ and Qt library functions.
The purpose of this document is to explain in detail the background, the necessity,
1.3 Overview
A general introduction, where a brief overview of the project including its purpose
A detailed system description which takes a more detailed look at the system,
A software methodology section which discusses the software model chosen with
A section that details the major setbacks and problems faced during planning
and implementation,
A testing section in which the high level testing results are discussed in brief and
The document ends with a list of references, a glossary of terms used in the
2. System Description
The idea behind the ARM board emulator is to emulate the various functions of an
ARM board that is being used in the University of Essex laboratories as a teaching
aid. These functions include the eight buttons that can be either ON or OFF (i.e. two
state), eight LEDs that can either be off, red, green or orange and an OLED display
that can be used to display text or graphics and can also be configured for use as a
The ARM board that is used by students in the laboratory is only available to be
used by students for a limited amount of time during the week. This might result in
using the ARM board emulator, students will be able to run and test their programs
at any time without having to be totally dependent on the availability of the physical
board. This will allow students to work on their assignments anywhere they want by
simply including alternate library files to their code and running a function to
establish connection to the emulator. This makes the entire process very easy and
straight forward. Wholesale change to the code will not be required. All the user
needs to do is change the header files that will allow them to connect to the emulator
The emulator will be perfect for students or staff who want to quickly test code that
they have written for the ARM board and either do not or cannot go to the lab to test
the code.
2.2 Assumptions
During the design phase of the system, it was assumed that the ARM board
emulator would only be used by students to test their codes for embedded systems
coursework, using the predefined functions to carry out the laboratory tasks and
To successfully implement the ARM Board Emulator, a large amount of back ground
reading and research had to be carried out. Due to a lack of prior knowledge, topics
such as networking and GUI programming had to be learnt from the very basics. The
following section summarises the topics that have been read about for the project.
2.3.1 Emulators
carry out the same functions, to run the same programs, and in essence, to behave
For this specific project, an emulation of the ARM board, rather than a simulation,
was ideal since it was not required to build a system which would replicate the
working of the actual processor [2][3]. If an ARM board simulator was to be built, all
the functions, including the processor would have to be simulated and that was not
In the long run, using an emulator will be much cheaper than purchasing new
hardware.
be made with relatively less effort than the effort it would take to modify an actual
board.
Software emulators are in general much more portable than the actual hardware.
of a device such as a mouse that manipulates and activates on screen images” [4].
The Graphical User Interface, or the GUI in short, is what the user will see and
interact with. A GUI allows users to interact with a program by making use of a
number of objects such pictures, icons, buttons, text boxes, etc. which accept data
from the user and relays this to the program to carry out a specified operation. The
alternative to using a GUI would be to use a command line interface. The problem
with using a command line interface is that it is not as user friendly as a GUI and
needs special practice and knowledge of the necessary commands for the user to
use the application effectively, while a GUI is much simpler and can be used by
The ARM board emulator GUI has been built using C++ and Qt Creator and has
been made to resemble the actual ARM board as closely as possible, so that the
user can use the ARM Board Emulator without too much difficulty.
are established and maintained between transmitting and receiving entities. Internet
Protocol (IP) is a protocol to handle addresses. Even though the protocol is called
TCP/IP, it is actually a full set of protocols including ARP, OSFP, ICMP, BGP/EGP,
2.3.4 Sockets
same machine, distribute information and allow access to centralized data easily [7].
Sockets can use two different methods of communication – TCP or UDP. UDP
stands for User Datagram Protocol and is not a secure method of data transfer.
When using UDP, the client does not explicitly connect with a server. Instead, the
client transmits data and assumes that the server receives it [8]. TCP, on the other
hand, only allows data transmission after a secure connection has been established.
Socket application program interfaces (APIs) are the network standard for TCP/IP. A
given an IP address and port number, will listen for an incoming connection on that
specific port of that specific IP address. The other end of the socket is called the
client. This is the end that wishes to connect to the server. To connect to the server,
the client needs the specific IP address and port number on which the server is
listening. If both the client and the server have the same IP address and port
number, then a connection can be established and data can be transmitted and
received between the client and the server until the connection is closed or broken.
Using sockets is a reliable and secure method of data transmission and results in
2.3.5 Multithreading
processor. All though the threads use the same processor, each thread may be
system can have multiple tasks running at the same time which improves efficiency
of the system when the code is executed on systems with multiple core CPUs [10].
2.4 Tools
After careful consideration of a number of different tools that could be used to carry
out the project, Qt Creator and Eclipse were selected as the most simple and
2.4.1 Eclipse
Eclipse is a Java based open source ‘Integrated Desktop Environment’ that can be
This is the tool that is used by students in the laboratory to run their code. Using
Eclipse would mean that they do not have to use another tool just to be able to
2.4.2 Qt Creator
Qt Creator is a cross platform IDE that uses the Qt GUI Application development
framework to allow users to build powerful GUIs [12]. Qt Creator was chosen for this
project because
Qt Creator comes with a lot of tutorials and documentation which makes it easy
The software model that has been chosen for this project is the waterfall model. This
various phases. This is mainly due to the simplicity of the model. Because only a
single person is going to be working on the project, the simplicity of the software
The waterfall model emphasizes a step by step approach to accomplish the target
3.1.1 Requirements
During the requirements gathering phase of the project, the following requirements
Build a clean, simple and efficient GUI application that would look and feel similar
LEDs, the buttons and the OLED display on the ARM board function.
Write library functions that will translate the embedded C code written by the user
into a control word that will carry out the specified functions on the emulator GUI.
Find a way to establish a connection between the emulator GUI and the user
3.1.2 Analysis
Each of the requirements stated above were carefully analysed and different
considered. Initially, Microsoft Visual Studio was considered as the tool that would
be used to build the emulator GUI, since it offered a number of built in options that
would be extremely useful for this specific project. Visual Studio also had the
advantage of having an excellent debugger built in. But after a lot of research, Qt
creator presented itself as a better tool. The reasons for choosing Qt Creator were
that it was much easier to use than Visual Studio, had a larger number of powerful
options that were specifically designed for GUI application development and also
Similarly, after extensive research, Microsoft’s Winsock was used to build the client
Windows MSDN websites, while Qt’s QtTcpSocket was used to build the server end
functions that the custom functions that were provided to students would
accomplish.
3.1.3 Design
The project design was kept as simple as possible. The project has been designed
in such a way that the emulator functions exactly how the elements of the actual
1. Custom library functions were written to generate a control word. These libraries
2. The library functions, when executed, would initialise the socket Client and
3. The Emulator GUI would replicate all the functions of the actual ARM board.
4. When executed, the emulator would initialise the socket server and begin to wait
5. Once a connection was established, the control word generated by the library
functions would be sent and received by the sockets, thus enabling the user to
3.2 Scheduling
The project schedule had been planned out across the summer term, i.e. from the
9th of June to the 20th of August 2014. The detailed Gantt chart can be found in the
attempt to mimic the working of the physical ARM board produced by Atmel that is
used in the University of Essex labs to teach embedded systems. Any code that is
written in eclipse, when run, will send an appropriately constructed control word to
the emulator based on which the emulator will respond with either an action or a
return value. The control word is generated and transmitted by using the custom
libraries that were written specifically for this project. These libraries must be
included in the original user code instead of the libraries provided in the lab. The
functions, when called, will establish a TCP socket connection with the emulator,
execute [15]. In our case, the compiler is used to compile the code written by
students. This is normally in C. The user code will typically contains library files that
allow the program to manipulate the ARM hardware. To use the emulator, these files
The library files contain functions that act as transmission and translation
components. When the user runs their program, a control word is created by the
functions and transmitted to the Emulator using the TCP sockets. The control word
is an integer array that specifies all the different operations that can be carried out by
the emulator. Based on the Function value, control is shifted between LEDs, buttons
1 LED functions.
2 Button functions.
If the function field has an array value 1, i.e. it is set to LED functions, the next two
array elements will denote the LED number and colour respectively.
ARRAY VALUE (LED) LED NUMBER LED COLOUR
1 LED 1 RED
2 LED 2 GREEN
3 LED 3 ORANGE
4 LED 4 OFF
5 LED 5 -
6 LED 6 -
7 LED 7 -
8 LED 8 -
9 ALL LEDs -
If the function field is set to an array value of 2, i.e. button functions, then the next
two array elements will represent the button number and the request type
respectively.
ARRAY VALUE
BUTTON NUMBER REQUEST TYPE
(BUTTON)
1 BUTTON 1 PRESSED
2 BUTTON 2 RELEASED
3 BUTTON 3 -
4 BUTTON 4 -
5 BUTTON 5 -
6 BUTTON 6 -
7 BUTTON 7 -
8 BUTTON 8 -
When the function field is set to 3, then the control word will control the seven
segment display. The next two array elements will hold the values of the digit
1 DIGIT 1 1
2 DIGIT 2 2
3 DIGIT 3 3
4 DIGIT 4 4
5 Decimal Point 5
6 - 6
7 - 7
8 - 8
9 - 9
0 - 0
The different library functions that have been implemented to be used for the
specified colour.
The emulator carries out all the functions based on the control word received from
the user and responds with button state if and when it is requested.
4.1.3 Seven Segment Display Functions
Emulators 7 segment
display.
value.
Future implementations of the project may include library functions to control the
OLED display.
4.1.4 Communication function
The client socket can be initialised and connected to the server socket at the
connection with the server that is listening to the port 8888 on the localhost.
4.2 Sockets
If the user was to run his code on the actual ARM board, communication from the
compiler to the ARM board would require a remote connection to the hardware from
the computer. Open OCD is an open source On-Chip Debugger which is used to
generate the electrical signals to the debug target to negate the lack of native
support from the debug hosts to connect with the target. In this case a JTAG adapter
is used.
For the user to connect to the emulator, TCP socket connections are used. A socket
acts as the server and waits for information from the client, i.e. the user to carry out
operations on the interface. The implementation of the client side of the socket
The Emulator interface has been designed to look and feel exactly like the actual
ARM board. It has eight check boxes which represent the eight two state buttons,
eight coloured text labels which represent the eight LEDs in each of their different
states, i.e. off, red, green or orange. It also has a text display and a seven segment
display unit. In addition to the 8 buttons, there is an additional button added which is
a ‘Release All’ button. This button may be used to release multiple buttons
simultaneously. This is to make the emulator’s button functionality exactly like the
Figure 7 is a snap shot of the clean and simple GUI that has been achieved.
Figure 7. The Emulator Interface
The emulator will have a software socket or adapter with which it can receive and send
5. Problems Encountered
A number of problems were encountered during implementation.
GUI programming was an entirely new concept that had to be learnt from the
basics. Using Qt Creator helped greatly because of the large number of different
tutorials and examples that are included. The Qt documentation was also very
helpful.
Basic networking, much like GUI programming, was a whole new experience and
problem, a Windows Registry fix solved the issue. According to the MSDN
website [16],
failed.
Another problem that had to be worked around was that on the actual ARM
Implementing this on the emulator GUI proved a challenge. The problem was
solved by using check boxes to represent the buttons and adding an additional
“Release All” button which would release all checked buttons immediately.
Finally, the only problem that hasn’t been solved at this time is the transmission
and reception of the control word as an integer array. The program works as
expected when single integers are transmitted, but breaks every time an array is
transmitted.
6. Testing
AS per the waterfall methodology, all code that was written was thoroughly tested.
As seen from the test results, with exception to transmitting and receiving the control
emulate all the functions of the ARM board that is used in the Embedded Systems
Laboratory at the University of Essex. Within the given time period, a number of
objectives were achieved, while a few points to be improved upon were also noted
The GUI for the emulator, including eight buttons with ON/OFF states, eight
The Library functions to control each of the GUI elements has been written and
tested successfully. A full list of the library functions written can be found in
A server socket has been successfully implemented into the emulator. The
server socket, when enabled, waits for a connection from a client on the localhost
A Winsock client socket has been successfully added to the library files that the
user will need to add to their program. This client socket will transmit the control
word generated by the library functions and send it to a specified port on the
localhost to connect and exchange data with the server socket of the emulator.
Even though the project implementation was largely successful, there are a number
not implemented. This can be done in the future if more time was available.
The two expansion boards – the audio board and the motor board, may be
emulated as well.
8. Conclusion
As stated earlier, the main objective of the project was to build an emulator that
could be used by students and staff to test their embedded programming code at
their convenience without having to go to the lab every time. To a certain extent,
given the limited time available, the objective has been achieved. Topics such as
networking, including socket programming and basic TCP/IP and GUI programming
had to be learnt from the basics and used for project implementation. Despite all the
[3] van der Hoeven, Jeffrey, Bram Lohman, and Remco Verdegem. "Emulation
Company. http://dictionary.reference.com/browse/GUI.
Howe. http://dictionary.reference.com/browse/multithreading.
[11] "Where did Eclipse come from?", Eclipse Wiki. Retrieved 16 July, 2014.
[13] Gomaa, Hassan. Software Modeling and Design: UML, Use Cases, Patterns,
http://en.wikipedia.org/w/index.php?title=Gdbserver&oldid=583885733,
[16] http://msdn.microsoft.com/en-gb/library/windows/desktop/ms740668.aspx,
The following code was based on code provided by Dr. Martin Colley and example
int ConnectToServer()
{
WSADATA wsa;
SOCKET s;
struct sockaddr_in server;
if (WSAStartup(MAKEWORD(2,2),&wsa) != 0)
{
printf("Failed. Error Code : %d",WSAGetLastError());
return 1;
}
else
{
printf("Initialised.\n");
}
//Create a socket
if((s = socket(PF_INET , SOCK_STREAM , 0 )) == INVALID_SOCKET)
{
printf("Could not create socket : %d" , WSAGetLastError());
}
else
{
printf("Socket created.\n");
}
server.sin_addr.s_addr = inet_addr("127.0.0.1");
server.sin_family = AF_INET;
server.sin_port = htons(8888);
return (0);
}
The code in the following section was generated using the Qt Creator GUI tools.