Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 67

WEB-BASED FPGA LAB

To provide access to Field Programmable Gate Array (FPGA) remotely via website.

BE (CIS) PROJECT REPORT

BY

TAYYABA ADNAN

Department of Computer and Information Systems Engineering


NED University of Engg. & Tech.,

Karachi – 75270

WEB BASED FPGA LAB


To provide access to Field Programmable Gate Array (FPGA) remotely via website.

BE (CIS) PROJECT REPORT

GROUP BY

TAYYABA ADNAN (CS-003)

SYEDA UROOJ FATIMA (CS-059)

FATIMA QAISER (CS-023)

AQSA QADEER (CS-050)

BATCH: 2010-2011

PROJECT ADVISOR

SYED JASEEM UD DIN (INTERNAL ADVISOR)

08, NOVEMBER, 2014.

Department of Computer and Information Systems Engineering


NED University of Engg. & Tech.,

Karachi – 75270

ABSTRACT
A remote laboratory system that allows performing experiments controlled across the

Internet via web interface as well as locally in the classroom. The system has been developed

for courses of advanced digital design and signal processing using complex Field

Programmable Gate Array (FPGA) platforms. It allows clients full access to laboratory

equipments, advanced software licenses, and FPGA platforms remotely using any common

web browser and standard remote desktop interface. The system consists of SPARTAN3 FPGA

Board (XStend with XSA-3S100 FPGA mounted atop it), MEGA Arduino Board and a camera

for live video streaming. All the components work together with the LINUX software running

on the PC simultaneously.
ACKNOWLEDGEMENTS
CONTENTS
S.No. Page No.

1. INTRODUCTION 1
1.1 COMMUNICATION VIA WEBSITE 3
1.2 SWITCHES 3

2. WEB DEVELOPMENT 4

2.1. LANGUAGES USED


5
2.1.1 HTML 6
2.1.2 CSS 6

2.2. WEBSITE LAYOUT 7

2.3. PHP WEBSITE


7
2.3.1 PHP WEB FORMS 8
2.3.2 BASIC FUNCTIONALITY OF PAGES 11
2.3.2.1 PHP PAGES 11
2.3.2.2 HTML PAGES 15

2.4 DATABASE 20
2.4.1 XAMPP 21
2.4.2 WEBSITE AND DATABASE CONNECTION 21
2.5 DEPLOYMENT OF WEBSITE 23

3. FILE UPLOADING 27

3.1. FILE UPLOADING 27


3.2. FILE CREATION
28
3.3. FILE CHECKING
29
3.4. FILE TRANSFER
30

4. COMMUNICATION OF WEB SWITCHES WITH FPGA INPUTS 34

4.1. PHP WEBSITE


35
4.2. ARDUINO PROCESSING 35
4.2.1. WHY ARDUINO MEGA? 36
4.2.2. PROGRAMMING THE ARDUINO 37
4.3. FPGA CONNECTION AND PROCESSING
41

5. LIVE STREAMING OF OUTPUT 44

5.1. WHERE IS THE OUTPUT DISPLAYED? 44


5.1.1. HOW IS THE OUTPUT DISPLAYED? 46
5.2. USTREAM 48
5.2.1. GETTING THE EMBED CODE FROM A USTREAM 48
PLAYER
5.2.2. USTREAM DASHBOARD EMBED PAGE 49

6. CONCLUSION 52

Appendix A: name of first appendix

Appendix B: name of second appendix


Appendix C: name of third appendix

References

Bibliography
-1-

CHAPTER-1

INTRODUCTION
This report signifies the use of costly hardware via website for complex computation.

Web based FPGA lab is a platform through which access of expensive FPGA can be easily

done via website and result can be seen through the live video streaming. A Field

Programmable Gate Arrays (FPGA) is a logical board that contains memory called

‘Programmable Logic’. These FPGA boards can be programmed to perform multiple

functions which include basically gate functions (such as AND, OR, XOR) or more

complicated functions such as decoders or encoders. They are mainly used for educational

purposes but can be used to simulate very complex circuits to see the behavior that the circuit

would cause through live video streaming. The great thing about FPGA boards is that you can

create a circuit and then manipulate the input using switches, buttons, or changing a wave

frequency. The most common language used to simulate circuits on a FPGA logic board is

called Very-High-Speed Integrated Circuits (VHSIC) hardware description language; VISIC

HDL or VHDL for short. VHDL code can be compiled and uploaded to an FPGA board using

Arduino board (hardware) and LINUX (software). After the VHDL code is dumped, the

FPGA can respond to input and give output based on the VHDL code. For student use, an

FPGA board is very useful in actually seeing how circuits are designed and tested. Using

VHDL, a student can design a circuit that can do pretty much anything. However, the student

might never see their design in action. Using an FPGA board will enable the student to

compile and upload their creation onto a physical FPGA board and see what their circuit does

when given inputs or conditions are manipulated, and this is viewed through video streaming
capturing the changes in FPGA board. Using an FPGA board can lead to further

understanding of hardware circuit design and implementation, it can even lead to a circuit that

-2-

