Professional Documents
Culture Documents
Bui Van De
HA NOI - 2014
Bui Van De
HA NOI - 2014
AUTHORSHIP
I hereby declare that the work contained in this thesis is of my own and has not been
previously submitted for a degree or diploma at this or any other higher education
institution. To the best of my knowledge and belief, the thesis contains no materials
previously published or written by another person except where due reference or
acknowledgement is made.
Signature:
SUPERVISORS APPROVAL
I hereby approve that the thesis in its current form is ready for committee
examination as a requirement for the Bachelor of Electronics and Communications
Engineering degree at the VNU University of Engineering and Technology.
Signature:
TABLE OF CONTENTS
Abstract.............................................................................................................vi
List of Figures...................................................................................................ix
List of Tables......................................................................................................x
List of Abbreviations.........................................................................................xi
INTRODUCTION.........................................................................................1
OVERVIEW OF EMBEDDED SYSTEM AND FPGA
TECHNOLOGY.........................................................................................................3
1.1
Abstract
In recent years, embedded systems have emerged at a faster rate and become
pervasive in many field from household products such as microwaves, to automotive
products such as air bags sensing and control, to industrial robots. The design of
embedded systems is now becoming increasingly difficult due to the tight constraints
on area usage, size, power consumption and performance. In addition to these
constraints, many embedded system developers are faced with tight time-to-market
deadlines. The product should be deployed when the demand for the product still
exists, if the demand ceases then the product would not yield any profit for the
company.
To develop these products, various tools and technologies have been used such as
microcontroller, DSP processor, ASIC, and FPGA. In terms of flexibility, the FPGA is
one of the most efficient methods. Informally, an FPGA can be thought of as a blank
slate on which any digital circuit can be configured in the field that is, after the
device has been manufactured, installed in a product, or, in some cases, even after the
product has been shipped to the consumer. This makes the FPGA device
fundamentally different from other Integrated Circuit (IC) devices. In short, an FPGA
provides programmable hardware to the embedded systems developer. FPGAs offer
a great deal to the embedded systems designer. They not only meet the complex and
demanding requirements of embedded systems that are becoming so universal today
but also offer a low-risk, quick time-to-market solution that designers can easily
modify when they need to make changes, fix bugs or create product derivatives at
some point in the future.
In this project we have tried to implement such powerful FPGAs in the design of
football match application. The aim of the project is to develop a 5-player soccer
system on multiple Xilinx FPGA boards using embedded processors. Besides making
us similar with FPGA technology, the project also makes us understand real-time
concepts like scheduling, handling shared resources and priority management and
some another typical embedded system requirements. The football match has been
succefully implemented on two client FPGAs (each for each football team) and a
server FPGA.
ii
Acknowledgement
This thesis was done at the Key Laboratory for Smart Integrated System (SIS
Lab), VNU University of Engineering and Technology (VNU-UET) under the
supervision of Assoc. Prof. Xuan-Tu Tran.
First of all, I want to give my sincerely thanks to the faculty members and
staffs of the Faculty of Electronics and Telecommunication, VNU-UET for their
enthusiasm to guide me to for the background of knowledge.
I would like to express special thanks to Assoc.Prof. Xuan-Tu Tran who
always guides me, points out the mistakes, and gives me the instructions and
comments during the time to realize this work. Without his supervising, I would have
many difficulties to finish this thesis.
I also thank all members of the SIS Lab who always facilitate me to do this
thesis, answer my questions in a familiar way and share their experience for me as
well as make me feel comfortable and better in studying.
Finally, I want to give the best thank to my parents, my relatives and my
friends who always encourage, take care me during the studying and researching
period.
Sincerely,
Bui Van De
iii
List of Figures
Figure 2-1 System overview.........................................................................11
Figure 2-2: Hardware architecture...................................................................13
Figure 2-3: Football ground.............................................................................14
Figure 3-1: Base System Builder Wizard.........................................................19
Figure 3-2: Name of My Project......................................................................19
Figure 3-3: Select Target Board.......................................................................20
Figure 3-4: Select Processor to Be Used..........................................................20
Figure 3-5: Configure the processor................................................................21
Figure 3-6: Add or Remove External Peripheral..............................................22
Figure 3-7: Summary Screen...........................................................................22
Figure 3-8: Add Peripherals.............................................................................23
Figure 3-9: Making Bus Connection................................................................24
Figure 3-10: Assigning Addresses....................................................................24
Figure 3-11: Parameterize IP instances............................................................25
Figure 3-12: Connecting Ports.........................................................................25
Figure 3-13: Make Pin Assignments................................................................26
Figure 3-14: Final Screen.................................................................................26
Figure 3-15: Export & Launch SDK................................................................27
Figure 3-16: EDK Start Screen........................................................................28
Figure 3-17: Xilinx Board Support Package Selection....................................29
Figure 3-18: Board Support Packet Settings....................................................30
Figure 3-19: Move_to_target function.............................................................32
Figure 3-20: Dan Bong.....................................................................................33
Figure 3-21: Goal Function..............................................................................36
Figure 3-22: Formation....................................................................................37
Figure 4-1: Build Project..................................................................................41
Figure 4-2: Program FPGA..............................................................................42
Figure 4-3: Hardware System..........................................................................43
Figure 4-4: Simulation results..........................................................................44
iv
List of Tables
Table 2-1: Initial pack......................................................................................15
Table 2-2: Update packet..................................................................................15
Table 2-3: Information packet from server to clients.......................................16
Table 3-1: Distance and corresponding speed of player 1...............................34
Table 3-2: Relationship between delta and direction of player 1.....................35
List of Abbreviations
ASIC
BSB
DSP
EDK
FPGA
GPIO
HDL
IC
Integrated Circuit
IP
Intellectual Property
OS
Operating System
VGA
XPS
INTRODUCTION
vi
The scope and role of embedded systems are continually expanding. For example in
2003, there was an average of 8 billion embedded programmable components
worldwide. This number was doubled in 2010, or three embedded devices for every
person on earth. This rapid proliferation is predicted to rise to 24.6 billion multiprocessors based embedded systems by the year 2020[3]. Therefore, learning to
design such complex and diverse embedded computing system has become very
important.
Nowadays, designing real-time embedded systems is a difficult task. The first
problem is
that
smaller. This will lead to new developments taking place more frequently to replace
the outdated products. The second demand is that the complexity of the embedded
system is rapidly increasing. With this increase in functionality and complexity of
systems, the embedded system design cycle may be longer and require more time and
manpower. The consumers demand for increasing functionality translates directly
into the increased complexity of the embedded system on a chip. FPGA technology
may alleviate the complexity gap problem and assist with the current trends in the
embedded system market.
Various tools and technologies have been used: microcontroller, DSP processor,
ASIC, and now FPGA. A key question is why FPGA should be used instead of
microprocessors, microcontrollers and ASICs in designing embedded system. The use
of FPGAs (Field Programmable Gate Arrays) and configurable processors is an
interesting new phenomenon in embedded development. The functionality of the
FPGA can be customized in the field. The ASIC cannot be changed after a certain
point in the design process is passed. The disadvantage of ASICs is that the designing
and building of the device is very time-consuming and expensive. The final design
created for the ASIC cannot be modified without going through the long process of
development again. FPGAs are of great interest when it comes to prototyping a
system due to the efficient. The development of a prototype should be efficient in
order for the final product to be marketed quickly.
In this report, we describe our process in handing a real-time embedded system using
FPGA technology . The project develop a 5-player soccer system on multiple Xilinx
FPGA boards using embedded processors. . The system comprises of two clients
vii
control players and one server to referee and display the game in real-time. we have to
design the hardware architecture of the embedded system and the software for the
strategy to control how to move the players in response to the position of all players
and the ball. They also develop a server to communicate with the two teams and
display the progress of the game on an attached VGA monitor. Besides making us
similar with real-time concepts like scheduling, handling shared resources, priority
management and the constraints in a typical embedded system, the project also makes
us understand the process in design embedded system in FPGA technology using
Xilinx tool (Embedded Development Kit 12.1).
This report is organized as follows. Chapter 1 gives a brief overview about embedded
systems and its basic concepts, FPGA technology are also discussed in this chapter.
Architecture of the system and introduction of the task of each component will be
introduced in chapter 2. More specifically, this section will answer for the question
The system consist of which peripherals and how they are works with each other.
Chapter 3 we are going to talks about hardware design process using Xilinx Platform
Studio tool. This part also discuss about the software design. We are going to talks
about some functions server for displaying and simulating the football match. Chapter
4 concludes the report with a discussion on the achievements from this project and
give the near future works which far related to the main topic.
viii
Chapter 1
components of the embedded system are similarly chosen, so as to lower the manufacturing
cost.
Some systems are mission critical systems which are hard real-time systems whose failure
can cause catastrophic results. The best way to deal with this situation is the use of Real-time
Embedded systems. In most of the real-life applications, real-time systems often work in an
embedded scenario and most of the embedded systems have real-time processing needs. Such
software is called Real-time Embedded Software systems.
In our project we went for the design of such kind of embedded systems by using an FPGA as
our main processing block and implementing the characteristic features of an FPGA in the
development of single purpose specifically designed embedded platforms.
FPGA chip adoption across all industries is driven by the fact that FPGAs combine the best
parts of ASICs and processor-based systems. FPGAs provide hardware-timed speed and
reliability, but they do not require high volumes to justify the large upfront expense of custom
ASIC design. Reprogrammable silicon also has the same flexibility of software running on a
processor-based system, but it is not limited by the number of processing cores available.
Unlike processors, FPGAs are truly parallel in nature, so different processing operations do
not have to compete for the same resources. Each independent processing task is assigned to
a dedicated section of the chip, and can function autonomously without any influence from
other logic blocks. As a result, the performance of one part of the application is not affected
when we add more processing.
changes to FPGA designs is negligible when compared to the large expense of repining an
ASIC.
Reliability: While software tools provide the programming environment, FPGA
circuitry is truly a hard implementation of program execution. Processor-based systems
often involve several layers of abstraction to help schedule tasks and share resources among
multiple processes. The driver layer controls hardware resources and the OS manages
memory and processor bandwidth. For any given processor core, only one instruction can
execute at a time, and processor-based systems are continually at risk of time-critical tasks
preempting one another. FPGAs, which do not use OSs, minimize reliability concerns with
true parallel execution and deterministic hardware dedicated to every task.
Long-term maintenance: As mentioned earlier, FPGA chips are field-upgradable and
do not require the time and expense involved with ASIC redesign. Digital communication
protocols, for example, have specifications that can change over time, and ASIC-based
interfaces
may
cause
maintenance
and
forward-compatibility
challenges.
Being
reconfigurable, FPGA chips can keep up with future modifications that might be necessary.
As a product or system matures, we can make functional enhancements without spending
time redesigning hardware or modifying the board layout.
1.3. Summary
This chapter briefly represents about real time embedded system concepts and it also gives an
introduction to FPGA technology .The advantages of using FPGA in real time embedded
system design are introduced in this chapter. However, more detail about design process will
be talk in next chapter.
Chapter 2
SYSTEM OVERVIEW
Player movement of
team B
- Speed of player
- Direction of player
Player movement of
team A
- Speed of player
- Direction of player
Information
- Player position
- Ball position
- Goal or fault information
Figure 2-1: System overview.
A, Server tasks
The server carries out the tasks that are expected of the referee and simulate the process of
the game. Details of these tasks are provided below.
- Receive initial player co-ordinates from clients. In the initial time of the game start, clients
send initial position to the server and this information has to be processed by the server to
sure that none of player has the same position with other.
- Receive player movement updates from team - no positions, only speed and direction.
- Receive 'kick' information from the teams. When a player is close enough to the ball, it may
want to kick the ball in a particular direction. This information has to be received and
processed by the server.
- Send ball's position, direction and speed of movement.
- Send teams players' positions. Please note that the speed and direction of players is not sent
by the server since that may reveal the strategy of the other team. The server only sends the
information that is generally available to the other team in a real game.
- Referee the game. Server decides is the goal valid or not and server also makes some
punishment if player breaks the rule.
- Display the field and the flayers moving at 25Hz. The physical laws have to be respected by
the server as well. Some physic theories are going to process when a collision occurs.
B, Client tasks
- Send initial co -ordinates for all players. In the initial time of the game start, clients send
initial position to the server. If collision occurs clients will send initial position again.
- Send player movement updates. It is important to note that the client does not send the
actual positions of the players during the game, as this may result in some unrealistic
movements, e.g. the client may move a player from the center of the field to near the goal
instantly. The client, therefore, only sends the direction towards which the player intends to
move and the speed at which the movement is desired.
- Receive position of ball and players of both teams.
- Develop strategy for player movement by considering position of ball and all players.
* UART(Lite)
* GPIO
* Timer/Counter
Number of bits
1 initialize packet
0 team A
Player ID
X_position
Y_position
1 team B
4 bits
10 bits
10 bits
Number of bits
0 update packet
1 kick
Team ID
0 movement
0 team A
Player ID
Direction
Speed
1 team B
4 bits
4 bits
4 bits
Number of bits
4 bits
1 control
Team ID
Player/ Ball
1 bit
X_position(ball) 10 bits
Y_position(ball) 10 bits
Player ID
4 bits
X_position(player) 10 bits
Y_position(player) 10 bits
Speed
4 bits
Team ID
0 team A
1 team B
1 Foul
0 Goal
2.3. Summary
This chapter has represented the system overview. Next chapter will present the process in
design hardware platform using Embedded Development Kit 12.1 Tool.
Chapter 3
SYSTEM DESIGN
Once the system is generated, we will see the above screen. Now we add external peripheral
to the system. For this project, we require the peripherals: DDR_SDRAM, xps_intc_0,
Buttons_4Bit, , LEDs_8Bit, xps_timer_1, RS232_DCE, RS232_DTE.
That is the process for adding GPIO intellectual property core. We will do the same for the
other IP core. Once finish adding IP, we will see the above screen.
To generate the hardware, we can select the Generate Bitstream from the menu bar or the
toolbar. This will take some time to complete. We have successfully completer hardware
design on FPGA. We can see that, just some click we have successfully build a hardware for
football match demonstration system. Software design will be described in next.
After the Workspace is launched, we will see the screen for choosing the workspace folder to
be same as where our hardware system is located for simplicity. Once the SDK is launched,
we can see the following screen
3. From the Board Support Package OS drop-down list, select the type of board support
package to create. A description of the platform types displays in the box below the
drop-down list. In this field, we choose Xilkernel ( Xilkernel is a simple and
lightweight kernel that provides POSIX style services such as scheduling, threads,
synchronization, message passing and timers. The kernel requires a programmable
timer that is either built-in or attached to the processor as a peripheral)
4. Click Finish. The wizard creates a new software platform and displays it in the SDK
Navigator pane.
Systmr_dev : xps_timer0
Sysmr_freq : 50000000
Systmr_interval : 100
Config_time : true
Stdin: RS232 DCE
Stdout RS232 DCE
Sysintc_spec : xps_intc_0
We still have to configure the thread management and scheduling parameters of the OS as
well. Set the following configuration:
Config_pthread_support : true(default)
Config_sched : true(default)
Sched_type : SCHED_PRIO
n_prio
max_readyq : 10(default)[3]
: 32(default)
In the main.c file, we will see a call to the XilKernel called xilkernel_main () in the
function main. When CPU starts executing this kernel, the functionmain_thread() in
the source code has to start execution. We need to configure a thread that starts this
function in Xilkernel. To do this, under the subsection config_pthread_support, select
static_pthread_table and then do a single click on its Current Value space. A window
opens up where we will add the thread calling function to be ((main_thread, 0)). The
numeric digit 0 after the comma is used to set the priority of function main_thread
(). Setting the priority to be 0 ensures that this thread gets the highest among all
threads. By doing these settings, we ensure that main_prog() get executes first and
thus can start new threads as required.
We have now completed configuring the system for priority scheduling. Now we
develop a program using Xilkernel. This program will have three threads.
-
Strategy thread: Strategy thread will generate strategy for players by controlling
speed and direction of them. Each player has their own different strategy
.However, they have to communicate with other players to get the final purpose
kick a goal. Strategy thread will read the coordinate pair of all player and ball and
return the speed, direction of players.
Simulation thread: Simulation thread will check if player came into collision with
ball or player. Simulation thread will read the coordinate pair of all player, ball
and if collision is occurred this thread will return the new speed, direction of
players to avoid two players or players and ball move on top of each other.
Display thread: Display thread will display the game. It will read the position and
direction of players, ball and draw a color filled circle, of radius 7 pixels for
players and 5 pixels for ball, with its center located at coordinate (x, y) into
screen (620x480).
VGA_U32 y
Return
Return integer number demonstrate that the function work correctly or not.
This function is used to move player to any position in the football ground. The algorithm of
this function will be described following.
First of all, we calculate delta_x and delta_y between the coordinate of target and the
coordinate of player .From that function is divided into four cases corresponding to four
position of ball compare with player. If delta_x =0 or delta_y =0, player move in one of 0, 4,
8, 12 directions until it reach the target coordinate. If delta_x # 0 and delta_y # 0, and
delta_x==delta_y, player move in one of 2, 6, 10, 14 directions until it reach the target
coordinate. If delta_x # delta_y. We will divide the movement of player into two parts. We
compare the distance of x coordinate and y-coordinate between player and the target position
(delta x, and delta y) to decide the first target and move in one of 2, 6, 10, 14 directions until
it reach the first target and move in one of 0, 4, 8, 10 until it reach the final target.
For example, we are going to talk one of those four cases- ball stays in the IV quadrant
compare with player.
Case 1: In figure 4-case1, if the target position is in one of 4 direction players will go directly
to the target
Case 2: In figure 4-case2, if the target position isn't in one of 4 direction player. We will
divide the movement of player into two parts. As an example in figure 5 we will go to the 2direction until the y-coordinate value of player equal to y-coordinate value of ball and the
second part, we will go to the 0 direction until the x-coordinate value of player equal to xcoordinate value of ball.
Parameters
int player_num : define the player will do this action
VGA_U32 x
Return
Return integer number demonstrate that the function work correctly or not.
This function is used to dribbling to x target position in the football ground. By kicking the
ball will small force and following the ball, the ball will always in controls of player. The
algorithm of this function will be described following.
First of all, we check three forward direction of player to find out any obstacles-player.
If there arent any obstacles-player in the 0 direction, player will dribble in the 0 direction. If
there are obstacles-player in the 0 direction, and there arent any obstacles-player in the 2
direction player will dribbling in the 2 direction. If there are obstacles-player in the 0 and 2
direction, and there arent any obstacles-player in the 14 direction player will dribbling in the
14 direction. The figure following describe this function.
int player_num2: the player target who will get the ball from player_num1.
Return
Return integer number demonstrate that the function work correctly or not.
The main task of this function is to pass the ball. Player1 will calculate, estimating and take
action to pass the ball as closest as possible to player2.
The algorithm of this function will be described following.
First of all, we will calculate the distance between player1 and player2. From this number, we
can find out the force of player1. Table 3-1 shown us the relation between distance and the
speed of player1.
Player 1 speed
Distance >=450
45
15
After that, we calculate delta_x and delta_y between the coordinate of player2 and the
player1. From this number, we can get the direction of player1 as the table 3-2
player[player_num1].dir
if (2*delta_x <delta_y)
12
if (2*delta_x <delta_y )
if ((delta_x >= 0) && (delta_y <= 0)) {
14
Sum of two elements: force and direction of player1 will kick the ball move as closest as
possible to the player2.
3.2.1.4 Goal
int goal3(int player_num)
Parameters
int player_num1 : define the player will do this action.
Return
Return integer number demonstrate that the function work correctly or not.
This function read the coordinate of player and calculates the best suitable direction and force
to kick the ball to the goal. The algorithm of this function will be describe following
If player.y_pos>=170 && player.y_pos<=230 player will kick the ball in 0 direction. Else if
player.y_pos <170 player will kick the ball in 2 direction. Else if player.y_pos>230 player
will kick the ball in 14 direction. The algorithm of goal function is shown in Figure 3-20.
1 goalkeeper.
2 defender and also midfielder
2 attacker
3.2.1.6 Defender
int cau_thu_so_2(int player_num, int player_num2)
Parameters
zero. When the player move near goal line player[player_num].x_pos > 620 PLAYER_RADIUS or player[player_num].x_pos < 20 + PLAYER_RADIUS the delta_y
coordinate of players will equal to zero. We make sure that all players will move in football
ground area.
- When the collision occurs between two players. If a moving player comes in contact with a
stationary player, the moving player will increase direction to. In the case collision occurs
between two moving player, we calculate the delta direction between them. If delta_dir ==8,
each player will increase direction to 2 to avoid player move on top of another. If delta_dir!
=8, player with smaller direction will continue going and player with bigger direction will
stop until collision is no longer occurs. After collision, all players will get the initial speed
and direction.
When a moving player comes in contact with ball (delta <=15=5+7+3) player have full
permissions to control the ball.
3.2.2.2 Ball
When the moving ball comes in contact with side line or goal line or player the perpendicular
speed of the ball is reversed.
When a moving player comes in contact with a stationary ball, the ball gets twice the speed of
the player, and follows the player's direction. Kick is only allowed in the front direction of the
player. i.e. 8 or 9 out of 16 directions. The ball gets the new velocity and the player retains the
old velocity.
Ground Friction - This reduces speed of ball 10 pixels per sec per sec.
int vacham
3.3 Summary
This chapter focuses on the implementation of the proposed design in both hardware and
software. Hardware has been designed and built successfully in Spartan 3E kit. Software has
been developed and gotten some basic achievement.
Chapter 4
We build an application by right click on it and select Build Project. This will create an
*.ELF file (executable and linkable format).This file can be run on the Microblaze just like
*.EXE files on Personal Computer. So build the soccer application project like Figure 4-1
below.
We download the bit stream to the FPGA (or program the FPGA). Firstly, we need to connect
PC to the FPGA board using the programming cable. In this case, the programming cable is
the USB cable given with the kit. Secondly, we need to connect the VGA port of monitor to
the VGA of the FPGA board so as to observe the results from the FPGA board. Now I will
download my program by selecting Program FPGA and then click Program as shown in
Figure 4-2 below.
CONCLUSION
From smart phones to medical equipment, from microwaves to antilock braking systems
modern embedded systems projects develop computing machines that have become an
integral part of our society. However, designing an embedded system nowadays becomes
quite challenging because of the increasing complexity as well as real-time requirements.
Especially, many embedded system developers are faced with tight time-to-market deadlines.
The product should be deployed when the demand for the product still exists, if the demand
ceases then the product would not yield any profit for the company. FPGA technology is an
effective solution for designing embedded system in this present age. It not only meets the
requirement of complexity, but it also helps us to reduce design time, thereby reducing
production costs and time to market. In other words, FPGA technology enhances market
competitiveness of the product [7].
In this work, I designed real-time embedded systems for demonstrating a football match 5player. Thereby, I understood the process of designing an embedded system using Embedded
Development Kit 12.1 tool kit of Xilinx. In next steps, I will finish some remain module such
as UART, TIMER and develop another strategy for team two. After that, I will hold a
competition between two teams to find out which team has a better strategy? . Further, the
project can be developed to a simple football game using keyboard controls.
References
[1]
[2]
http://www.xilinx.com/products/design-tools/ise-design-suite/index.htm .
Xilinx Inc., Products: Spartan-3E, Website:
[3]
http://www.xilinx.com/products/silicon-devices/fpga/xa-spartan-3e/index.htm.
Wiki.nus, Real-time Embedded Systems Labs Homepage:
[4]
http://wiki.nus.edu.sg/display/ee4214
Bbc.vnu.edu.vn, Real-time Embedded Systems Course
[5]
[6]
http://bbc.vnu.edu.vn
Final_report_v2, K54D University of Technology and Engineering.
B. Daya, Rapid pototyping of embedded systems using field programmable gate
[7]
[8]
[9]