DPL Fpga Dev Sys Um
DPL Fpga Dev Sys Um
DPL Fpga Dev Sys Um
DUEPROLOGIC
The DueProLogic (DPL) and its integrated development and distinctive runtime
environment has been specifically designed for Electrical Engineering students,
hobbyists, and entrepreneurs prototyping/developing/running projects involving logic,
with the added opportunity, of readily mating with a widely used microprocessor board,
the Arduino Due, and other ARM Cortex compatibles . The combination of FPGA
programmable logic and a microcontroller is unbeatable in an educational student
learning setting and in many other projects where each can bring its strength.
The DPL FPGA development system provides a convenient, user-friendly work flow by
connecting seamlessly with Altera’s Quartus Prime software. The user will develop the
code in the Quartus environment on a Windows Personal Computer. The programmable
logic code is loaded into the FPGA using only the Quartus Programmer tool and a
standard USB cable. The Active Host SDK provides a highly configurable bi-
directional communications interface between Arduino and host. It connects
transparently with the Active Transfer Library in the FPGA code. This Active
Host/Active Transfer combination eliminates the complexity of designing a USB
communication system. No scheduling USB transfers, USB driver interface or inf file
changes are needed. The EPT FPGA development system is a unique combination of
hardware and software.
Circuit designs, software and documentation are copyright © 2021, Earth People
Technology, Inc
http://www.earthpeopletechnology.com/
Page 1
FPGA Development System User Manual
Table of Contents
1 Introduction and General Description ....................................................................... 4
1.1 Test Driving the Active Host Test Application .................................................. 6
1.2 Hardware Description ....................................................................................... 13
1.2.1 Inputs and Outputs .................................................................................... 15
1.2.2 FPGA Configuration ................................................................................. 16
1.2.3 FT2232H Dual Channel USB to Serial Chip ............................................ 16
1.2.4 SD Card Interface ...................................................................................... 17
1.2.5 LEDs ......................................................................................................... 18
1.2.6 Pushbuttons ............................................................................................... 18
1.2.7 Power Options ........................................................................................... 19
1.2.8 JTAG Header ............................................................................................ 20
1.3 FPGA Active Host Development ..................................................................... 21
1.4 Active Host EndTerms ..................................................................................... 21
1.5 Active Transfer EndTerms ............................................................................... 26
2 EPT Drivers............................................................................................................. 26
2.1 USB Driver ....................................................................................................... 27
2.2 JTAG DLL Insert to Quartus Prime ................................................................. 29
2.2.1 Installing Quartus ...................................................................................... 29
2.2.2 Downloading Quartus ............................................................................... 31
2.2.3 Quartus Installer ........................................................................................ 36
2.2.4 Adding the EPT_Blaster to Quartus Prime ............................................... 44
2.3 Active Host Application DLL .......................................................................... 45
3 FPGA Active Transfer Library ............................................................................... 50
3.1 EPT Active Transfer System Overview ........................................................... 51
3.2 Active Transfer Library .................................................................................... 52
3.2.1 Active Trigger EndTerm ........................................................................... 55
3.2.2 Active Transfer EndTerm ......................................................................... 59
3.2.3 Active Block EndTerm ............................................................................. 61
3.3 Timing Diagram for Active Transfer EndTerms .............................................. 64
3.3.1 Active Trigger EndTerm Timing .............................................................. 64
3.3.2 Active Transfer EndTerm Timing............................................................. 64
3.3.3 Active Block EndTerm Timing................................................................. 65
4 Compiling, Synthesizing, and Programming FPGA ............................................... 66
4.1 Setting up the Project and Compiling............................................................... 66
4.1.1 Selecting Pins and Synthesizing................................................................ 74
4.1.2 Configuring the FPGA .............................................................................. 84
5 Active Host Application .......................................................................................... 97
5.1 Trigger EndTerm .............................................................................................. 98
Page 2
FPGA Development System User Manual
Page 3
FPGA Development System User Manual
Page 4
FPGA Development System User Manual
The DueProLogic FPGA Development System allows users to write HDL code (either
Verilog or VHDL) that will implement any digital logic circuit. The user’s HDL code is
compiled and synthesized and packaged into a programming file. The programming file
is programmed into the Configuration Flash using one channel of the USB to Serial
chip, the FT2232H.The Active Host SDK contains a dll which maintains device
connection, polling, writes and includes a unique receive mechanism that automatically
transfers data from DPL when data is ready. It also alerts the user code when the dll has
stored the transfer and the data is available to the software GUI (graphical user
interface). Users do not need to interface with the USB Host Driver or any Windows
drivers. They need only to include the Active Host dll in their projects. The Active
Transfer Libraries must be included in the FPGA project to take advantage of the
configurability of the Active Host SDK. All of the drivers, libraries, and project source
code are available at www.earthpeopletechnology.com .
Page 5
FPGA Development System User Manual
The DueProLogic board comes pre-loaded with the EPT_Platform_Demo HDL project
in the FPGA. This project allows the user to test out the functions of the Active Host
API and the board hardware.
To test drive the application, connect the DPL to the Windows PC using a Micro B
USB cable. Load the driver for the board. See the section “EPT Drivers” for instructions
on loading the DPL driver. If the USB driver fails to load, the Windows OS will
indicate that no driver was loaded for the device. In the case of the failed USB driver,
try rebooting the PC and following the steps in the EPT Drivers section of this User
Manual.
Page 6
FPGA Development System User Manual
Browse to the
Projects_ActiveHost\EPT_Platform_Demo\EPT_Transfer_Demo\bin\X64\Release\
folder on the DUEPROLOGIC_USB_FPGA_PROJECT_x.x_DVD.
Page 7
FPGA Development System User Manual
With the application loaded, select the FPGA board from the dropdown combo box and
click on the “Open” button.
Page 8
FPGA Development System User Manual
Leave the Address set at 2 for the Transfer Controls Group. And, leave the Address set
at 4 for the Block Controls Group.
To exercise the Single Byte Transfer EndTerm, click the “LoopBack” button in the
Transfer Controls group. Type in several numbers separated by a space and less 256
into the Multiple Byte textbox. Then hit the Multi Byte button. The numbers appear in
the Receive Byte textbox.
Page 9
FPGA Development System User Manual
To exercise the Block Transfer EndTerm, click the “BLOCK 8”, “BLOCK 16” or
“BLOCK 128” button in the Block Controls group. A pre-selected group of numbers
appear in the Block Receive textbox.
Under LED Controls, press the “EPT” button under the “Load EPT Image”.
The characters “EPT” will be displayed on the 6x6 LED array. All the characters cannot
be displayed at once, so the “Shift Left” or “Shift Right” button must be pressed to see
all characters.
Page
10
FPGA Development System User Manual
Next press any of the numbered buttons in the “LED Controls” group. This will toggle
the corresponding LED in the 6x6 LED Array. It performs this operation as a Block
Write. So, an entire LED frame will be transferred to the DueProLogic each time a
button is pressed.
Page
11
FPGA Development System User Manual
Page
12
FPGA Development System User Manual
Page
13
FPGA Development System User Manual
EPT-4CE6-AF-D2
Page
14
FPGA Development System User Manual
DueProLogic
Hardware
Page
15
FPGA Development System User Manual
programmed directly from Quartus Prime by using the EPT-Blaster driver. Follow the
instructions in the “EPT Drivers” section of this manual.
Page
16
FPGA Development System User Manual
Page
17
FPGA Development System User Manual
1.2.5 LEDs
The DueProLogic includes a 6x6 Green LED array. Each LED is sinked to an
individual pin on the FPGA. Each LED is current limited to 6mA. The total current
consumed for all 36 LEDs is 216mAs. The FPGA can easily sink this current. So,
individually sinking all 36 LEDs makes easy control for User Code. The DueProLogic
also contains a method to turn on/off the LEDs in four unit blocks. A jumper is used to
control the state of each LED block.
Connect LED
1.2.6 Pushbuttons
The DueProLogic includes two pushbuttons that can be used in a way the user would
like. They are both attached to separate debounce circuits. These pushbuttons were
designed to use as little PCB are as possible. The switch is engaged by the plunger
which is directed off the PCB.
Page
18
FPGA Development System User Manual
Page
19
FPGA Development System User Manual
The Barrel Connector is the located on the front of the board. It has 2.0mm inner
diameter and 5.5mm outer diameter. The inner male connection is the positive
connection and the outer connection is the ground. This connection can accept between
+5VDC and +12VDC power. However, great care must be used when using this
connection. This power is applied to several pins on the I/O headers. Consult the Data
Sheet for these connections.
Page
20
FPGA Development System User Manual
Page
21
FPGA Development System User Manual
from PC/Windows application code through the USB driver to the user FPGA code.
The user code connects to “Endterms” in the Active Host dll. These Host “Endterms”
have complementary HDL “Endterms” in the Active Transfer Library. Users have
seamless bi-directional communications at their disposal in the form of:
• Trigger Endterm
• Transfer Endterm
• Block Endterm
User code writes to the Endterms as function calls. Just include the address of the
individual module (there are eight individually addressable modules of each Endterm).
Page
22
FPGA Development System User Manual
Immediately after writing to the selected Endterm, the value is received at the HDL
Endterm in the FPGA.
Page
23
FPGA Development System User Manual
The above is a code sample from a C# Windows Form. You can see functions that write
a byte to the FPGA (EPT_AH_SendByte(0x01, (char)LEDStatus)) and write a trigger
bit to the FPGA (EPT_AH_SendTrigger((byte)0x02).
Page
24
FPGA Development System User Manual
The above code is the interface Verilog which resides in the FPGA. When the C#
Windows form sends a byte or trigger, the signals in the FPGA code react and allow the
user code to receive the byte and trigger and perform some function with the
information. In the case of this example, the LEDs will change state.
Receiving data from the FPGA is made simple by Active Host. Active Host transfers
data from the FPGA as soon as it is available. It stores the transferred data into circular
buffer. When the transfer is complete, Active Host invokes a callback function which is
registered in the users application. This callback function provides a mechanism to
transparently receive data from the FPGA. The user application does not need to
schedule a read from the USB or call any blocking threads.
Page
25
FPGA Development System User Manual
BLOCK ENDTERM
at the commensurate EndTerm in the Active Host/user application. The transfer through
the USB is transparent. User HDL code doesn’t need to set up Endpoints or respond to
Host initiated data requests. The whole process is easy yet powerful.
2 EPT Drivers
The DueProLogic Development system requires drivers for any interaction between PC
and the board. The communication between the two consists of programming the FPGA
and data transfer. In both cases, the USB Driver is required. This will allow Windows to
recognize the USB Chip and setup a pathway for Windows to communicate with the
USB hardware.
Page
26
FPGA Development System User Manual
Double click on the *.exe file and select the default settings when the software tool
queries the user.
Page
27
FPGA Development System User Manual
Windows will attempt to locate a driver for the USB device. Allow Windows to install
the driver for the DueProLogic.
If Windows cannot load a driver for the DPL, a notification window will inform the
user that the driver load has failed for the device.
Page
28
FPGA Development System User Manual
If the driver is successfully installed, Windows will inform the user. The user can check
Device Manager to ensure the correct driver was installed for the DPL. The DPL will
show up as two COM Ports under the “Ports (COM &LPT)” under the Device Manager.
When this is complete, the drivers are installed and the DueProLogic can be used for
programming and USB data transfers.
Page
29
FPGA Development System User Manual
If you don’t have the EPT FPGA Development System DVD, you can download the
Quartus Prime by following the directions in the Section Downloading Quartus.
Page
30
FPGA Development System User Manual
When the install shield window pops up click “Yes” or if needed, enter the
administrator password for the users PC. Click “Ok”
Next, skip the “Download Quartus” section. Go down to the “Quartus Installer” section
to complete the Quartus installation.
You will first need to apply for an account with Intel. Then use your login and password
to access the download site. Click on the Download Windows Version.
Page
31
FPGA Development System User Manual
The next page will require you to sign into your “myAltera” account. If you do not have
one, follow the directions under the box, “Don’t have an account?”
Once you have created your myAltera account, enter the User Name and Password. The
next window will ask you to allow pop ups so that the file download can proceed.
Page
32
FPGA Development System User Manual
Page
33
FPGA Development System User Manual
The file is 5.9 GB, so this could take a couple of hours depending on your internet
connection. When download is complete, store the *.tar file in a directory on your PC.
Page
34
FPGA Development System User Manual
Page
35
FPGA Development System User Manual
Page
36
FPGA Development System User Manual
Page
37
FPGA Development System User Manual
Click the checkbox to agree to the license terms. Then click “Next”.
At the Select Products Window, de-select the Quartus Prime Supbscription Edition by
clicking on its check box so that the box is not checked. Then click on the check box by
the Quartus Prime Web Edition (Free).
Page
38
FPGA Development System User Manual
Page
39
FPGA Development System User Manual
Page
40
FPGA Development System User Manual
Page
41
FPGA Development System User Manual
Page
42
FPGA Development System User Manual
Click “Ok”, then click “Finish”. The Quartus Prime is now installed and ready to be
used.
Page
43
FPGA Development System User Manual
Page
44
FPGA Development System User Manual
5. Click Ok.
6. Open the Quartus Prime application.
The DLL is installed and the JTAG server should recognize it. Go to the section
“Programming the FPGA” of this manual for testing of the programming. If the driver
is not found in the Programmer Tool->Hardware Setup box, see the JTAG DLL Insert
to Quartus Prime Troubleshooting Guide.
https://visualstudio.microsoft.com/vs/express/
Go to the website and click on the “+” icon next to the Visual C# Express.
Page
45
FPGA Development System User Manual
Page
46
FPGA Development System User Manual
Page
47
FPGA Development System User Manual
Next, follow the on screen windows and accept the default answers.
Page
48
FPGA Development System User Manual
Visual C# 2010 Express will install. This may take up to twenty minutes depending on
your internet connection.
Page
49
FPGA Development System User Manual
The installed successfully window will be displayed when Visual C# Express is ready
to use.
The Active Host Application Software will allow the user to create a custom
applications on the PC using the EndTerms to perform Triggers and Data Transfer
to/from the DueProLogic. The methods and parameters of the Active Host library are
explained in the Active Host Application section. Locate the \Projects_ActiveHost
folders on the EPT FPGA Development System DVD.
Page
50
FPGA Development System User Manual
that the user will add to their project before building it. The description of what the
library does and how to use its components are described in this manual.
INPUT/OUTPUT PINS
TOP LEVEL
UC_OUT[21..0]
TRIGGER IN
TRIGGER OUT
TRANSFER IN
TRANSFER OUT
BLOCK IN
BLOCK OUT
Figure 6 shows how the modules of the EPT Active Transfer Library attach to the
overall user project. The EPT Active_Transfer_Library.vqm, Active_Trigger.vqm,
Active_Transfer.vqm and Active_Block.vqm modules are instantiated in the top level
Page
51
FPGA Development System User Manual
of the user project. The User_Code module is also instantiated in the top level. The
Active_Transfer modules communicate with the User_Code through module
parameters. Each module is a bi-directional component that facilitates data transfer from
PC to FPGA. The user code can send a transfer to the Host, and the Host can send a
transfer to the user code. This provides significant control for both data transfers and
signaling from the user code to PC. The Triggers are used to send momentary signals
that can turn on (or off) functions in user code or PC. The Active Transfer is used to
send a single byte. And the Active Block is used to send a block of data. The
Active_Transfer and Active_Block modules have addressing built into them. This
means the user can declare up to 8 individual instantiations of Active_Transfer or
Active_Block, and send/receive data to each module separately.
Page
52
FPGA Development System User Manual
Page
53
FPGA Development System User Manual
The interface from the library to the user code is two uni directional buses,
UC_IN[22:0] and UC_OUT[20:0]. The UC_IN[22:0] bus is an output bus (from the
library, input bus to the Active Modules) that is used channel data, address, length and
control information to the Active Modules. The UC_OUT[21:0] bus is an input bus (to
the library, output bus from the Active Modules) that is used to communicate data,
address, length, and control information to the Active Modules.
Page
54
FPGA Development System User Manual
The UART signals are used to channel data, and control signals to the USB interface
chip. These signals are connected directly to input and output pins of the FPGA.
Page
55
FPGA Development System User Manual
To send a trigger, decide which bit (or multiple bits) of the eight bits you want to send
the trigger on. Then, set that bit (or bits) high. The Active Transfer Library will send a
high on that trigger bit for one clock cycle (66 MHz), then reset itself to zero. The bit
can stay high on the user code and does not need to be reset to zero. However, if the
user sends another trigger using the trigger byte, then any bit that is set high will cause a
trigger to occur on the Host side.
Page
56
FPGA Development System User Manual
So, care should be used if the user code uses byte masks to send triggers. It is best to set
only the trigger bits needed for a given time when sending triggers.
The user code must be setup to receive triggers from the Host. This can be done by
using an asynchronous always block. Whenever a change occurs on a particular trigger
bit (or bits), a conditional branch can detect if the trigger bit is for that block of code.
Then, execute some code based on that trigger.
Page
57
FPGA Development System User Manual
Page
58
FPGA Development System User Manual
To send a byte to the Host, select the appropriate address that corresponds to an address
on Host side. Place the byte in the “transfer_to_host” parameter, then strobe the
“start_transfer” bit. Setting the “start_transfer” bit to high will send one byte from the
“transfer_to_host” byte to the Host on the next clock high signal (66 MHz). The
“start_transfer” bit can stay high for the duration of the operation of the device, the
Active Transfer module will not send another byte. In order to send another byte, the
user must cycle the “start_transfer” bit to low for a minimum of one clock cycle (66
MHz). After the “start_transfer” bit has been cycled low, the rising edge of the bit will
cause the byte on the “transfer_to_host” parameter to transfer to the host.
Page
59
FPGA Development System User Manual
Page
60
FPGA Development System User Manual
To receive a byte, the Active Host will send a byte using it’s dll. The user code must
monitor the transfer_received port. The transfer_received port will assert high for one
clock cycle (66 MHz) when a byte is ready for reading on the transfer_to_device port.
User code should use an asynchronous always block to detect when the
transfer_received port is asserted. Upon assertion, the user code should read the byte
from the transfer_to_device port into a local register.
Page
61
FPGA Development System User Manual
modules can be instantiated and separately addressed. The length of the block to be
transferred must also be specified in the uc_length port.
To send a block, it’s best to have buffer filled in a previous transaction, Then assert the
start_transfer bit. This method is opposed to collecting and processing data bytes after
the start_transfer bit has been asserted and data is being sent to the Host.
Once the buffer to send is filled with the requisite amount of data, the address and
buffer length should be written to the uc_addr and uc_length ports. Set the start_transfer
bit high, the user code should monitor the transfer_ready port. At the rising edge of the
transfer_ready port, the byte at transfer_to_host port is transferred to the USB chip.
Once this occurs, the user code should copy the next byte in the buffer to
transfer_to_host port. On the next rising edge of transfer-ready, the byte at
transfer_to_host will be transferred to theUSB chip. This process continues until the
number of bytes desicribed by the uc_length have been transferred into the USB chip.
Page
62
FPGA Development System User Manual
Page
63
FPGA Development System User Manual
To receive a buffer from the Host, the user code should monitor the transfer_received
port for assertion. When the bit is asserted, the next rising edge of transfer_ready will
indicate that the byte at transfer_to_device is ready for the user code to read.
[Add code snippet showing Active Block Module bytes received by the user code]
Page
64
FPGA Development System User Manual
Page
65
FPGA Development System User Manual
The FPGA on the EPT-4CE6-AF-D2 can be programmed with the Active Transfer
Library and custom HDL code created by the user. Programming the FPGA requires the
use of the Quartus Prime software and a standard USB cable. There are no extra parts to
buy, just plug in the USB cable. Once the user HDL code is written according to the
syntax rules of the language (Verilog and VHDL) it can be compiled and synthesized
using the Quartus Prime software. This manual will not focus on HDL coding or proper
coding techniques, instead it will use the example code to compile, synthesize and
program the FPGA.
Page
66
FPGA Development System User Manual
Under Quartus, Select File->New Project Wizard. The Wizard will walk you through
setting up files and directories for your project.
Page
67
FPGA Development System User Manual
Page
68
FPGA Development System User Manual
Page
69
FPGA Development System User Manual
Page
70
FPGA Development System User Manual
• EPT_4CE6_AF_D1_Top.v
Select Next, at the Device Family group, select Cyclone IV for Family. In the Available
Devices group, browse down to EP4CE6E22C8 for Name.
Page
71
FPGA Development System User Manual
Page
72
FPGA Development System User Manual
Select Next, then select Finish. You are done with the project level selections.
Page
73
FPGA Development System User Manual
Page
74
FPGA Development System User Manual
Page
75
FPGA Development System User Manual
Click Ok. Under Assignments, Select Pin Planner. Verify the pins have been imported
correctly.
Page
76
FPGA Development System User Manual
The pin locations should not need to be changed for EPT USB FPGA Development
System. However, if you need to change any pin location, just click on the “location”
column for the particular node you wish to change. Then, select the new pin location
from the drop down box.
Page
77
FPGA Development System User Manual
Exit the Pin Planner. Next, we need to add the Synopsys Design Constraint file. This
file contains timing constraints which forces the built in tool called TimeQuest Timing
Analyzer to analyze the path of the synthesized HDL code with setup and hold times of
the internal registers. It takes note of any path that may be too long to appropriately
meet the timing qualifications. For more information on TimeQuest Timing Analyzer,
see
Page
78
FPGA Development System User Manual
Page
79
FPGA Development System User Manual
If you forget to include a file or some other error you should expect to see a screen
similar to this:
Page
80
FPGA Development System User Manual
Click Ok, the select the “Error” tab to see the error.
Page
81
FPGA Development System User Manual
The error in this case is the missing file “active_control_register”. Click on the
Assignment menu, then select Settings, then select Files. Add the
“active_control_register.v” file from the database.
Page
82
FPGA Development System User Manual
Click Ok then re-run the Compile process. After successful completion, the screen
should look like the following:
Page
83
FPGA Development System User Manual
At this point the project has been successfully compiled, synthesized and a
programming file has been produce. See the next section on how to program the FPGA.
Page
84
FPGA Development System User Manual
If the project created in the previous sections is not open, open it. Click on the
Programmer button.
The Programmer Window will open up with the programming file selected. Click on the
Hardware Setup button in the upper left corner.
Page
85
FPGA Development System User Manual
The Hardware Setup Window will open. In the “Available hardware items”, double
click on “EPT-Blaster v1.6b”.
Page
86
FPGA Development System User Manual
If you successfully double clicked, the “Currently selected hardware:” dropdown box
will show the “EPT-Blaster v1.6b”.
Page
87
FPGA Development System User Manual
Click on the “Mode:” drop down box. Select the “Active Serial Programming” option.
Page
88
FPGA Development System User Manual
Page
89
FPGA Development System User Manual
Page
90
FPGA Development System User Manual
Page
91
FPGA Development System User Manual
Double click on the “EPT_4CE6_D1_Top.pof” file. Click the Open button in the lower
right corner.
Page
92
FPGA Development System User Manual
Next, selet the checkbox under the “Program/Configure” of the Programmer Tool.
Page
93
FPGA Development System User Manual
Click on the Start button to to start programming the FPGA. The Progress bar will
indicate the progress of programming.
Page
94
FPGA Development System User Manual
The programming of the DueProLogic will start and you can check the progress in the
“Progress” Bar.
Page
95
FPGA Development System User Manual
When the programming is complete, the Progress bar will indicate success.
Page
96
FPGA Development System User Manual
At this point, the DueProLogic is programmed and ready for use. To test that the FPGA
is properly programmed, bring up the Active Transfer Demo Tool. Click on one of the
LED’s and verify that the LED selected lights up. Press one of the switches on the
board and ensure that the switch is captured on the Active Host Test Tool. Now you are
ready to connect to the Arduino Due and write some code to transfer data between
microcontroller and PC.
Page
97
FPGA Development System User Manual
complementary HDL “Endterms” in the Active Transfer Library. Users have seamless
bi-directional communications at their disposal in the form of:
• Trigger Endterm
• Transfer Endterm
• Block Endterm
User code writes to the Endterms as function calls. Just include the address of the
individual module (there are eight individually addressable modules of each Endterm).
Immediately after writing to the selected Endterm, the value is received at the HDL
Endterm in the FPGA. The Trigger Endterms are used as “switches”. The user code can
set a Trigger bit in the FPGA and cause an event to occur. The Transfer Endterm sends
one byte to the FPGA. The Block Endterm sends a block of bytes. By using one of the
Active Host Endterms, the user can create a dynamic, bi-directional, and configurable
data transfer design.
Page
98
FPGA Development System User Manual
byte is easy, just use the function call with the address and byte value. The byte is
immediately sent to the corresponding EndTerm in the FPGA. Receiving a byte is just
as easy, a callback function is registered at initialization. When the FPGA transmits a
byte using its EndTerm, the callback function is called in the user application. The user
code must store this byte in order to use it. The incoming Transfers are stored in a
circular buffer in memory. This allows the user code to fetch the transfers with out
losing bytes.
The data seamlessly appears in Host PC memory from the Arduino. The user code will
direct the data to a control such as a textbox on a Windows Form. The transparent
receive transfer path is made possible by a Callback mechanism in the Active Host dll.
Page
99
FPGA Development System User Manual
The dll calls a registered callback function in the user code. The user code callback can
be designed to generate any number of events to handle the received data.
The user application will access the FPGA by use of functions contained in the Active
Host dll. The functions to access the FPGA are:
• EPT_AH_SendTrigger ()
• EPT_AH_SendByte ()
• EPT_AH_SendBlock ()
• EPT_AH_SendTransferControlByte()
Page
100
FPGA Development System User Manual
The ComPortNames() searches through all attached COM Ports and attempts to find the
DueProLogic. Once it finds the DPL, a List is populated with each channel. The code in
*_Load() function then adds the appropriate name to the COM Port channel and
matches the COM Port number with the string in the list.
Page
101
FPGA Development System User Manual
The user will select the device from the drop down combo box. This can be seen when
the Windows Form is opened and the cmbDevList combo box is populated with all the
devices. The selected device will be stored as an index number in the variable
device_index.
In order to select the device, the user will click on the “Open” button which calls the
OpenSerialPort1() function. The PortName is passed into the OpenSerialPort1 ()
function. If the function is successful, the device name is displayed in the label,
labelDeviceCnt. Next, the device is made the active device the Open button is grayed
out and the Close button is made active.
Page
102
FPGA Development System User Manual
Page
103
FPGA Development System User Manual
Once the serialPort_AH_DataReceived() has stored all incoming bytes due to the
transfer, it calls the EPT_AH_Receive(). This function will process the incoming
transfer and populate the class:
• EPTReceiveDevice
Page
104
FPGA Development System User Manual
Page
105
FPGA Development System User Manual
This object holds the command, address and payload for the transfer. Once the object is
populated, the function calls the EPTParseReceive() function.
Page
106
FPGA Development System User Manual
To detect a trigger from the FPGA, the user application will set up functions in the
EPTParseReceive() function. A switch statement is used to decode which event should
be called to handle the incoming received data.
• TRIGGER_IN
• TRANSFER_IN
• BLOCK_IN
The event handler function for the TRIGGER_IN’s uses a switch statement to
determine which trigger was asserted and what to do with it.
Page
107
FPGA Development System User Manual
Use the function EPT_AH_SendByte() to send a byte the selected module. Then add the
address of the transfer module as the first parameter of the EPT_AH_SendByte()
function. Enter the byte to be transferred in the second parameter. Then execute the
function, the byte will appear in the ports of the Active Transfer module in the user
code on the FPGA.
To transfer data from the FPGA Device, a polling technique is used. This polling
technique is because the Bulk Transfer USB is a Host initiated bus. The Device will not
transfer any bytes until the Host commands it to. If the Device has data to send to the
Host in an asynchronous manner (meaning the Host did not command the Device to
send data), the Host must periodically check the Device for data in it’s transmit FIFO. If
Page
108
FPGA Development System User Manual
data exists, the Host will command the Device to send it’s data. The received data is
then stored into local memory and register bits are set that will indicate data has been
received from a particular address.
To receive a byte transfer from the Active host, user code must subscribe to the event
created when the incoming byte transfer has arrived. A switch statement is used to
decode which event should be called to handle the incoming received data. The event
handler function will check for any bytes read for that address.
For our example project, the TransferOutReceive() function writes the Transfer byte
received to a text block. The receive callback method is complex, however, Earth
People Technology has created several projects which implement callbacks. Any part of
these sample projects can copied and pasted into a user’s project.
Page
109
FPGA Development System User Manual
To send a block, first, open the EPT device to be used with openSerialPort1(), transfer
module as the first parameter. Next, place the pointer to the buffer in the second
parameter of EPT_AH_SendBlock(). Add the length of the buffer as the third
parameter. Then execute the function, the entire buffer will be transferred to the USB
chip. The data is available at the port of the Active Block module in the user code on
the FPGA.
Page
110
FPGA Development System User Manual
To receive a block transfer from the FPGA Device, a polling technique is used by the
Active Host dll. This is because the Bulk Transfer USB is a Host initiated bus. The
Device will not transfer any bytes until the Host commands it to. If the Device has data
to send to the Host in an asynchronous manner (meaning the Host did not command the
Device to send data), the Host must periodically check the Device for data in its
transmit FIFO. If data exists, the Host will command the Device to send its data. The
received data is then stored into local memory and register bits are set that will indicate
data has been received from a particular address. The receive callback function is then
called from the Active Host dll. This function start a thread to do something with the
block data.
To receive a byte transfer from the callback function, user code must subscribe to the
event created when the incoming byte transfer has arrived at the Read Callback
function. The Read Callback must store the incoming transfer payload and module
Page
111
FPGA Development System User Manual
address in a local memory block. A switch statement is used to decode which event
should be called to handle the incoming received data. The event handler function will
check for any bytes read for that address.
Page
112
FPGA Development System User Manual
For our example project, the Receive_Block_In() function writes the Transfer block
received to a text block. The receive callback method is complex, however, Earth
People Technology has created several projects which implement callbacks. Any part of
these sample projects can copied and pasted into a user’s project.
Page
113
FPGA Development System User Manual
At the New Project window, select the Windows Forms Application. Then, at the
Name: box, type in EPT_Transfer_Demo
Page
114
FPGA Development System User Manual
Page
115
FPGA Development System User Manual
if your system supports, you can check it by going to Start->Control Panel->System and
Security->System
Click on System.
Page
116
FPGA Development System User Manual
First, we need tell C# Express to produce 64 bit code if we are running on a x64
platform. Go to Tools->Settings and select Expert Settings
Page
117
FPGA Development System User Manual
Go to Tools->Options, locate the “Show all settings” check box. Check the box.
In the window on the left, go to “Projects and Solutions”. Locate the “Show advanced
build configurations” check box. Check the box.
Go to Build->Configuration Manager.
Page
118
FPGA Development System User Manual
In the Configuration Manager window, locate the “Active solution platform:” label,
select “New” from the drop down box.
In the New Solution Platform window, click on the drop down box under “Type or
select the new platform:”. Select “x64”.
Page
119
FPGA Development System User Manual
Click the Ok button. Verify that the “Active Solution Platform” and the “Platform” tab
are both showing “x64”.
Page
120
FPGA Development System User Manual
Verify that the “Platform:” label has “Active (x64)” selected from the drop down box.
Click on the Save All button on the tool bar. The project environment is now setup and
ready for the project files. Close the Project.
Page
121
FPGA Development System User Manual
Page
122
FPGA Development System User Manual
Page
123
FPGA Development System User Manual
Page
124
FPGA Development System User Manual
Page
125
FPGA Development System User Manual
Page
126
FPGA Development System User Manual
In the C# Express Solution Explorer, you should be able to browse the files by clicking
on them. There should be no errors noted in the Error List box.
Event based programming means the software responds to events created by the user, a
timer event, external events such as serial communication into PC, internal events such
as the OS, or other events. The events we are concerned with for our example program
are user events and the timer event. The user events occur when the user clicks on a
button on the Windows Form or selects a radio button. We will add a button to our
example program to show how the button adds an event to the Windows Form and a
function that gets executed when the event occurs.
The easiest way to add a button to a form is to double click the Form1.cs in the Solution
Explorer. Click on the button to launch the Toolbox.
Page
127
FPGA Development System User Manual
Locate the button on the Toolbox, grab and drag the button onto the Form1.cs [Design]
and drop it near the top.
Go to the Properties box and locate the (Name) cell. Change the name to
“btnOpenDevice”. Locate the Text cell, and change the name to Open.
Page
128
FPGA Development System User Manual
Double click on the Open button. The C# Explorer will automatically switch to the
Form1.cs code view. The callback function will be inserted with the name of the button
along with “_click” appended to it. The parameter list includes (object sender,
System.EventArgs e). These two additions are required for the callback function to
initiate when the “click” event occurs.
There is one more addition to the project files. Double click on the Form1.Designer.cs
file in the Solution Explorer. Locate the following section of code.
Page
129
FPGA Development System User Manual
This code sets up the button, size, placement, and text. It also declares the
“System.EventHandler()”. This statement sets the click method (which is a member of
the button class) of the btnOpenDevice button to call the EventHandler –
btnOpenDevice_Click. This is where the magic of the button click event happens.
http://www.homeandlearn.co.uk/csharp/csharp.html
Page
130
FPGA Development System User Manual
Page
131
FPGA Development System User Manual
The C# Express compiler will start the building process. If there are no errors with code
syntax, function usage, or linking, then the environment responds with “Build
Succeeded”.
Page
132
FPGA Development System User Manual
The EPT_Platform_Demo.exe file can now be tested using the DueProLogic board. To
test the file, connect the DueProLogic to the Windows PC using Type A to Type Micro
B USB cable. Make sure the driver for the board loads. If the USB driver fails to load,
the Windows OS will indicate that no driver was loaded for the device. Go to the folder
where the EPT_Platform_Demo.exe file resides, and double click on the file. The
application should load with a Windows form.
Page
133
FPGA Development System User Manual
With the application loaded, select the USB-FPGA board from the dropdown combo
box and click on the “Open” button.
Page
134
FPGA Development System User Manual
Click on one of the LED buttons in the middle of the window. The corresponding LED
on the DueProLogic board should light up.
To exercise the Single Byte Transfer EndTerm, click the “LoopBack” button in the
Transfer Controls group. Type in several numbers separated by a space and less 256
Page
135
FPGA Development System User Manual
into the Multiple Byte textbox. Then hit the Multi Byte button. The numbers appear in
the Receive Byte textbox.
Page
136