performs some useful high-level function. More and more advancements are taking place

towards the development of complex circuits and their results.

FLOW DIAGRAM
-3-

1.1 COMMUNICATION VIA WEBSITE

The reason we are creating a web based FPGA lab is to make it easier and more

readily available for a student to learn the VHDL language and see it in action. For a general

overview of how we will attempt to do this is to create a website that will enable the student to

upload their VHDL code to a server, compile their code and output any errors or warnings,

and finally execute the program on an FPGA board. The website will display output from a

webcam to see exactly what is happening on the FPGA board. In this way, it will be as if the

student is actually in front of the FPGA board manually doing everything to prepare the FPGA

board for production.

1.2 SWITCHES

To get a little more in-depth to what an FPGA actually is we will need to look deeper

into what a programmable switch is. As stated earlier, an FPGA is a board that contains

programmable logic; these programmable switches, in junction, make up what we call

programmable logic. The FPGA has many paths to many other switches or small circuits that

are by default turned off; therefore the FPGA routing is depicted as unsegmented. Whenever

two wires intersect, there is a programmable switch at that junction. That programmable

switch enables the wires to connect to any number of adjacent channel segments. Based on

what the programmable switches do, the routing in the FPGA can create complicated

pathways that simulate circuit designs. In this way, any combination of switches or circuits

can be made using only the programmable switches at the junctions in wires.
-4-

CHAPTER-2

WEBSITE DEVELOPMENT

A website used as a source of communication between client and server, helps in

minimizing the need to be present at the laboratory where FPGA is available. Taking the

example of an educational environment, the students have to compile and upload their code to

the FPGA, and then tweak or change that code outside of the FPGA lab again and again. So,

for each student, developing one circuit would most likely take multiple trips to the lab to

develop fully. Because of such factors physical lab method creates many problems with the

amount of resources available such as scheduling, space for students, and multiple terminals

setup dedicated to FPGA boards. This remote FPGA lab would need to be accessed from

anywhere quickly and frequently which means there would need to be more FPGA ‘terminals’

that students can access. Therefore, having the lab web-based will enable the student to login

from anywhere to upload their code and see the result of their compiled circuit. It would also

let the frequency of students that use a single FPGA board increase because the amount of

time used in one terminal would only be the amount of time it takes to compile and upload the

VHDL code and hence it is preferred to use a website for such conditions.
-5-
2.1 LANGUAGES USED

For the development of the website, the following languages have been used:

 HTML

 CSS

 PHP

-6-

For building the Web pages, the above two languages, that are HTML (the Hypertext

Markup Language) and CSS (Cascading Style Sheet), are the main technologies. The

structure of the page is provided using HTML and the virtual layout for this website is

provided by CSS. Both, HTML and CSS are the main source for building Web pages and

applications.

2.1.1 HTML

HTML (the Hyper Markup Text Language) is the language for describing the structure

of the page.

It allows us to:

 Publish documents online with texts, headings, tables, photos, lists, etc.

 Include video clips, sounds clips and other applications directly.

 Retrieve online information at the click of a button.

2.1.2 CSS

CSS (Cascading Style Sheet) is the language used for describing how we want our

website to look like. By specifying the colors, font size of different texts, font type on the
pages, whether the text should be appeared in bold or italics, and the list goes on. It allows us

to control the appearance of our website.

CSS is independent of HTML. It can be used with any XML-based markup language.

Since both are independent of each other, therefore:

 It is easy to maintain the different pages.

 The style sheets can be shared across the pages.

-7-

 The pages can be tailored according to different environments.

2.2 WEBSITE LAYOUT

The structure of the website is described below:

 On the top-left, the logo of our project has been added.

 On the top-center, there is a header where the links to different pages has been

provided.

 On the top-right, there is a Logout button through which the user logs out from the

website.

 The content of each page is presented in the middle part of the respective page.

 At the bottom part of each page, a footer has been added, where the name and group

number of our project and copyright statement has been added.

2.3 PHP WEBSITE

PHP is a server-side scripting language designed for web development but also used

as a general-purpose programming language. A phpWebSite is a web content management

system provided by Electronic Student Services at Appalachian State University. Web-based


administration allows for easy maintenance of interactive, community-driven web sites and

also allows for easy site customization without the need for unwanted or unused features.

A PHP website is more preferred because of the following 5 benefits:

#1: Easy to Learn

Compared to other web languages that require a bit of study, PHP does not require one

to spend a lot of time researching a manual. Thanks to the syntax being logical and command

-8-

functions describing exactly what they do, one can easily get right to the part of creating and

optimizing the application.

#2: Familiarity with syntax

If you have programming experience in both Perl and C, then learning PHP will be

quite easy, as its syntax is based on these languages.

#3: Free of Cost

Since PHP is an open source web language, it’s completely free of cost. It doesn’t get

better than that, now does it?

#4: Efficiency in Performance

Depending on how you code, PHP can turn out to be an efficient web language to use.

In fact, PHP is known to be scalable when writing code as well as in creating applications and

is very reliable when you need to serve several web pages.

#5: A helpful PHP Community

If you get stuck or are getting started when using PHP, one of the best places you can

find information about the language is php.net apart from also obtaining tips from PHP pros

from numerous websites and forums that are available over the internet.
2.3.1 PHP WEB FORMS

For our website we used complex functionality and made few basic forms which

include the index page, home page, about page, lab page, manual page, contact page, signup

page, validate page, field validate page, upload file page, output page and session timeout

page. These pages are linked with each other and direct towards the output page ultimately if

the user has signed in. However, some of the pages are still under construction. Following is

the brief description of the above mentioned pages.

-9-

o INDEX PAGE

On our index page we have the option of either sign up or sign in. A client can only

proceed any further if he/she has opted for either of the two options. The registration of the

website is linked to our database (MySQL database).

o HOME PAGE

On our home page we have brief details about our project describing it precisely. After

signing in from the index page the client is redirected towards the home page. On the home

page there are links available to the about, lab, manual and contact page.

o ABOUT PAGE

In our about page we have provided details about the team members and a few lines

defining our project.

o LAB PAGE
In our lab page we have two functionalities. First one is to upload the bit stream file

which redirected towards the upload page (here the code uploaded by the client is dumped on

the FPGA board) and the second one is ustream which redirect towards the live video

streaming page (where the client can actually view the FPGA board at the server send).

o MANUAL PAGE

On this page we have uploaded the manuals for XSA3S1000, XStend and XS tools.

Any client who needs help getting acquainted with the FPGA board can access this page.

-10-

o CONTACT PAGE

On this page the client can contact on the given email address or phone number for any

sort of queries encountered while using our website.

o SIGN UP PAGE

On this page, the client registers to the website by entering the user ID and password

which is stored in our database (which is MySQL database).

o VALIDATE PAGE

On this page we have applied validation checks that the specific user ID and password

with which the client registered, matches with the one he/she is entering on the website. It it

matches then the validation page approves the client to proceed, if not then the client is asked

to enter the user ID and password again.


o FIELD VALIDATION PAGE

This page is responsible for checking whether the client has entered correct

information in the text field or left it blank. In such cases an error will generate displaying

“please enter correct and complete details”.

o UPLOAD FILE PAGE

This page uploads only the bit stream file that the client wants to dumped on the FPGA

board. After file is uploaded the user is informed that the file is uploaded and is redirected

towards the output page.

-11-

o OUTPUT PAGE

On this page we have ustream window which displays the output of the dumped

program. Switches are provided on the website which alter the inputs so that output can be

observed accordingly.

o SESSION TIMEOUT PAGE

On this page we have assigned time limit to our clients so that no two users can access

FPGA at the same time. After some predefined time the session will expire which will in

return give the second client access to FPGA. The clients can access FPGA in FCFS (first

come first serve) order.


2.3.2 BASIC FUNCTIONALITY OF PAGES

Our website contains two types of functionalities, some basic and some complex.

Basic functionalities include php website built in functionalities are others are customized so

that the website works according to our requirements. Complex functionalities include the

uploading of the bit stream file, the live video streaming through Ustream and provided

switches for altering inputs and observing their outputs.

2.3.2.1 PHP PAGES

Some of the pages on website are ‘.php’ while others are ‘.html’. Following are .php pages:

o INDEX.PHP

This page has options for a client to either login (if they have registered already) or to

signup to the website. This page is linked to the database where the information for new user

is saved. The next time the user signs in, the information is retrieved from the database and the

-12-

user is allowed to proceed towards availing more functionalities of the website. This page is

basically the first page of the website and this page allows the user to either enter the website

or leave without revealing information.


o VALIDATE.PHP

This page is responsible for checking whether the user is typing in appropriate

information or not. When the user signs up to the website their data is stored on the database.

This data is retrieved from the database when the user logs in later. For that, this page first

validates the data in the database and then compares it to the entered data by the client on the

website. If the data matches, that means the client has entered correct information (that is

correct user ID and password), if not then it will redirect to the index page again displaying

the error “Enter correct information!”.

-13-
o FIELDVALIDATE.PHP

This page is responsible for checking if the client has entered invalid characters or left

the field blank. If the client has entered invalid character or left any of the field blank then an

error will be generated displaying “Please enter correct and complete details”. This pages

makes sure that invalid information is restricted so that only people who have signed up can

avail facilities of this website. Also by these validations no intruder or hacker can take over

this website and misuse it.


-14-

o SIGNUP.PHP

This page helps the client to get registered to the website. This page is linked to the

database in such a way that when a client signs up, that information is stored in the database

and is retrieved from the database when the client signs in again. The fields on this page are

“user ID” and “password”. After the client has entered appropriate information he/she is

granted the access to website for accessing FPGA board.


-15-

o SIGNOUT.PHP

This page is responsible for terminating a session when the client has completed the

work he/she was doing. This pages redirects towards the index page as soon as the client

clicks on signout button. This page expires the current session and then new client is granted

permission to use website for accessing FPGA board.

o SESSION.PHP

This page is basically linked with the database. When a client logs in to the website,

the value in database is set to 1 just for that client. After predefined time interval the session

will expire when the value in the database turns to 0. The next client can then access FPGA

for again the same time interval and so on.

2.3.2.2 HTML PAGES

The following are .HTML pages:

o INDEX PAGE

The index page is the main page of the project’s website. Once the user opens the

website, the user will be seeing this page. This page is basically the login page. There are two

conditions:

 The user is already a member.

 The user is not a member.

 If User Is Already A Member


If the user is already a member, he will directly login his account by entering the

username and password.

-16-

 If User Is Not A member

If the user is not a member, he will first register his self by signing up first and then he

will be able to login his account.

o HOME PAGE

The user after logging in his account, his details will be verified from the database and

the user will then be re-directed to the home page where he will be able to view the overview

of the project.
-17-

o ABOUT PAGE

In the about page, the main idea of the project has been presented. And details of the

group members has also been provided.


-18-

o LAB PAGE

This page is where the working of our project has actually been presented. The user

can perform the following tasks:

 Uploading the file

 Changing the push buttons and dip switches

 Viewing the live video streaming


o FILE UPLOADING

The user first needs to upload the bit stream file generated from the FPGA on the

website through which a check bit file will be generated and the user will be able to change

the switches then.

-19-

 DIP SWITCHES AND PUSH BUTTONS

Dip Switches and Push Buttons have been provided for interactive and user-friendly

implementation of remote switch access.

After uploading the file, the user can now change the switches and push buttons to

view the results through live video streaming.

 VIDEO STREAMING
For the live video streaming, u-stream code has been embedded in our code. The user

when changes the buttons and dip switches, through the live video streaming he will be able

to see the changes in the lightening of LEDS taking place in the FPGA board.

o MANUALS PAGE

The manuals related to the usage and working of FPGA has been provided in the

manuals section so that user can easily perform his specific tasks and it would be beneficial

for him. User can access the page to view the manuals and read how the FPGA actually

works. On this page we have uploaded the manuals for XSA3S1000, XStend and XS tools.

o CONTACT PAGE

The contact page has been also developed for the ease of the users. Users can feel free

to contact the developer for any questions and queries. The user needs to jut fill the form

provided on the contact page. Contact number and email address have also been provided for

direct help. The form provided for contacting allows the user to enter his name, email address,

subject and message and after submitting the message is sent to the email address mentioned

on the website.

-20-
2.4 DATABASE

For our website database is one of the most important component. Database helps in

storing the website’s information about the clients to keep a record and allow only those

clients who have registered to the website. When a client signs up, their information is stored

in MySQL database so that the next time the client logs in, their user ID and password are

matched with the one they had registered with and then they are either permitted access to the

website or denied (incase of incorrect user ID or password).

The database used in this project is XAMPP because it allows website designers and

programmers to test their work on their own computers without any access to the Internet.

Also XAMPP is more user friendly.


-21-

2.4.1 XAMPP

XAMPP is a free and open source cross-platform web server consisting mainly of

the Apache HTTP Server, MySQL database, and interpreters for scripts written in the PHP

and Perl programming languages. In practice, however, XAMPP is sometimes used to actually

serve web pages on the World Wide Web. XAMPP also provides support for creating and

manipulating databases in MySQL and SQLite among others.

COMPONENTS OF XAMPP

Components of XAMMP include the following:

 Apache 2.4.10
 MySQL 5.6.20
 PHP 5.5.15
 phpMyAdmin 4.2.7.1
 FileZilla FTP Server 0.9.41
 Tomcat 7.0.42 (with mod_proxy_ajp as connector)
 Strawberry Perl 5.16.3.1 Portable
 XAMPP Control Panel 3.2.1 (from hackattack142)

2.4.2 WEBSITE AND DATABASE CONNECTION

Basically, the content of any website comprises of data, including text, images, media

and numerical values. Using a database to store this data is an efficient approach for many

sites. If a site's data is stored in a database, for example, using a database management system

such as MySQL, there might be need of presenting the data within your Web pages. This

process involves connecting to the database, querying it for data and presenting the data in

HTML, often by using a server side scripting language such as PHP (which we have used for

our website).
-22-

STEPS OF CONNECTION BETWEEN PHP WEBSITE AND DATABASE

Following steps briefly define how the connection is stablished between the website

and database (XAMPP):

Step 1

Prepare your database user account details. Database systems use accounts, with

specific levels of access to each user. Your account details should include a username and

password. Locate these details, if necessary copying them into a file. You will also need the

name and location of your database. Find all of these details before you start coding. Your

Web host should be able to help you with this information if you cannot find it.

Step 2

Connect to your database. You will need to use one or more server side scripts to

connect to your database. The following example code demonstrates making a database

connection to a MySQL system within a PHP script:

<?php mysql_connect("database_host", "username", "password"); ?>

You will need to alter the host address, username and password to reflect your own account.

The process for making a connection is similar for other database systems and programming

languages.

Step 3

Query your data. In most cases scripts use SQL (Structured Query Language) to

retrieve specific sets of data from databases. These SQL queries can execute from inside a

server side script. The following sample query demonstrates retrieving all records in a table

named "Customers": SELECT * FROM Customers


-23-

The following code demonstrates executing this query in PHP:

$customer_result = mysql_query("SELECT * FROM Customers");

The variable contains the result data following the query.

Step 4

Output your data. Once you retrieve the data from your database, you can present it

within your site pages, which are structured in HTML markup. The following code

demonstrates writing the query results into a page within HTML structures:

while($customer_row = mysql_fetch_array($customer_result)) { echo "<p>".

$customer_row['CustName']."</p>"; }

In this case the while loop iterates through each record in the "Customer" table, writing the

value from a "CustName" field into the page as part of a paragraph element. You will need to

alter the code to reflect the fields in your database table and the HTML structures you want to

display them within.

Step 5

Test your script. Once you have your database connection script complete, or partially

complete, upload it to your server to test it. If you encounter errors, check your database

account details as well as the structure of your tables. Once you have established that you can

connect to the database successfully in your script, you can build on the basic code to present

your data to site users.

2.5 DEPLOYMENT OF WEBSITE


Deployment means moving a website from a local environment to live servers. What

seems like a simple thing can actually be quite complex. There are absolutely a lot of ways to

go about it. They range from user friendly software and services, to more complex command

-24-

line tools, to full blown systems with lots of moving parts. There are a number of steps

involved in deploying a PHP website.

STEPS OF DEPLOYMENT OF A WEBSITE

Following steps describe the process of deploying a website:

STEP 1

Go to the dashboard by using cp.virtaulfpgalab.com (for every user deploying a

website the name of the web address will be different). Then type in the user ID and password

provided.
STEP 2

After signing in, go to file manager, the wwwroot folder (it contains content that is to

be displayed on the website), click on upload and browse the zip folder you want to upload

and click on upload.

-25-

STEP 3
Now that the website is uploaded, database that is created is imported and uploaded.

For importing database:

Go to database, click on MySQL 5.x, click on browse database (select the one you want to

upload), click on import and press go.

-26-
-27-

CHAPTER 3

FILE UPLOADING

3.1. FILE CREATION

The most common language used to simulate circuits on an FPGA logic board is called

Very-High-Speed Integrated Circuits (VHSIC) hardware description language; VHSIC HDL

or VHDL for short. VHDL code can be compiled and uploaded to an FPGA. Client creates a

file with an extension “bit” that is in VHDL code form built in Xilinx Software.

The sample of the code is shown below:


-28-

The above is HDL code for BCD to 7-segment display converter.

The resultant bit file which is to be uploaded on the website should appear in the form shown

as:
3.2 FILE CHECKING

This section elaborates that how after the proper creation; the file is gone through

some checks then is uploaded on the website by the client. As soon as the client clicks the

upload button, file to be uploaded goes through the checks which are coded in PHP. The

checks are defined as:

Size: The size of the file should not exceed 2MB.

Type: File should be a “.bit” file.

-29-
The coding of the checks is given:

If the file appears to be faultless i.e. it surpasses the above restrictions then it will be

uploaded successfully and a confirmation message will be shown to the client that states

“File Uploaded”. But if the file doesn’t satisfy the above limitations than it will not be

Uploaded and again a message of unsuccessful upload will be shown to the client.

3.3 FILE TRANSFER PROTOCOL

FTP (File Transfer Protocol) is the quickest and easiest way to transfer images and

other files to and from your account. With FTP one can easily transfer lots of files (images,

web pages, even a whole site) from one computer to the Web Hosting account and the Internet

— making it a convenient tool for building and managing your site as shown in figure 3.1.3.
-30-

Figure 3.1.3

With the help of File Tranfer Protocol services file is uploaded by the client and then

this file is downloaded on the srever. As soon as the file is downloaded, it is prepared to be

executable.

3.4 FILE EXECUTION

The XSTOOLs package contains the GUI-based / command line-based utilities:


-31-

The utilities we are going to use are:

GXSTEST / XSTEST: This utility lets you test an XS Board for proper functioning.

The XSTEST utility performs the same functions as GXSTEST, but using a command line

interface:

 XSPORT [-[h|help]] [-[p|port] [1|2|3]] [-[b|board] <type>]

Here is an example that tests an XS40-005XL Board connected to the LPT2 parallel port:

 XSTEST –p 2 –b xs40-005xl

XSTEST remembers the parallel port and type of XS Board that was used on the previous

run, so the next example re-runs the test on the XS40-005XL Board:

 XSTEST

You can get a synopsis of the XSTEST command arguments as follows:

 XSTEST -help

GXSSETCLKXSLOAD: During the development and testing phases, user usually connects

the XS Board to the parallel port of a PC and downloads the circuit each time when changes

are made to it. Client can download an FPGA design into the XS Board using the GXSLOAD

utility as follows.
-32-

The XSLOAD utility performs the same functions as GXSLOAD, but using a command line

interface. XSLOAD remembers the parallel port and type of XS Board that was used on the

previous run, so the next example programs the FPGA with a bitstream file.

 XSLOAD –fpga test.bit

All of it was the front end work. But our goal is to do all these tasks in the back end
so the user will only be notified of the upload and the result.

FTP is built on a client-server architecture and uses separate control and data

connections between the client and the server. Here FTP users are bound to FTP is
FTP is built on a client-server architecture and uses separate control and data connections

between the client and the server. FTP users are bounded 

authenticate themselves using a clear-textsign-in protocol, normally in the form of a username

and password for the security purpose. But since everytime it will ask to

-33-

enter the password manually therefore PowerShell Scripts are used for the proper automation.

PowerShell scripts are command line-based but user friendly.


-34-

CHAPTER 4

COMMUNICATION OF WEB-

SWITCHES WITH FPGA INPUTS

This module of the project deals with how the data is travelling from the client-end

GUI, which is the PHP website, all the way to the FPGA board, which is connected at the

server-end.

This has been done in several steps:

1. Sending data from the switches to the serial port

2. Listening to the serial port through Arduino

3. Forwarding data from the Arduino board to the FPGA board


The data is Arduino Board, The FPGA board is

CLIENT-END PROCESSING

ARDUINO PROCESSING

FPGA PROCESSING
captured from connected at the connected to the
client-end server-end, reads Arduino board
through the the received data and the data
fopen() and the as it continuously received by the
PHP Serial class listens to the Arduino is
functionality and COM port on forwarded to the
sent to the serial which data from respective FPGA
port. the PHP webpage inputs.
is being sent.

The details of the connections and the programming details are given below:

-35-

4.1 PHP WEBSITE – SENDING DATA FROM THE SWITCHES TO THE SERIAL

PORT

Once the user has uploaded the .BIT file from their ends into the FPGA connected at

the server-end, they need to change the inputs of the board to check the correctness and

observe the working of their code. For this purpose, 8 switches and 4 push buttons have been

provided for the clients on the website which can be changed to manipulate the inputs of the

FPGA board.

When a user clicks on the pushbutton or switch provided on the website, the following process

takes place:
The function helps
The invoked PHP
The pressing of the set the required
page executes the
pushbutton / specifications and
fopen() function
switch invokes transfers data to
using the PHP
another PHP page the sreial COM
serial class
port

4.2 ARDUINO PROCESSING

Arduino is a single-board microcontroller, intended to make it easier to build

interactive objects or environments. The hardware consists of an open-source

hardware board designed around an 8-bit Atmel AVR microcontroller, or a 32-bit Atmel

ARM.

-36-

There are many different types of Arduino boards available such as Arduino UNO, Arduino

Mega 2560, Arduino Nano, Arduino Fio, etc. We decided to go for Arduino Mega 2560 for

our project.

The Arduino Mega 2560 is a microcontroller board based on the ATmega2560. It has

54 digital input/output pins (of which 15 can be used as PWM outputs), 16 analog inputs,

4 UARTs (hardware serial ports), a 16 MHz crystal oscillator, a USB connection, a power

jack, an ICSP header, and a reset button. It contains everything needed to support the

microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-

DC adapter or battery to get started.


The Mega2560 differs from all preceding boards in that it does not use the FTDI USB-

to-serial driver chip. Instead, it features the ATmega16U2 programmed as a USB-to-serial

converter.

Arduino Mega 2560 (Front) Arduino Mega 2560 (Back)

4.2.1 Why Arduino Mega 2560?

There are many reasons as to why we decided to use the Arduino Mega 2560 from the

different options of boards which were available to us and these are:

 Lots of I/O pins

 Larger storage space

 Consumes little power

-37-

These are the basic requirements of our project as the number of manipulative I/O pins

in Spartan 3 FPGA is many. The board we are using is the XStend board by XESS Company

with an XSA-3S10000 inserted in the innermost column of the socket strips provided on the

board. There are pins available beside this mounting socket (the outer column of the socket

strip) for providing access to different components present in the FPGA on the XSA board.
At this stage of our project, we are merely using a few I/O pins to provide basic manipulative

functions to the users, i.e., the users can only change the inputs and observe the outputs which

are thus reflected.

But as the scope of this project is much larger, and can go on to provide a wider range

of facilities to the users (such as access to the VGA Port and PS/2 Port on the XSA board or

the RS-232 serial port, USB interface or other additional facilities which are available on the

XST boards), it seemed prudent that we choose that Arduino board which has the support

system for such extensive functionalities, if the project is to be extended at any given point in

time in the future.

4.2.2 PROGRAMMING THE ARDUINO

The next big task in the project was the programming of the Arduino board, something

which we had no experience in whatsoever. However, doing a bit of research, practice and

implementation of a few codes made it clear that Arduino was a vast platform with a lot of

online help available, in addition to being easy to use and user-friendly.

The program to be written for the Arduino board was simple as it was only required to

make the selected pins from Arduino to change their states to HIGH on

-38-

receiving a 1 from the website and subsequently, they were to become LOW on receiving a 0.

Some basic Arduino functionalities which were initially figured out were as follows:
On Launching the Arduino Software Arduino IDE

Selecting the Right Board Selecting the Right COM Port

-39-

Before proceeding with the actual programming, it was first needed to figure out what

input/output facilities were provided by the board and the mode of its communication.

i. Input and Output


Each of the 54 digital pins on the Mega can be used as an input or output,

using pinMode(), digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each

pin can provide or receive a maximum of 40 mA and has an internal pull-up resistor

(disconnected by default) of 20-50 kOhms. In addition, some pins have specialized functions:

 Serial

 External Interrupts

 Pulse Width Modulation (PWM)

 Serial Peripheral Interface (SPI)

 Two Wire Interface (TWI)

However, of our concern at this point were the functions provided for serial

communication, the details of which are:

1. 0 (RX) and 1 (TX)

2. Serial 1: 19 (RX) and 18 (TX)

3. Serial 2: 17 (RX) and 16 (TX)

4. Serial 3: 15 (RX) and 14 (TX)

Used to receive (RX) and transmit (TX) TTL serial data. Pins 0 and 1 are also connected to

the corresponding pins of the ATmega16U2 USB-to-TTL Serial chip.

-40-

ii. Communication

The Arduino Mega2560 has a number of facilities for communicating with a computer,

another Arduino, or other microcontrollers (such as the FPGA in our case).


The ATmega2560 provides four hardware UARTs for TTL (5V) serial communication.

An ATmega16U2 on the board channels one of these over USB and provides a virtual com

port to software on the computer (Windows machines will need a .inf file, but OSX and Linux

machines will recognize the board as a COM port automatically). The Arduino software

includes a serial monitor which allows simple textual data to be sent to and from the board.

The RX and TX LEDs on the board will flash when data is being transmitted via the

ATmega16U2 chip and USB connection to the computer (but not for serial communication on

pins 0 and 1).

A SoftwareSerial library allows for serial communication on any of the Mega2560's digital

pins.

Having figured out these basic I/O and communication details, we could now proceed

with the actual development of the sketch and its testing and uploading.

Sketch development for the Arduino is extremely simple and basic at this point, as we are only

taking input on the serial pins and forwarding it to the FPGA board.

A snippet of the Arduino code which will be running during the execution of project is given

below:

-41-
Arduino Code for Switching

4.3 FPGA CONNECTION AND PROCESSING

The connection from the Arduino pins with the FPGA board was the next issue to

tackle. The first main issue which needed to be resolved was: which pins on the given XST

board could accept external input from the Arduino?

Our first focus was to figure out the connection that the dip-switches and pushbuttons present

on the XSA board had with external pins present on its two long borders. As it is, there are no

pins on the external side which can be used to manipulate the states of our input components,

which are the 4 dipswitches and 2 pushbuttons present on the XSA board.

The next concern, of course, was whether any of the input components of the XST

board could be accessed externally and connected to the Arduino pins which are transmitting

the data from web. To our relief, the XST configuration is such that the dipswitches and

pushbuttons can be accessed through pins on the prototyping header, hence giving us room to

feed it input from the respective Arduino pins.


-42-

The XStend has a bank of eight DIP switches and four pushbuttons that are accessible

by the XSA Board. When a DIP switch is closed or a pushbutton is pressed, the corresponding

signal line is pulled to ground. When a DIP switch is open or a pushbutton is released, the

signal line is pulled to a high level through a resistor.

The pushbuttons and switches are connected on the XStend Board as follows:

Pushbuttons /Switches XStend Connection


PB1 PB-D15
PB2 PB-A0
PB3 PB-A1
PB4 PB-A2
DIPSW-1 PB-D0
DIPSW-2 PB-D1
DIPSW-3 PB-D2
DIPSW-4 PB-D3
DIPSW-5 PB-D4
DIPSW-6 PB-D5
DIPSW-7 PB-D6
DIPSW-8 PB-D7

When the FPGA reads the state of the switches or pushbutton PB1, it must deactivate

the chip-selects of the other devices on the peripheral data bus so they will not interfere. This

is not necessary when reading the state of pushbuttons PB2, PB3 and PB4 because they are

attached to the address bus and only the FPGA can drive these lines. (Instead of simple

output-only drivers, you will have to use bidirectional I/O drivers for the peripheral address

bus if you want the FPGA to read the state of these pushbuttons.)

Current-limiting resistors are placed between the switches/pushbuttons and the

peripheral bus lines to prevent damage if another device drives these lines at the same time

that a switch or pushbutton is closed. In such cases, the level driven by the other device

overrides the level from the pushbutton or switch. This is the functionality which will come in

handy for our part of the project.


-43-

The connections we have established from the Arduino board to the pins on the XST board are

as follows:

XStend Connection Arduino Pins


PB1 3
PB2 4
PB3 5
PB4 6
DIPSW-1 7
DIPSW-2 8
DIPSW-3 9
DIPSW-4 10
DIPSW-5 11
DIPSW-6 12
DIPSW-7 13
DIPSW-8 14

The connection between the Arduino and XStend board pins has been done through female

connectors:
-44-

CHAPTER 5

LIVESTREAMING OF OUTPUT

Once the user has uploaded their code and sent the desired inputs through the virtual

switches provided on the website, the last thing remaining is to display the output of the

FPGA to the users at their ends.

The first requirement for this module was to figure out where the output will be displayed and

the next most important concern was how it will be displayed.

5.1 WHERE IS THE OUTPUT DISPLAYED?

There are many different types of displays present on the XStend board for the user to observe

the outputs. These include:

i. Ten-Segment Bar Graph LED (On the XStend Board)

ii. Two 7-Segment LED Displays (On the XStend Board)

iii. 7-Segment LED Display (On the XSA FPGA Board)

All these LEDs are active-high meaning that an LED segment will glow when a high logic

level is applied to it.


-45-

Outputs on XStend and XSA Boards

According to the functionality provided by this project, users who intend to upload and

test a code by changing inputs should aim for the LED displays which are present on the

XStend board. This is because input manipulation is not allowed on the XSA board due to the

limitations of not accessing the input buttons through external pins, a limitation exercised by

the manufacturers. As input buttons cannot be accessed by external hardware, hence the

Arduino board could not be programmed to change the inputs on the XSA board.

Thus the XSA board output LED segments can only be used by those programmers

who wish to observe their output after file uploading and do not require changing the inputs

for verification of code.


Now, to accommodate those programmers who wish to change the inputs for the

testing for the verification of their code, we have provided input manipulation through the

virtual switches which work in the following manner:

-46-

3. Arduino forwards data to the XStend


1.
2. Buttons are pressed
This invokes on the
the Arduino website
board at
pins
server end

This functionality is limited to the inputs on the XStend board because they can be directly

accessed by the Arduino board for feeding the input.

5.1.1 HOW IS THE OUTPUT DISPLAYED?

For this purpose, we are using a camera and the web-based video hosting service provided by

Ustream.
a. Camera – Specifications and Connection

The camera we are using for streaming is from A4Tech – Ruddyface WebCam (Model

No.: PKS-732K).

A brief description of the camera is that it is an 8.0 Mega Pixels (simulated by driver)

webcam. It is driver free with built-in microphone and can work on both PC & Mac with

cosmetic light to beautify our images and video and has an air-tight suction cup with USB 2.0

for connection. It has the following specifications and system requirements:

-47-

A4Tech – Ruddyface WebCam


(Model No.: PKS-732K)

Specifications System Requirements

- Highest Video Resolution: Up - PC with Pentium 166MHz or

to 2 Mega pixels, 1600x1200 (software above

enhanced) - 256MB main memory or above

- Still Image Capture


Resolution: Up to 8 Mega pixels, - 32MB Video RAM or above

3200x2400 (software enhanced) - Available USB Port

- Image Sensor: 1/5?CMOS, - Sound Card

640×480 Pixels (350K Pixels) - 165MB of free hard disk space

- Frame Rate: 30fps at VGA or above

Mode - CD-ROM drive

- Lens: F=2.4, f=3.0mm - Windows XP, Vista, or above,

- View Angle: 66 degrees Mac OS 10.4.8 or above

-48-

5.2 USTREAM
Ustream's video platform is known for its ability to provide viewers with different ways to

interact with the presenter during a live broadcast, providing broadcasters with chat and

instant polling features, as well as allowing integration with other websites.

All Ustream accounts allow you to embed your live channel player, a recorded video or

highlight, or the player sidebar which includes the chat and social stream on your own site or

blog. Ustream Pro Broadcasting accounts provide additional features around embedding.

There are two ways of getting the code for embedding:

5.2.1 Getting the embed code from a Ustream player

The simplest way to get the embed code for any Ustream live video or recorded video player

is the following. For more advanced options, use the Ustream dashboard embed page.

Hover over the video player and in the lower right corner click on the Share menu

From the share menu, click on the icon that looks like an HTML bracket:

-49-

Copy and paste the code that you will see in the lower portion of the pop up box. You can

customize the size using the interface and the code will update.
5.2.2 USTREAM DASHBOARD EMBED PAGE

Log in to your Ustream account, or create a new one if you don't have an account yet.

-50-
Click on your user icon in the top right of your screen and click on Dashboard from the drop

down menu
-51-

From the Channel menu, click on Embed

Now you will see the embed options screen:


-52-

Copy the code displayed in the text box and paste into an HTML page to embed the video

player on your own site.

7. CONCLUSION
The paper presents some aspects of the remote FPGA laboratory for development and

testing of complex reconfigurable systems which is being built up at the Department of

Electronics and Multimedia Communications at the Technical University of Kosice. The

laboratory is still in the process of development. Basic functionality has already been

successfully tested during development of video signal processing based on IP functions.

This paper fully confirmed advantages of availability to share remotely advanced HW and SW

tools for real development works. Currently, all equipments and evaluation boards are already

fully functional and basic connectivity of the equipment is under testing. Although complete

functionality of this remote laboratory is still not attained in the full scale, integration works

are going to continue in the upcoming months mostly as a part of specialized diploma works

and PhD theses. Simultaneously also typical FPGA based experiments are prepared for

demonstration of advantages of the modern FPGA devices for up to date embedded and DSP

applications.
APPENDIX
REFERENCES
Bibliography

You might also like