Add batch 3 (WangXuan95_FPGA-FOC, ultraembedded_cores, WangXuan95_FPGA-USB-Device, open-sdr_openwifi-hw, KastnerRG_riffa)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +1 -0
- KastnerRG_riffa/LICENSE +34 -0
- KastnerRG_riffa/Makefile +76 -0
- KastnerRG_riffa/README.md +8 -0
- KastnerRG_riffa/c_c++/Makefile +57 -0
- KastnerRG_riffa/c_c++/linux/x64/README.txt +3 -0
- KastnerRG_riffa/c_c++/linux/x64/sample_app/Makefile +61 -0
- KastnerRG_riffa/c_c++/linux/x64/sample_app/README.txt +8 -0
- KastnerRG_riffa/c_c++/linux/x64/sample_app/testutil.c +179 -0
- KastnerRG_riffa/c_c++/linux/x64/sample_app/timer.h +42 -0
- KastnerRG_riffa/c_c++/linux/x64/test_apps/Makefile +61 -0
- KastnerRG_riffa/c_c++/linux/x64/test_apps/asyncutil.sh +60 -0
- KastnerRG_riffa/c_c++/linux/x64/test_apps/testutil.c +543 -0
- KastnerRG_riffa/c_c++/linux/x64/test_apps/testutil.c_multi +194 -0
- KastnerRG_riffa/c_c++/linux/x64/test_apps/testutil.sh +55 -0
- KastnerRG_riffa/c_c++/linux/x64/test_apps/timer.h +42 -0
- KastnerRG_riffa/c_c++/linux/x86/README.txt +3 -0
- KastnerRG_riffa/c_c++/linux/x86/sample_app/Makefile +61 -0
- KastnerRG_riffa/c_c++/linux/x86/sample_app/README.txt +8 -0
- KastnerRG_riffa/c_c++/linux/x86/sample_app/testutil.c +179 -0
- KastnerRG_riffa/c_c++/linux/x86/sample_app/timer.h +42 -0
- KastnerRG_riffa/c_c++/windows/x64/README.txt +14 -0
- KastnerRG_riffa/c_c++/windows/x64/riffa.c +423 -0
- KastnerRG_riffa/c_c++/windows/x64/riffa.def +13 -0
- KastnerRG_riffa/c_c++/windows/x64/riffa.exp +0 -0
- KastnerRG_riffa/c_c++/windows/x64/riffa.h +142 -0
- KastnerRG_riffa/c_c++/windows/x64/riffa.lib +0 -0
- KastnerRG_riffa/c_c++/windows/x64/riffa.rc +76 -0
- KastnerRG_riffa/c_c++/windows/x64/riffa_driver.h +19 -0
- KastnerRG_riffa/c_c++/windows/x64/sample_app/README.txt +10 -0
- KastnerRG_riffa/c_c++/windows/x64/sample_app/riffa.h +142 -0
- KastnerRG_riffa/c_c++/windows/x64/sample_app/riffa.lib +0 -0
- KastnerRG_riffa/c_c++/windows/x64/sample_app/testutil.c +146 -0
- KastnerRG_riffa/c_c++/windows/x64/sample_app/timer.h +7 -0
- KastnerRG_riffa/c_c++/windows/x86/README.txt +14 -0
- KastnerRG_riffa/c_c++/windows/x86/riffa.c +423 -0
- KastnerRG_riffa/c_c++/windows/x86/riffa.def +13 -0
- KastnerRG_riffa/c_c++/windows/x86/riffa.exp +0 -0
- KastnerRG_riffa/c_c++/windows/x86/riffa.h +142 -0
- KastnerRG_riffa/c_c++/windows/x86/riffa.lib +0 -0
- KastnerRG_riffa/c_c++/windows/x86/riffa.rc +76 -0
- KastnerRG_riffa/c_c++/windows/x86/riffa_driver.h +23 -0
- KastnerRG_riffa/c_c++/windows/x86/sample_app/README.txt +10 -0
- KastnerRG_riffa/c_c++/windows/x86/sample_app/riffa.h +142 -0
- KastnerRG_riffa/c_c++/windows/x86/sample_app/riffa.lib +0 -0
- KastnerRG_riffa/c_c++/windows/x86/sample_app/testutil.c +146 -0
- KastnerRG_riffa/c_c++/windows/x86/sample_app/timer.h +7 -0
- KastnerRG_riffa/docs/Makefile +65 -0
- KastnerRG_riffa/docs/RIFFA.graphml +0 -0
- KastnerRG_riffa/docs/riffa_documentation.tex +1892 -0
.gitattributes
CHANGED
|
@@ -430,3 +430,4 @@ splinedrive_kianRiscV/linux_socs/kianv_mc_rv32ima_sv32/os/linux/buildroot-kianv-
|
|
| 430 |
splinedrive_kianRiscV/linux_socs/kianv_mc_rv32ima_sv32/os/linux/buildroot-kianv-soc/bldroot/rootfs-overlay/root/TinyPrograms/race filter=lfs diff=lfs merge=lfs -text
|
| 431 |
splinedrive_kianRiscV/linux_socs/kianv_mc_rv32ima_sv32/os/linux/buildroot-kianv-soc/bldroot/rootfs-overlay/root/TinyPrograms/render filter=lfs diff=lfs merge=lfs -text
|
| 432 |
splinedrive_kianRiscV/linux_socs/kianv_mc_rv32ima_sv32/os/linux/buildroot-kianv-soc/bldroot/rootfs-overlay/root/TinyPrograms/tinyraytracer filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 430 |
splinedrive_kianRiscV/linux_socs/kianv_mc_rv32ima_sv32/os/linux/buildroot-kianv-soc/bldroot/rootfs-overlay/root/TinyPrograms/race filter=lfs diff=lfs merge=lfs -text
|
| 431 |
splinedrive_kianRiscV/linux_socs/kianv_mc_rv32ima_sv32/os/linux/buildroot-kianv-soc/bldroot/rootfs-overlay/root/TinyPrograms/render filter=lfs diff=lfs merge=lfs -text
|
| 432 |
splinedrive_kianRiscV/linux_socs/kianv_mc_rv32ima_sv32/os/linux/buildroot-kianv-soc/bldroot/rootfs-overlay/root/TinyPrograms/tinyraytracer filter=lfs diff=lfs merge=lfs -text
|
| 433 |
+
KastnerRG_riffa/java/riffa.jar filter=lfs diff=lfs merge=lfs -text
|
KastnerRG_riffa/LICENSE
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
----------------------------------------------------------------------
|
| 2 |
+
Copyright (c) 2016, The Regents of the University of California All
|
| 3 |
+
rights reserved.
|
| 4 |
+
|
| 5 |
+
Redistribution and use in source and binary forms, with or without
|
| 6 |
+
modification, are permitted provided that the following conditions are
|
| 7 |
+
met:
|
| 8 |
+
|
| 9 |
+
* Redistributions of source code must retain the above copyright
|
| 10 |
+
notice, this list of conditions and the following disclaimer.
|
| 11 |
+
|
| 12 |
+
* Redistributions in binary form must reproduce the above
|
| 13 |
+
copyright notice, this list of conditions and the following
|
| 14 |
+
disclaimer in the documentation and/or other materials provided
|
| 15 |
+
with the distribution.
|
| 16 |
+
|
| 17 |
+
* Neither the name of The Regents of the University of California
|
| 18 |
+
nor the names of its contributors may be used to endorse or
|
| 19 |
+
promote products derived from this software without specific
|
| 20 |
+
prior written permission.
|
| 21 |
+
|
| 22 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 23 |
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 24 |
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 25 |
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE
|
| 26 |
+
UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 27 |
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 28 |
+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
| 29 |
+
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 30 |
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 31 |
+
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
| 32 |
+
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 33 |
+
DAMAGE.
|
| 34 |
+
----------------------------------------------------------------------
|
KastnerRG_riffa/Makefile
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ----------------------------------------------------------------------
|
| 2 |
+
# Copyright (c) 2016, The Regents of the University of California All
|
| 3 |
+
# rights reserved.
|
| 4 |
+
#
|
| 5 |
+
# Redistribution and use in source and binary forms, with or without
|
| 6 |
+
# modification, are permitted provided that the following conditions are
|
| 7 |
+
# met:
|
| 8 |
+
#
|
| 9 |
+
# * Redistributions of source code must retain the above copyright
|
| 10 |
+
# notice, this list of conditions and the following disclaimer.
|
| 11 |
+
#
|
| 12 |
+
# * Redistributions in binary form must reproduce the above
|
| 13 |
+
# copyright notice, this list of conditions and the following
|
| 14 |
+
# disclaimer in the documentation and/or other materials provided
|
| 15 |
+
# with the distribution.
|
| 16 |
+
#
|
| 17 |
+
# * Neither the name of The Regents of the University of California
|
| 18 |
+
# nor the names of its contributors may be used to endorse or
|
| 19 |
+
# promote products derived from this software without specific
|
| 20 |
+
# prior written permission.
|
| 21 |
+
#
|
| 22 |
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 23 |
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 24 |
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 25 |
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE
|
| 26 |
+
# UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 27 |
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 28 |
+
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
| 29 |
+
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 30 |
+
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 31 |
+
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
| 32 |
+
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 33 |
+
# DAMAGE.
|
| 34 |
+
# ----------------------------------------------------------------------
|
| 35 |
+
#-----------------------------------------------------------------------
|
| 36 |
+
# Filename: Makefile
|
| 37 |
+
# Version: 1.0
|
| 38 |
+
# Description: Top-level makefile for building a RIFFA distribution
|
| 39 |
+
# Author: Dustin Richmond (@darichmond)
|
| 40 |
+
#-----------------------------------------------------------------------
|
| 41 |
+
include release.mk
|
| 42 |
+
CURRENT_PATH := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
|
| 43 |
+
RIFFA_ROOT_PATH := $(CURRENT_PATH)
|
| 44 |
+
|
| 45 |
+
RELEASE_VER=2.2.2
|
| 46 |
+
RELEASE_DIR=riffa_$(RELEASE_VER)
|
| 47 |
+
RELEASE_PATH=$(CURRENT_PATH)/$(RELEASE_DIR)
|
| 48 |
+
RELEASE_SRC_DIR=$(RELEASE_DIR)/source
|
| 49 |
+
RELEASE_SRC_PATH=$(CURRENT_PATH)/$(RELEASE_SRC_DIR)
|
| 50 |
+
RELEASE_DOC_DIR=$(RELEASE_DIR)/documentation
|
| 51 |
+
RELEASE_DOC_PATH=$(CURRENT_PATH)/$(RELEASE_DOC_DIR)
|
| 52 |
+
RELEASE_INSTALL_DIR=$(RELEASE_DIR)/install
|
| 53 |
+
RELEASE_INSTALL_PATH=$(CURRENT_PATH)/$(RELEASE_INSTALL_DIR)
|
| 54 |
+
|
| 55 |
+
VENDORS=altera xilinx
|
| 56 |
+
SUBDIRS=c_c++ docs driver fpga java matlab python #install
|
| 57 |
+
|
| 58 |
+
all-boards:
|
| 59 |
+
$(MAKE) -C fpga $(VENDORS)
|
| 60 |
+
|
| 61 |
+
$(RELEASE_DIR):
|
| 62 |
+
mkdir $@
|
| 63 |
+
|
| 64 |
+
$(RELEASE_SRC_DIR): $(RELEASE_DIR) check-release
|
| 65 |
+
mkdir $@
|
| 66 |
+
|
| 67 |
+
$(RELEASE_DOC_DIR): $(RELEASE_DIR) check-release
|
| 68 |
+
mkdir $@
|
| 69 |
+
|
| 70 |
+
release: clean $(RELEASE_DIR) $(RELEASE_SRC_DIR) $(RELEASE_DOC_DIR) $(SUBDIRS)
|
| 71 |
+
|
| 72 |
+
$(SUBDIRS)::
|
| 73 |
+
make -C $@ $(MAKECMDGOALS) RELEASE_SRC_PATH=$(RELEASE_SRC_PATH) RELEASE_VER=$(RELEASE_VER) RIFFA_ROOT_PATH=$(RIFFA_ROOT_PATH) RELEASE_DOC_PATH=$(RELEASE_DOC_PATH)
|
| 74 |
+
|
| 75 |
+
clean:
|
| 76 |
+
rm -rf $(RELEASE_DIR)
|
KastnerRG_riffa/README.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# riffa
|
| 2 |
+
RIFFA (Reusable Integration Framework for FPGA Accelerators) is a simple framework for communicating data from a host CPU to a FPGA via a PCI Express bus. The framework requires a PCIe enabled workstation and a FPGA on a board with a PCIe connector. RIFFA supports Windows and Linux, Altera and Xilinx, with bindings for C/C++, Python, MATLAB and Java.
|
| 3 |
+
|
| 4 |
+
On the software side there are two main functions: data send and data receive. These functions are exposed via user libraries in C/C++, Python, MATLAB, and Java. The driver supports multiple FPGAs (up to 5) per system. The software bindings work on Linux and Windows operating systems. Users can communicate with FPGA IP cores by writing only a few lines of code.
|
| 5 |
+
|
| 6 |
+
On the hardware side, users access an interface with independent transmit and receive signals. The signals provide transaction handshaking and a first word fall through FIFO interface for reading/writing data. No knowledge of bus addresses, buffer sizes, or PCIe packet formats is required. Simply send data on a FIFO interface and receive data on a FIFO interface. RIFFA does not rely on a PCIe Bridge and therefore is not subject to the limitations of a bridge implementation. Instead, RIFFA works directly with the PCIe Endpoint and can run fast enough to saturate the PCIe link. Both the software and hardware interfaces have been greatly simplified. Details can be found on the hardware interface page.
|
| 7 |
+
|
| 8 |
+
RIFFA communicates data using direct memory access (DMA) transfers and interrupt signaling. This achieves high bandwidth over the PCIe link. In our tests we are able to saturate (or near saturate) the link in all our tests. We have implemented RIFFA on the AVNet Spartan LX150T, Xilinx ML605, and Xilinx VC707, as well as the Altera DE5-Net, DE4 and DE2i boards. The RIFFA distribution contains examples and guides for setting up designs on the three development boards listed above. In addition, this website has examples of how to access your design from all the software bindings. RIFFA has been tested on Fedora 13 & 17 (32/64 bit vers.) and Ubuntu Desktop 10.04 LTS & 12.04 LTS (32/64 bit vers.). RIFFA relies on a custom Linux kernel driver which is supported on Linux kernels 2.6.27+ (tested on versions between 2.6.32 - 3.3.0). The Windows driver is supported on: Windows 7 in both 32 bit and 64 bit variants
|
KastnerRG_riffa/c_c++/Makefile
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ----------------------------------------------------------------------
|
| 2 |
+
# Copyright (c) 2016, The Regents of the University of California All
|
| 3 |
+
# rights reserved.
|
| 4 |
+
#
|
| 5 |
+
# Redistribution and use in source and binary forms, with or without
|
| 6 |
+
# modification, are permitted provided that the following conditions are
|
| 7 |
+
# met:
|
| 8 |
+
#
|
| 9 |
+
# * Redistributions of source code must retain the above copyright
|
| 10 |
+
# notice, this list of conditions and the following disclaimer.
|
| 11 |
+
#
|
| 12 |
+
# * Redistributions in binary form must reproduce the above
|
| 13 |
+
# copyright notice, this list of conditions and the following
|
| 14 |
+
# disclaimer in the documentation and/or other materials provided
|
| 15 |
+
# with the distribution.
|
| 16 |
+
#
|
| 17 |
+
# * Neither the name of The Regents of the University of California
|
| 18 |
+
# nor the names of its contributors may be used to endorse or
|
| 19 |
+
# promote products derived from this software without specific
|
| 20 |
+
# prior written permission.
|
| 21 |
+
#
|
| 22 |
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 23 |
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 24 |
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 25 |
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE
|
| 26 |
+
# UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 27 |
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 28 |
+
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
| 29 |
+
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 30 |
+
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 31 |
+
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
| 32 |
+
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 33 |
+
# DAMAGE.
|
| 34 |
+
# ----------------------------------------------------------------------
|
| 35 |
+
#-----------------------------------------------------------------------
|
| 36 |
+
# Filename: Makefile
|
| 37 |
+
# Version: 1.0
|
| 38 |
+
# Description: Makefile for including the C/C++ subdirectory in
|
| 39 |
+
# a RIFFA release. Expects RELEASE_SRC_PATH to be set
|
| 40 |
+
# by parent Makefile.
|
| 41 |
+
# Author: Dustin Richmond (@darichmond)
|
| 42 |
+
#-----------------------------------------------------------------------
|
| 43 |
+
|
| 44 |
+
CURRENT_PATH := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
|
| 45 |
+
CURRENT_DIR := $(shell basename $(CURRENT_PATH))
|
| 46 |
+
DEST_PATH := $(RELEASE_SRC_PATH)/$(CURRENT_DIR)/
|
| 47 |
+
include $(RIFFA_ROOT_PATH)/release.mk
|
| 48 |
+
|
| 49 |
+
release: check-release-src clean-release
|
| 50 |
+
cp -r $(CURRENT_PATH) $(DEST_PATH)
|
| 51 |
+
rm -r $(DEST_PATH)/Makefile
|
| 52 |
+
|
| 53 |
+
clean-release: check-release-src
|
| 54 |
+
rm -rf $(DEST_PATH)
|
| 55 |
+
|
| 56 |
+
clean: check
|
| 57 |
+
|
KastnerRG_riffa/c_c++/linux/x64/README.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The Linux C/C++ library is compiled and installed with the kernel driver. This
|
| 2 |
+
directory contains a sample application subdirectory that you can use to test
|
| 3 |
+
your design.
|
KastnerRG_riffa/c_c++/linux/x64/sample_app/Makefile
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ----------------------------------------------------------------------
|
| 2 |
+
# Copyright (c) 2016, The Regents of the University of California All
|
| 3 |
+
# rights reserved.
|
| 4 |
+
#
|
| 5 |
+
# Redistribution and use in source and binary forms, with or without
|
| 6 |
+
# modification, are permitted provided that the following conditions are
|
| 7 |
+
# met:
|
| 8 |
+
#
|
| 9 |
+
# * Redistributions of source code must retain the above copyright
|
| 10 |
+
# notice, this list of conditions and the following disclaimer.
|
| 11 |
+
#
|
| 12 |
+
# * Redistributions in binary form must reproduce the above
|
| 13 |
+
# copyright notice, this list of conditions and the following
|
| 14 |
+
# disclaimer in the documentation and/or other materials provided
|
| 15 |
+
# with the distribution.
|
| 16 |
+
#
|
| 17 |
+
# * Neither the name of The Regents of the University of California
|
| 18 |
+
# nor the names of its contributors may be used to endorse or
|
| 19 |
+
# promote products derived from this software without specific
|
| 20 |
+
# prior written permission.
|
| 21 |
+
#
|
| 22 |
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 23 |
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 24 |
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 25 |
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE
|
| 26 |
+
# UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 27 |
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 28 |
+
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
| 29 |
+
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 30 |
+
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 31 |
+
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
| 32 |
+
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 33 |
+
# DAMAGE.
|
| 34 |
+
# ----------------------------------------------------------------------
|
| 35 |
+
program_NAME := testutil
|
| 36 |
+
program_C_SRCS := $(wildcard *.c)
|
| 37 |
+
program_CXX_SRCS := $(wildcard *.cpp)
|
| 38 |
+
program_C_OBJS := ${program_C_SRCS:.c=.o}
|
| 39 |
+
program_CXX_OBJS := ${program_CXX_SRCS:.cpp=.o}
|
| 40 |
+
program_OBJS := $(program_C_OBJS) $(program_CXX_OBJS)
|
| 41 |
+
program_INCLUDE_DIRS :=
|
| 42 |
+
program_LIBRARY_DIRS :=
|
| 43 |
+
program_LIBRARIES := riffa
|
| 44 |
+
CPPFLAGS += -g
|
| 45 |
+
|
| 46 |
+
CPPFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))
|
| 47 |
+
LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir))
|
| 48 |
+
LDFLAGS += $(foreach library,$(program_LIBRARIES),-l$(library))
|
| 49 |
+
|
| 50 |
+
.PHONY: all clean distclean
|
| 51 |
+
|
| 52 |
+
all: $(program_NAME)
|
| 53 |
+
|
| 54 |
+
$(program_NAME): $(program_OBJS)
|
| 55 |
+
$(CC) $(CPPFLAGS) $(program_OBJS) -o $(program_NAME) $(LDFLAGS)
|
| 56 |
+
|
| 57 |
+
clean:
|
| 58 |
+
@- $(RM) $(program_NAME)
|
| 59 |
+
@- $(RM) $(program_OBJS)
|
| 60 |
+
|
| 61 |
+
distclean: clean
|
KastnerRG_riffa/c_c++/linux/x64/sample_app/README.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The testutil example application works with the Verilog chnl_tester module
|
| 2 |
+
which receives data and then sends data back to the workstation.
|
| 3 |
+
|
| 4 |
+
To compile the example application:
|
| 5 |
+
|
| 6 |
+
make
|
| 7 |
+
|
| 8 |
+
The riffa C/C++ library must be installed (it gets installed with the driver).
|
KastnerRG_riffa/c_c++/linux/x64/sample_app/testutil.c
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// ----------------------------------------------------------------------
|
| 2 |
+
// Copyright (c) 2016, The Regents of the University of California All
|
| 3 |
+
// rights reserved.
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
//
|
| 12 |
+
// * Redistributions in binary form must reproduce the above
|
| 13 |
+
// copyright notice, this list of conditions and the following
|
| 14 |
+
// disclaimer in the documentation and/or other materials provided
|
| 15 |
+
// with the distribution.
|
| 16 |
+
//
|
| 17 |
+
// * Neither the name of The Regents of the University of California
|
| 18 |
+
// nor the names of its contributors may be used to endorse or
|
| 19 |
+
// promote products derived from this software without specific
|
| 20 |
+
// prior written permission.
|
| 21 |
+
//
|
| 22 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 23 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 24 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 25 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE
|
| 26 |
+
// UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 27 |
+
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 28 |
+
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
| 29 |
+
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 30 |
+
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 31 |
+
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
| 32 |
+
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 33 |
+
// DAMAGE.
|
| 34 |
+
// ----------------------------------------------------------------------
|
| 35 |
+
#include <stdlib.h>
|
| 36 |
+
#include <stdio.h>
|
| 37 |
+
#include "timer.h"
|
| 38 |
+
#include "riffa.h"
|
| 39 |
+
|
| 40 |
+
int main(int argc, char** argv) {
|
| 41 |
+
fpga_t * fpga;
|
| 42 |
+
fpga_info_list info;
|
| 43 |
+
int option;
|
| 44 |
+
int i;
|
| 45 |
+
int id;
|
| 46 |
+
int chnl;
|
| 47 |
+
size_t numWords;
|
| 48 |
+
int sent;
|
| 49 |
+
int recvd;
|
| 50 |
+
unsigned int * sendBuffer;
|
| 51 |
+
unsigned int * recvBuffer;
|
| 52 |
+
GET_TIME_INIT(3);
|
| 53 |
+
|
| 54 |
+
if (argc < 2) {
|
| 55 |
+
printf("Usage: %s <option>\n", argv[0]);
|
| 56 |
+
return -1;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
option = atoi(argv[1]);
|
| 60 |
+
|
| 61 |
+
if (option == 0) { // List FPGA info
|
| 62 |
+
// Populate the fpga_info_list struct
|
| 63 |
+
if (fpga_list(&info) != 0) {
|
| 64 |
+
printf("Error populating fpga_info_list\n");
|
| 65 |
+
return -1;
|
| 66 |
+
}
|
| 67 |
+
printf("Number of devices: %d\n", info.num_fpgas);
|
| 68 |
+
for (i = 0; i < info.num_fpgas; i++) {
|
| 69 |
+
printf("%d: id:%d\n", i, info.id[i]);
|
| 70 |
+
printf("%d: num_chnls:%d\n", i, info.num_chnls[i]);
|
| 71 |
+
printf("%d: name:%s\n", i, info.name[i]);
|
| 72 |
+
printf("%d: vendor id:%04X\n", i, info.vendor_id[i]);
|
| 73 |
+
printf("%d: device id:%04X\n", i, info.device_id[i]);
|
| 74 |
+
}
|
| 75 |
+
}
|
| 76 |
+
else if (option == 1) { // Reset FPGA
|
| 77 |
+
if (argc < 3) {
|
| 78 |
+
printf("Usage: %s %d <fpga id>\n", argv[0], option);
|
| 79 |
+
return -1;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
id = atoi(argv[2]);
|
| 83 |
+
|
| 84 |
+
// Get the device with id
|
| 85 |
+
fpga = fpga_open(id);
|
| 86 |
+
if (fpga == NULL) {
|
| 87 |
+
printf("Could not get FPGA %d\n", id);
|
| 88 |
+
return -1;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
// Reset
|
| 92 |
+
fpga_reset(fpga);
|
| 93 |
+
|
| 94 |
+
// Done with device
|
| 95 |
+
fpga_close(fpga);
|
| 96 |
+
}
|
| 97 |
+
else if (option == 2) { // Send data, receive data
|
| 98 |
+
if (argc < 5) {
|
| 99 |
+
printf("Usage: %s %d <fpga id> <chnl> <num words to transfer>\n", argv[0], option);
|
| 100 |
+
return -1;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
id = atoi(argv[2]);
|
| 104 |
+
chnl = atoi(argv[3]);
|
| 105 |
+
numWords = atoi(argv[4]);
|
| 106 |
+
|
| 107 |
+
// Get the device with id
|
| 108 |
+
fpga = fpga_open(id);
|
| 109 |
+
if (fpga == NULL) {
|
| 110 |
+
printf("Could not get FPGA %d\n", id);
|
| 111 |
+
return -1;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
// Malloc the arrays
|
| 115 |
+
sendBuffer = (unsigned int *)malloc(numWords<<2);
|
| 116 |
+
if (sendBuffer == NULL) {
|
| 117 |
+
printf("Could not malloc memory for sendBuffer\n");
|
| 118 |
+
fpga_close(fpga);
|
| 119 |
+
return -1;
|
| 120 |
+
}
|
| 121 |
+
recvBuffer = (unsigned int *)malloc(numWords<<2);
|
| 122 |
+
if (recvBuffer == NULL) {
|
| 123 |
+
printf("Could not malloc memory for recvBuffer\n");
|
| 124 |
+
free(sendBuffer);
|
| 125 |
+
fpga_close(fpga);
|
| 126 |
+
return -1;
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
// Initialize the data
|
| 130 |
+
for (i = 0; i < numWords; i++) {
|
| 131 |
+
sendBuffer[i] = i+1;
|
| 132 |
+
recvBuffer[i] = 0;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
GET_TIME_VAL(0);
|
| 136 |
+
|
| 137 |
+
// Send the data
|
| 138 |
+
sent = fpga_send(fpga, chnl, sendBuffer, numWords, 0, 1, 25000);
|
| 139 |
+
printf("words sent: %d\n", sent);
|
| 140 |
+
|
| 141 |
+
GET_TIME_VAL(1);
|
| 142 |
+
|
| 143 |
+
if (sent != 0) {
|
| 144 |
+
// Recv the data
|
| 145 |
+
recvd = fpga_recv(fpga, chnl, recvBuffer, numWords, 25000);
|
| 146 |
+
printf("words recv: %d\n", recvd);
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
GET_TIME_VAL(2);
|
| 150 |
+
|
| 151 |
+
// Done with device
|
| 152 |
+
fpga_close(fpga);
|
| 153 |
+
|
| 154 |
+
// Display some data
|
| 155 |
+
for (i = 0; i < 20; i++) {
|
| 156 |
+
printf("recvBuffer[%d]: %d\n", i, recvBuffer[i]);
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
// Check the data
|
| 160 |
+
if (recvd != 0) {
|
| 161 |
+
for (i = 4; i < recvd; i++) {
|
| 162 |
+
if (recvBuffer[i] != sendBuffer[i]) {
|
| 163 |
+
printf("recvBuffer[%d]: %d, expected %d\n", i, recvBuffer[i], sendBuffer[i]);
|
| 164 |
+
break;
|
| 165 |
+
}
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
printf("send bw: %f MB/s %fms\n",
|
| 169 |
+
sent*4.0/1024/1024/((TIME_VAL_TO_MS(1) - TIME_VAL_TO_MS(0))/1000.0),
|
| 170 |
+
(TIME_VAL_TO_MS(1) - TIME_VAL_TO_MS(0)) );
|
| 171 |
+
|
| 172 |
+
printf("recv bw: %f MB/s %fms\n",
|
| 173 |
+
recvd*4.0/1024/1024/((TIME_VAL_TO_MS(2) - TIME_VAL_TO_MS(1))/1000.0),
|
| 174 |
+
(TIME_VAL_TO_MS(2) - TIME_VAL_TO_MS(1)) );
|
| 175 |
+
}
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
return 0;
|
| 179 |
+
}
|
KastnerRG_riffa/c_c++/linux/x64/sample_app/timer.h
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// ----------------------------------------------------------------------
|
| 2 |
+
// Copyright (c) 2016, The Regents of the University of California All
|
| 3 |
+
// rights reserved.
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
//
|
| 12 |
+
// * Redistributions in binary form must reproduce the above
|
| 13 |
+
// copyright notice, this list of conditions and the following
|
| 14 |
+
// disclaimer in the documentation and/or other materials provided
|
| 15 |
+
// with the distribution.
|
| 16 |
+
//
|
| 17 |
+
// * Neither the name of The Regents of the University of California
|
| 18 |
+
// nor the names of its contributors may be used to endorse or
|
| 19 |
+
// promote products derived from this software without specific
|
| 20 |
+
// prior written permission.
|
| 21 |
+
//
|
| 22 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 23 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 24 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 25 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE
|
| 26 |
+
// UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 27 |
+
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 28 |
+
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
| 29 |
+
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 30 |
+
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 31 |
+
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
| 32 |
+
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 33 |
+
// DAMAGE.
|
| 34 |
+
// ----------------------------------------------------------------------
|
| 35 |
+
#include <sys/time.h>
|
| 36 |
+
|
| 37 |
+
#define GET_TIME_INIT(num) struct timeval _timers[num]
|
| 38 |
+
|
| 39 |
+
#define GET_TIME_VAL(num) gettimeofday(&_timers[num], NULL)
|
| 40 |
+
|
| 41 |
+
#define TIME_VAL_TO_MS(num) (((double)_timers[num].tv_sec*1000.0) + ((double)_timers[num].tv_usec/1000.0))
|
| 42 |
+
|
KastnerRG_riffa/c_c++/linux/x64/test_apps/Makefile
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ----------------------------------------------------------------------
|
| 2 |
+
# Copyright (c) 2016, The Regents of the University of California All
|
| 3 |
+
# rights reserved.
|
| 4 |
+
#
|
| 5 |
+
# Redistribution and use in source and binary forms, with or without
|
| 6 |
+
# modification, are permitted provided that the following conditions are
|
| 7 |
+
# met:
|
| 8 |
+
#
|
| 9 |
+
# * Redistributions of source code must retain the above copyright
|
| 10 |
+
# notice, this list of conditions and the following disclaimer.
|
| 11 |
+
#
|
| 12 |
+
# * Redistributions in binary form must reproduce the above
|
| 13 |
+
# copyright notice, this list of conditions and the following
|
| 14 |
+
# disclaimer in the documentation and/or other materials provided
|
| 15 |
+
# with the distribution.
|
| 16 |
+
#
|
| 17 |
+
# * Neither the name of The Regents of the University of California
|
| 18 |
+
# nor the names of its contributors may be used to endorse or
|
| 19 |
+
# promote products derived from this software without specific
|
| 20 |
+
# prior written permission.
|
| 21 |
+
#
|
| 22 |
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 23 |
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 24 |
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 25 |
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE
|
| 26 |
+
# UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 27 |
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 28 |
+
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
| 29 |
+
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 30 |
+
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 31 |
+
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
| 32 |
+
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 33 |
+
# DAMAGE.
|
| 34 |
+
# ----------------------------------------------------------------------
|
| 35 |
+
program_NAME := testutil
|
| 36 |
+
program_C_SRCS := $(wildcard *.c)
|
| 37 |
+
program_CXX_SRCS := $(wildcard *.cpp)
|
| 38 |
+
program_C_OBJS := ${program_C_SRCS:.c=.o}
|
| 39 |
+
program_CXX_OBJS := ${program_CXX_SRCS:.cpp=.o}
|
| 40 |
+
program_OBJS := $(program_C_OBJS) $(program_CXX_OBJS)
|
| 41 |
+
program_INCLUDE_DIRS :=
|
| 42 |
+
program_LIBRARY_DIRS :=
|
| 43 |
+
program_LIBRARIES := riffa
|
| 44 |
+
CPPFLAGS += -g
|
| 45 |
+
|
| 46 |
+
CPPFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))
|
| 47 |
+
LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir))
|
| 48 |
+
LDFLAGS += $(foreach library,$(program_LIBRARIES),-l$(library))
|
| 49 |
+
|
| 50 |
+
.PHONY: all clean distclean
|
| 51 |
+
|
| 52 |
+
all: $(program_NAME)
|
| 53 |
+
|
| 54 |
+
$(program_NAME): $(program_OBJS)
|
| 55 |
+
$(CC) $(CPPFLAGS) $(program_OBJS) -o $(program_NAME) $(LDFLAGS)
|
| 56 |
+
|
| 57 |
+
clean:
|
| 58 |
+
@- $(RM) $(program_NAME)
|
| 59 |
+
@- $(RM) $(program_OBJS)
|
| 60 |
+
|
| 61 |
+
distclean: clean
|
KastnerRG_riffa/c_c++/linux/x64/test_apps/asyncutil.sh
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# ----------------------------------------------------------------------
|
| 3 |
+
# Copyright (c) 2016, The Regents of the University of California All
|
| 4 |
+
# rights reserved.
|
| 5 |
+
#
|
| 6 |
+
# Redistribution and use in source and binary forms, with or without
|
| 7 |
+
# modification, are permitted provided that the following conditions are
|
| 8 |
+
# met:
|
| 9 |
+
#
|
| 10 |
+
# * Redistributions of source code must retain the above copyright
|
| 11 |
+
# notice, this list of conditions and the following disclaimer.
|
| 12 |
+
#
|
| 13 |
+
# * Redistributions in binary form must reproduce the above
|
| 14 |
+
# copyright notice, this list of conditions and the following
|
| 15 |
+
# disclaimer in the documentation and/or other materials provided
|
| 16 |
+
# with the distribution.
|
| 17 |
+
#
|
| 18 |
+
# * Neither the name of The Regents of the University of California
|
| 19 |
+
# nor the names of its contributors may be used to endorse or
|
| 20 |
+
# promote products derived from this software without specific
|
| 21 |
+
# prior written permission.
|
| 22 |
+
#
|
| 23 |
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 24 |
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 25 |
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 26 |
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE
|
| 27 |
+
# UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 28 |
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 29 |
+
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
| 30 |
+
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 31 |
+
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 32 |
+
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
| 33 |
+
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 34 |
+
# DAMAGE.
|
| 35 |
+
# ----------------------------------------------------------------------
|
| 36 |
+
|
| 37 |
+
PATH=$PATH:./
|
| 38 |
+
RESULT_PATH=./results/
|
| 39 |
+
|
| 40 |
+
if [ "$#" -lt 2 ]; then
|
| 41 |
+
echo "usage: $0 <fpga id> <board name>"
|
| 42 |
+
exit
|
| 43 |
+
fi
|
| 44 |
+
|
| 45 |
+
for i in {0..11}
|
| 46 |
+
do
|
| 47 |
+
testutil 1 $1
|
| 48 |
+
|
| 49 |
+
# Run full bandwidth test
|
| 50 |
+
testutil 2 $1 $i 1048576 | tee $RESULT_PATH/$2_C$i\_bw.txt
|
| 51 |
+
|
| 52 |
+
# Run RX Sweep Test
|
| 53 |
+
testutil 3 $1 $i 2048 | tee $RESULT_PATH/$2_C$i\_rx.txt
|
| 54 |
+
|
| 55 |
+
# Run TX Sweep Test
|
| 56 |
+
testutil 4 $1 $i 2048 | tee $RESULT_PATH/$2_C$i\_tx.txt
|
| 57 |
+
|
| 58 |
+
done
|
| 59 |
+
|
| 60 |
+
|
KastnerRG_riffa/c_c++/linux/x64/test_apps/testutil.c
ADDED
|
@@ -0,0 +1,543 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// ----------------------------------------------------------------------
|
| 2 |
+
// Copyright (c) 2016, The Regents of the University of California All
|
| 3 |
+
// rights reserved.
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
//
|
| 12 |
+
// * Redistributions in binary form must reproduce the above
|
| 13 |
+
// copyright notice, this list of conditions and the following
|
| 14 |
+
// disclaimer in the documentation and/or other materials provided
|
| 15 |
+
// with the distribution.
|
| 16 |
+
//
|
| 17 |
+
// * Neither the name of The Regents of the University of California
|
| 18 |
+
// nor the names of its contributors may be used to endorse or
|
| 19 |
+
// promote products derived from this software without specific
|
| 20 |
+
// prior written permission.
|
| 21 |
+
//
|
| 22 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 23 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 24 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 25 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE
|
| 26 |
+
// UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 27 |
+
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 28 |
+
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
| 29 |
+
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 30 |
+
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 31 |
+
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
| 32 |
+
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 33 |
+
// DAMAGE.
|
| 34 |
+
// ----------------------------------------------------------------------
|
| 35 |
+
#include <stdlib.h>
|
| 36 |
+
#include <stdio.h>
|
| 37 |
+
#include "timer.h"
|
| 38 |
+
#include "riffa.h"
|
| 39 |
+
#define NUM_TESTS 100
|
| 40 |
+
|
| 41 |
+
int main(int argc, char** argv) {
|
| 42 |
+
fpga_t * fpga;
|
| 43 |
+
fpga_info_list info;
|
| 44 |
+
int option;
|
| 45 |
+
int i;
|
| 46 |
+
int id;
|
| 47 |
+
int chnl;
|
| 48 |
+
size_t numWords;
|
| 49 |
+
int sent;
|
| 50 |
+
int recvd;
|
| 51 |
+
int failure = 0;
|
| 52 |
+
unsigned int * sendBuffer;
|
| 53 |
+
unsigned int * recvBuffer;
|
| 54 |
+
int err;
|
| 55 |
+
GET_TIME_INIT(3);
|
| 56 |
+
|
| 57 |
+
if (argc < 2) {
|
| 58 |
+
printf("Usage: %s <option>\n", argv[0]);
|
| 59 |
+
return -1;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
option = atoi(argv[1]);
|
| 63 |
+
|
| 64 |
+
if (option == 0) {
|
| 65 |
+
// List FPGA info
|
| 66 |
+
// Populate the fpga_info_list struct
|
| 67 |
+
if (fpga_list(&info) != 0) {
|
| 68 |
+
printf("Error populating fpga_info_list\n");
|
| 69 |
+
return -1;
|
| 70 |
+
}
|
| 71 |
+
printf("Number of devices: %d\n", info.num_fpgas);
|
| 72 |
+
for (i = 0; i < info.num_fpgas; i++) {
|
| 73 |
+
printf("%d: id:%d\n", i, info.id[i]);
|
| 74 |
+
printf("%d: num_chnls:%d\n", i, info.num_chnls[i]);
|
| 75 |
+
printf("%d: name:%s\n", i, info.name[i]);
|
| 76 |
+
printf("%d: vendor id:%04X\n", i, info.vendor_id[i]);
|
| 77 |
+
printf("%d: device id:%04X\n", i, info.device_id[i]);
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
else if (option == 1) { // Reset FPGA
|
| 81 |
+
if (argc < 3) {
|
| 82 |
+
printf("Usage: %s %d <fpga id>\n", argv[0], option);
|
| 83 |
+
return -1;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
id = atoi(argv[2]);
|
| 87 |
+
|
| 88 |
+
// Get the device with id
|
| 89 |
+
fpga = fpga_open(id);
|
| 90 |
+
if (fpga == NULL) {
|
| 91 |
+
printf("Could not get FPGA %d\n", id);
|
| 92 |
+
return -1;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
// Reset
|
| 96 |
+
fpga_reset(fpga);
|
| 97 |
+
|
| 98 |
+
// Done with device
|
| 99 |
+
fpga_close(fpga);
|
| 100 |
+
}
|
| 101 |
+
else if (option == 2) { // Send data, receive data
|
| 102 |
+
if (argc < 5) {
|
| 103 |
+
printf("Usage: %s %d <fpga id> <chnl> <num words to transfer>\n", argv[0], option);
|
| 104 |
+
return -1;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
size_t maxWords, minWords;
|
| 108 |
+
id = atoi(argv[2]);
|
| 109 |
+
chnl = atoi(argv[3]);
|
| 110 |
+
minWords = 4; // Must be at least 4 for the channel tester app
|
| 111 |
+
maxWords = atoi(argv[4]);
|
| 112 |
+
printf("Running bandwidth test from %zu up to %zu words\n", minWords, maxWords);
|
| 113 |
+
|
| 114 |
+
// Get the device with id
|
| 115 |
+
fpga = fpga_open(id);
|
| 116 |
+
if (fpga == NULL) {
|
| 117 |
+
printf("Could not get FPGA %d\n", id);
|
| 118 |
+
return -1;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
// Malloc the arrays
|
| 122 |
+
sendBuffer = (unsigned int *)malloc(maxWords*4);
|
| 123 |
+
if (sendBuffer == NULL) {
|
| 124 |
+
printf("Could not malloc memory for sendBuffer\n");
|
| 125 |
+
fpga_close(fpga);
|
| 126 |
+
return -1;
|
| 127 |
+
}
|
| 128 |
+
recvBuffer = (unsigned int *)malloc(maxWords*4 + 4);
|
| 129 |
+
recvBuffer +=1;
|
| 130 |
+
if (recvBuffer == NULL) {
|
| 131 |
+
printf("Could not malloc memory for recvBuffer\n");
|
| 132 |
+
free(sendBuffer);
|
| 133 |
+
fpga_close(fpga);
|
| 134 |
+
return -1;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
int numWords;
|
| 138 |
+
for (numWords = minWords; numWords <= maxWords; numWords = numWords*2) {
|
| 139 |
+
int j;
|
| 140 |
+
for (j = 0; j < NUM_TESTS + 1; ++j) {
|
| 141 |
+
// Initialize the data
|
| 142 |
+
for (i = 0; i < numWords; i++) {
|
| 143 |
+
sendBuffer[i] = i+1;
|
| 144 |
+
recvBuffer[i] = 0;
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
GET_TIME_VAL(0);
|
| 148 |
+
|
| 149 |
+
// Send the data
|
| 150 |
+
sent = fpga_send(fpga, chnl, sendBuffer, numWords, 0, 1, 25000);
|
| 151 |
+
printf("Test %d: words sent: %d\n", j, sent);
|
| 152 |
+
|
| 153 |
+
GET_TIME_VAL(1);
|
| 154 |
+
|
| 155 |
+
if (sent != 0) {
|
| 156 |
+
// Recv the data
|
| 157 |
+
recvd = fpga_recv(fpga, chnl, recvBuffer, numWords, 25000);
|
| 158 |
+
printf("Test %d: words recv: %d\n", j, recvd);
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
GET_TIME_VAL(2);
|
| 162 |
+
|
| 163 |
+
// Check the data
|
| 164 |
+
if (recvd != 0) {
|
| 165 |
+
for (i = 4; i < recvd; i++) {
|
| 166 |
+
if (recvBuffer[i] != sendBuffer[i]) {
|
| 167 |
+
printf("recvBuffer[%d]: %d, expected %d\n", i, recvBuffer[i], sendBuffer[i]);
|
| 168 |
+
return;
|
| 169 |
+
}
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
if (j > 0)
|
| 173 |
+
printf("send bw: %f\n",
|
| 174 |
+
sent*4.0/1000/1000/((TIME_VAL_TO_MS(1) - TIME_VAL_TO_MS(0))/1000.0)); //,
|
| 175 |
+
|
| 176 |
+
if (j > 0)
|
| 177 |
+
printf("recv bw: %f\n",
|
| 178 |
+
recvd*4.0/1000/1000/((TIME_VAL_TO_MS(2) - TIME_VAL_TO_MS(1))/1000.0)); //,
|
| 179 |
+
}
|
| 180 |
+
}
|
| 181 |
+
}
|
| 182 |
+
// Done with device
|
| 183 |
+
fpga_close(fpga);
|
| 184 |
+
}
|
| 185 |
+
else if (option == 3) { // Send data, receive data
|
| 186 |
+
if (argc < 5) {
|
| 187 |
+
printf("Usage: %s %d <fpga id> <chnl> <num words to transfer>\n", argv[0], option);
|
| 188 |
+
return -1;
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
size_t maxWords, minWords;
|
| 192 |
+
id = atoi(argv[2]);
|
| 193 |
+
chnl = atoi(argv[3]);
|
| 194 |
+
minWords = 4; // Must be at least 4 for the channel tester app
|
| 195 |
+
maxWords = atoi(argv[4]);
|
| 196 |
+
printf("Running receive offset test from %zu up to %zu words\n", minWords, maxWords);
|
| 197 |
+
|
| 198 |
+
// Get the device with id
|
| 199 |
+
fpga = fpga_open(id);
|
| 200 |
+
if (fpga == NULL) {
|
| 201 |
+
printf("Could not get FPGA %d\n", id);
|
| 202 |
+
return -1;
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
// Malloc the arrays (page aligned)
|
| 206 |
+
printf("Asked for %zu bytes\n",((maxWords*sizeof(unsigned int)*2 + 4096)/4096)*4096 + 4096);
|
| 207 |
+
err = posix_memalign((void **)&sendBuffer, 4096, ((maxWords*sizeof(unsigned int)*2 + 4096)/4096)*4096 + 4096);
|
| 208 |
+
if (sendBuffer == NULL) {
|
| 209 |
+
printf("Could not malloc memory for sendBuffer\n");
|
| 210 |
+
fpga_close(fpga);
|
| 211 |
+
return -1;
|
| 212 |
+
}
|
| 213 |
+
err = posix_memalign((void **)&recvBuffer, 4096, ((maxWords*sizeof(unsigned int)*2 + 4096)/4096)*4096 + 4096);
|
| 214 |
+
|
| 215 |
+
recvBuffer = (unsigned int *)malloc(((maxWords*sizeof(unsigned int)*2 + 4096)/4096)*4096 + 4096);
|
| 216 |
+
if (recvBuffer == NULL) {
|
| 217 |
+
printf("Could not malloc memory for recvBuffer\n");
|
| 218 |
+
free(sendBuffer);
|
| 219 |
+
fpga_close(fpga);
|
| 220 |
+
return -1;
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
int numWords;
|
| 224 |
+
for (numWords = minWords; numWords <= maxWords; numWords = numWords*2) {
|
| 225 |
+
int j;
|
| 226 |
+
for (j = 0; j < 4096/sizeof(unsigned int); j++) {
|
| 227 |
+
int rxOffset = j;
|
| 228 |
+
// Initialize the data
|
| 229 |
+
for (i = 0; i < numWords; i++) {
|
| 230 |
+
sendBuffer[i+ rxOffset] = i+1;
|
| 231 |
+
recvBuffer[i] = 0;
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
GET_TIME_VAL(0);
|
| 235 |
+
|
| 236 |
+
// Send the data
|
| 237 |
+
sent = fpga_send(fpga, chnl, &sendBuffer[rxOffset], numWords, 0, 1, 25000);
|
| 238 |
+
printf("Test %d: words sent from address %p: %d\n", j, &sendBuffer[rxOffset], sent);
|
| 239 |
+
|
| 240 |
+
GET_TIME_VAL(1);
|
| 241 |
+
|
| 242 |
+
if (sent != 0) {
|
| 243 |
+
// Recv the data
|
| 244 |
+
recvd = fpga_recv(fpga, chnl, recvBuffer, numWords, 25000);
|
| 245 |
+
printf("Test %d: words recv: %d\n", j, recvd);
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
GET_TIME_VAL(2);
|
| 249 |
+
|
| 250 |
+
// Check the data
|
| 251 |
+
if (recvd != 0) {
|
| 252 |
+
for (i = 4; i < recvd; i++) {
|
| 253 |
+
if (recvBuffer[i] != sendBuffer[i + rxOffset]) {
|
| 254 |
+
printf("recvBuffer[%d]: %d, expected %d\n", i, recvBuffer[i], sendBuffer[i + rxOffset]);
|
| 255 |
+
failure = 1;
|
| 256 |
+
}
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
if (j > 0)
|
| 261 |
+
printf("send bw: %f\n",
|
| 262 |
+
sent*4.0/1000/1000/((TIME_VAL_TO_MS(1) - TIME_VAL_TO_MS(0))/1000.0)); //,
|
| 263 |
+
|
| 264 |
+
if (j > 0)
|
| 265 |
+
printf("recv bw: %f\n",
|
| 266 |
+
recvd*4.0/1000/1000/((TIME_VAL_TO_MS(2) - TIME_VAL_TO_MS(1))/1000.0)); //,
|
| 267 |
+
if(failure)
|
| 268 |
+
return;
|
| 269 |
+
}
|
| 270 |
+
}
|
| 271 |
+
}
|
| 272 |
+
// Done with device
|
| 273 |
+
fpga_close(fpga);
|
| 274 |
+
}
|
| 275 |
+
else if (option == 4) { // Send data, receive data
|
| 276 |
+
if (argc < 5) {
|
| 277 |
+
printf("Usage: %s %d <fpga id> <chnl> <num words to transfer>\n", argv[0], option);
|
| 278 |
+
return -1;
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
size_t maxWords, minWords;
|
| 282 |
+
id = atoi(argv[2]);
|
| 283 |
+
chnl = atoi(argv[3]);
|
| 284 |
+
minWords = 4; // Must be at least 4 for the channel tester app
|
| 285 |
+
maxWords = atoi(argv[4]);
|
| 286 |
+
printf("Running tx offset test from %zu up to %zu words\n", minWords, maxWords);
|
| 287 |
+
|
| 288 |
+
// Get the device with id
|
| 289 |
+
fpga = fpga_open(id);
|
| 290 |
+
if (fpga == NULL) {
|
| 291 |
+
printf("Could not get FPGA %d\n", id);
|
| 292 |
+
return -1;
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
// Malloc the arrays (page aligned)
|
| 296 |
+
printf("Asked for %zu bytes\n",((maxWords*sizeof(unsigned int)*2 + 4096)/4096)*4096 + 4096);
|
| 297 |
+
|
| 298 |
+
err = posix_memalign((void **)&sendBuffer, 4096, ((maxWords*sizeof(unsigned int)*2 + 4096)/4096)*4096 + 4096);
|
| 299 |
+
if (err) {
|
| 300 |
+
printf("Could not malloc memory for sendBuffer\n");
|
| 301 |
+
fpga_close(fpga);
|
| 302 |
+
return -1;
|
| 303 |
+
}
|
| 304 |
+
err = posix_memalign((void **)&recvBuffer, 4096, ((maxWords*sizeof(unsigned int)*2 + 4096)/4096)*4096 + 4096);
|
| 305 |
+
|
| 306 |
+
if (err) {
|
| 307 |
+
printf("Could not malloc memory for recvBuffer\n");
|
| 308 |
+
free(sendBuffer);
|
| 309 |
+
fpga_close(fpga);
|
| 310 |
+
return -1;
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
int numWords;
|
| 314 |
+
for (numWords = minWords; numWords <= maxWords; numWords = numWords*2) {
|
| 315 |
+
int j;
|
| 316 |
+
for (j = 0; j < 4096/sizeof(unsigned int); ++j) {
|
| 317 |
+
int txOffset = j;
|
| 318 |
+
// Initialize the data
|
| 319 |
+
for (i = 0; i < numWords; i++) {
|
| 320 |
+
sendBuffer[i] = i+1;
|
| 321 |
+
recvBuffer[i + txOffset] = 0;
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
GET_TIME_VAL(0);
|
| 325 |
+
|
| 326 |
+
// Send the data
|
| 327 |
+
sent = fpga_send(fpga, chnl, sendBuffer, numWords, 0, 1, 25000);
|
| 328 |
+
printf("Test %d: words sent: %d (Address %p) \n", j, sent, sendBuffer);
|
| 329 |
+
|
| 330 |
+
GET_TIME_VAL(1);
|
| 331 |
+
|
| 332 |
+
if (sent != 0) {
|
| 333 |
+
// Recv the data
|
| 334 |
+
recvd = fpga_recv(fpga, chnl, &recvBuffer[txOffset], numWords, 25000);
|
| 335 |
+
printf("Test %d: words recv: %d (Address %p) \n", j, recvd, &recvBuffer[txOffset]);
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
GET_TIME_VAL(2);
|
| 339 |
+
|
| 340 |
+
// Check the data
|
| 341 |
+
if (recvd != 0) {
|
| 342 |
+
for (i = 4; i < recvd; i++) {
|
| 343 |
+
if (recvBuffer[i + txOffset] != sendBuffer[i]) {
|
| 344 |
+
printf("recvBuffer[%d]: %d, expected %d\n", i, recvBuffer[i + txOffset], sendBuffer[i]);
|
| 345 |
+
failure = 1;
|
| 346 |
+
}
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
+
if (j > 0)
|
| 350 |
+
printf("send bw: %f\n",
|
| 351 |
+
sent*4.0/1000/1000/((TIME_VAL_TO_MS(1) - TIME_VAL_TO_MS(0))/1000.0)); //,
|
| 352 |
+
|
| 353 |
+
if (j > 0)
|
| 354 |
+
printf("recv bw: %f\n",
|
| 355 |
+
recvd*4.0/1000/1000/((TIME_VAL_TO_MS(2) - TIME_VAL_TO_MS(1))/1000.0)); //,
|
| 356 |
+
if(failure)
|
| 357 |
+
return;
|
| 358 |
+
|
| 359 |
+
}
|
| 360 |
+
}
|
| 361 |
+
}
|
| 362 |
+
// Done with device
|
| 363 |
+
fpga_close(fpga);
|
| 364 |
+
}
|
| 365 |
+
else if (option == 5) { // Send data, receive data
|
| 366 |
+
if (argc < 7) {
|
| 367 |
+
printf("Usage: %s %d <fpga id> <chnl> <offset> <num words to transfer> <number of iterations>\n", argv[0], option);
|
| 368 |
+
return -1;
|
| 369 |
+
}
|
| 370 |
+
size_t offset;
|
| 371 |
+
size_t numWords;
|
| 372 |
+
unsigned int numIter;
|
| 373 |
+
id = atoi(argv[2]);
|
| 374 |
+
chnl = atoi(argv[3]);
|
| 375 |
+
offset = atoi(argv[4]) % (4096 / sizeof(unsigned int));
|
| 376 |
+
if(numWords < 4) {
|
| 377 |
+
printf("Must transfer at least 4 words %d\n", id);
|
| 378 |
+
return -1;
|
| 379 |
+
}
|
| 380 |
+
numWords = atoi(argv[5]);
|
| 381 |
+
numIter = atoi(argv[6]);
|
| 382 |
+
printf("Running single test with %zu words, from host-page offset %zu \n", numWords, offset);
|
| 383 |
+
|
| 384 |
+
// Get the device with id
|
| 385 |
+
fpga = fpga_open(id);
|
| 386 |
+
if (fpga == NULL) {
|
| 387 |
+
printf("Could not get FPGA %d\n", id);
|
| 388 |
+
return -1;
|
| 389 |
+
}
|
| 390 |
+
|
| 391 |
+
// Malloc the arrays (page aligned)
|
| 392 |
+
printf("Asked for %zu bytes\n",((numWords*sizeof(unsigned int) + 4096)/4096)*4096 + 4096);
|
| 393 |
+
err = posix_memalign((void **)&sendBuffer, 4096, ((numWords*sizeof(unsigned int)*2 + 4096)/4096)*4096 + 4096);
|
| 394 |
+
if (err) {
|
| 395 |
+
printf("Could not malloc memory for sendBuffer\n");
|
| 396 |
+
fpga_close(fpga);
|
| 397 |
+
return -1;
|
| 398 |
+
}
|
| 399 |
+
|
| 400 |
+
err = posix_memalign((void **)&recvBuffer, 4096, ((numWords*sizeof(unsigned int)*2 + 4096)/4096)*4096 + 4096);
|
| 401 |
+
if (err) {
|
| 402 |
+
printf("Could not malloc memory for recvBuffer\n");
|
| 403 |
+
free(sendBuffer);
|
| 404 |
+
fpga_close(fpga);
|
| 405 |
+
return -1;
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
int j;
|
| 409 |
+
for (j = 0; j < numIter; ++j) {
|
| 410 |
+
for (i = 0; i < numWords; i++) {
|
| 411 |
+
sendBuffer[i + offset] = i+1;
|
| 412 |
+
recvBuffer[i] = 0;
|
| 413 |
+
}
|
| 414 |
+
|
| 415 |
+
GET_TIME_VAL(0);
|
| 416 |
+
|
| 417 |
+
// Send the data
|
| 418 |
+
sent = fpga_send(fpga, chnl, &sendBuffer[offset], numWords, 0, 1, 25000);
|
| 419 |
+
printf("words sent: %d\n", sent);
|
| 420 |
+
|
| 421 |
+
GET_TIME_VAL(1);
|
| 422 |
+
|
| 423 |
+
if (sent != 0) {
|
| 424 |
+
// Recv the data
|
| 425 |
+
recvd = fpga_recv(fpga, chnl, recvBuffer, numWords, 25000);
|
| 426 |
+
printf("words recv: %d\n", recvd);
|
| 427 |
+
}
|
| 428 |
+
|
| 429 |
+
GET_TIME_VAL(2);
|
| 430 |
+
|
| 431 |
+
// Check the data
|
| 432 |
+
if (recvd != 0) {
|
| 433 |
+
for (i = 4; i < recvd; i++) {
|
| 434 |
+
if (recvBuffer[i] != sendBuffer[i + offset]) {
|
| 435 |
+
printf("recvBuffer[%d]: %d, expected %d\n", i, recvBuffer[i], sendBuffer[i + offset]);
|
| 436 |
+
failure = 1;
|
| 437 |
+
}
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
+
printf("send bw: %f\n",
|
| 441 |
+
sent*4.0/1000/1000/((TIME_VAL_TO_MS(1) - TIME_VAL_TO_MS(0))/1000.0)); //,
|
| 442 |
+
|
| 443 |
+
printf("recv bw: %f\n",
|
| 444 |
+
recvd*4.0/1000/1000/((TIME_VAL_TO_MS(2) - TIME_VAL_TO_MS(1))/1000.0)); //,
|
| 445 |
+
if(failure)
|
| 446 |
+
return;
|
| 447 |
+
|
| 448 |
+
}
|
| 449 |
+
}
|
| 450 |
+
// Done with device
|
| 451 |
+
fpga_close(fpga);
|
| 452 |
+
}
|
| 453 |
+
else if (option == 6) { // Send data, receive data
|
| 454 |
+
if (argc < 7) {
|
| 455 |
+
printf("Usage: %s %d <fpga id> <chnl> <offset> <num words to transfer> <number of iterations>\n", argv[0], option);
|
| 456 |
+
return -1;
|
| 457 |
+
}
|
| 458 |
+
size_t offset;
|
| 459 |
+
size_t numWords;
|
| 460 |
+
unsigned int numIter;
|
| 461 |
+
|
| 462 |
+
id = atoi(argv[2]);
|
| 463 |
+
chnl = atoi(argv[3]);
|
| 464 |
+
offset = atoi(argv[4]) % (4096 / sizeof(unsigned int));
|
| 465 |
+
if(numWords < 4) {
|
| 466 |
+
printf("Must transfer at least 4 words %d\n", id);
|
| 467 |
+
return -1;
|
| 468 |
+
}
|
| 469 |
+
numWords = atoi(argv[5]);
|
| 470 |
+
numIter = atoi(argv[6]);
|
| 471 |
+
printf("Running single test with %zu words, to host-page offset %zu \n", numWords, offset);
|
| 472 |
+
|
| 473 |
+
// Get the device with id
|
| 474 |
+
fpga = fpga_open(id);
|
| 475 |
+
if (fpga == NULL) {
|
| 476 |
+
printf("Could not get FPGA %d\n", id);
|
| 477 |
+
return -1;
|
| 478 |
+
}
|
| 479 |
+
|
| 480 |
+
// Malloc the arrays (page aligned)
|
| 481 |
+
printf("Asked for %zu bytes\n",((numWords*sizeof(unsigned int) + 4096)/4096)*4096 + 4096);
|
| 482 |
+
err = posix_memalign((void **)&sendBuffer, 4096, ((numWords*sizeof(unsigned int)*2 + 4096)/4096)*4096 + 4096);
|
| 483 |
+
if (err) {
|
| 484 |
+
printf("Could not malloc memory for sendBuffer\n");
|
| 485 |
+
fpga_close(fpga);
|
| 486 |
+
return -1;
|
| 487 |
+
}
|
| 488 |
+
|
| 489 |
+
err = posix_memalign((void **)&recvBuffer, 4096, ((numWords*sizeof(unsigned int)*2 + 4096)/4096)*4096 + 4096);
|
| 490 |
+
if (err) {
|
| 491 |
+
printf("Could not malloc memory for recvBuffer\n");
|
| 492 |
+
free(sendBuffer);
|
| 493 |
+
fpga_close(fpga);
|
| 494 |
+
return -1;
|
| 495 |
+
}
|
| 496 |
+
|
| 497 |
+
int j;
|
| 498 |
+
for (j = 0; j < numIter; ++j) {
|
| 499 |
+
for (i = 0; i < numWords; i++) {
|
| 500 |
+
sendBuffer[i] = i+1;
|
| 501 |
+
recvBuffer[i + offset] = 0;
|
| 502 |
+
}
|
| 503 |
+
|
| 504 |
+
GET_TIME_VAL(0);
|
| 505 |
+
|
| 506 |
+
// Send the data
|
| 507 |
+
sent = fpga_send(fpga, chnl, sendBuffer, numWords, 0, 1, 25000);
|
| 508 |
+
printf("test %d: words sent: %d\n", j, sent);
|
| 509 |
+
|
| 510 |
+
GET_TIME_VAL(1);
|
| 511 |
+
|
| 512 |
+
if (sent != 0) {
|
| 513 |
+
// Recv the data
|
| 514 |
+
recvd = fpga_recv(fpga, chnl, &recvBuffer[offset], numWords, 25000);
|
| 515 |
+
printf("test %d: words recv: %d (Address %p %p)\n", j, recvd, &recvBuffer[offset], &recvBuffer[offset+numWords]);
|
| 516 |
+
}
|
| 517 |
+
|
| 518 |
+
GET_TIME_VAL(2);
|
| 519 |
+
|
| 520 |
+
// Check the data
|
| 521 |
+
if (recvd != 0) {
|
| 522 |
+
for (i = 4; i < recvd; i++) {
|
| 523 |
+
if (recvBuffer[i + offset] != sendBuffer[i]) {
|
| 524 |
+
printf("recvBuffer[%d]: %d, expected %d\n", i, recvBuffer[i + offset], sendBuffer[i]);
|
| 525 |
+
failure = 1;
|
| 526 |
+
}
|
| 527 |
+
}
|
| 528 |
+
|
| 529 |
+
printf("send bw: %f\n",
|
| 530 |
+
sent*4.0/1000/1000/((TIME_VAL_TO_MS(1) - TIME_VAL_TO_MS(0))/1000.0)); //,
|
| 531 |
+
|
| 532 |
+
printf("recv bw: %f\n",
|
| 533 |
+
recvd*4.0/1000/1000/((TIME_VAL_TO_MS(2) - TIME_VAL_TO_MS(1))/1000.0)); //,
|
| 534 |
+
if(failure)
|
| 535 |
+
return;
|
| 536 |
+
|
| 537 |
+
}
|
| 538 |
+
}
|
| 539 |
+
// Done with device
|
| 540 |
+
fpga_close(fpga);
|
| 541 |
+
}
|
| 542 |
+
return 0;
|
| 543 |
+
}
|
KastnerRG_riffa/c_c++/linux/x64/test_apps/testutil.c_multi
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// ----------------------------------------------------------------------
|
| 2 |
+
// Copyright (c) 2016, The Regents of the University of California All
|
| 3 |
+
// rights reserved.
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
//
|
| 12 |
+
// * Redistributions in binary form must reproduce the above
|
| 13 |
+
// copyright notice, this list of conditions and the following
|
| 14 |
+
// disclaimer in the documentation and/or other materials provided
|
| 15 |
+
// with the distribution.
|
| 16 |
+
//
|
| 17 |
+
// * Neither the name of The Regents of the University of California
|
| 18 |
+
// nor the names of its contributors may be used to endorse or
|
| 19 |
+
// promote products derived from this software without specific
|
| 20 |
+
// prior written permission.
|
| 21 |
+
//
|
| 22 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 23 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 24 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 25 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE
|
| 26 |
+
// UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 27 |
+
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 28 |
+
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
| 29 |
+
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 30 |
+
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 31 |
+
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
| 32 |
+
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 33 |
+
// DAMAGE.
|
| 34 |
+
// ----------------------------------------------------------------------
|
| 35 |
+
#include <stdlib.h>
|
| 36 |
+
#include <stdio.h>
|
| 37 |
+
#include "timer.h"
|
| 38 |
+
#include "riffa.h"
|
| 39 |
+
|
| 40 |
+
int main(int argc, char** argv) {
|
| 41 |
+
fpga_t * fpga;
|
| 42 |
+
fpga_info_list info;
|
| 43 |
+
int option;
|
| 44 |
+
int i;
|
| 45 |
+
int id;
|
| 46 |
+
int chnl;
|
| 47 |
+
size_t numWords;
|
| 48 |
+
int sent;
|
| 49 |
+
int recvd;
|
| 50 |
+
unsigned int * sendBuffer;
|
| 51 |
+
unsigned int * recvBuffer;
|
| 52 |
+
GET_TIME_INIT(3);
|
| 53 |
+
|
| 54 |
+
if (argc < 2) {
|
| 55 |
+
printf("Usage: %s <option>\n", argv[0]);
|
| 56 |
+
return -1;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
option = atoi(argv[1]);
|
| 60 |
+
|
| 61 |
+
if (option == 0) { // List FPGA info
|
| 62 |
+
// Populate the fpga_info_list struct
|
| 63 |
+
if (fpga_list(&info) != 0) {
|
| 64 |
+
printf("Error populating fpga_info_list\n");
|
| 65 |
+
return -1;
|
| 66 |
+
}
|
| 67 |
+
printf("Number of devices: %d\n", info.num_fpgas);
|
| 68 |
+
for (i = 0; i < info.num_fpgas; i++) {
|
| 69 |
+
printf("%d: id:%d\n", i, info.id[i]);
|
| 70 |
+
printf("%d: num_chnls:%d\n", i, info.num_chnls[i]);
|
| 71 |
+
printf("%d: name:%s\n", i, info.name[i]);
|
| 72 |
+
printf("%d: vendor id:%04X\n", i, info.vendor_id[i]);
|
| 73 |
+
printf("%d: device id:%04X\n", i, info.device_id[i]);
|
| 74 |
+
}
|
| 75 |
+
}
|
| 76 |
+
else if (option == 1) { // Reset FPGA
|
| 77 |
+
if (argc < 3) {
|
| 78 |
+
printf("Usage: %s %d <fpga id>\n", argv[0], option);
|
| 79 |
+
return -1;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
id = atoi(argv[2]);
|
| 83 |
+
|
| 84 |
+
// Get the device with id
|
| 85 |
+
fpga = fpga_open(id);
|
| 86 |
+
if (fpga == NULL) {
|
| 87 |
+
printf("Could not get FPGA %d\n", id);
|
| 88 |
+
return -1;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
// Reset
|
| 92 |
+
fpga_reset(fpga);
|
| 93 |
+
|
| 94 |
+
// Done with device
|
| 95 |
+
fpga_close(fpga);
|
| 96 |
+
}
|
| 97 |
+
else if (option == 2) { // Send data, receive data
|
| 98 |
+
if (argc < 5) {
|
| 99 |
+
printf("Usage: %s %d <fpga id> <chnl> <num words to transfer>\n", argv[0], option);
|
| 100 |
+
return -1;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
size_t maxWords;
|
| 104 |
+
id = atoi(argv[2]);
|
| 105 |
+
chnl = atoi(argv[3]);
|
| 106 |
+
maxWords = atoi(argv[4]);
|
| 107 |
+
|
| 108 |
+
// Get the device with id
|
| 109 |
+
fpga = fpga_open(id);
|
| 110 |
+
if (fpga == NULL) {
|
| 111 |
+
printf("Could not get FPGA %d\n", id);
|
| 112 |
+
return -1;
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
// Malloc the arrays
|
| 116 |
+
// sendBuffer = (unsigned int *)malloc(2147483648l);
|
| 117 |
+
sendBuffer = (unsigned int *)malloc(maxWords*4);
|
| 118 |
+
if (sendBuffer == NULL) {
|
| 119 |
+
printf("Could not malloc memory for sendBuffer\n");
|
| 120 |
+
fpga_close(fpga);
|
| 121 |
+
return -1;
|
| 122 |
+
}
|
| 123 |
+
recvBuffer = (unsigned int *)malloc(maxWords*4);
|
| 124 |
+
if (recvBuffer == NULL) {
|
| 125 |
+
printf("Could not malloc memory for recvBuffer\n");
|
| 126 |
+
free(sendBuffer);
|
| 127 |
+
fpga_close(fpga);
|
| 128 |
+
return -1;
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
int numWords;
|
| 133 |
+
for (numWords = 256; numWords <= maxWords; numWords = numWords*2) {
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
int j;
|
| 137 |
+
for (j = 0; j < 101; ++j) {
|
| 138 |
+
// Initialize the data
|
| 139 |
+
for (i = 0; i < numWords; i++) {
|
| 140 |
+
sendBuffer[i] = i+1;
|
| 141 |
+
recvBuffer[i] = 0;
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
GET_TIME_VAL(0);
|
| 145 |
+
|
| 146 |
+
// Send the data
|
| 147 |
+
sent = fpga_send(fpga, chnl, sendBuffer, numWords, 0, 1, 25000);
|
| 148 |
+
printf("words sent: %d\n", sent);
|
| 149 |
+
|
| 150 |
+
GET_TIME_VAL(1);
|
| 151 |
+
|
| 152 |
+
if (sent != 0) {
|
| 153 |
+
// Recv the data
|
| 154 |
+
recvd = fpga_recv(fpga, chnl, recvBuffer, numWords, 25000);
|
| 155 |
+
printf("words recv: %d\n", recvd);
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
GET_TIME_VAL(2);
|
| 159 |
+
|
| 160 |
+
// Display some data
|
| 161 |
+
// for (i = 0; i < 20; i++) {
|
| 162 |
+
// printf("recvBuffer[%d]: %d\n", i, recvBuffer[i]);
|
| 163 |
+
// }
|
| 164 |
+
|
| 165 |
+
// Check the data
|
| 166 |
+
if (recvd != 0) {
|
| 167 |
+
for (i = 4; i < recvd; i++) {
|
| 168 |
+
if (recvBuffer[i] != sendBuffer[i]) {
|
| 169 |
+
printf("recvBuffer[%d]: %d, expected %d\n", i, recvBuffer[i], sendBuffer[i]);
|
| 170 |
+
return;
|
| 171 |
+
}
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
if (j > 0)
|
| 175 |
+
printf("send bw: %f\n",
|
| 176 |
+
sent*4.0/1000/1000/((TIME_VAL_TO_MS(1) - TIME_VAL_TO_MS(0))/1000.0)); //,
|
| 177 |
+
// (TIME_VAL_TO_MS(1) - TIME_VAL_TO_MS(0)) );
|
| 178 |
+
|
| 179 |
+
if (j > 0)
|
| 180 |
+
printf("recv bw: %f\n",
|
| 181 |
+
recvd*4.0/1000/1000/((TIME_VAL_TO_MS(2) - TIME_VAL_TO_MS(1))/1000.0)); //,
|
| 182 |
+
// (TIME_VAL_TO_MS(2) - TIME_VAL_TO_MS(1)) );
|
| 183 |
+
}
|
| 184 |
+
}
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
// Done with device
|
| 188 |
+
fpga_close(fpga);
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
return 0;
|
| 194 |
+
}
|
KastnerRG_riffa/c_c++/linux/x64/test_apps/testutil.sh
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# ----------------------------------------------------------------------
|
| 3 |
+
# Copyright (c) 2016, The Regents of the University of California All
|
| 4 |
+
# rights reserved.
|
| 5 |
+
#
|
| 6 |
+
# Redistribution and use in source and binary forms, with or without
|
| 7 |
+
# modification, are permitted provided that the following conditions are
|
| 8 |
+
# met:
|
| 9 |
+
#
|
| 10 |
+
# * Redistributions of source code must retain the above copyright
|
| 11 |
+
# notice, this list of conditions and the following disclaimer.
|
| 12 |
+
#
|
| 13 |
+
# * Redistributions in binary form must reproduce the above
|
| 14 |
+
# copyright notice, this list of conditions and the following
|
| 15 |
+
# disclaimer in the documentation and/or other materials provided
|
| 16 |
+
# with the distribution.
|
| 17 |
+
#
|
| 18 |
+
# * Neither the name of The Regents of the University of California
|
| 19 |
+
# nor the names of its contributors may be used to endorse or
|
| 20 |
+
# promote products derived from this software without specific
|
| 21 |
+
# prior written permission.
|
| 22 |
+
#
|
| 23 |
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 24 |
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 25 |
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 26 |
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE
|
| 27 |
+
# UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 28 |
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 29 |
+
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
| 30 |
+
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 31 |
+
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 32 |
+
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
| 33 |
+
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 34 |
+
# DAMAGE.
|
| 35 |
+
# ----------------------------------------------------------------------
|
| 36 |
+
|
| 37 |
+
PATH=$PATH:./
|
| 38 |
+
RESULT_PATH=~/
|
| 39 |
+
|
| 40 |
+
if [ "$#" -lt 2 ]; then
|
| 41 |
+
echo "usage: $0 <fpga id> <board name>"
|
| 42 |
+
exit
|
| 43 |
+
fi
|
| 44 |
+
|
| 45 |
+
# Run full bandwidth test
|
| 46 |
+
testutil 2 $1 0 536970912 | tee $RESULT_PATH/$2_bw.txt
|
| 47 |
+
|
| 48 |
+
# Run RX Sweep Test
|
| 49 |
+
testutil 3 $1 0 2048 | tee $RESULT_PATH/$2_rx.txt
|
| 50 |
+
|
| 51 |
+
# Run TX Sweep Test
|
| 52 |
+
testutil 4 $1 0 2048 | tee $RESULT_PATH/$2_tx.txt
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
|
KastnerRG_riffa/c_c++/linux/x64/test_apps/timer.h
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// ----------------------------------------------------------------------
|
| 2 |
+
// Copyright (c) 2016, The Regents of the University of California All
|
| 3 |
+
// rights reserved.
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
//
|
| 12 |
+
// * Redistributions in binary form must reproduce the above
|
| 13 |
+
// copyright notice, this list of conditions and the following
|
| 14 |
+
// disclaimer in the documentation and/or other materials provided
|
| 15 |
+
// with the distribution.
|
| 16 |
+
//
|
| 17 |
+
// * Neither the name of The Regents of the University of California
|
| 18 |
+
// nor the names of its contributors may be used to endorse or
|
| 19 |
+
// promote products derived from this software without specific
|
| 20 |
+
// prior written permission.
|
| 21 |
+
//
|
| 22 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 23 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 24 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 25 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE
|
| 26 |
+
// UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 27 |
+
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 28 |
+
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
| 29 |
+
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 30 |
+
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 31 |
+
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
| 32 |
+
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 33 |
+
// DAMAGE.
|
| 34 |
+
// ----------------------------------------------------------------------
|
| 35 |
+
#include <sys/time.h>
|
| 36 |
+
|
| 37 |
+
#define GET_TIME_INIT(num) struct timeval _timers[num]
|
| 38 |
+
|
| 39 |
+
#define GET_TIME_VAL(num) gettimeofday(&_timers[num], NULL)
|
| 40 |
+
|
| 41 |
+
#define TIME_VAL_TO_MS(num) (((double)_timers[num].tv_sec*1000.0) + ((double)_timers[num].tv_usec/1000.0))
|
| 42 |
+
|
KastnerRG_riffa/c_c++/linux/x86/README.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The Linux C/C++ library is compiled and installed with the kernel driver. This
|
| 2 |
+
directory contains a sample application subdirectory that you can use to test
|
| 3 |
+
your design.
|
KastnerRG_riffa/c_c++/linux/x86/sample_app/Makefile
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ----------------------------------------------------------------------
|
| 2 |
+
# Copyright (c) 2016, The Regents of the University of California All
|
| 3 |
+
# rights reserved.
|
| 4 |
+
#
|
| 5 |
+
# Redistribution and use in source and binary forms, with or without
|
| 6 |
+
# modification, are permitted provided that the following conditions are
|
| 7 |
+
# met:
|
| 8 |
+
#
|
| 9 |
+
# * Redistributions of source code must retain the above copyright
|
| 10 |
+
# notice, this list of conditions and the following disclaimer.
|
| 11 |
+
#
|
| 12 |
+
# * Redistributions in binary form must reproduce the above
|
| 13 |
+
# copyright notice, this list of conditions and the following
|
| 14 |
+
# disclaimer in the documentation and/or other materials provided
|
| 15 |
+
# with the distribution.
|
| 16 |
+
#
|
| 17 |
+
# * Neither the name of The Regents of the University of California
|
| 18 |
+
# nor the names of its contributors may be used to endorse or
|
| 19 |
+
# promote products derived from this software without specific
|
| 20 |
+
# prior written permission.
|
| 21 |
+
#
|
| 22 |
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 23 |
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 24 |
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 25 |
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE
|
| 26 |
+
# UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 27 |
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 28 |
+
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
| 29 |
+
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 30 |
+
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 31 |
+
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
| 32 |
+
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 33 |
+
# DAMAGE.
|
| 34 |
+
# ----------------------------------------------------------------------
|
| 35 |
+
program_NAME := testutil
|
| 36 |
+
program_C_SRCS := $(wildcard *.c)
|
| 37 |
+
program_CXX_SRCS := $(wildcard *.cpp)
|
| 38 |
+
program_C_OBJS := ${program_C_SRCS:.c=.o}
|
| 39 |
+
program_CXX_OBJS := ${program_CXX_SRCS:.cpp=.o}
|
| 40 |
+
program_OBJS := $(program_C_OBJS) $(program_CXX_OBJS)
|
| 41 |
+
program_INCLUDE_DIRS :=
|
| 42 |
+
program_LIBRARY_DIRS :=
|
| 43 |
+
program_LIBRARIES := riffa
|
| 44 |
+
CPPFLAGS += -g
|
| 45 |
+
|
| 46 |
+
CPPFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))
|
| 47 |
+
LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir))
|
| 48 |
+
LDFLAGS += $(foreach library,$(program_LIBRARIES),-l$(library))
|
| 49 |
+
|
| 50 |
+
.PHONY: all clean distclean
|
| 51 |
+
|
| 52 |
+
all: $(program_NAME)
|
| 53 |
+
|
| 54 |
+
$(program_NAME): $(program_OBJS)
|
| 55 |
+
$(CC) $(CPPFLAGS) $(program_OBJS) -o $(program_NAME) $(LDFLAGS)
|
| 56 |
+
|
| 57 |
+
clean:
|
| 58 |
+
@- $(RM) $(program_NAME)
|
| 59 |
+
@- $(RM) $(program_OBJS)
|
| 60 |
+
|
| 61 |
+
distclean: clean
|
KastnerRG_riffa/c_c++/linux/x86/sample_app/README.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The testutil example application works with the Verilog chnl_tester module
|
| 2 |
+
which receives data and then sends data back to the workstation.
|
| 3 |
+
|
| 4 |
+
To compile the example application:
|
| 5 |
+
|
| 6 |
+
make
|
| 7 |
+
|
| 8 |
+
The riffa C/C++ library must be installed (it gets installed with the driver).
|
KastnerRG_riffa/c_c++/linux/x86/sample_app/testutil.c
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// ----------------------------------------------------------------------
|
| 2 |
+
// Copyright (c) 2016, The Regents of the University of California All
|
| 3 |
+
// rights reserved.
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
//
|
| 12 |
+
// * Redistributions in binary form must reproduce the above
|
| 13 |
+
// copyright notice, this list of conditions and the following
|
| 14 |
+
// disclaimer in the documentation and/or other materials provided
|
| 15 |
+
// with the distribution.
|
| 16 |
+
//
|
| 17 |
+
// * Neither the name of The Regents of the University of California
|
| 18 |
+
// nor the names of its contributors may be used to endorse or
|
| 19 |
+
// promote products derived from this software without specific
|
| 20 |
+
// prior written permission.
|
| 21 |
+
//
|
| 22 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 23 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 24 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 25 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE
|
| 26 |
+
// UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 27 |
+
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 28 |
+
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
| 29 |
+
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 30 |
+
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 31 |
+
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
| 32 |
+
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 33 |
+
// DAMAGE.
|
| 34 |
+
// ----------------------------------------------------------------------
|
| 35 |
+
#include <stdlib.h>
|
| 36 |
+
#include <stdio.h>
|
| 37 |
+
#include "timer.h"
|
| 38 |
+
#include "riffa.h"
|
| 39 |
+
|
| 40 |
+
int main(int argc, char** argv) {
|
| 41 |
+
fpga_t * fpga;
|
| 42 |
+
fpga_info_list info;
|
| 43 |
+
int option;
|
| 44 |
+
int i;
|
| 45 |
+
int id;
|
| 46 |
+
int chnl;
|
| 47 |
+
size_t numWords;
|
| 48 |
+
int sent;
|
| 49 |
+
int recvd;
|
| 50 |
+
unsigned int * sendBuffer;
|
| 51 |
+
unsigned int * recvBuffer;
|
| 52 |
+
GET_TIME_INIT(3);
|
| 53 |
+
|
| 54 |
+
if (argc < 2) {
|
| 55 |
+
printf("Usage: %s <option>\n", argv[0]);
|
| 56 |
+
return -1;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
option = atoi(argv[1]);
|
| 60 |
+
|
| 61 |
+
if (option == 0) { // List FPGA info
|
| 62 |
+
// Populate the fpga_info_list struct
|
| 63 |
+
if (fpga_list(&info) != 0) {
|
| 64 |
+
printf("Error populating fpga_info_list\n");
|
| 65 |
+
return -1;
|
| 66 |
+
}
|
| 67 |
+
printf("Number of devices: %d\n", info.num_fpgas);
|
| 68 |
+
for (i = 0; i < info.num_fpgas; i++) {
|
| 69 |
+
printf("%d: id:%d\n", i, info.id[i]);
|
| 70 |
+
printf("%d: num_chnls:%d\n", i, info.num_chnls[i]);
|
| 71 |
+
printf("%d: name:%s\n", i, info.name[i]);
|
| 72 |
+
printf("%d: vendor id:%04X\n", i, info.vendor_id[i]);
|
| 73 |
+
printf("%d: device id:%04X\n", i, info.device_id[i]);
|
| 74 |
+
}
|
| 75 |
+
}
|
| 76 |
+
else if (option == 1) { // Reset FPGA
|
| 77 |
+
if (argc < 3) {
|
| 78 |
+
printf("Usage: %s %d <fpga id>\n", argv[0], option);
|
| 79 |
+
return -1;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
id = atoi(argv[2]);
|
| 83 |
+
|
| 84 |
+
// Get the device with id
|
| 85 |
+
fpga = fpga_open(id);
|
| 86 |
+
if (fpga == NULL) {
|
| 87 |
+
printf("Could not get FPGA %d\n", id);
|
| 88 |
+
return -1;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
// Reset
|
| 92 |
+
fpga_reset(fpga);
|
| 93 |
+
|
| 94 |
+
// Done with device
|
| 95 |
+
fpga_close(fpga);
|
| 96 |
+
}
|
| 97 |
+
else if (option == 2) { // Send data, receive data
|
| 98 |
+
if (argc < 5) {
|
| 99 |
+
printf("Usage: %s %d <fpga id> <chnl> <num words to transfer>\n", argv[0], option);
|
| 100 |
+
return -1;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
id = atoi(argv[2]);
|
| 104 |
+
chnl = atoi(argv[3]);
|
| 105 |
+
numWords = atoi(argv[4]);
|
| 106 |
+
|
| 107 |
+
// Get the device with id
|
| 108 |
+
fpga = fpga_open(id);
|
| 109 |
+
if (fpga == NULL) {
|
| 110 |
+
printf("Could not get FPGA %d\n", id);
|
| 111 |
+
return -1;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
// Malloc the arrays
|
| 115 |
+
sendBuffer = (unsigned int *)malloc(numWords<<2);
|
| 116 |
+
if (sendBuffer == NULL) {
|
| 117 |
+
printf("Could not malloc memory for sendBuffer\n");
|
| 118 |
+
fpga_close(fpga);
|
| 119 |
+
return -1;
|
| 120 |
+
}
|
| 121 |
+
recvBuffer = (unsigned int *)malloc(numWords<<2);
|
| 122 |
+
if (recvBuffer == NULL) {
|
| 123 |
+
printf("Could not malloc memory for recvBuffer\n");
|
| 124 |
+
free(sendBuffer);
|
| 125 |
+
fpga_close(fpga);
|
| 126 |
+
return -1;
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
// Initialize the data
|
| 130 |
+
for (i = 0; i < numWords; i++) {
|
| 131 |
+
sendBuffer[i] = i+1;
|
| 132 |
+
recvBuffer[i] = 0;
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
GET_TIME_VAL(0);
|
| 136 |
+
|
| 137 |
+
// Send the data
|
| 138 |
+
sent = fpga_send(fpga, chnl, sendBuffer, numWords, 0, 1, 25000);
|
| 139 |
+
printf("words sent: %d\n", sent);
|
| 140 |
+
|
| 141 |
+
GET_TIME_VAL(1);
|
| 142 |
+
|
| 143 |
+
if (sent != 0) {
|
| 144 |
+
// Recv the data
|
| 145 |
+
recvd = fpga_recv(fpga, chnl, recvBuffer, numWords, 25000);
|
| 146 |
+
printf("words recv: %d\n", recvd);
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
GET_TIME_VAL(2);
|
| 150 |
+
|
| 151 |
+
// Done with device
|
| 152 |
+
fpga_close(fpga);
|
| 153 |
+
|
| 154 |
+
// Display some data
|
| 155 |
+
for (i = 0; i < 20; i++) {
|
| 156 |
+
printf("recvBuffer[%d]: %d\n", i, recvBuffer[i]);
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
// Check the data
|
| 160 |
+
if (recvd != 0) {
|
| 161 |
+
for (i = 4; i < recvd; i++) {
|
| 162 |
+
if (recvBuffer[i] != sendBuffer[i]) {
|
| 163 |
+
printf("recvBuffer[%d]: %d, expected %d\n", i, recvBuffer[i], sendBuffer[i]);
|
| 164 |
+
break;
|
| 165 |
+
}
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
printf("send bw: %f MB/s %fms\n",
|
| 169 |
+
sent*4.0/1024/1024/((TIME_VAL_TO_MS(1) - TIME_VAL_TO_MS(0))/1000.0),
|
| 170 |
+
(TIME_VAL_TO_MS(1) - TIME_VAL_TO_MS(0)) );
|
| 171 |
+
|
| 172 |
+
printf("recv bw: %f MB/s %fms\n",
|
| 173 |
+
recvd*4.0/1024/1024/((TIME_VAL_TO_MS(2) - TIME_VAL_TO_MS(1))/1000.0),
|
| 174 |
+
(TIME_VAL_TO_MS(2) - TIME_VAL_TO_MS(1)) );
|
| 175 |
+
}
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
return 0;
|
| 179 |
+
}
|
KastnerRG_riffa/c_c++/linux/x86/sample_app/timer.h
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// ----------------------------------------------------------------------
|
| 2 |
+
// Copyright (c) 2016, The Regents of the University of California All
|
| 3 |
+
// rights reserved.
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
//
|
| 12 |
+
// * Redistributions in binary form must reproduce the above
|
| 13 |
+
// copyright notice, this list of conditions and the following
|
| 14 |
+
// disclaimer in the documentation and/or other materials provided
|
| 15 |
+
// with the distribution.
|
| 16 |
+
//
|
| 17 |
+
// * Neither the name of The Regents of the University of California
|
| 18 |
+
// nor the names of its contributors may be used to endorse or
|
| 19 |
+
// promote products derived from this software without specific
|
| 20 |
+
// prior written permission.
|
| 21 |
+
//
|
| 22 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 23 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 24 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 25 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE
|
| 26 |
+
// UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 27 |
+
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 28 |
+
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
| 29 |
+
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 30 |
+
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 31 |
+
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
| 32 |
+
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 33 |
+
// DAMAGE.
|
| 34 |
+
// ----------------------------------------------------------------------
|
| 35 |
+
#include <sys/time.h>
|
| 36 |
+
|
| 37 |
+
#define GET_TIME_INIT(num) struct timeval _timers[num]
|
| 38 |
+
|
| 39 |
+
#define GET_TIME_VAL(num) gettimeofday(&_timers[num], NULL)
|
| 40 |
+
|
| 41 |
+
#define TIME_VAL_TO_MS(num) (((double)_timers[num].tv_sec*1000.0) + ((double)_timers[num].tv_usec/1000.0))
|
| 42 |
+
|
KastnerRG_riffa/c_c++/windows/x64/README.txt
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
To build the C/C++ library:
|
| 2 |
+
|
| 3 |
+
windres.exe riffa.rc resource.o
|
| 4 |
+
gcc.exe -m64 -c -o riffa.o riffa.c -D RIFFA_EXPORTS
|
| 5 |
+
gcc.exe -m64 -o riffa.dll riffa.o resource.o -s -shared -Wl,--subsystem,windows,--out-implib,riffa.lib -luser32 -lsetupapi
|
| 6 |
+
del riffa.lib
|
| 7 |
+
gendef riffa.dll
|
| 8 |
+
lib /def:riffa.def /machine:X64 /out:riffa.lib
|
| 9 |
+
|
| 10 |
+
This will compile the resource file for the dll (metadata properties for the
|
| 11 |
+
.dll). This will also produce a .dll and .lib file. The .dll is the dynamic
|
| 12 |
+
library. The .lib file is the import library. You will want to copy the .dll
|
| 13 |
+
into say Windows\System32. You will want to use the .h file and the .lib files
|
| 14 |
+
when compiling and linking your applications.
|
KastnerRG_riffa/c_c++/windows/x64/riffa.c
ADDED
|
@@ -0,0 +1,423 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// ----------------------------------------------------------------------
|
| 2 |
+
// Copyright (c) 2016, The Regents of the University of California All
|
| 3 |
+
// rights reserved.
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
//
|
| 12 |
+
// * Redistributions in binary form must reproduce the above
|
| 13 |
+
// copyright notice, this list of conditions and the following
|
| 14 |
+
// disclaimer in the documentation and/or other materials provided
|
| 15 |
+
// with the distribution.
|
| 16 |
+
//
|
| 17 |
+
// * Neither the name of The Regents of the University of California
|
| 18 |
+
// nor the names of its contributors may be used to endorse or
|
| 19 |
+
// promote products derived from this software without specific
|
| 20 |
+
// prior written permission.
|
| 21 |
+
//
|
| 22 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 23 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 24 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 25 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE
|
| 26 |
+
// UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 27 |
+
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 28 |
+
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
| 29 |
+
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 30 |
+
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 31 |
+
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
| 32 |
+
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 33 |
+
// DAMAGE.
|
| 34 |
+
// ----------------------------------------------------------------------
|
| 35 |
+
/*
|
| 36 |
+
* Filename: riffa.c
|
| 37 |
+
* Version: 2.0
|
| 38 |
+
* Description: Windows PCIe communications API for RIFFA.
|
| 39 |
+
* Author: Matthew Jacobsen
|
| 40 |
+
* History: @mattj: Initial release. Version 2.0.
|
| 41 |
+
*/
|
| 42 |
+
|
| 43 |
+
#define INITGUID
|
| 44 |
+
|
| 45 |
+
#include <windows.h>
|
| 46 |
+
#include <setupapi.h>
|
| 47 |
+
#include <stdio.h>
|
| 48 |
+
#include <stdlib.h>
|
| 49 |
+
#include "riffa_driver.h"
|
| 50 |
+
#include "riffa.h"
|
| 51 |
+
|
| 52 |
+
// The structure used to hold data transfer information
|
| 53 |
+
typedef struct RIFFA_FPGA_CHNL_IO {
|
| 54 |
+
UINT32 Id;
|
| 55 |
+
UINT32 Chnl;
|
| 56 |
+
UINT32 Length;
|
| 57 |
+
UINT32 Offset;
|
| 58 |
+
UINT32 Last;
|
| 59 |
+
UINT64 Timeout;
|
| 60 |
+
} RIFFA_FPGA_CHNL_IO, * PRIFFA_FPGA_CHNL_IO;
|
| 61 |
+
|
| 62 |
+
// Represents the FPGA device
|
| 63 |
+
struct fpga_t
|
| 64 |
+
{
|
| 65 |
+
HANDLE dev;
|
| 66 |
+
int id;
|
| 67 |
+
};
|
| 68 |
+
|
| 69 |
+
HANDLE get_device(UINT32 index, BOOLEAN overlapped);
|
| 70 |
+
DWORD fill_device_info(fpga_info_list * info);
|
| 71 |
+
|
| 72 |
+
fpga_t * RIFFACALL fpga_open(int id) {
|
| 73 |
+
fpga_t * fpga;
|
| 74 |
+
|
| 75 |
+
// Allocate space for the fpga_dev
|
| 76 |
+
fpga = (fpga_t *)malloc(sizeof(fpga_t));
|
| 77 |
+
if (fpga == NULL)
|
| 78 |
+
return NULL;
|
| 79 |
+
fpga->id = id;
|
| 80 |
+
|
| 81 |
+
// Open the device handle.
|
| 82 |
+
fpga->dev = get_device(id, TRUE);
|
| 83 |
+
if (fpga->dev == INVALID_HANDLE_VALUE) {
|
| 84 |
+
free(fpga);
|
| 85 |
+
return NULL;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
return fpga;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
void RIFFACALL fpga_close(fpga_t * fpga) {
|
| 92 |
+
// Validate the device handle
|
| 93 |
+
if (fpga->dev == NULL || fpga->dev == INVALID_HANDLE_VALUE) {
|
| 94 |
+
printf("Invalid fpga_t device handle\n");
|
| 95 |
+
return;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
// Close the device handle.
|
| 99 |
+
CloseHandle(fpga->dev);
|
| 100 |
+
fpga->dev = NULL;
|
| 101 |
+
|
| 102 |
+
// Free the fpga_t struct
|
| 103 |
+
free(fpga);
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
int RIFFACALL fpga_send(fpga_t * fpga, int chnl, void * data, int len,
|
| 107 |
+
int destoff, int last, long long timeout) {
|
| 108 |
+
RIFFA_FPGA_CHNL_IO io;
|
| 109 |
+
OVERLAPPED overlapStruct = {0};
|
| 110 |
+
HANDLE evt;
|
| 111 |
+
BOOLEAN status;
|
| 112 |
+
ULONG wordsReturned;
|
| 113 |
+
|
| 114 |
+
// Validate the device handle
|
| 115 |
+
if (fpga->dev == NULL || fpga->dev == INVALID_HANDLE_VALUE) {
|
| 116 |
+
printf("Invalid fpga_t device handle\n");
|
| 117 |
+
return 0;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
// Initialize the RIFFA_FPGA_CHNL_IO struct
|
| 121 |
+
io.Id = fpga->id;
|
| 122 |
+
io.Chnl = chnl;
|
| 123 |
+
io.Length = len;
|
| 124 |
+
io.Offset = destoff;
|
| 125 |
+
io.Last = last;
|
| 126 |
+
io.Timeout = timeout;
|
| 127 |
+
|
| 128 |
+
// Create a thread specific event to wait on.
|
| 129 |
+
evt = CreateEvent(NULL, TRUE, TRUE, NULL);
|
| 130 |
+
overlapStruct.hEvent = evt;
|
| 131 |
+
|
| 132 |
+
// Call IOCTL with IOCTL_RIFFA_SEND
|
| 133 |
+
status = DeviceIoControl(fpga->dev, IOCTL_RIFFA_SEND, (LPVOID)&io,
|
| 134 |
+
sizeof(io), data, (len<<2), &wordsReturned, &overlapStruct);
|
| 135 |
+
if(!status) {
|
| 136 |
+
// Should be the IO Pending error
|
| 137 |
+
if(GetLastError() == ERROR_IO_PENDING) {
|
| 138 |
+
// Wait for the IOCTL to complete and get the return value
|
| 139 |
+
WaitForSingleObject(evt, INFINITE);
|
| 140 |
+
status = GetOverlappedResult(fpga->dev, &overlapStruct,
|
| 141 |
+
&wordsReturned, FALSE);
|
| 142 |
+
if(!status) {
|
| 143 |
+
if (GetLastError() == ERROR_OPERATION_ABORTED)
|
| 144 |
+
printf("Operation timed out or was aborted\n");
|
| 145 |
+
else
|
| 146 |
+
printf("Error in GetOverlappedResult: %d\n", GetLastError());
|
| 147 |
+
}
|
| 148 |
+
}
|
| 149 |
+
else {
|
| 150 |
+
printf("Error in DeviceIoControl: %d\n", GetLastError());
|
| 151 |
+
}
|
| 152 |
+
}
|
| 153 |
+
return wordsReturned;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
int RIFFACALL fpga_recv(fpga_t * fpga, int chnl, void * data, int len,
|
| 157 |
+
long long timeout) {
|
| 158 |
+
RIFFA_FPGA_CHNL_IO io;
|
| 159 |
+
OVERLAPPED overlapStruct = {0};
|
| 160 |
+
HANDLE evt;
|
| 161 |
+
BOOLEAN status;
|
| 162 |
+
ULONG wordsReturned;
|
| 163 |
+
|
| 164 |
+
// Validate the device handle
|
| 165 |
+
if (fpga->dev == NULL || fpga->dev == INVALID_HANDLE_VALUE) {
|
| 166 |
+
printf("Invalid fpga_t device handle\n");
|
| 167 |
+
return 0;
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
// Initialize the RIFFA_FPGA_CHNL_IO struct
|
| 171 |
+
io.Id = fpga->id;
|
| 172 |
+
io.Chnl = chnl;
|
| 173 |
+
io.Length = len;
|
| 174 |
+
io.Timeout = timeout;
|
| 175 |
+
|
| 176 |
+
// Create a thread specific event to wait on.
|
| 177 |
+
evt = CreateEvent(NULL, TRUE, TRUE, NULL);
|
| 178 |
+
overlapStruct.hEvent = evt;
|
| 179 |
+
|
| 180 |
+
// Call IOCTL with IOCTL_RIFFA_RECV
|
| 181 |
+
status = DeviceIoControl(fpga->dev, IOCTL_RIFFA_RECV, (LPVOID)&io,
|
| 182 |
+
sizeof(io), data, (len<<2), &wordsReturned, &overlapStruct);
|
| 183 |
+
if(!status) {
|
| 184 |
+
// Should be the IO Pending error
|
| 185 |
+
if(GetLastError() == ERROR_IO_PENDING) {
|
| 186 |
+
// Wait for the IOCTL to complete and get the return value
|
| 187 |
+
WaitForSingleObject(evt, INFINITE);
|
| 188 |
+
status = GetOverlappedResult(fpga->dev, &overlapStruct,
|
| 189 |
+
&wordsReturned, FALSE);
|
| 190 |
+
if(!status) {
|
| 191 |
+
if (GetLastError() == ERROR_OPERATION_ABORTED)
|
| 192 |
+
printf("Operation timed out or was aborted\n");
|
| 193 |
+
else
|
| 194 |
+
printf("Error in GetOverlappedResult: %d\n", GetLastError());
|
| 195 |
+
}
|
| 196 |
+
}
|
| 197 |
+
else {
|
| 198 |
+
printf("Error in DeviceIoControl: %d\n", GetLastError());
|
| 199 |
+
}
|
| 200 |
+
}
|
| 201 |
+
return wordsReturned;
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
void RIFFACALL fpga_reset(fpga_t * fpga) {
|
| 205 |
+
BOOLEAN status;
|
| 206 |
+
OVERLAPPED overlapStruct = {0};
|
| 207 |
+
ULONG wordsReturned;
|
| 208 |
+
|
| 209 |
+
// Validate the device handle
|
| 210 |
+
if (fpga->dev == NULL || fpga->dev == INVALID_HANDLE_VALUE) {
|
| 211 |
+
printf("Invalid fpga_t device handle\n");
|
| 212 |
+
return;
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
// Call IOCTL with IOCTL_RIFFA_RESET. Must use the overlapped struct as the
|
| 216 |
+
// device was opened with overlap support.
|
| 217 |
+
status = DeviceIoControl(fpga->dev, IOCTL_RIFFA_RESET, NULL, 0, NULL, 0,
|
| 218 |
+
&wordsReturned, &overlapStruct);
|
| 219 |
+
if(!status) {
|
| 220 |
+
// Should be the IO Pending error
|
| 221 |
+
if(GetLastError() == ERROR_IO_PENDING) {
|
| 222 |
+
// Wait for the IOCTL to complete and get the return value
|
| 223 |
+
status = GetOverlappedResult(fpga->dev, &overlapStruct,
|
| 224 |
+
&wordsReturned, TRUE);
|
| 225 |
+
if(!status)
|
| 226 |
+
printf("Error in GetOverlappedResult: %d\n", GetLastError());
|
| 227 |
+
}
|
| 228 |
+
else {
|
| 229 |
+
printf("Error in DeviceIoControl: %d\n", GetLastError());
|
| 230 |
+
}
|
| 231 |
+
}
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
int RIFFACALL fpga_list(fpga_info_list * list) {
|
| 235 |
+
// Populate the fpga_info_list struct
|
| 236 |
+
list->num_fpgas = 0;
|
| 237 |
+
return (int)fill_device_info(list);
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
/**
|
| 241 |
+
* Returns a handle to the FPGA device specified by index. On failure, returns
|
| 242 |
+
* an INVALID_HANDLE_VALUE. If the value of overlapped is TRUE, the device
|
| 243 |
+
* handle will be opened with flag FILE_FLAG_OVERLAPPED to signal that future
|
| 244 |
+
* operations will use overlapped IO. If the value of overlapped is FALSE, the
|
| 245 |
+
* device handle will be opened with flag FILE_ATTRIBUTE_NORMAL and no
|
| 246 |
+
* overlapped IO can be used with the returned device handle.
|
| 247 |
+
*/
|
| 248 |
+
HANDLE get_device(UINT32 index, BOOLEAN overlapped) {
|
| 249 |
+
PSP_DEVICE_INTERFACE_DETAIL_DATA devIntfDetail;
|
| 250 |
+
SP_DEVICE_INTERFACE_DATA devIntfData;
|
| 251 |
+
SP_DEVINFO_DATA devInfoData;
|
| 252 |
+
SECURITY_ATTRIBUTES secAttr;
|
| 253 |
+
HDEVINFO devInfo;
|
| 254 |
+
BOOLEAN status = TRUE;
|
| 255 |
+
ULONG size;
|
| 256 |
+
HANDLE dev;
|
| 257 |
+
DWORD flags;
|
| 258 |
+
|
| 259 |
+
// Retreive the device information for all RIFFA devices.
|
| 260 |
+
devInfo = SetupDiGetClassDevs(&GUID_RIFFA_INTERFACE, NULL, NULL,
|
| 261 |
+
DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
|
| 262 |
+
if (devInfo == INVALID_HANDLE_VALUE) {
|
| 263 |
+
printf("SetupDiGetClassDevs failed, Error: %d\n", GetLastError());
|
| 264 |
+
return INVALID_HANDLE_VALUE;
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
// Initialize the appropriate data structures for the SetupDi calls.
|
| 268 |
+
devIntfData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
|
| 269 |
+
devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
|
| 270 |
+
|
| 271 |
+
// Get information for specific device.
|
| 272 |
+
status = SetupDiEnumDeviceInterfaces(devInfo, NULL, (LPGUID)&GUID_RIFFA_INTERFACE,
|
| 273 |
+
index, &devIntfData);
|
| 274 |
+
if (!status) {
|
| 275 |
+
printf("SetupDiEnumDeviceInterfaces failed, Error: %d\n", GetLastError());
|
| 276 |
+
SetupDiDestroyDeviceInfoList(devInfo);
|
| 277 |
+
return INVALID_HANDLE_VALUE;
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
// Determine the size required for the devIntfData
|
| 281 |
+
SetupDiGetDeviceInterfaceDetail(devInfo, &devIntfData, NULL, 0, &size, NULL);
|
| 282 |
+
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
|
| 283 |
+
printf("SetupDiGetDeviceInterfaceDetail failed, Error: %d\n", GetLastError());
|
| 284 |
+
SetupDiDestroyDeviceInfoList(devInfo);
|
| 285 |
+
return INVALID_HANDLE_VALUE;
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
devIntfDetail = (PSP_DEVICE_INTERFACE_DETAIL_DATA)malloc(size);
|
| 289 |
+
if (!devIntfDetail) {
|
| 290 |
+
printf("Insufficient memory.\n");
|
| 291 |
+
SetupDiDestroyDeviceInfoList(devInfo);
|
| 292 |
+
return INVALID_HANDLE_VALUE;
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
// Initialize structure and retrieve data.
|
| 296 |
+
devIntfDetail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
|
| 297 |
+
status = SetupDiGetDeviceInterfaceDetail(devInfo, &devIntfData, devIntfDetail,
|
| 298 |
+
size, NULL, &devInfoData);
|
| 299 |
+
if (!status) {
|
| 300 |
+
printf("SetupDiGetDeviceInterfaceDetail failed, Error: %d\n", GetLastError());
|
| 301 |
+
free(devIntfDetail);
|
| 302 |
+
SetupDiDestroyDeviceInfoList(devInfo);
|
| 303 |
+
return INVALID_HANDLE_VALUE;
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
// Prepare the security attributes for interitance.
|
| 307 |
+
secAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
|
| 308 |
+
secAttr.bInheritHandle = TRUE;
|
| 309 |
+
secAttr.lpSecurityDescriptor = NULL;
|
| 310 |
+
|
| 311 |
+
// Get the device handle itself (finally!)
|
| 312 |
+
flags = (overlapped ? FILE_FLAG_OVERLAPPED : FILE_ATTRIBUTE_NORMAL);
|
| 313 |
+
flags = flags | FILE_FLAG_NO_BUFFERING;
|
| 314 |
+
dev = CreateFile(devIntfDetail->DevicePath, GENERIC_READ|GENERIC_WRITE,
|
| 315 |
+
FILE_SHARE_READ | FILE_SHARE_WRITE, &secAttr, OPEN_EXISTING, flags, NULL);
|
| 316 |
+
if (dev == INVALID_HANDLE_VALUE) {
|
| 317 |
+
printf("CreateFile failed. Error:%d\n", GetLastError());
|
| 318 |
+
free(devIntfDetail);
|
| 319 |
+
SetupDiDestroyDeviceInfoList(devInfo);
|
| 320 |
+
return INVALID_HANDLE_VALUE;
|
| 321 |
+
}
|
| 322 |
+
free(devIntfDetail);
|
| 323 |
+
SetupDiDestroyDeviceInfoList(devInfo);
|
| 324 |
+
|
| 325 |
+
return dev;
|
| 326 |
+
}
|
| 327 |
+
|
| 328 |
+
/**
|
| 329 |
+
* Populates the specified fpga_info_list struct with FPGA information. Returns
|
| 330 |
+
* zero on success. On failure, returns an error code (positive value).
|
| 331 |
+
*/
|
| 332 |
+
DWORD fill_device_info(fpga_info_list * info) {
|
| 333 |
+
PSP_DEVICE_INTERFACE_DETAIL_DATA devIntfDetail;
|
| 334 |
+
SP_DEVICE_INTERFACE_DATA devIntfData;
|
| 335 |
+
SP_DEVINFO_DATA devInfoData;
|
| 336 |
+
HDEVINFO devInfo;
|
| 337 |
+
BOOLEAN status = TRUE;
|
| 338 |
+
ULONG size;
|
| 339 |
+
UINT32 i;
|
| 340 |
+
ULONG wordsReturned;
|
| 341 |
+
HANDLE dev;
|
| 342 |
+
|
| 343 |
+
// Retreive the device information for all RIFFA devices.
|
| 344 |
+
devInfo = SetupDiGetClassDevs(&GUID_RIFFA_INTERFACE, NULL, NULL,
|
| 345 |
+
DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
|
| 346 |
+
if (devInfo == INVALID_HANDLE_VALUE) {
|
| 347 |
+
printf("SetupDiGetClassDevs failed, Error: %d\n", GetLastError());
|
| 348 |
+
return GetLastError();
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
// Initialize the appropriate data structures for the SetupDi calls.
|
| 352 |
+
devIntfData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
|
| 353 |
+
devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
|
| 354 |
+
|
| 355 |
+
// Loop through the device list.
|
| 356 |
+
i = 0;
|
| 357 |
+
while (SetupDiEnumDeviceInterfaces(devInfo, NULL, (LPGUID)&GUID_RIFFA_INTERFACE,
|
| 358 |
+
i, &devIntfData)) {
|
| 359 |
+
// Determine the size required for the devIntfData
|
| 360 |
+
SetupDiGetDeviceInterfaceDetail(devInfo, &devIntfData, NULL, 0, &size, NULL);
|
| 361 |
+
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
|
| 362 |
+
printf("SetupDiGetDeviceInterfaceDetail failed, Error: %d\n", GetLastError());
|
| 363 |
+
SetupDiDestroyDeviceInfoList(devInfo);
|
| 364 |
+
return GetLastError();
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
// Create the SP_DEVICE_INTERFACE_DETAIL_DATA
|
| 368 |
+
devIntfDetail = (PSP_DEVICE_INTERFACE_DETAIL_DATA)malloc(size);
|
| 369 |
+
if (!devIntfDetail) {
|
| 370 |
+
printf("Insufficient memory.\n");
|
| 371 |
+
SetupDiDestroyDeviceInfoList(devInfo);
|
| 372 |
+
return ERROR_NOT_ENOUGH_MEMORY;
|
| 373 |
+
}
|
| 374 |
+
|
| 375 |
+
// Initialize structure and retrieve data.
|
| 376 |
+
devIntfDetail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
|
| 377 |
+
status = SetupDiGetDeviceInterfaceDetail(devInfo, &devIntfData, devIntfDetail,
|
| 378 |
+
size, NULL, &devInfoData);
|
| 379 |
+
if (!status) {
|
| 380 |
+
printf("SetupDiGetDeviceInterfaceDetail failed, Error: %d\n", GetLastError());
|
| 381 |
+
free(devIntfDetail);
|
| 382 |
+
SetupDiDestroyDeviceInfoList(devInfo);
|
| 383 |
+
return GetLastError();
|
| 384 |
+
}
|
| 385 |
+
|
| 386 |
+
// Get the device handle itself (no overlap)
|
| 387 |
+
dev = CreateFile(devIntfDetail->DevicePath, GENERIC_READ|GENERIC_WRITE,
|
| 388 |
+
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
| 389 |
+
if (dev == INVALID_HANDLE_VALUE) {
|
| 390 |
+
printf("CreateFile failed. Error:%d\n", GetLastError());
|
| 391 |
+
free(devIntfDetail);
|
| 392 |
+
SetupDiDestroyDeviceInfoList(devInfo);
|
| 393 |
+
return GetLastError();
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
// Call IOCTL with IOCTL_RIFFA_LIST
|
| 397 |
+
status = DeviceIoControl(dev, IOCTL_RIFFA_LIST, (LPVOID)&i, sizeof(i),
|
| 398 |
+
(LPVOID)info, sizeof(*info), &wordsReturned, NULL);
|
| 399 |
+
if (!status) {
|
| 400 |
+
printf("Error in DeviceIoControl: %d\n", GetLastError());
|
| 401 |
+
CloseHandle(dev);
|
| 402 |
+
free(devIntfDetail);
|
| 403 |
+
SetupDiDestroyDeviceInfoList(devInfo);
|
| 404 |
+
return GetLastError();
|
| 405 |
+
}
|
| 406 |
+
info->num_fpgas = info->num_fpgas + 1;
|
| 407 |
+
|
| 408 |
+
// Done with the device
|
| 409 |
+
CloseHandle(dev);
|
| 410 |
+
free(devIntfDetail);
|
| 411 |
+
|
| 412 |
+
// Cycle through the available devices.
|
| 413 |
+
i++;
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
// Done with the DeviceInfo
|
| 417 |
+
SetupDiDestroyDeviceInfoList(devInfo);
|
| 418 |
+
|
| 419 |
+
return 0;
|
| 420 |
+
}
|
| 421 |
+
|
| 422 |
+
|
| 423 |
+
|
KastnerRG_riffa/c_c++/windows/x64/riffa.def
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
;
|
| 2 |
+
; Definition file of riffa.dll
|
| 3 |
+
; Automatic generated by gendef
|
| 4 |
+
; written by Kai Tietz 2008
|
| 5 |
+
;
|
| 6 |
+
LIBRARY "riffa.dll"
|
| 7 |
+
EXPORTS
|
| 8 |
+
fpga_close
|
| 9 |
+
fpga_list
|
| 10 |
+
fpga_open
|
| 11 |
+
fpga_recv
|
| 12 |
+
fpga_reset
|
| 13 |
+
fpga_send
|
KastnerRG_riffa/c_c++/windows/x64/riffa.exp
ADDED
|
Binary file (1.33 kB). View file
|
|
|
KastnerRG_riffa/c_c++/windows/x64/riffa.h
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// ----------------------------------------------------------------------
|
| 2 |
+
// Copyright (c) 2016, The Regents of the University of California All
|
| 3 |
+
// rights reserved.
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
//
|
| 12 |
+
// * Redistributions in binary form must reproduce the above
|
| 13 |
+
// copyright notice, this list of conditions and the following
|
| 14 |
+
// disclaimer in the documentation and/or other materials provided
|
| 15 |
+
// with the distribution.
|
| 16 |
+
//
|
| 17 |
+
// * Neither the name of The Regents of the University of California
|
| 18 |
+
// nor the names of its contributors may be used to endorse or
|
| 19 |
+
// promote products derived from this software without specific
|
| 20 |
+
// prior written permission.
|
| 21 |
+
//
|
| 22 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 23 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 24 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 25 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE
|
| 26 |
+
// UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 27 |
+
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 28 |
+
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
| 29 |
+
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 30 |
+
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 31 |
+
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
| 32 |
+
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 33 |
+
// DAMAGE.
|
| 34 |
+
// ----------------------------------------------------------------------
|
| 35 |
+
/*
|
| 36 |
+
* Filename: riffa.h
|
| 37 |
+
* Version: 2.0
|
| 38 |
+
* Description: Windows PCIe communications API for RIFFA.
|
| 39 |
+
* Author: Matthew Jacobsen
|
| 40 |
+
* History: @mattj: Initial release. Version 2.0.
|
| 41 |
+
*/
|
| 42 |
+
|
| 43 |
+
#ifndef RIFFA_H
|
| 44 |
+
#define RIFFA_H
|
| 45 |
+
|
| 46 |
+
// Must RIFFA_EXPORTS *only* when building the DLL.
|
| 47 |
+
#ifdef RIFFA_EXPORTS
|
| 48 |
+
#define RIFFAAPI __declspec(dllexport)
|
| 49 |
+
#else
|
| 50 |
+
#define RIFFAAPI __declspec(dllimport)
|
| 51 |
+
#endif
|
| 52 |
+
|
| 53 |
+
// Define calling convention in one place, for convenience.
|
| 54 |
+
#define RIFFACALL __cdecl
|
| 55 |
+
|
| 56 |
+
#ifdef __cplusplus
|
| 57 |
+
extern "C" {
|
| 58 |
+
#endif
|
| 59 |
+
|
| 60 |
+
// Maximum number of RIFFA FPGAs
|
| 61 |
+
#define RIFFA_MAX_NUM_FPGAS (5)
|
| 62 |
+
|
| 63 |
+
// Holds FPGA information for installed RIFFA FPGAs
|
| 64 |
+
struct fpga_info_list
|
| 65 |
+
{
|
| 66 |
+
int num_fpgas;
|
| 67 |
+
int id[RIFFA_MAX_NUM_FPGAS];
|
| 68 |
+
int num_chnls[RIFFA_MAX_NUM_FPGAS];
|
| 69 |
+
char name[RIFFA_MAX_NUM_FPGAS][16];
|
| 70 |
+
int vendor_id[RIFFA_MAX_NUM_FPGAS];
|
| 71 |
+
int device_id[RIFFA_MAX_NUM_FPGAS];
|
| 72 |
+
};
|
| 73 |
+
typedef struct fpga_info_list fpga_info_list;
|
| 74 |
+
|
| 75 |
+
// Represents the FPGA device
|
| 76 |
+
struct fpga_t;
|
| 77 |
+
typedef struct fpga_t fpga_t;
|
| 78 |
+
|
| 79 |
+
/**
|
| 80 |
+
* Populates the fpga_info_list pointer with all FPGAs registered in the system.
|
| 81 |
+
* Returns 0 on success, non-zero on error.
|
| 82 |
+
*/
|
| 83 |
+
RIFFAAPI int RIFFACALL fpga_list(fpga_info_list * list);
|
| 84 |
+
|
| 85 |
+
/**
|
| 86 |
+
* Initializes the FPGA specified by id. On success, returns a pointer to a
|
| 87 |
+
* fpga_t struct. On error, returns NULL. Each FPGA must be opened before any
|
| 88 |
+
* channels can be accessed. Once opened, any number of threads can use the
|
| 89 |
+
* fpga_t struct.
|
| 90 |
+
*/
|
| 91 |
+
RIFFAAPI fpga_t * RIFFACALL fpga_open(int id);
|
| 92 |
+
|
| 93 |
+
/**
|
| 94 |
+
* Cleans up memory/resources for the FPGA specified by the fd descriptor.
|
| 95 |
+
*/
|
| 96 |
+
RIFFAAPI void RIFFACALL fpga_close(fpga_t * fpga);
|
| 97 |
+
|
| 98 |
+
/**
|
| 99 |
+
* Sends len words (4 byte words) from data to FPGA channel chnl using the
|
| 100 |
+
* fpga_t struct. The FPGA channel will be sent len, destoff, and last. If last
|
| 101 |
+
* is 1, the channel should interpret the end of this send as the end of a
|
| 102 |
+
* transaction. If last is 0, the channel should wait for additional sends
|
| 103 |
+
* before the end of the transaction. If timeout is non-zero, this call will
|
| 104 |
+
* send data and wait up to timeout ms for the FPGA to respond (between
|
| 105 |
+
* packets) before timing out. If timeout is zero, this call may block
|
| 106 |
+
* indefinitely. Multiple threads sending on the same channel may result in
|
| 107 |
+
* corrupt data or error. This function is thread safe across channels.
|
| 108 |
+
* Returns the number of words sent.
|
| 109 |
+
*/
|
| 110 |
+
RIFFAAPI int RIFFACALL fpga_send(fpga_t * fpga, int chnl, void * data, int len,
|
| 111 |
+
int destoff, int last, long long timeout);
|
| 112 |
+
|
| 113 |
+
/**
|
| 114 |
+
* Receives data from the FPGA channel chnl to the data pointer, using the
|
| 115 |
+
* fpga_t struct. The FPGA channel can send any amount of data, so the data
|
| 116 |
+
* array should be large enough to accommodate. The len parameter specifies the
|
| 117 |
+
* actual size of the data buffer in words (4 byte words). The FPGA channel will
|
| 118 |
+
* specify an offset which will determine where in the data array the data will
|
| 119 |
+
* start being written. If the amount of data (plus offset) exceed the size of
|
| 120 |
+
* the data array (len), then that data will be discarded. If timeout is
|
| 121 |
+
* non-zero, this call will wait up to timeout ms for the FPGA to respond
|
| 122 |
+
* (between packets) before timing out. If timeout is zero, this call may block
|
| 123 |
+
* indefinitely. Multiple threads receiving on the same channel may result in
|
| 124 |
+
* corrupt data or error. This function is thread safe across channels.
|
| 125 |
+
* Returns the number of words received to the data array.
|
| 126 |
+
*/
|
| 127 |
+
RIFFAAPI int RIFFACALL fpga_recv(fpga_t * fpga, int chnl, void * data, int len,
|
| 128 |
+
long long timeout);
|
| 129 |
+
|
| 130 |
+
/**
|
| 131 |
+
* Resets the state of the FPGA and all transfers across all channels. This is
|
| 132 |
+
* meant to be used as an alternative to rebooting if an error occurs while
|
| 133 |
+
* sending/receiving. Calling this function while other threads are sending or
|
| 134 |
+
* receiving will result in unexpected behavior.
|
| 135 |
+
*/
|
| 136 |
+
RIFFAAPI void RIFFACALL fpga_reset(fpga_t * fpga);
|
| 137 |
+
|
| 138 |
+
#ifdef __cplusplus
|
| 139 |
+
}
|
| 140 |
+
#endif
|
| 141 |
+
|
| 142 |
+
#endif
|
KastnerRG_riffa/c_c++/windows/x64/riffa.lib
ADDED
|
Binary file (2.53 kB). View file
|
|
|
KastnerRG_riffa/c_c++/windows/x64/riffa.rc
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* ----------------------------------------------------------------------
|
| 2 |
+
* Copyright (c) 2016, The Regents of the University of California All
|
| 3 |
+
* rights reserved.
|
| 4 |
+
*
|
| 5 |
+
* Redistribution and use in source and binary forms, with or without
|
| 6 |
+
* modification, are permitted provided that the following conditions are
|
| 7 |
+
* met:
|
| 8 |
+
*
|
| 9 |
+
* * Redistributions of source code must retain the above copyright
|
| 10 |
+
* notice, this list of conditions and the following disclaimer.
|
| 11 |
+
*
|
| 12 |
+
* * Redistributions in binary form must reproduce the above
|
| 13 |
+
* copyright notice, this list of conditions and the following
|
| 14 |
+
* disclaimer in the documentation and/or other materials provided
|
| 15 |
+
* with the distribution.
|
| 16 |
+
*
|
| 17 |
+
* * Neither the name of The Regents of the University of California
|
| 18 |
+
* nor the names of its contributors may be used to endorse or
|
| 19 |
+
* promote products derived from this software without specific
|
| 20 |
+
* prior written permission.
|
| 21 |
+
*
|
| 22 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 23 |
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 24 |
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 25 |
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE
|
| 26 |
+
* UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 27 |
+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 28 |
+
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
| 29 |
+
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 30 |
+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 31 |
+
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
| 32 |
+
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 33 |
+
* DAMAGE.
|
| 34 |
+
* ----------------------------------------------------------------------
|
| 35 |
+
*/
|
| 36 |
+
/*
|
| 37 |
+
* Filename: riffa.rc
|
| 38 |
+
* Version: 2.0
|
| 39 |
+
* Description: Windows PCIe communications API for RIFFA.
|
| 40 |
+
* Author: Matthew Jacobsen
|
| 41 |
+
* History: @mattj: Initial release. Version 2.0.
|
| 42 |
+
*/
|
| 43 |
+
|
| 44 |
+
1 VERSIONINFO
|
| 45 |
+
FILEVERSION 1,0,0,0
|
| 46 |
+
PRODUCTVERSION 2,0,0,0
|
| 47 |
+
FILEFLAGSMASK 0x17L
|
| 48 |
+
#ifdef _DEBUG
|
| 49 |
+
FILEFLAGS 0x1L
|
| 50 |
+
#else
|
| 51 |
+
FILEFLAGS 0x0L
|
| 52 |
+
#endif
|
| 53 |
+
FILEOS 0x4L
|
| 54 |
+
FILETYPE 0x1L
|
| 55 |
+
FILESUBTYPE 0x0L
|
| 56 |
+
BEGIN
|
| 57 |
+
BLOCK "StringFileInfo"
|
| 58 |
+
BEGIN
|
| 59 |
+
BLOCK "040904b0"
|
| 60 |
+
BEGIN
|
| 61 |
+
VALUE "Comments", "RIFFA 64 bit Windows Library"
|
| 62 |
+
VALUE "CompanyName", "University of California, San Diego"
|
| 63 |
+
VALUE "FileDescription", "User 64 bit library for RIFFA."
|
| 64 |
+
VALUE "FileVersion", "1, 0, 0, 0"
|
| 65 |
+
VALUE "InternalName", "RIFFA"
|
| 66 |
+
VALUE "LegalCopyright", "Copyright � 2011 The Regents of the University of California. All Rights Reserved."
|
| 67 |
+
VALUE "OriginalFilename", "riffa.dll"
|
| 68 |
+
VALUE "ProductName", "RIFFA Library"
|
| 69 |
+
VALUE "ProductVersion", "2, 0, 0, 0"
|
| 70 |
+
END
|
| 71 |
+
END
|
| 72 |
+
BLOCK "VarFileInfo"
|
| 73 |
+
BEGIN
|
| 74 |
+
VALUE "Translation", 0x409, 1200
|
| 75 |
+
END
|
| 76 |
+
END
|
KastnerRG_riffa/c_c++/windows/x64/riffa_driver.h
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//
|
| 2 |
+
// The following value is arbitrarily chosen from the space defined
|
| 3 |
+
// by Microsoft as being "for non-Microsoft use"
|
| 4 |
+
//
|
| 5 |
+
//
|
| 6 |
+
// {40d49fb9-6085-4e1d-8753-822be944d7bb}
|
| 7 |
+
DEFINE_GUID (GUID_RIFFA_INTERFACE,
|
| 8 |
+
0x40d49fb9, 0x6085, 0x4e1d, 0x87, 0x53, 0x82, 0x2b, 0xe9, 0x44, 0xd7, 0xbb);
|
| 9 |
+
|
| 10 |
+
// The IOCTL function codes from 0x800 to 0xFFF are for customer use.
|
| 11 |
+
#define IOCTL_RIFFA_SEND \
|
| 12 |
+
CTL_CODE(FILE_DEVICE_UNKNOWN, 0x900, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
|
| 13 |
+
#define IOCTL_RIFFA_RECV \
|
| 14 |
+
CTL_CODE(FILE_DEVICE_UNKNOWN, 0x901, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
|
| 15 |
+
#define IOCTL_RIFFA_LIST \
|
| 16 |
+
CTL_CODE(FILE_DEVICE_UNKNOWN, 0x902, METHOD_OUT_DIRECT ,FILE_ANY_ACCESS)
|
| 17 |
+
#define IOCTL_RIFFA_RESET \
|
| 18 |
+
CTL_CODE(FILE_DEVICE_UNKNOWN, 0x903, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
|
| 19 |
+
|
KastnerRG_riffa/c_c++/windows/x64/sample_app/README.txt
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The testutil example application works with the Verilog chnl_tester module
|
| 2 |
+
which receives data and then sends data back to the workstation.
|
| 3 |
+
|
| 4 |
+
To compile the example application:
|
| 5 |
+
|
| 6 |
+
gcc.exe -o testutil.exe testutil.c -L. -lriffa
|
| 7 |
+
|
| 8 |
+
The riffa.lib import library must be in the directory specified by the -L
|
| 9 |
+
parameter (in this example, the current directory). The riffa.h header must be
|
| 10 |
+
in the same directory as testutil.c.
|
KastnerRG_riffa/c_c++/windows/x64/sample_app/riffa.h
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// ----------------------------------------------------------------------
|
| 2 |
+
// Copyright (c) 2016, The Regents of the University of California All
|
| 3 |
+
// rights reserved.
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
//
|
| 12 |
+
// * Redistributions in binary form must reproduce the above
|
| 13 |
+
// copyright notice, this list of conditions and the following
|
| 14 |
+
// disclaimer in the documentation and/or other materials provided
|
| 15 |
+
// with the distribution.
|
| 16 |
+
//
|
| 17 |
+
// * Neither the name of The Regents of the University of California
|
| 18 |
+
// nor the names of its contributors may be used to endorse or
|
| 19 |
+
// promote products derived from this software without specific
|
| 20 |
+
// prior written permission.
|
| 21 |
+
//
|
| 22 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 23 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 24 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 25 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE
|
| 26 |
+
// UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 27 |
+
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 28 |
+
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
| 29 |
+
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 30 |
+
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 31 |
+
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
| 32 |
+
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 33 |
+
// DAMAGE.
|
| 34 |
+
// ----------------------------------------------------------------------
|
| 35 |
+
/*
|
| 36 |
+
* Filename: riffa.h
|
| 37 |
+
* Version: 2.0
|
| 38 |
+
* Description: Windows PCIe communications API for RIFFA.
|
| 39 |
+
* Author: Matthew Jacobsen
|
| 40 |
+
* History: @mattj: Initial release. Version 2.0.
|
| 41 |
+
*/
|
| 42 |
+
|
| 43 |
+
#ifndef RIFFA_H
|
| 44 |
+
#define RIFFA_H
|
| 45 |
+
|
| 46 |
+
// Must RIFFA_EXPORTS *only* when building the DLL.
|
| 47 |
+
#ifdef RIFFA_EXPORTS
|
| 48 |
+
#define RIFFAAPI __declspec(dllexport)
|
| 49 |
+
#else
|
| 50 |
+
#define RIFFAAPI __declspec(dllimport)
|
| 51 |
+
#endif
|
| 52 |
+
|
| 53 |
+
// Define calling convention in one place, for convenience.
|
| 54 |
+
#define RIFFACALL __cdecl
|
| 55 |
+
|
| 56 |
+
#ifdef __cplusplus
|
| 57 |
+
extern "C" {
|
| 58 |
+
#endif
|
| 59 |
+
|
| 60 |
+
// Maximum number of RIFFA FPGAs
|
| 61 |
+
#define RIFFA_MAX_NUM_FPGAS (5)
|
| 62 |
+
|
| 63 |
+
// Holds FPGA information for installed RIFFA FPGAs
|
| 64 |
+
struct fpga_info_list
|
| 65 |
+
{
|
| 66 |
+
int num_fpgas;
|
| 67 |
+
int id[RIFFA_MAX_NUM_FPGAS];
|
| 68 |
+
int num_chnls[RIFFA_MAX_NUM_FPGAS];
|
| 69 |
+
char name[RIFFA_MAX_NUM_FPGAS][16];
|
| 70 |
+
int vendor_id[RIFFA_MAX_NUM_FPGAS];
|
| 71 |
+
int device_id[RIFFA_MAX_NUM_FPGAS];
|
| 72 |
+
};
|
| 73 |
+
typedef struct fpga_info_list fpga_info_list;
|
| 74 |
+
|
| 75 |
+
// Represents the FPGA device
|
| 76 |
+
struct fpga_t;
|
| 77 |
+
typedef struct fpga_t fpga_t;
|
| 78 |
+
|
| 79 |
+
/**
|
| 80 |
+
* Populates the fpga_info_list pointer with all FPGAs registered in the system.
|
| 81 |
+
* Returns 0 on success, non-zero on error.
|
| 82 |
+
*/
|
| 83 |
+
RIFFAAPI int RIFFACALL fpga_list(fpga_info_list * list);
|
| 84 |
+
|
| 85 |
+
/**
|
| 86 |
+
* Initializes the FPGA specified by id. On success, returns a pointer to a
|
| 87 |
+
* fpga_t struct. On error, returns NULL. Each FPGA must be opened before any
|
| 88 |
+
* channels can be accessed. Once opened, any number of threads can use the
|
| 89 |
+
* fpga_t struct.
|
| 90 |
+
*/
|
| 91 |
+
RIFFAAPI fpga_t * RIFFACALL fpga_open(int id);
|
| 92 |
+
|
| 93 |
+
/**
|
| 94 |
+
* Cleans up memory/resources for the FPGA specified by the fd descriptor.
|
| 95 |
+
*/
|
| 96 |
+
RIFFAAPI void RIFFACALL fpga_close(fpga_t * fpga);
|
| 97 |
+
|
| 98 |
+
/**
|
| 99 |
+
* Sends len words (4 byte words) from data to FPGA channel chnl using the
|
| 100 |
+
* fpga_t struct. The FPGA channel will be sent len, destoff, and last. If last
|
| 101 |
+
* is 1, the channel should interpret the end of this send as the end of a
|
| 102 |
+
* transaction. If last is 0, the channel should wait for additional sends
|
| 103 |
+
* before the end of the transaction. If timeout is non-zero, this call will
|
| 104 |
+
* send data and wait up to timeout ms for the FPGA to respond (between
|
| 105 |
+
* packets) before timing out. If timeout is zero, this call may block
|
| 106 |
+
* indefinitely. Multiple threads sending on the same channel may result in
|
| 107 |
+
* corrupt data or error. This function is thread safe across channels.
|
| 108 |
+
* Returns the number of words sent.
|
| 109 |
+
*/
|
| 110 |
+
RIFFAAPI int RIFFACALL fpga_send(fpga_t * fpga, int chnl, void * data, int len,
|
| 111 |
+
int destoff, int last, long long timeout);
|
| 112 |
+
|
| 113 |
+
/**
|
| 114 |
+
* Receives data from the FPGA channel chnl to the data pointer, using the
|
| 115 |
+
* fpga_t struct. The FPGA channel can send any amount of data, so the data
|
| 116 |
+
* array should be large enough to accommodate. The len parameter specifies the
|
| 117 |
+
* actual size of the data buffer in words (4 byte words). The FPGA channel will
|
| 118 |
+
* specify an offset which will determine where in the data array the data will
|
| 119 |
+
* start being written. If the amount of data (plus offset) exceed the size of
|
| 120 |
+
* the data array (len), then that data will be discarded. If timeout is
|
| 121 |
+
* non-zero, this call will wait up to timeout ms for the FPGA to respond
|
| 122 |
+
* (between packets) before timing out. If timeout is zero, this call may block
|
| 123 |
+
* indefinitely. Multiple threads receiving on the same channel may result in
|
| 124 |
+
* corrupt data or error. This function is thread safe across channels.
|
| 125 |
+
* Returns the number of words received to the data array.
|
| 126 |
+
*/
|
| 127 |
+
RIFFAAPI int RIFFACALL fpga_recv(fpga_t * fpga, int chnl, void * data, int len,
|
| 128 |
+
long long timeout);
|
| 129 |
+
|
| 130 |
+
/**
|
| 131 |
+
* Resets the state of the FPGA and all transfers across all channels. This is
|
| 132 |
+
* meant to be used as an alternative to rebooting if an error occurs while
|
| 133 |
+
* sending/receiving. Calling this function while other threads are sending or
|
| 134 |
+
* receiving will result in unexpected behavior.
|
| 135 |
+
*/
|
| 136 |
+
RIFFAAPI void RIFFACALL fpga_reset(fpga_t * fpga);
|
| 137 |
+
|
| 138 |
+
#ifdef __cplusplus
|
| 139 |
+
}
|
| 140 |
+
#endif
|
| 141 |
+
|
| 142 |
+
#endif
|
KastnerRG_riffa/c_c++/windows/x64/sample_app/riffa.lib
ADDED
|
Binary file (4.33 kB). View file
|
|
|
KastnerRG_riffa/c_c++/windows/x64/sample_app/testutil.c
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <stdlib.h>
|
| 2 |
+
#include <stdio.h>
|
| 3 |
+
#include <windows.h>
|
| 4 |
+
#include "timer.h"
|
| 5 |
+
#include "riffa.h"
|
| 6 |
+
|
| 7 |
+
int main(int argc, char** argv) {
|
| 8 |
+
fpga_t * fpga;
|
| 9 |
+
fpga_info_list info;
|
| 10 |
+
int option;
|
| 11 |
+
int i;
|
| 12 |
+
int id;
|
| 13 |
+
int chnl;
|
| 14 |
+
size_t numWords;
|
| 15 |
+
int sent;
|
| 16 |
+
int recvd;
|
| 17 |
+
unsigned int * sendBuffer;
|
| 18 |
+
unsigned int * recvBuffer;
|
| 19 |
+
GET_TIME_INIT(3);
|
| 20 |
+
|
| 21 |
+
if (argc < 2) {
|
| 22 |
+
printf("Usage: %s <option>\n", argv[0]);
|
| 23 |
+
return -1;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
option = atoi(argv[1]);
|
| 27 |
+
|
| 28 |
+
if (option == 0) { // List FPGA info
|
| 29 |
+
// Populate the fpga_info_list struct
|
| 30 |
+
if (fpga_list(&info) != 0) {
|
| 31 |
+
printf("Error populating fpga_info_list\n");
|
| 32 |
+
return -1;
|
| 33 |
+
}
|
| 34 |
+
printf("Number of devices: %d\n", info.num_fpgas);
|
| 35 |
+
for (i = 0; i < info.num_fpgas; i++) {
|
| 36 |
+
printf("%d: id:%d\n", i, info.id[i]);
|
| 37 |
+
printf("%d: num_chnls:%d\n", i, info.num_chnls[i]);
|
| 38 |
+
printf("%d: name:%s\n", i, info.name[i]);
|
| 39 |
+
printf("%d: vendor id:%04X\n", i, info.vendor_id[i]);
|
| 40 |
+
printf("%d: device id:%04X\n", i, info.device_id[i]);
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
else if (option == 1) { // Reset FPGA
|
| 44 |
+
if (argc < 3) {
|
| 45 |
+
printf("Usage: %s %d <fpga id>\n", argv[0], option);
|
| 46 |
+
return -1;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
id = atoi(argv[2]);
|
| 50 |
+
|
| 51 |
+
// Get the device with id
|
| 52 |
+
fpga = fpga_open(id);
|
| 53 |
+
if (fpga == NULL) {
|
| 54 |
+
printf("Could not get FPGA %d\n", id);
|
| 55 |
+
return -1;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
// Reset
|
| 59 |
+
fpga_reset(fpga);
|
| 60 |
+
|
| 61 |
+
// Done with device
|
| 62 |
+
fpga_close(fpga);
|
| 63 |
+
}
|
| 64 |
+
else if (option == 2) { // Send data, receive data
|
| 65 |
+
if (argc < 5) {
|
| 66 |
+
printf("Usage: %s %d <fpga id> <chnl> <num words to transfer>\n", argv[0], option);
|
| 67 |
+
return -1;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
id = atoi(argv[2]);
|
| 71 |
+
chnl = atoi(argv[3]);
|
| 72 |
+
numWords = atoi(argv[4]);
|
| 73 |
+
|
| 74 |
+
// Get the device with id
|
| 75 |
+
fpga = fpga_open(id);
|
| 76 |
+
if (fpga == NULL) {
|
| 77 |
+
printf("Could not get FPGA %d\n", id);
|
| 78 |
+
return -1;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
// Malloc the arrays
|
| 82 |
+
sendBuffer = (unsigned int *)malloc(numWords<<2);
|
| 83 |
+
if (sendBuffer == NULL) {
|
| 84 |
+
printf("Could not malloc memory for sendBuffer\n");
|
| 85 |
+
fpga_close(fpga);
|
| 86 |
+
return -1;
|
| 87 |
+
}
|
| 88 |
+
recvBuffer = (unsigned int *)malloc(numWords<<2);
|
| 89 |
+
if (recvBuffer == NULL) {
|
| 90 |
+
printf("Could not malloc memory for recvBuffer\n");
|
| 91 |
+
free(sendBuffer);
|
| 92 |
+
fpga_close(fpga);
|
| 93 |
+
return -1;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
// Initialize the data
|
| 97 |
+
for (i = 0; i < numWords; i++) {
|
| 98 |
+
sendBuffer[i] = i+1;
|
| 99 |
+
recvBuffer[i] = 0;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
GET_TIME_VAL(0);
|
| 103 |
+
|
| 104 |
+
// Send the data
|
| 105 |
+
sent = fpga_send(fpga, chnl, sendBuffer, numWords, 0, 1, 25000);
|
| 106 |
+
printf("words sent: %d\n", sent);
|
| 107 |
+
|
| 108 |
+
GET_TIME_VAL(1);
|
| 109 |
+
|
| 110 |
+
if (sent != 0) {
|
| 111 |
+
// Recv the data
|
| 112 |
+
recvd = fpga_recv(fpga, chnl, recvBuffer, numWords, 25000);
|
| 113 |
+
printf("words recv: %d\n", recvd);
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
GET_TIME_VAL(2);
|
| 117 |
+
|
| 118 |
+
// Done with device
|
| 119 |
+
fpga_close(fpga);
|
| 120 |
+
|
| 121 |
+
// Display some data
|
| 122 |
+
for (i = 0; i < 20; i++) {
|
| 123 |
+
printf("recvBuffer[%d]: %d\n", i, recvBuffer[i]);
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
// Check the data
|
| 127 |
+
if (recvd != 0) {
|
| 128 |
+
for (i = 4; i < recvd; i++) {
|
| 129 |
+
if (recvBuffer[i] != sendBuffer[i]) {
|
| 130 |
+
printf("recvBuffer[%d]: %d, expected %d\n", i, recvBuffer[i], sendBuffer[i]);
|
| 131 |
+
break;
|
| 132 |
+
}
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
printf("send bw: %f MB/s %fms\n",
|
| 136 |
+
sent*4.0/1024/1024/((TIME_VAL_TO_MS(1) - TIME_VAL_TO_MS(0))/1000.0),
|
| 137 |
+
(TIME_VAL_TO_MS(1) - TIME_VAL_TO_MS(0)) );
|
| 138 |
+
|
| 139 |
+
printf("recv bw: %f MB/s %fms\n",
|
| 140 |
+
recvd*4.0/1024/1024/((TIME_VAL_TO_MS(2) - TIME_VAL_TO_MS(1))/1000.0),
|
| 141 |
+
(TIME_VAL_TO_MS(2) - TIME_VAL_TO_MS(1)) );
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
return 0;
|
| 146 |
+
}
|
KastnerRG_riffa/c_c++/windows/x64/sample_app/timer.h
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <windows.h>
|
| 2 |
+
|
| 3 |
+
#define GET_TIME_INIT(num) LARGE_INTEGER _timers[num]; LARGE_INTEGER _freq; QueryPerformanceFrequency(&_freq)
|
| 4 |
+
|
| 5 |
+
#define GET_TIME_VAL(num) QueryPerformanceCounter(&_timers[num])
|
| 6 |
+
|
| 7 |
+
#define TIME_VAL_TO_MS(num) ((double)_timers[num].QuadPart*1000.0/_freq.QuadPart)
|
KastnerRG_riffa/c_c++/windows/x86/README.txt
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
To build the C/C++ library:
|
| 2 |
+
|
| 3 |
+
windres.exe riffa.rc resource.o
|
| 4 |
+
gcc.exe -c -o riffa.o riffa.c -D RIFFA_EXPORTS
|
| 5 |
+
gcc.exe -o riffa.dll riffa.o resource.o -s -shared -Wl,--subsystem,windows,--out-implib,riffa.lib -luser32 -lsetupapi
|
| 6 |
+
del riffa.lib
|
| 7 |
+
gendef riffa.dll
|
| 8 |
+
lib /def:riffa.def /machine:x86 /out:riffa.lib
|
| 9 |
+
|
| 10 |
+
This will compile the resource file for the dll (metadata properties for the
|
| 11 |
+
.dll). This will also produce a .dll and .lib file. The .dll is the dynamic
|
| 12 |
+
library. The .lib file is the import library. You will want to copy the .dll
|
| 13 |
+
into say Windows\System32. You will want to use the .h file and the .lib files
|
| 14 |
+
when compiling and linking your applications.
|
KastnerRG_riffa/c_c++/windows/x86/riffa.c
ADDED
|
@@ -0,0 +1,423 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// ----------------------------------------------------------------------
|
| 2 |
+
// Copyright (c) 2016, The Regents of the University of California All
|
| 3 |
+
// rights reserved.
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
//
|
| 12 |
+
// * Redistributions in binary form must reproduce the above
|
| 13 |
+
// copyright notice, this list of conditions and the following
|
| 14 |
+
// disclaimer in the documentation and/or other materials provided
|
| 15 |
+
// with the distribution.
|
| 16 |
+
//
|
| 17 |
+
// * Neither the name of The Regents of the University of California
|
| 18 |
+
// nor the names of its contributors may be used to endorse or
|
| 19 |
+
// promote products derived from this software without specific
|
| 20 |
+
// prior written permission.
|
| 21 |
+
//
|
| 22 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 23 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 24 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 25 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE
|
| 26 |
+
// UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 27 |
+
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 28 |
+
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
| 29 |
+
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 30 |
+
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 31 |
+
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
| 32 |
+
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 33 |
+
// DAMAGE.
|
| 34 |
+
// ----------------------------------------------------------------------
|
| 35 |
+
/*
|
| 36 |
+
* Filename: riffa.c
|
| 37 |
+
* Version: 2.0
|
| 38 |
+
* Description: Windows PCIe communications API for RIFFA.
|
| 39 |
+
* Author: Matthew Jacobsen
|
| 40 |
+
* History: @mattj: Initial release. Version 2.0.
|
| 41 |
+
*/
|
| 42 |
+
|
| 43 |
+
#define INITGUID
|
| 44 |
+
|
| 45 |
+
#include <windows.h>
|
| 46 |
+
#include <setupapi.h>
|
| 47 |
+
#include <stdio.h>
|
| 48 |
+
#include <stdlib.h>
|
| 49 |
+
#include "riffa_driver.h"
|
| 50 |
+
#include "riffa.h"
|
| 51 |
+
|
| 52 |
+
// The structure used to hold data transfer information
|
| 53 |
+
typedef struct RIFFA_FPGA_CHNL_IO {
|
| 54 |
+
UINT32 Id;
|
| 55 |
+
UINT32 Chnl;
|
| 56 |
+
UINT32 Length;
|
| 57 |
+
UINT32 Offset;
|
| 58 |
+
UINT32 Last;
|
| 59 |
+
UINT64 Timeout;
|
| 60 |
+
} RIFFA_FPGA_CHNL_IO, * PRIFFA_FPGA_CHNL_IO;
|
| 61 |
+
|
| 62 |
+
// Represents the FPGA device
|
| 63 |
+
struct fpga_t
|
| 64 |
+
{
|
| 65 |
+
HANDLE dev;
|
| 66 |
+
int id;
|
| 67 |
+
};
|
| 68 |
+
|
| 69 |
+
HANDLE get_device(UINT32 index, BOOLEAN overlapped);
|
| 70 |
+
DWORD fill_device_info(fpga_info_list * info);
|
| 71 |
+
|
| 72 |
+
fpga_t * RIFFACALL fpga_open(int id) {
|
| 73 |
+
fpga_t * fpga;
|
| 74 |
+
|
| 75 |
+
// Allocate space for the fpga_dev
|
| 76 |
+
fpga = (fpga_t *)malloc(sizeof(fpga_t));
|
| 77 |
+
if (fpga == NULL)
|
| 78 |
+
return NULL;
|
| 79 |
+
fpga->id = id;
|
| 80 |
+
|
| 81 |
+
// Open the device handle.
|
| 82 |
+
fpga->dev = get_device(id, TRUE);
|
| 83 |
+
if (fpga->dev == INVALID_HANDLE_VALUE) {
|
| 84 |
+
free(fpga);
|
| 85 |
+
return NULL;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
return fpga;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
void RIFFACALL fpga_close(fpga_t * fpga) {
|
| 92 |
+
// Validate the device handle
|
| 93 |
+
if (fpga->dev == NULL || fpga->dev == INVALID_HANDLE_VALUE) {
|
| 94 |
+
printf("Invalid fpga_t device handle\n");
|
| 95 |
+
return;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
// Close the device handle.
|
| 99 |
+
CloseHandle(fpga->dev);
|
| 100 |
+
fpga->dev = NULL;
|
| 101 |
+
|
| 102 |
+
// Free the fpga_t struct
|
| 103 |
+
free(fpga);
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
int RIFFACALL fpga_send(fpga_t * fpga, int chnl, void * data, int len,
|
| 107 |
+
int destoff, int last, long long timeout) {
|
| 108 |
+
RIFFA_FPGA_CHNL_IO io;
|
| 109 |
+
OVERLAPPED overlapStruct = {0};
|
| 110 |
+
HANDLE evt;
|
| 111 |
+
BOOLEAN status;
|
| 112 |
+
ULONG wordsReturned;
|
| 113 |
+
|
| 114 |
+
// Validate the device handle
|
| 115 |
+
if (fpga->dev == NULL || fpga->dev == INVALID_HANDLE_VALUE) {
|
| 116 |
+
printf("Invalid fpga_t device handle\n");
|
| 117 |
+
return 0;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
// Initialize the RIFFA_FPGA_CHNL_IO struct
|
| 121 |
+
io.Id = fpga->id;
|
| 122 |
+
io.Chnl = chnl;
|
| 123 |
+
io.Length = len;
|
| 124 |
+
io.Offset = destoff;
|
| 125 |
+
io.Last = last;
|
| 126 |
+
io.Timeout = timeout;
|
| 127 |
+
|
| 128 |
+
// Create a thread specific event to wait on.
|
| 129 |
+
evt = CreateEvent(NULL, TRUE, TRUE, NULL);
|
| 130 |
+
overlapStruct.hEvent = evt;
|
| 131 |
+
|
| 132 |
+
// Call IOCTL with IOCTL_RIFFA_SEND
|
| 133 |
+
status = DeviceIoControl(fpga->dev, IOCTL_RIFFA_SEND, (LPVOID)&io,
|
| 134 |
+
sizeof(io), data, (len<<2), &wordsReturned, &overlapStruct);
|
| 135 |
+
if(!status) {
|
| 136 |
+
// Should be the IO Pending error
|
| 137 |
+
if(GetLastError() == ERROR_IO_PENDING) {
|
| 138 |
+
// Wait for the IOCTL to complete and get the return value
|
| 139 |
+
WaitForSingleObject(evt, INFINITE);
|
| 140 |
+
status = GetOverlappedResult(fpga->dev, &overlapStruct,
|
| 141 |
+
&wordsReturned, FALSE);
|
| 142 |
+
if(!status) {
|
| 143 |
+
if (GetLastError() == ERROR_OPERATION_ABORTED)
|
| 144 |
+
printf("Operation timed out or was aborted\n");
|
| 145 |
+
else
|
| 146 |
+
printf("Error in GetOverlappedResult: %d\n", GetLastError());
|
| 147 |
+
}
|
| 148 |
+
}
|
| 149 |
+
else {
|
| 150 |
+
printf("Error in DeviceIoControl: %d\n", GetLastError());
|
| 151 |
+
}
|
| 152 |
+
}
|
| 153 |
+
return wordsReturned;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
int RIFFACALL fpga_recv(fpga_t * fpga, int chnl, void * data, int len,
|
| 157 |
+
long long timeout) {
|
| 158 |
+
RIFFA_FPGA_CHNL_IO io;
|
| 159 |
+
OVERLAPPED overlapStruct = {0};
|
| 160 |
+
HANDLE evt;
|
| 161 |
+
BOOLEAN status;
|
| 162 |
+
ULONG wordsReturned;
|
| 163 |
+
|
| 164 |
+
// Validate the device handle
|
| 165 |
+
if (fpga->dev == NULL || fpga->dev == INVALID_HANDLE_VALUE) {
|
| 166 |
+
printf("Invalid fpga_t device handle\n");
|
| 167 |
+
return 0;
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
// Initialize the RIFFA_FPGA_CHNL_IO struct
|
| 171 |
+
io.Id = fpga->id;
|
| 172 |
+
io.Chnl = chnl;
|
| 173 |
+
io.Length = len;
|
| 174 |
+
io.Timeout = timeout;
|
| 175 |
+
|
| 176 |
+
// Create a thread specific event to wait on.
|
| 177 |
+
evt = CreateEvent(NULL, TRUE, TRUE, NULL);
|
| 178 |
+
overlapStruct.hEvent = evt;
|
| 179 |
+
|
| 180 |
+
// Call IOCTL with IOCTL_RIFFA_RECV
|
| 181 |
+
status = DeviceIoControl(fpga->dev, IOCTL_RIFFA_RECV, (LPVOID)&io,
|
| 182 |
+
sizeof(io), data, (len<<2), &wordsReturned, &overlapStruct);
|
| 183 |
+
if(!status) {
|
| 184 |
+
// Should be the IO Pending error
|
| 185 |
+
if(GetLastError() == ERROR_IO_PENDING) {
|
| 186 |
+
// Wait for the IOCTL to complete and get the return value
|
| 187 |
+
WaitForSingleObject(evt, INFINITE);
|
| 188 |
+
status = GetOverlappedResult(fpga->dev, &overlapStruct,
|
| 189 |
+
&wordsReturned, FALSE);
|
| 190 |
+
if(!status) {
|
| 191 |
+
if (GetLastError() == ERROR_OPERATION_ABORTED)
|
| 192 |
+
printf("Operation timed out or was aborted\n");
|
| 193 |
+
else
|
| 194 |
+
printf("Error in GetOverlappedResult: %d\n", GetLastError());
|
| 195 |
+
}
|
| 196 |
+
}
|
| 197 |
+
else {
|
| 198 |
+
printf("Error in DeviceIoControl: %d\n", GetLastError());
|
| 199 |
+
}
|
| 200 |
+
}
|
| 201 |
+
return wordsReturned;
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
void RIFFACALL fpga_reset(fpga_t * fpga) {
|
| 205 |
+
BOOLEAN status;
|
| 206 |
+
OVERLAPPED overlapStruct = {0};
|
| 207 |
+
ULONG wordsReturned;
|
| 208 |
+
|
| 209 |
+
// Validate the device handle
|
| 210 |
+
if (fpga->dev == NULL || fpga->dev == INVALID_HANDLE_VALUE) {
|
| 211 |
+
printf("Invalid fpga_t device handle\n");
|
| 212 |
+
return;
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
// Call IOCTL with IOCTL_RIFFA_RESET. Must use the overlapped struct as the
|
| 216 |
+
// device was opened with overlap support.
|
| 217 |
+
status = DeviceIoControl(fpga->dev, IOCTL_RIFFA_RESET, NULL, 0, NULL, 0,
|
| 218 |
+
&wordsReturned, &overlapStruct);
|
| 219 |
+
if(!status) {
|
| 220 |
+
// Should be the IO Pending error
|
| 221 |
+
if(GetLastError() == ERROR_IO_PENDING) {
|
| 222 |
+
// Wait for the IOCTL to complete and get the return value
|
| 223 |
+
status = GetOverlappedResult(fpga->dev, &overlapStruct,
|
| 224 |
+
&wordsReturned, TRUE);
|
| 225 |
+
if(!status)
|
| 226 |
+
printf("Error in GetOverlappedResult: %d\n", GetLastError());
|
| 227 |
+
}
|
| 228 |
+
else {
|
| 229 |
+
printf("Error in DeviceIoControl: %d\n", GetLastError());
|
| 230 |
+
}
|
| 231 |
+
}
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
int RIFFACALL fpga_list(fpga_info_list * list) {
|
| 235 |
+
// Populate the fpga_info_list struct
|
| 236 |
+
list->num_fpgas = 0;
|
| 237 |
+
return (int)fill_device_info(list);
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
/**
|
| 241 |
+
* Returns a handle to the FPGA device specified by index. On failure, returns
|
| 242 |
+
* an INVALID_HANDLE_VALUE. If the value of overlapped is TRUE, the device
|
| 243 |
+
* handle will be opened with flag FILE_FLAG_OVERLAPPED to signal that future
|
| 244 |
+
* operations will use overlapped IO. If the value of overlapped is FALSE, the
|
| 245 |
+
* device handle will be opened with flag FILE_ATTRIBUTE_NORMAL and no
|
| 246 |
+
* overlapped IO can be used with the returned device handle.
|
| 247 |
+
*/
|
| 248 |
+
HANDLE get_device(UINT32 index, BOOLEAN overlapped) {
|
| 249 |
+
PSP_DEVICE_INTERFACE_DETAIL_DATA devIntfDetail;
|
| 250 |
+
SP_DEVICE_INTERFACE_DATA devIntfData;
|
| 251 |
+
SP_DEVINFO_DATA devInfoData;
|
| 252 |
+
SECURITY_ATTRIBUTES secAttr;
|
| 253 |
+
HDEVINFO devInfo;
|
| 254 |
+
BOOLEAN status = TRUE;
|
| 255 |
+
ULONG size;
|
| 256 |
+
HANDLE dev;
|
| 257 |
+
DWORD flags;
|
| 258 |
+
|
| 259 |
+
// Retreive the device information for all RIFFA devices.
|
| 260 |
+
devInfo = SetupDiGetClassDevs(&GUID_RIFFA_INTERFACE, NULL, NULL,
|
| 261 |
+
DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
|
| 262 |
+
if (devInfo == INVALID_HANDLE_VALUE) {
|
| 263 |
+
printf("SetupDiGetClassDevs failed, Error: %d\n", GetLastError());
|
| 264 |
+
return INVALID_HANDLE_VALUE;
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
// Initialize the appropriate data structures for the SetupDi calls.
|
| 268 |
+
devIntfData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
|
| 269 |
+
devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
|
| 270 |
+
|
| 271 |
+
// Get information for specific device.
|
| 272 |
+
status = SetupDiEnumDeviceInterfaces(devInfo, NULL, (LPGUID)&GUID_RIFFA_INTERFACE,
|
| 273 |
+
index, &devIntfData);
|
| 274 |
+
if (!status) {
|
| 275 |
+
printf("SetupDiEnumDeviceInterfaces failed, Error: %d\n", GetLastError());
|
| 276 |
+
SetupDiDestroyDeviceInfoList(devInfo);
|
| 277 |
+
return INVALID_HANDLE_VALUE;
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
// Determine the size required for the devIntfData
|
| 281 |
+
SetupDiGetDeviceInterfaceDetail(devInfo, &devIntfData, NULL, 0, &size, NULL);
|
| 282 |
+
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
|
| 283 |
+
printf("SetupDiGetDeviceInterfaceDetail failed, Error: %d\n", GetLastError());
|
| 284 |
+
SetupDiDestroyDeviceInfoList(devInfo);
|
| 285 |
+
return INVALID_HANDLE_VALUE;
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
devIntfDetail = (PSP_DEVICE_INTERFACE_DETAIL_DATA)malloc(size);
|
| 289 |
+
if (!devIntfDetail) {
|
| 290 |
+
printf("Insufficient memory.\n");
|
| 291 |
+
SetupDiDestroyDeviceInfoList(devInfo);
|
| 292 |
+
return INVALID_HANDLE_VALUE;
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
// Initialize structure and retrieve data.
|
| 296 |
+
devIntfDetail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
|
| 297 |
+
status = SetupDiGetDeviceInterfaceDetail(devInfo, &devIntfData, devIntfDetail,
|
| 298 |
+
size, NULL, &devInfoData);
|
| 299 |
+
if (!status) {
|
| 300 |
+
printf("SetupDiGetDeviceInterfaceDetail failed, Error: %d\n", GetLastError());
|
| 301 |
+
free(devIntfDetail);
|
| 302 |
+
SetupDiDestroyDeviceInfoList(devInfo);
|
| 303 |
+
return INVALID_HANDLE_VALUE;
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
// Prepare the security attributes for interitance.
|
| 307 |
+
secAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
|
| 308 |
+
secAttr.bInheritHandle = TRUE;
|
| 309 |
+
secAttr.lpSecurityDescriptor = NULL;
|
| 310 |
+
|
| 311 |
+
// Get the device handle itself (finally!)
|
| 312 |
+
flags = (overlapped ? FILE_FLAG_OVERLAPPED : FILE_ATTRIBUTE_NORMAL);
|
| 313 |
+
flags = flags | FILE_FLAG_NO_BUFFERING;
|
| 314 |
+
dev = CreateFile(devIntfDetail->DevicePath, GENERIC_READ|GENERIC_WRITE,
|
| 315 |
+
FILE_SHARE_READ | FILE_SHARE_WRITE, &secAttr, OPEN_EXISTING, flags, NULL);
|
| 316 |
+
if (dev == INVALID_HANDLE_VALUE) {
|
| 317 |
+
printf("CreateFile failed. Error:%d\n", GetLastError());
|
| 318 |
+
free(devIntfDetail);
|
| 319 |
+
SetupDiDestroyDeviceInfoList(devInfo);
|
| 320 |
+
return INVALID_HANDLE_VALUE;
|
| 321 |
+
}
|
| 322 |
+
free(devIntfDetail);
|
| 323 |
+
SetupDiDestroyDeviceInfoList(devInfo);
|
| 324 |
+
|
| 325 |
+
return dev;
|
| 326 |
+
}
|
| 327 |
+
|
| 328 |
+
/**
|
| 329 |
+
* Populates the specified fpga_info_list struct with FPGA information. Returns
|
| 330 |
+
* zero on success. On failure, returns an error code (positive value).
|
| 331 |
+
*/
|
| 332 |
+
DWORD fill_device_info(fpga_info_list * info) {
|
| 333 |
+
PSP_DEVICE_INTERFACE_DETAIL_DATA devIntfDetail;
|
| 334 |
+
SP_DEVICE_INTERFACE_DATA devIntfData;
|
| 335 |
+
SP_DEVINFO_DATA devInfoData;
|
| 336 |
+
HDEVINFO devInfo;
|
| 337 |
+
BOOLEAN status = TRUE;
|
| 338 |
+
ULONG size;
|
| 339 |
+
UINT32 i;
|
| 340 |
+
ULONG wordsReturned;
|
| 341 |
+
HANDLE dev;
|
| 342 |
+
|
| 343 |
+
// Retreive the device information for all RIFFA devices.
|
| 344 |
+
devInfo = SetupDiGetClassDevs(&GUID_RIFFA_INTERFACE, NULL, NULL,
|
| 345 |
+
DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
|
| 346 |
+
if (devInfo == INVALID_HANDLE_VALUE) {
|
| 347 |
+
printf("SetupDiGetClassDevs failed, Error: %d\n", GetLastError());
|
| 348 |
+
return GetLastError();
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
// Initialize the appropriate data structures for the SetupDi calls.
|
| 352 |
+
devIntfData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
|
| 353 |
+
devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
|
| 354 |
+
|
| 355 |
+
// Loop through the device list.
|
| 356 |
+
i = 0;
|
| 357 |
+
while (SetupDiEnumDeviceInterfaces(devInfo, NULL, (LPGUID)&GUID_RIFFA_INTERFACE,
|
| 358 |
+
i, &devIntfData)) {
|
| 359 |
+
// Determine the size required for the devIntfData
|
| 360 |
+
SetupDiGetDeviceInterfaceDetail(devInfo, &devIntfData, NULL, 0, &size, NULL);
|
| 361 |
+
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
|
| 362 |
+
printf("SetupDiGetDeviceInterfaceDetail failed, Error: %d\n", GetLastError());
|
| 363 |
+
SetupDiDestroyDeviceInfoList(devInfo);
|
| 364 |
+
return GetLastError();
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
// Create the SP_DEVICE_INTERFACE_DETAIL_DATA
|
| 368 |
+
devIntfDetail = (PSP_DEVICE_INTERFACE_DETAIL_DATA)malloc(size);
|
| 369 |
+
if (!devIntfDetail) {
|
| 370 |
+
printf("Insufficient memory.\n");
|
| 371 |
+
SetupDiDestroyDeviceInfoList(devInfo);
|
| 372 |
+
return ERROR_NOT_ENOUGH_MEMORY;
|
| 373 |
+
}
|
| 374 |
+
|
| 375 |
+
// Initialize structure and retrieve data.
|
| 376 |
+
devIntfDetail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
|
| 377 |
+
status = SetupDiGetDeviceInterfaceDetail(devInfo, &devIntfData, devIntfDetail,
|
| 378 |
+
size, NULL, &devInfoData);
|
| 379 |
+
if (!status) {
|
| 380 |
+
printf("SetupDiGetDeviceInterfaceDetail failed, Error: %d\n", GetLastError());
|
| 381 |
+
free(devIntfDetail);
|
| 382 |
+
SetupDiDestroyDeviceInfoList(devInfo);
|
| 383 |
+
return GetLastError();
|
| 384 |
+
}
|
| 385 |
+
|
| 386 |
+
// Get the device handle itself (no overlap)
|
| 387 |
+
dev = CreateFile(devIntfDetail->DevicePath, GENERIC_READ|GENERIC_WRITE,
|
| 388 |
+
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
| 389 |
+
if (dev == INVALID_HANDLE_VALUE) {
|
| 390 |
+
printf("CreateFile failed. Error:%d\n", GetLastError());
|
| 391 |
+
free(devIntfDetail);
|
| 392 |
+
SetupDiDestroyDeviceInfoList(devInfo);
|
| 393 |
+
return GetLastError();
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
// Call IOCTL with IOCTL_RIFFA_LIST
|
| 397 |
+
status = DeviceIoControl(dev, IOCTL_RIFFA_LIST, (LPVOID)&i, sizeof(i),
|
| 398 |
+
(LPVOID)info, sizeof(*info), &wordsReturned, NULL);
|
| 399 |
+
if (!status) {
|
| 400 |
+
printf("Error in DeviceIoControl: %d\n", GetLastError());
|
| 401 |
+
CloseHandle(dev);
|
| 402 |
+
free(devIntfDetail);
|
| 403 |
+
SetupDiDestroyDeviceInfoList(devInfo);
|
| 404 |
+
return GetLastError();
|
| 405 |
+
}
|
| 406 |
+
info->num_fpgas = info->num_fpgas + 1;
|
| 407 |
+
|
| 408 |
+
// Done with the device
|
| 409 |
+
CloseHandle(dev);
|
| 410 |
+
free(devIntfDetail);
|
| 411 |
+
|
| 412 |
+
// Cycle through the available devices.
|
| 413 |
+
i++;
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
// Done with the DeviceInfo
|
| 417 |
+
SetupDiDestroyDeviceInfoList(devInfo);
|
| 418 |
+
|
| 419 |
+
return 0;
|
| 420 |
+
}
|
| 421 |
+
|
| 422 |
+
|
| 423 |
+
|
KastnerRG_riffa/c_c++/windows/x86/riffa.def
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
;
|
| 2 |
+
; Definition file of riffa.dll
|
| 3 |
+
; Automatic generated by gendef
|
| 4 |
+
; written by Kai Tietz 2008
|
| 5 |
+
;
|
| 6 |
+
LIBRARY "riffa.dll"
|
| 7 |
+
EXPORTS
|
| 8 |
+
fpga_close
|
| 9 |
+
fpga_list
|
| 10 |
+
fpga_open
|
| 11 |
+
fpga_recv
|
| 12 |
+
fpga_reset
|
| 13 |
+
fpga_send
|
KastnerRG_riffa/c_c++/windows/x86/riffa.exp
ADDED
|
Binary file (1.33 kB). View file
|
|
|
KastnerRG_riffa/c_c++/windows/x86/riffa.h
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// ----------------------------------------------------------------------
|
| 2 |
+
// Copyright (c) 2016, The Regents of the University of California All
|
| 3 |
+
// rights reserved.
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
//
|
| 12 |
+
// * Redistributions in binary form must reproduce the above
|
| 13 |
+
// copyright notice, this list of conditions and the following
|
| 14 |
+
// disclaimer in the documentation and/or other materials provided
|
| 15 |
+
// with the distribution.
|
| 16 |
+
//
|
| 17 |
+
// * Neither the name of The Regents of the University of California
|
| 18 |
+
// nor the names of its contributors may be used to endorse or
|
| 19 |
+
// promote products derived from this software without specific
|
| 20 |
+
// prior written permission.
|
| 21 |
+
//
|
| 22 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 23 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 24 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 25 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE
|
| 26 |
+
// UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 27 |
+
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 28 |
+
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
| 29 |
+
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 30 |
+
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 31 |
+
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
| 32 |
+
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 33 |
+
// DAMAGE.
|
| 34 |
+
// ----------------------------------------------------------------------
|
| 35 |
+
/*
|
| 36 |
+
* Filename: riffa.h
|
| 37 |
+
* Version: 2.0
|
| 38 |
+
* Description: Windows PCIe communications API for RIFFA.
|
| 39 |
+
* Author: Matthew Jacobsen
|
| 40 |
+
* History: @mattj: Initial release. Version 2.0.
|
| 41 |
+
*/
|
| 42 |
+
|
| 43 |
+
#ifndef RIFFA_H
|
| 44 |
+
#define RIFFA_H
|
| 45 |
+
|
| 46 |
+
// Must RIFFA_EXPORTS *only* when building the DLL.
|
| 47 |
+
#ifdef RIFFA_EXPORTS
|
| 48 |
+
#define RIFFAAPI __declspec(dllexport)
|
| 49 |
+
#else
|
| 50 |
+
#define RIFFAAPI __declspec(dllimport)
|
| 51 |
+
#endif
|
| 52 |
+
|
| 53 |
+
// Define calling convention in one place, for convenience.
|
| 54 |
+
#define RIFFACALL __cdecl
|
| 55 |
+
|
| 56 |
+
#ifdef __cplusplus
|
| 57 |
+
extern "C" {
|
| 58 |
+
#endif
|
| 59 |
+
|
| 60 |
+
// Maximum number of RIFFA FPGAs
|
| 61 |
+
#define RIFFA_MAX_NUM_FPGAS (5)
|
| 62 |
+
|
| 63 |
+
// Holds FPGA information for installed RIFFA FPGAs
|
| 64 |
+
struct fpga_info_list
|
| 65 |
+
{
|
| 66 |
+
int num_fpgas;
|
| 67 |
+
int id[RIFFA_MAX_NUM_FPGAS];
|
| 68 |
+
int num_chnls[RIFFA_MAX_NUM_FPGAS];
|
| 69 |
+
char name[RIFFA_MAX_NUM_FPGAS][16];
|
| 70 |
+
int vendor_id[RIFFA_MAX_NUM_FPGAS];
|
| 71 |
+
int device_id[RIFFA_MAX_NUM_FPGAS];
|
| 72 |
+
};
|
| 73 |
+
typedef struct fpga_info_list fpga_info_list;
|
| 74 |
+
|
| 75 |
+
// Represents the FPGA device
|
| 76 |
+
struct fpga_t;
|
| 77 |
+
typedef struct fpga_t fpga_t;
|
| 78 |
+
|
| 79 |
+
/**
|
| 80 |
+
* Populates the fpga_info_list pointer with all FPGAs registered in the system.
|
| 81 |
+
* Returns 0 on success, non-zero on error.
|
| 82 |
+
*/
|
| 83 |
+
RIFFAAPI int RIFFACALL fpga_list(fpga_info_list * list);
|
| 84 |
+
|
| 85 |
+
/**
|
| 86 |
+
* Initializes the FPGA specified by id. On success, returns a pointer to a
|
| 87 |
+
* fpga_t struct. On error, returns NULL. Each FPGA must be opened before any
|
| 88 |
+
* channels can be accessed. Once opened, any number of threads can use the
|
| 89 |
+
* fpga_t struct.
|
| 90 |
+
*/
|
| 91 |
+
RIFFAAPI fpga_t * RIFFACALL fpga_open(int id);
|
| 92 |
+
|
| 93 |
+
/**
|
| 94 |
+
* Cleans up memory/resources for the FPGA specified by the fd descriptor.
|
| 95 |
+
*/
|
| 96 |
+
RIFFAAPI void RIFFACALL fpga_close(fpga_t * fpga);
|
| 97 |
+
|
| 98 |
+
/**
|
| 99 |
+
* Sends len words (4 byte words) from data to FPGA channel chnl using the
|
| 100 |
+
* fpga_t struct. The FPGA channel will be sent len, destoff, and last. If last
|
| 101 |
+
* is 1, the channel should interpret the end of this send as the end of a
|
| 102 |
+
* transaction. If last is 0, the channel should wait for additional sends
|
| 103 |
+
* before the end of the transaction. If timeout is non-zero, this call will
|
| 104 |
+
* send data and wait up to timeout ms for the FPGA to respond (between
|
| 105 |
+
* packets) before timing out. If timeout is zero, this call may block
|
| 106 |
+
* indefinitely. Multiple threads sending on the same channel may result in
|
| 107 |
+
* corrupt data or error. This function is thread safe across channels.
|
| 108 |
+
* Returns the number of words sent.
|
| 109 |
+
*/
|
| 110 |
+
RIFFAAPI int RIFFACALL fpga_send(fpga_t * fpga, int chnl, void * data, int len,
|
| 111 |
+
int destoff, int last, long long timeout);
|
| 112 |
+
|
| 113 |
+
/**
|
| 114 |
+
* Receives data from the FPGA channel chnl to the data pointer, using the
|
| 115 |
+
* fpga_t struct. The FPGA channel can send any amount of data, so the data
|
| 116 |
+
* array should be large enough to accommodate. The len parameter specifies the
|
| 117 |
+
* actual size of the data buffer in words (4 byte words). The FPGA channel will
|
| 118 |
+
* specify an offset which will determine where in the data array the data will
|
| 119 |
+
* start being written. If the amount of data (plus offset) exceed the size of
|
| 120 |
+
* the data array (len), then that data will be discarded. If timeout is
|
| 121 |
+
* non-zero, this call will wait up to timeout ms for the FPGA to respond
|
| 122 |
+
* (between packets) before timing out. If timeout is zero, this call may block
|
| 123 |
+
* indefinitely. Multiple threads receiving on the same channel may result in
|
| 124 |
+
* corrupt data or error. This function is thread safe across channels.
|
| 125 |
+
* Returns the number of words received to the data array.
|
| 126 |
+
*/
|
| 127 |
+
RIFFAAPI int RIFFACALL fpga_recv(fpga_t * fpga, int chnl, void * data, int len,
|
| 128 |
+
long long timeout);
|
| 129 |
+
|
| 130 |
+
/**
|
| 131 |
+
* Resets the state of the FPGA and all transfers across all channels. This is
|
| 132 |
+
* meant to be used as an alternative to rebooting if an error occurs while
|
| 133 |
+
* sending/receiving. Calling this function while other threads are sending or
|
| 134 |
+
* receiving will result in unexpected behavior.
|
| 135 |
+
*/
|
| 136 |
+
RIFFAAPI void RIFFACALL fpga_reset(fpga_t * fpga);
|
| 137 |
+
|
| 138 |
+
#ifdef __cplusplus
|
| 139 |
+
}
|
| 140 |
+
#endif
|
| 141 |
+
|
| 142 |
+
#endif
|
KastnerRG_riffa/c_c++/windows/x86/riffa.lib
ADDED
|
Binary file (2.56 kB). View file
|
|
|
KastnerRG_riffa/c_c++/windows/x86/riffa.rc
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* ----------------------------------------------------------------------
|
| 2 |
+
* Copyright (c) 2016, The Regents of the University of California All
|
| 3 |
+
* rights reserved.
|
| 4 |
+
*
|
| 5 |
+
* Redistribution and use in source and binary forms, with or without
|
| 6 |
+
* modification, are permitted provided that the following conditions are
|
| 7 |
+
* met:
|
| 8 |
+
*
|
| 9 |
+
* * Redistributions of source code must retain the above copyright
|
| 10 |
+
* notice, this list of conditions and the following disclaimer.
|
| 11 |
+
*
|
| 12 |
+
* * Redistributions in binary form must reproduce the above
|
| 13 |
+
* copyright notice, this list of conditions and the following
|
| 14 |
+
* disclaimer in the documentation and/or other materials provided
|
| 15 |
+
* with the distribution.
|
| 16 |
+
*
|
| 17 |
+
* * Neither the name of The Regents of the University of California
|
| 18 |
+
* nor the names of its contributors may be used to endorse or
|
| 19 |
+
* promote products derived from this software without specific
|
| 20 |
+
* prior written permission.
|
| 21 |
+
*
|
| 22 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 23 |
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 24 |
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 25 |
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE
|
| 26 |
+
* UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 27 |
+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 28 |
+
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
| 29 |
+
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 30 |
+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 31 |
+
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
| 32 |
+
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 33 |
+
* DAMAGE.
|
| 34 |
+
* ----------------------------------------------------------------------
|
| 35 |
+
*/
|
| 36 |
+
/*
|
| 37 |
+
* Filename: riffa.rc
|
| 38 |
+
* Version: 2.0
|
| 39 |
+
* Description: Windows PCIe communications API for RIFFA.
|
| 40 |
+
* Author: Matthew Jacobsen
|
| 41 |
+
* History: @mattj: Initial release. Version 2.0.
|
| 42 |
+
*/
|
| 43 |
+
|
| 44 |
+
1 VERSIONINFO
|
| 45 |
+
FILEVERSION 1,0,0,0
|
| 46 |
+
PRODUCTVERSION 2,0,0,0
|
| 47 |
+
FILEFLAGSMASK 0x17L
|
| 48 |
+
#ifdef _DEBUG
|
| 49 |
+
FILEFLAGS 0x1L
|
| 50 |
+
#else
|
| 51 |
+
FILEFLAGS 0x0L
|
| 52 |
+
#endif
|
| 53 |
+
FILEOS 0x4L
|
| 54 |
+
FILETYPE 0x1L
|
| 55 |
+
FILESUBTYPE 0x0L
|
| 56 |
+
BEGIN
|
| 57 |
+
BLOCK "StringFileInfo"
|
| 58 |
+
BEGIN
|
| 59 |
+
BLOCK "040904b0"
|
| 60 |
+
BEGIN
|
| 61 |
+
VALUE "Comments", "RIFFA 64 bit Windows Library"
|
| 62 |
+
VALUE "CompanyName", "University of California, San Diego"
|
| 63 |
+
VALUE "FileDescription", "User 32 bit library for RIFFA."
|
| 64 |
+
VALUE "FileVersion", "1, 0, 0, 0"
|
| 65 |
+
VALUE "InternalName", "RIFFA"
|
| 66 |
+
VALUE "LegalCopyright", "Copyright � 2011 The Regents of the University of California. All Rights Reserved."
|
| 67 |
+
VALUE "OriginalFilename", "riffa.dll"
|
| 68 |
+
VALUE "ProductName", "RIFFA Library"
|
| 69 |
+
VALUE "ProductVersion", "2, 0, 0, 0"
|
| 70 |
+
END
|
| 71 |
+
END
|
| 72 |
+
BLOCK "VarFileInfo"
|
| 73 |
+
BEGIN
|
| 74 |
+
VALUE "Translation", 0x409, 1200
|
| 75 |
+
END
|
| 76 |
+
END
|
KastnerRG_riffa/c_c++/windows/x86/riffa_driver.h
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//
|
| 2 |
+
// The following value is arbitrarily chosen from the space defined
|
| 3 |
+
// by Microsoft as being "for non-Microsoft use"
|
| 4 |
+
//
|
| 5 |
+
//
|
| 6 |
+
// {40d49fb9-6085-4e1d-8753-822be944d7bb}
|
| 7 |
+
DEFINE_GUID (GUID_RIFFA_INTERFACE,
|
| 8 |
+
0x40d49fb9, 0x6085, 0x4e1d, 0x87, 0x53, 0x82, 0x2b, 0xe9, 0x44, 0xd7, 0xbb);
|
| 9 |
+
|
| 10 |
+
// The IOCTL function codes from 0x800 to 0xFFF are for customer use.
|
| 11 |
+
#define CTL_CODE( DeviceType, Function, Method, Access ) ( \
|
| 12 |
+
((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
#define IOCTL_RIFFA_SEND \
|
| 16 |
+
CTL_CODE(0x00000022, 0x900, 2, 0)
|
| 17 |
+
#define IOCTL_RIFFA_RECV \
|
| 18 |
+
CTL_CODE(0x00000022, 0x901, 2, 0)
|
| 19 |
+
#define IOCTL_RIFFA_LIST \
|
| 20 |
+
CTL_CODE(0x00000022, 0x902, 2 ,0)
|
| 21 |
+
#define IOCTL_RIFFA_RESET \
|
| 22 |
+
CTL_CODE(0x00000022, 0x903, 2, 0)
|
| 23 |
+
|
KastnerRG_riffa/c_c++/windows/x86/sample_app/README.txt
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The testutil example application works with the Verilog chnl_tester module
|
| 2 |
+
which receives data and then sends data back to the workstation.
|
| 3 |
+
|
| 4 |
+
To compile the example application:
|
| 5 |
+
|
| 6 |
+
gcc.exe -o testutil.exe testutil.c -L. -lriffa
|
| 7 |
+
|
| 8 |
+
The riffa.lib import library must be in the directory specified by the -L
|
| 9 |
+
parameter (in this example, the current directory). The riffa.h header must be
|
| 10 |
+
in the same directory as testutil.c.
|
KastnerRG_riffa/c_c++/windows/x86/sample_app/riffa.h
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// ----------------------------------------------------------------------
|
| 2 |
+
// Copyright (c) 2016, The Regents of the University of California All
|
| 3 |
+
// rights reserved.
|
| 4 |
+
//
|
| 5 |
+
// Redistribution and use in source and binary forms, with or without
|
| 6 |
+
// modification, are permitted provided that the following conditions are
|
| 7 |
+
// met:
|
| 8 |
+
//
|
| 9 |
+
// * Redistributions of source code must retain the above copyright
|
| 10 |
+
// notice, this list of conditions and the following disclaimer.
|
| 11 |
+
//
|
| 12 |
+
// * Redistributions in binary form must reproduce the above
|
| 13 |
+
// copyright notice, this list of conditions and the following
|
| 14 |
+
// disclaimer in the documentation and/or other materials provided
|
| 15 |
+
// with the distribution.
|
| 16 |
+
//
|
| 17 |
+
// * Neither the name of The Regents of the University of California
|
| 18 |
+
// nor the names of its contributors may be used to endorse or
|
| 19 |
+
// promote products derived from this software without specific
|
| 20 |
+
// prior written permission.
|
| 21 |
+
//
|
| 22 |
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 23 |
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 24 |
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 25 |
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE
|
| 26 |
+
// UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 27 |
+
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 28 |
+
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
| 29 |
+
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 30 |
+
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 31 |
+
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
| 32 |
+
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 33 |
+
// DAMAGE.
|
| 34 |
+
// ----------------------------------------------------------------------
|
| 35 |
+
/*
|
| 36 |
+
* Filename: riffa.h
|
| 37 |
+
* Version: 2.0
|
| 38 |
+
* Description: Windows PCIe communications API for RIFFA.
|
| 39 |
+
* Author: Matthew Jacobsen
|
| 40 |
+
* History: @mattj: Initial release. Version 2.0.
|
| 41 |
+
*/
|
| 42 |
+
|
| 43 |
+
#ifndef RIFFA_H
|
| 44 |
+
#define RIFFA_H
|
| 45 |
+
|
| 46 |
+
// Must RIFFA_EXPORTS *only* when building the DLL.
|
| 47 |
+
#ifdef RIFFA_EXPORTS
|
| 48 |
+
#define RIFFAAPI __declspec(dllexport)
|
| 49 |
+
#else
|
| 50 |
+
#define RIFFAAPI __declspec(dllimport)
|
| 51 |
+
#endif
|
| 52 |
+
|
| 53 |
+
// Define calling convention in one place, for convenience.
|
| 54 |
+
#define RIFFACALL __cdecl
|
| 55 |
+
|
| 56 |
+
#ifdef __cplusplus
|
| 57 |
+
extern "C" {
|
| 58 |
+
#endif
|
| 59 |
+
|
| 60 |
+
// Maximum number of RIFFA FPGAs
|
| 61 |
+
#define RIFFA_MAX_NUM_FPGAS (5)
|
| 62 |
+
|
| 63 |
+
// Holds FPGA information for installed RIFFA FPGAs
|
| 64 |
+
struct fpga_info_list
|
| 65 |
+
{
|
| 66 |
+
int num_fpgas;
|
| 67 |
+
int id[RIFFA_MAX_NUM_FPGAS];
|
| 68 |
+
int num_chnls[RIFFA_MAX_NUM_FPGAS];
|
| 69 |
+
char name[RIFFA_MAX_NUM_FPGAS][16];
|
| 70 |
+
int vendor_id[RIFFA_MAX_NUM_FPGAS];
|
| 71 |
+
int device_id[RIFFA_MAX_NUM_FPGAS];
|
| 72 |
+
};
|
| 73 |
+
typedef struct fpga_info_list fpga_info_list;
|
| 74 |
+
|
| 75 |
+
// Represents the FPGA device
|
| 76 |
+
struct fpga_t;
|
| 77 |
+
typedef struct fpga_t fpga_t;
|
| 78 |
+
|
| 79 |
+
/**
|
| 80 |
+
* Populates the fpga_info_list pointer with all FPGAs registered in the system.
|
| 81 |
+
* Returns 0 on success, non-zero on error.
|
| 82 |
+
*/
|
| 83 |
+
RIFFAAPI int RIFFACALL fpga_list(fpga_info_list * list);
|
| 84 |
+
|
| 85 |
+
/**
|
| 86 |
+
* Initializes the FPGA specified by id. On success, returns a pointer to a
|
| 87 |
+
* fpga_t struct. On error, returns NULL. Each FPGA must be opened before any
|
| 88 |
+
* channels can be accessed. Once opened, any number of threads can use the
|
| 89 |
+
* fpga_t struct.
|
| 90 |
+
*/
|
| 91 |
+
RIFFAAPI fpga_t * RIFFACALL fpga_open(int id);
|
| 92 |
+
|
| 93 |
+
/**
|
| 94 |
+
* Cleans up memory/resources for the FPGA specified by the fd descriptor.
|
| 95 |
+
*/
|
| 96 |
+
RIFFAAPI void RIFFACALL fpga_close(fpga_t * fpga);
|
| 97 |
+
|
| 98 |
+
/**
|
| 99 |
+
* Sends len words (4 byte words) from data to FPGA channel chnl using the
|
| 100 |
+
* fpga_t struct. The FPGA channel will be sent len, destoff, and last. If last
|
| 101 |
+
* is 1, the channel should interpret the end of this send as the end of a
|
| 102 |
+
* transaction. If last is 0, the channel should wait for additional sends
|
| 103 |
+
* before the end of the transaction. If timeout is non-zero, this call will
|
| 104 |
+
* send data and wait up to timeout ms for the FPGA to respond (between
|
| 105 |
+
* packets) before timing out. If timeout is zero, this call may block
|
| 106 |
+
* indefinitely. Multiple threads sending on the same channel may result in
|
| 107 |
+
* corrupt data or error. This function is thread safe across channels.
|
| 108 |
+
* Returns the number of words sent.
|
| 109 |
+
*/
|
| 110 |
+
RIFFAAPI int RIFFACALL fpga_send(fpga_t * fpga, int chnl, void * data, int len,
|
| 111 |
+
int destoff, int last, long long timeout);
|
| 112 |
+
|
| 113 |
+
/**
|
| 114 |
+
* Receives data from the FPGA channel chnl to the data pointer, using the
|
| 115 |
+
* fpga_t struct. The FPGA channel can send any amount of data, so the data
|
| 116 |
+
* array should be large enough to accommodate. The len parameter specifies the
|
| 117 |
+
* actual size of the data buffer in words (4 byte words). The FPGA channel will
|
| 118 |
+
* specify an offset which will determine where in the data array the data will
|
| 119 |
+
* start being written. If the amount of data (plus offset) exceed the size of
|
| 120 |
+
* the data array (len), then that data will be discarded. If timeout is
|
| 121 |
+
* non-zero, this call will wait up to timeout ms for the FPGA to respond
|
| 122 |
+
* (between packets) before timing out. If timeout is zero, this call may block
|
| 123 |
+
* indefinitely. Multiple threads receiving on the same channel may result in
|
| 124 |
+
* corrupt data or error. This function is thread safe across channels.
|
| 125 |
+
* Returns the number of words received to the data array.
|
| 126 |
+
*/
|
| 127 |
+
RIFFAAPI int RIFFACALL fpga_recv(fpga_t * fpga, int chnl, void * data, int len,
|
| 128 |
+
long long timeout);
|
| 129 |
+
|
| 130 |
+
/**
|
| 131 |
+
* Resets the state of the FPGA and all transfers across all channels. This is
|
| 132 |
+
* meant to be used as an alternative to rebooting if an error occurs while
|
| 133 |
+
* sending/receiving. Calling this function while other threads are sending or
|
| 134 |
+
* receiving will result in unexpected behavior.
|
| 135 |
+
*/
|
| 136 |
+
RIFFAAPI void RIFFACALL fpga_reset(fpga_t * fpga);
|
| 137 |
+
|
| 138 |
+
#ifdef __cplusplus
|
| 139 |
+
}
|
| 140 |
+
#endif
|
| 141 |
+
|
| 142 |
+
#endif
|
KastnerRG_riffa/c_c++/windows/x86/sample_app/riffa.lib
ADDED
|
Binary file (2.56 kB). View file
|
|
|
KastnerRG_riffa/c_c++/windows/x86/sample_app/testutil.c
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <stdlib.h>
|
| 2 |
+
#include <stdio.h>
|
| 3 |
+
#include <windows.h>
|
| 4 |
+
#include "timer.h"
|
| 5 |
+
#include "riffa.h"
|
| 6 |
+
|
| 7 |
+
int main(int argc, char** argv) {
|
| 8 |
+
fpga_t * fpga;
|
| 9 |
+
fpga_info_list info;
|
| 10 |
+
int option;
|
| 11 |
+
int i;
|
| 12 |
+
int id;
|
| 13 |
+
int chnl;
|
| 14 |
+
size_t numWords;
|
| 15 |
+
int sent;
|
| 16 |
+
int recvd;
|
| 17 |
+
unsigned int * sendBuffer;
|
| 18 |
+
unsigned int * recvBuffer;
|
| 19 |
+
GET_TIME_INIT(3);
|
| 20 |
+
|
| 21 |
+
if (argc < 2) {
|
| 22 |
+
printf("Usage: %s <option>\n", argv[0]);
|
| 23 |
+
return -1;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
option = atoi(argv[1]);
|
| 27 |
+
|
| 28 |
+
if (option == 0) { // List FPGA info
|
| 29 |
+
// Populate the fpga_info_list struct
|
| 30 |
+
if (fpga_list(&info) != 0) {
|
| 31 |
+
printf("Error populating fpga_info_list\n");
|
| 32 |
+
return -1;
|
| 33 |
+
}
|
| 34 |
+
printf("Number of devices: %d\n", info.num_fpgas);
|
| 35 |
+
for (i = 0; i < info.num_fpgas; i++) {
|
| 36 |
+
printf("%d: id:%d\n", i, info.id[i]);
|
| 37 |
+
printf("%d: num_chnls:%d\n", i, info.num_chnls[i]);
|
| 38 |
+
printf("%d: name:%s\n", i, info.name[i]);
|
| 39 |
+
printf("%d: vendor id:%04X\n", i, info.vendor_id[i]);
|
| 40 |
+
printf("%d: device id:%04X\n", i, info.device_id[i]);
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
else if (option == 1) { // Reset FPGA
|
| 44 |
+
if (argc < 3) {
|
| 45 |
+
printf("Usage: %s %d <fpga id>\n", argv[0], option);
|
| 46 |
+
return -1;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
id = atoi(argv[2]);
|
| 50 |
+
|
| 51 |
+
// Get the device with id
|
| 52 |
+
fpga = fpga_open(id);
|
| 53 |
+
if (fpga == NULL) {
|
| 54 |
+
printf("Could not get FPGA %d\n", id);
|
| 55 |
+
return -1;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
// Reset
|
| 59 |
+
fpga_reset(fpga);
|
| 60 |
+
|
| 61 |
+
// Done with device
|
| 62 |
+
fpga_close(fpga);
|
| 63 |
+
}
|
| 64 |
+
else if (option == 2) { // Send data, receive data
|
| 65 |
+
if (argc < 5) {
|
| 66 |
+
printf("Usage: %s %d <fpga id> <chnl> <num words to transfer>\n", argv[0], option);
|
| 67 |
+
return -1;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
id = atoi(argv[2]);
|
| 71 |
+
chnl = atoi(argv[3]);
|
| 72 |
+
numWords = atoi(argv[4]);
|
| 73 |
+
|
| 74 |
+
// Get the device with id
|
| 75 |
+
fpga = fpga_open(id);
|
| 76 |
+
if (fpga == NULL) {
|
| 77 |
+
printf("Could not get FPGA %d\n", id);
|
| 78 |
+
return -1;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
// Malloc the arrays
|
| 82 |
+
sendBuffer = (unsigned int *)malloc(numWords<<2);
|
| 83 |
+
if (sendBuffer == NULL) {
|
| 84 |
+
printf("Could not malloc memory for sendBuffer\n");
|
| 85 |
+
fpga_close(fpga);
|
| 86 |
+
return -1;
|
| 87 |
+
}
|
| 88 |
+
recvBuffer = (unsigned int *)malloc(numWords<<2);
|
| 89 |
+
if (recvBuffer == NULL) {
|
| 90 |
+
printf("Could not malloc memory for recvBuffer\n");
|
| 91 |
+
free(sendBuffer);
|
| 92 |
+
fpga_close(fpga);
|
| 93 |
+
return -1;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
// Initialize the data
|
| 97 |
+
for (i = 0; i < numWords; i++) {
|
| 98 |
+
sendBuffer[i] = i+1;
|
| 99 |
+
recvBuffer[i] = 0;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
GET_TIME_VAL(0);
|
| 103 |
+
|
| 104 |
+
// Send the data
|
| 105 |
+
sent = fpga_send(fpga, chnl, sendBuffer, numWords, 0, 1, 25000);
|
| 106 |
+
printf("words sent: %d\n", sent);
|
| 107 |
+
|
| 108 |
+
GET_TIME_VAL(1);
|
| 109 |
+
|
| 110 |
+
if (sent != 0) {
|
| 111 |
+
// Recv the data
|
| 112 |
+
recvd = fpga_recv(fpga, chnl, recvBuffer, numWords, 25000);
|
| 113 |
+
printf("words recv: %d\n", recvd);
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
GET_TIME_VAL(2);
|
| 117 |
+
|
| 118 |
+
// Done with device
|
| 119 |
+
fpga_close(fpga);
|
| 120 |
+
|
| 121 |
+
// Display some data
|
| 122 |
+
for (i = 0; i < 20; i++) {
|
| 123 |
+
printf("recvBuffer[%d]: %d\n", i, recvBuffer[i]);
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
// Check the data
|
| 127 |
+
if (recvd != 0) {
|
| 128 |
+
for (i = 4; i < recvd; i++) {
|
| 129 |
+
if (recvBuffer[i] != sendBuffer[i]) {
|
| 130 |
+
printf("recvBuffer[%d]: %d, expected %d\n", i, recvBuffer[i], sendBuffer[i]);
|
| 131 |
+
break;
|
| 132 |
+
}
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
printf("send bw: %f MB/s %fms\n",
|
| 136 |
+
sent*4.0/1024/1024/((TIME_VAL_TO_MS(1) - TIME_VAL_TO_MS(0))/1000.0),
|
| 137 |
+
(TIME_VAL_TO_MS(1) - TIME_VAL_TO_MS(0)) );
|
| 138 |
+
|
| 139 |
+
printf("recv bw: %f MB/s %fms\n",
|
| 140 |
+
recvd*4.0/1024/1024/((TIME_VAL_TO_MS(2) - TIME_VAL_TO_MS(1))/1000.0),
|
| 141 |
+
(TIME_VAL_TO_MS(2) - TIME_VAL_TO_MS(1)) );
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
return 0;
|
| 146 |
+
}
|
KastnerRG_riffa/c_c++/windows/x86/sample_app/timer.h
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <windows.h>
|
| 2 |
+
|
| 3 |
+
#define GET_TIME_INIT(num) LARGE_INTEGER _timers[num]; LARGE_INTEGER _freq; QueryPerformanceFrequency(&_freq)
|
| 4 |
+
|
| 5 |
+
#define GET_TIME_VAL(num) QueryPerformanceCounter(&_timers[num])
|
| 6 |
+
|
| 7 |
+
#define TIME_VAL_TO_MS(num) ((double)_timers[num].QuadPart*1000.0/_freq.QuadPart)
|
KastnerRG_riffa/docs/Makefile
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ----------------------------------------------------------------------
|
| 2 |
+
# Copyright (c) 2016, The Regents of the University of California All
|
| 3 |
+
# rights reserved.
|
| 4 |
+
#
|
| 5 |
+
# Redistribution and use in source and binary forms, with or without
|
| 6 |
+
# modification, are permitted provided that the following conditions are
|
| 7 |
+
# met:
|
| 8 |
+
#
|
| 9 |
+
# * Redistributions of source code must retain the above copyright
|
| 10 |
+
# notice, this list of conditions and the following disclaimer.
|
| 11 |
+
#
|
| 12 |
+
# * Redistributions in binary form must reproduce the above
|
| 13 |
+
# copyright notice, this list of conditions and the following
|
| 14 |
+
# disclaimer in the documentation and/or other materials provided
|
| 15 |
+
# with the distribution.
|
| 16 |
+
#
|
| 17 |
+
# * Neither the name of The Regents of the University of California
|
| 18 |
+
# nor the names of its contributors may be used to endorse or
|
| 19 |
+
# promote products derived from this software without specific
|
| 20 |
+
# prior written permission.
|
| 21 |
+
#
|
| 22 |
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 23 |
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 24 |
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 25 |
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE
|
| 26 |
+
# UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT,
|
| 27 |
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
| 28 |
+
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
| 29 |
+
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
| 30 |
+
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 31 |
+
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
| 32 |
+
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
| 33 |
+
# DAMAGE.
|
| 34 |
+
# ----------------------------------------------------------------------
|
| 35 |
+
#-----------------------------------------------------------------------
|
| 36 |
+
# Filename: Makefile
|
| 37 |
+
# Version: 1.0
|
| 38 |
+
# Description: Makefile for including the C/C++ subdirectory in
|
| 39 |
+
# a RIFFA release. Expects RELEASE_SRC_PATH to be set
|
| 40 |
+
# by parent Makefile.
|
| 41 |
+
# Author: Dustin Richmond (@darichmond)
|
| 42 |
+
#-----------------------------------------------------------------------
|
| 43 |
+
|
| 44 |
+
CURRENT_PATH := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
|
| 45 |
+
CURRENT_DIR := $(shell basename $(CURRENT_PATH))
|
| 46 |
+
|
| 47 |
+
include $(RIFFA_ROOT_PATH)/release.mk
|
| 48 |
+
|
| 49 |
+
all:docs
|
| 50 |
+
|
| 51 |
+
docs: riffa_documentation.pdf
|
| 52 |
+
|
| 53 |
+
riffa_documentation.pdf:riffa_documentation.tex images/* images/*/*
|
| 54 |
+
pdflatex \\nonstopmode\\input riffa_documentation.tex
|
| 55 |
+
pdflatex \\nonstopmode\\input riffa_documentation.tex
|
| 56 |
+
pdflatex \\nonstopmode\\input riffa_documentation.tex
|
| 57 |
+
|
| 58 |
+
release: check-release-doc docs clean-release
|
| 59 |
+
cp riffa_documentation.pdf $(RELEASE_DOC_PATH)/RIFFA_$(RELEASE_VER)_Instructions.pdf
|
| 60 |
+
|
| 61 |
+
clean-release: check-release-src
|
| 62 |
+
rm -rf $(RELEASE_SRC_PATH)/documentation
|
| 63 |
+
|
| 64 |
+
clean:
|
| 65 |
+
rm -rf *~ *.aux *.toc riffa_documentation.pdf *.log
|
KastnerRG_riffa/docs/RIFFA.graphml
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
KastnerRG_riffa/docs/riffa_documentation.tex
ADDED
|
@@ -0,0 +1,1892 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
\documentclass{refrep}
|
| 2 |
+
\settextfraction{.9}
|
| 3 |
+
\usepackage{extramarks}
|
| 4 |
+
\usepackage{amsmath}
|
| 5 |
+
\usepackage{amsthm}
|
| 6 |
+
\usepackage{amsfonts}
|
| 7 |
+
\usepackage{tikz}
|
| 8 |
+
\usepackage[plain]{algorithm}
|
| 9 |
+
\usepackage{algpseudocode}
|
| 10 |
+
\usepackage{listings}
|
| 11 |
+
\usepackage{datetime}
|
| 12 |
+
\usepackage{xcolor}
|
| 13 |
+
\usepackage{float}
|
| 14 |
+
\usepackage{graphicx}
|
| 15 |
+
\usepackage[export]{adjustbox}
|
| 16 |
+
\usepackage{caption}
|
| 17 |
+
\usepackage{contour}
|
| 18 |
+
\makeatletter
|
| 19 |
+
\newcount\dirtree@lvl
|
| 20 |
+
\newcount\dirtree@plvl
|
| 21 |
+
\newcount\dirtree@clvl
|
| 22 |
+
\def\dirtree@growth{
|
| 23 |
+
\ifnum\tikznumberofcurrentchild=1\relax
|
| 24 |
+
\global\advance\dirtree@plvl by 1
|
| 25 |
+
\expandafter\xdef\csname dirtree@p@\the\dirtree@plvl\endcsname{\the\dirtree@lvl}
|
| 26 |
+
\fi
|
| 27 |
+
\global\advance\dirtree@lvl by 1\relax
|
| 28 |
+
\dirtree@clvl=\dirtree@lvl
|
| 29 |
+
\advance\dirtree@clvl by -\csname dirtree@p@\the\dirtree@plvl\endcsname
|
| 30 |
+
\pgf@xa=.25cm\relax
|
| 31 |
+
\pgf@ya=-.5cm\relax
|
| 32 |
+
\pgf@ya=\dirtree@clvl\pgf@ya
|
| 33 |
+
\pgftransformshift{\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}%
|
| 34 |
+
\ifnum\tikznumberofcurrentchild=\tikznumberofchildren
|
| 35 |
+
\global\advance\dirtree@plvl by -1
|
| 36 |
+
\fi
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
\tikzset{
|
| 40 |
+
dirtree/.style={
|
| 41 |
+
growth function=\dirtree@growth,
|
| 42 |
+
every node/.style={anchor=north},
|
| 43 |
+
every child node/.style={anchor=west},
|
| 44 |
+
edge from parent path={(\tikzparentnode\tikzparentanchor) |- (\tikzchildnode\tikzchildanchor)}
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
\makeatother
|
| 49 |
+
\graphicspath{ {images/vc707/} {images/vc709/} {images/qsys/} {images/ipc/} {images/perf/} {images/}}
|
| 50 |
+
\newcommand{\figurewidth}{350px}
|
| 51 |
+
\newcommand{\VivadoVer}{2014.4}
|
| 52 |
+
\newcommand{\QuartusVer}{14.1}
|
| 53 |
+
\newcommand{\RIFFAVer}{2.2.2}
|
| 54 |
+
\newcommand{\Directory}[1]{\textit{#1}}
|
| 55 |
+
\newcommand{\EnvVariable}[1]{\textbf{#1}}
|
| 56 |
+
\newcommand{\TermCmd}[1]{\$ \texttt{#1}}
|
| 57 |
+
\newcommand{\TODO}[1]{\textbf{\color{red}{#1}}}
|
| 58 |
+
\newcommand{\Xilinx}[1]{{\color{red}{#1}}}
|
| 59 |
+
\newcommand{\Altera}[1]{{\color{blue}{#1}}}
|
| 60 |
+
\newcommand{\ConfigSetting}[1]{\textbf{#1}}
|
| 61 |
+
\newcommand{\VCSevenOhNineExampleDesignsLong}{VC709\_Gen1x8If64 (PCIe Gen1, 8 lanes, 64-bit CHNL interface), VC709\_Gen2x8If128 (PCIe Gen2, 8 lanes, 128-bit CHNL interface), VC709\_Gen3x4If128 (PCIe Gen3, 8 lanes, 128-bit CHNL interface)}
|
| 62 |
+
\newcommand{\VCSevenOhNineExampleDesignsShort}{VC709\_Gen1x8If64, VC709\_Gen2x8If128, VC709\_Gen3x4If128}
|
| 63 |
+
\newcommand{\RIFFAParameter}[1]{\textit{\textbf{#1}}}
|
| 64 |
+
|
| 65 |
+
\title{RIFFA \RIFFAVer~ Documentation}
|
| 66 |
+
\author{Dustin Richmond, Matt Jacobsen}
|
| 67 |
+
\date{\today}
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
\begin{document}
|
| 71 |
+
|
| 72 |
+
\maketitle
|
| 73 |
+
\pagebreak
|
| 74 |
+
\tableofcontents
|
| 75 |
+
|
| 76 |
+
\chapter{Introduction: RIFFA}
|
| 77 |
+
\section{What is RIFFA}
|
| 78 |
+
|
| 79 |
+
RIFFA (Reusable Integration Framework for FPGA Accelerators) is a simple
|
| 80 |
+
framework for communicating data from a host CPU to a FPGA via a PCI Express
|
| 81 |
+
bus. The framework requires a PCIe enabled workstation and a FPGA on a board
|
| 82 |
+
with a PCIe connector. RIFFA supports Windows and Linux, Altera and Xilinx, with
|
| 83 |
+
bindings in C/C++, Python, MATLAB and Java.
|
| 84 |
+
|
| 85 |
+
On the software side there are two main functions: data send and data
|
| 86 |
+
receive. These functions are exposed via user libraries in C/C++, Python,
|
| 87 |
+
MATLAB, and Java. The driver supports multiple FPGAs (up to 5) per system. The
|
| 88 |
+
software bindings work on Linux and Windows operating systems. Users can
|
| 89 |
+
communicate with FPGA IP cores by writing only a few lines of code.
|
| 90 |
+
|
| 91 |
+
On the hardware side, users access an interface with independent transmit and
|
| 92 |
+
receive signals. The signals provide transaction handshaking and a first word
|
| 93 |
+
fall through FIFO interface for reading/writing data to the host. No knowledge
|
| 94 |
+
of bus addresses, buffer sizes, or PCIe packet formats is required. Simply send
|
| 95 |
+
data on a FIFO interface and receive data on a FIFO interface. RIFFA does not
|
| 96 |
+
rely on a PCIe Bridge and therefore is not subject to the limitations of a
|
| 97 |
+
bridge implementation. Instead, RIFFA works directly with the PCIe Endpoint and
|
| 98 |
+
can run fast enough to saturate the PCIe link.
|
| 99 |
+
|
| 100 |
+
RIFFA communicates data using direct memory access (DMA) transfers and interrupt
|
| 101 |
+
signaling. This achieves high bandwidth over the PCIe link. In our tests we are
|
| 102 |
+
able to saturate (or near saturate) the link in all our tests. The RIFFA distribution
|
| 103 |
+
contains examples and guides for setting up designs on several standard development
|
| 104 |
+
boards.
|
| 105 |
+
|
| 106 |
+
\begin{figure}[H]
|
| 107 |
+
\includegraphics[width=300px,center]{bw_sg_2_1_maxs.png}
|
| 108 |
+
\caption{Graph of Bandwidth vs Transfer Size}
|
| 109 |
+
\label{Fig:RIFFA:Performance}
|
| 110 |
+
\end{figure}
|
| 111 |
+
|
| 112 |
+
RIFFA \RIFFAVer~is significantly more efficient than its predecesor RIFFA
|
| 113 |
+
1.0. RIFFA \RIFFAVer~is able to saturate the PCIe link for nearly all link
|
| 114 |
+
configurations supported. Figure~\ref{Fig:RIFFA:Performance} shows the
|
| 115 |
+
performance of designs using the 32 bit, 64 bit, and 128 bit interfaces. The
|
| 116 |
+
colored bands show the bandwidth region between the theoretical maximum and the
|
| 117 |
+
maximum achievable. PCIe Gen 1 and 2 use 8 bit / 10 bit encoding which limits
|
| 118 |
+
the maximum achievable bandwidth to 80\% of the theoretical. Our experiments
|
| 119 |
+
show that RIFFA can achieve 80\% of the theoretical bandwidth in nearly all
|
| 120 |
+
cases. The 128 bit interface achieves 76\% of the theoretical maximum.
|
| 121 |
+
|
| 122 |
+
If you are using RIFFA on a new platform not listed above let us know and we’ll
|
| 123 |
+
help you out!
|
| 124 |
+
|
| 125 |
+
%\pagebreak
|
| 126 |
+
\section{Licensing}
|
| 127 |
+
|
| 128 |
+
Copyright (c) 2016, The Regents of the University of California All rights
|
| 129 |
+
reserved.
|
| 130 |
+
|
| 131 |
+
Redistribution and use in source and binary forms, with or without modification,
|
| 132 |
+
are permitted provided that the following conditions are met:
|
| 133 |
+
|
| 134 |
+
\begin{itemize}
|
| 135 |
+
\item Redistributions of source code must retain the above copyright
|
| 136 |
+
notice, this list of conditions and the following disclaimer.
|
| 137 |
+
|
| 138 |
+
\item Redistributions in binary form must reproduce the above
|
| 139 |
+
copyright notice, this list of conditions and the following
|
| 140 |
+
disclaimer in the documentation and/or other materials provided
|
| 141 |
+
with the distribution.
|
| 142 |
+
|
| 143 |
+
\item Neither the name of The Regents of the University of California
|
| 144 |
+
nor the names of its contributors may be used to endorse or
|
| 145 |
+
promote products derived from this software without specific
|
| 146 |
+
prior written permission.
|
| 147 |
+
\end{itemize}
|
| 148 |
+
|
| 149 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
|
| 150 |
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
| 151 |
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
| 152 |
+
DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE
|
| 153 |
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
| 154 |
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
| 155 |
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
| 156 |
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
| 157 |
+
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
| 158 |
+
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
\pagebreak
|
| 162 |
+
\chapter{Getting Started}
|
| 163 |
+
\section{Development Board Support in RIFFA \RIFFAVer}
|
| 164 |
+
RIFFA \RIFFAVer~supports:
|
| 165 |
+
\begin{itemize}
|
| 166 |
+
\item The VC707, ZC706 and similar boards with the Xilinx IP Core 7-Series
|
| 167 |
+
Integrated Block for PCI Express. Example designs for the VC707 and ZC706
|
| 168 |
+
boards are provided, and contain this core. The current distribution supports
|
| 169 |
+
all 64-bit interfaces for these devices, with 128-bit support coming soon
|
| 170 |
+
after the initial release. (Support for the 128-bit interface is in RIFFA 2.1,
|
| 171 |
+
but is temporarily mising due to changes)
|
| 172 |
+
\item The VC709 board and similar boards with the Xilinx IP Gen3 Integrated
|
| 173 |
+
Block for PCI Express. Example designs for the VC709 are provided, and contain
|
| 174 |
+
this core. The current distribution supports all 64-bit and 128-bit AXI
|
| 175 |
+
interfaces. 256-bit (PCIe Gen3 x8) support is planned for a later date.
|
| 176 |
+
\item The DE5-Net board and similar boards with the Stratix V, Cyclone V, and
|
| 177 |
+
Arria V, Hard IP for PCI express (Avalon Streaming Interface). Example designs
|
| 178 |
+
for the DE5-net board are provided, and contain the Stratix V version of this
|
| 179 |
+
core. The current distribution supports all 64-bit and 128-bit Avalon
|
| 180 |
+
Streaming interfaces.
|
| 181 |
+
\item The DE4 and similar boards with the IP Compiler for PCI Express Core,
|
| 182 |
+
supporting Stratix IV, Cyclone IV and Arria II devices. Example designs for
|
| 183 |
+
the DE4 board are provided. The current distribution supports all 64-bit and
|
| 184 |
+
128-bit Avalon Streaming interfaces.
|
| 185 |
+
\end{itemize}
|
| 186 |
+
\section{Understanding this User Guide}
|
| 187 |
+
In this user guide, we use the following conventions:
|
| 188 |
+
\begin{center}
|
| 189 |
+
\begin{tabular}{ | l | l |}
|
| 190 |
+
\hline
|
| 191 |
+
Object & Example \\ \hline
|
| 192 |
+
Directories and Paths & \Directory{RIFFA \RIFFAVer/source/fpga/riffa} \\ \hline
|
| 193 |
+
Xilinx Specific Content & \Xilinx{vc709} \\ \hline
|
| 194 |
+
Altera Specific Content & \Altera{de5} \\ \hline
|
| 195 |
+
Configuration Setting & \ConfigSetting{Number of Lanes} \\ \hline
|
| 196 |
+
Terminal Command, Code Snippet & \TermCmd{echo ``Hello World''}\\ \hline
|
| 197 |
+
RIFFA Parameter & \RIFFAParameter{C\_NUM\_CHNL}\\\hline
|
| 198 |
+
\end{tabular}
|
| 199 |
+
\end{center}
|
| 200 |
+
|
| 201 |
+
\section{Decoding What's Provided}
|
| 202 |
+
\label{Sec:Intro:Decoding}
|
| 203 |
+
Fig~\ref{Fig:RIFFA:DirStructure} shows the directory hierarchy of RIFFA. This
|
| 204 |
+
instruction manual uses this directory tree when specifying all directory paths.
|
| 205 |
+
|
| 206 |
+
The \Directory{RIFFA \RIFFAVer/source/fpga/} contains a directory for each board
|
| 207 |
+
we have tested for the current distribution:\Altera{de5, de4}, \Xilinx{VC709,
|
| 208 |
+
VC707, ZC706}. Each board directory has several example project directories
|
| 209 |
+
(e.g. \Altera{DE5Gen1x8If64} and \Xilinx{VC709\_Gen1x8If64}). Each example
|
| 210 |
+
project directory has 5 sub-directories:
|
| 211 |
+
\begin{itemize}
|
| 212 |
+
\item \Directory{prj/} contains all of the project files (\Altera{.qsf,.qpf}, \Xilinx{.xpr}).
|
| 213 |
+
\item \Directory{ip/} contains all of the ip files (\Altera{.qsys}, \Xilinx{.xci}) generated for the project, when permitted by licensing agreements.
|
| 214 |
+
\item \Directory{bit/} contains the example programming file for the corresponding FPGA example design. \Altera{Quartus} and \Xilinx{Vivado} do not modify this programming (\Altera{.sof}, \Xilinx{.bit}).
|
| 215 |
+
\item \Directory{constr/} contains the user constraint files (\Altera{.sdc}, \Xilinx{.xdc}).
|
| 216 |
+
\item \Directory{hdl/} contains any example-project specific Verilog files, such as the project top level file.
|
| 217 |
+
\end{itemize}
|
| 218 |
+
|
| 219 |
+
\begin{figure}[H]
|
| 220 |
+
\begin{tikzpicture}[dirtree]
|
| 221 |
+
\node {RIFFA \RIFFAVer}
|
| 222 |
+
child { node {Documentation}
|
| 223 |
+
child { node {RIFFA User Guide.pdf (This Document)} }
|
| 224 |
+
}
|
| 225 |
+
child { node {install}
|
| 226 |
+
child { node {windows}
|
| 227 |
+
child{ node {setup.exe}}
|
| 228 |
+
child{ node {setup\_debug.exe}}
|
| 229 |
+
}
|
| 230 |
+
child { node {linux}
|
| 231 |
+
child{ node {README.txt}}
|
| 232 |
+
}
|
| 233 |
+
}
|
| 234 |
+
child { node {source}
|
| 235 |
+
child { node {c\_c++} }
|
| 236 |
+
child { node {java} }
|
| 237 |
+
child { node {matlab} }
|
| 238 |
+
child { node {python} }
|
| 239 |
+
child { node {driver}
|
| 240 |
+
child { node {linux}
|
| 241 |
+
child{ node {makefile}}
|
| 242 |
+
child{ node {... (Other source files)}}
|
| 243 |
+
}
|
| 244 |
+
child { node {windows}
|
| 245 |
+
child{ node {... (Other source files \& directories)}}
|
| 246 |
+
}
|
| 247 |
+
}
|
| 248 |
+
child { node{fpga}
|
| 249 |
+
child { node{riffa}
|
| 250 |
+
child {node{(RIFFA Source)}}
|
| 251 |
+
}
|
| 252 |
+
child { node{\Altera{de5}}
|
| 253 |
+
child {node{\Altera{DE5Gen1x8If64}}
|
| 254 |
+
child{node{prj}}
|
| 255 |
+
child{node{bit}}
|
| 256 |
+
child{node{ip}}
|
| 257 |
+
child{node{constr}}
|
| 258 |
+
child{node{hdl}}
|
| 259 |
+
}
|
| 260 |
+
child {node{... (Other example projects)}}
|
| 261 |
+
}
|
| 262 |
+
child { node{\Altera{de4}}
|
| 263 |
+
child {node{\Altera{DE4Gen1x8If64}}}
|
| 264 |
+
child {node{...}}
|
| 265 |
+
}
|
| 266 |
+
child { node{\Xilinx{vc709}}
|
| 267 |
+
child {node{\Xilinx{VC709\_Gen1x8If64}}}
|
| 268 |
+
child {node{...}}
|
| 269 |
+
}
|
| 270 |
+
child { node{\Xilinx{zc706}}
|
| 271 |
+
child {node{\Xilinx{ZC706\_Gen1x8If64}}}
|
| 272 |
+
child {node{...}}
|
| 273 |
+
}
|
| 274 |
+
child { node{\Xilinx{vc707}}
|
| 275 |
+
child {node{\Xilinx{VC707\_Gen1x8If64}}}
|
| 276 |
+
child {node{...}}
|
| 277 |
+
}
|
| 278 |
+
}
|
| 279 |
+
};
|
| 280 |
+
\end{tikzpicture}
|
| 281 |
+
\caption{Directory hierarchy of the RIFFA \RIFFAVer~distribution} \label{Fig:RIFFA:DirStructure}
|
| 282 |
+
\end{figure}
|
| 283 |
+
|
| 284 |
+
\section{Release Notes}
|
| 285 |
+
\subsection{Version 2.2.2}
|
| 286 |
+
\begin{itemize}
|
| 287 |
+
\item Fixed: Unsigned Windows Driver (Commit: 4e989fc)
|
| 288 |
+
|
| 289 |
+
\item Fixed: A bug in the clock-crossing interface where a low-frequency user
|
| 290 |
+
clock (<40 MHz) could cause incorrect channel behavior. (Commit: 778c42e)
|
| 291 |
+
|
| 292 |
+
\item Fixed: Support for 64-bit pointers in Python 3. Shout out to
|
| 293 |
+
@jrobrien (Commit: af7c592)
|
| 294 |
+
|
| 295 |
+
\item Fixed: Includes in linux driver. linux/slab.h was not included in
|
| 296 |
+
riffa\_driver.c (Commit: cd494e1)
|
| 297 |
+
|
| 298 |
+
\item Fixed: Capability backwards/forwards compatibility issues to support Linux
|
| 299 |
+
for Tegra. (Commit: 1d228c1)
|
| 300 |
+
|
| 301 |
+
\item New: Support for new get\_user\_pages API in the linux kernel. Shout out to
|
| 302 |
+
@marzoul (Commit: TBD)
|
| 303 |
+
|
| 304 |
+
\item Removed: Non-Qsys DE5 Board Example Designs (QSys > IP Generator)
|
| 305 |
+
@marzoul (Commit: TBD)
|
| 306 |
+
|
| 307 |
+
\end{itemize}
|
| 308 |
+
\subsection{Version 2.2.1}
|
| 309 |
+
\begin{itemize}
|
| 310 |
+
\item New: Reset logic for the Engine layer to handle RIFFA induced resets
|
| 311 |
+
|
| 312 |
+
\item New: Stability/multi-thread-concurrency warnings in the Linux driver
|
| 313 |
+
(Shoutout to @marzoul)
|
| 314 |
+
|
| 315 |
+
\item Fixed: A bug in the Linux Driver that prevented compilation on older kernels
|
| 316 |
+
|
| 317 |
+
\item Fixed: Windows driver issue for back-to-back small transfers (See 2.2.0)
|
| 318 |
+
|
| 319 |
+
\item Fixed: WORD\_ENABLE bug fix for the Classic Xilinx (VC707, ZC706, AC701,
|
| 320 |
+
KC705) 128-bit interface
|
| 321 |
+
|
| 322 |
+
\item Fixed: TX Engine Buffer sizing (high-bandwidth transfers occasionally had
|
| 323 |
+
corruption)
|
| 324 |
+
|
| 325 |
+
\item Fixed: RX Engine rx\_st\_valid bug fix for Altera IP Compiler for PCI express
|
| 326 |
+
(Cyclone IV, Stratix IV)
|
| 327 |
+
\end{itemize}
|
| 328 |
+
|
| 329 |
+
\subsection{Version 2.2.0}
|
| 330 |
+
\begin{itemize}
|
| 331 |
+
\item Added: Support for the new Gen3 Integrated Block for PCIe Express, and the VC709 Development board.
|
| 332 |
+
\item Added: ZC706 Example Designs
|
| 333 |
+
\item Changed: Xilinx example project packaging. All Xilinx Virtex 7 projects are now click-to-compile, and come with instantiated IP.
|
| 334 |
+
\item Re-wrote and refactored: Various parts of the TX and RX engines to maximize code reuse between different vendors and PCIe endpoint implementations
|
| 335 |
+
\item Fixed: A bug in the Linux Driver that prevented compilation on older kernels
|
| 336 |
+
\item Fixed: A bug in the Windows Driver that prevented repeated small transfers.
|
| 337 |
+
\end{itemize}
|
| 338 |
+
\subsection{Version 2.1.0}
|
| 339 |
+
\begin{itemize}
|
| 340 |
+
|
| 341 |
+
\item Added reorder\_queue and updated many rx/tx engine and channel modules that
|
| 342 |
+
use it.
|
| 343 |
+
\item Added parameters for number of tags to use and max payload length for sizing
|
| 344 |
+
RAM for reorder\_queue.
|
| 345 |
+
\item Fixed: Bug in the riffa\_driver.c, too few circular buffer elements.
|
| 346 |
+
\item Fixed: Bug in the riffa\_driver.c, bad order in which interrupt vector bits
|
| 347 |
+
were processed. Can cause deadlock in heavy use situations.
|
| 348 |
+
\item Fixed: Bug in the tx\_port\_writer.v, maxlen did not start with a value of 1.
|
| 349 |
+
Can cause deadlock behavior on second transfer.
|
| 350 |
+
\item Fixed: Bug in the rx\_port\_reader.v, added delay to allow FIFO flush to
|
| 351 |
+
propagate.
|
| 352 |
+
\item Fixed: Bug in rx\_port\_xxx.v, changed to use FWFT FIFO instead of existing
|
| 353 |
+
logic that could cause CHNL\_RX\_DATA\_VALID to drop for a cycle after CHNL\_RX
|
| 354 |
+
dropped even when there is still data in the FIFO. Can cause premature
|
| 355 |
+
transmission termination.
|
| 356 |
+
\item Changed rx\_port\_channel\_gate.v to use FWFT FIFO.
|
| 357 |
+
\item Removed unused signal from rx\_port\_requester\_mux.v.
|
| 358 |
+
\item Fixed: Typo/bug that would attempt to change state within
|
| 359 |
+
tx\_port\_monitor\_xxx.v.
|
| 360 |
+
\item Added flow control for receive credits to avoid over driving upstream transactions
|
| 361 |
+
(applies to Altera devices).
|
| 362 |
+
\end{itemize}
|
| 363 |
+
|
| 364 |
+
\subsection{Version 2.0.2}
|
| 365 |
+
\begin{itemize}
|
| 366 |
+
|
| 367 |
+
\item Fixed: Bug in Windows and Linux drivers that could report data sent/received
|
| 368 |
+
before such data was confirmed.
|
| 369 |
+
\item Fixed: Updated common functions to avoid assigning input values.
|
| 370 |
+
\item Fixed: FIFO overflow error causing data corruption in tx\_engine\_upper and
|
| 371 |
+
breaking the Xilinx Endpoint.
|
| 372 |
+
\item Fixed: Missing default cases in rx\_port\_reader, \\
|
| 373 |
+
sg\_list\_requester, tx\_engine\_upper, and tx\_port\_writer.
|
| 374 |
+
\item Fixed: Bug in tx\_engine\_lower\_128 corrupting s\_axis\_tx\_tkeep, causing Xilinx
|
| 375 |
+
PCIe endpoint core to shut down.
|
| 376 |
+
\item Fixed: Bug in tx\_engine\_upper\_128 causing incomplete TX data timeouts.
|
| 377 |
+
\item Changed rx\_engine to not block on nonposted TLPs. They're added to a FIFO and
|
| 378 |
+
serviced in order.
|
| 379 |
+
\item Reset rx\_port FIFOs before a receive transaction to avoid data corruption from
|
| 380 |
+
replayed TLPs.
|
| 381 |
+
\end{itemize}
|
| 382 |
+
|
| 383 |
+
\subsection{Version 2.0.1}
|
| 384 |
+
|
| 385 |
+
\begin{itemize}
|
| 386 |
+
\item RIFFA 2.0.1 is a general release. This means we've tested it in a number of
|
| 387 |
+
ways. Please let us know if you encounter a bug.
|
| 388 |
+
\item Neither the HDL nor the drivers from RIFFA 2.0.1 are backwards compatible with
|
| 389 |
+
the components of any previous release of RIFFA.
|
| 390 |
+
\item RIFFA 2.0.1 consumes more resources than 2.0 beta. This is because 2.0.1 was
|
| 391 |
+
rewritten to support scatter gather DMA, higher bandwidth, and appreciably
|
| 392 |
+
more signal registering. The additional registering was included to help meet
|
| 393 |
+
timing constraints.
|
| 394 |
+
\item The Windows driver is supported on Windows 7 32/64. Other Windows versions
|
| 395 |
+
can be supported. The driver simply needs to be built for that target.
|
| 396 |
+
\item Debugging on Windows is difficult because there exists no system log file.
|
| 397 |
+
Driver log messages are visible only to an attached kernel debugger. So to see
|
| 398 |
+
any messages you'll need the Windows Development Kit debugger (WinDbg) or a
|
| 399 |
+
small utility called DbgView. DbgView is a standalone kernel debug viewer that
|
| 400 |
+
\item http://technet.microsoft.com/ens/sysinternals/bb896647.aspx
|
| 401 |
+
Run DbgView with administrator privileges and be sure to enable the following
|
| 402 |
+
capture options: Capture Kernel, Capture Events, and Capture Verbose Kernel
|
| 403 |
+
Output.
|
| 404 |
+
\item The Linux driver is supported on kernel version 2.6.27+.
|
| 405 |
+
\item The Java bindings make use of a native library (in order to connect Java JNI
|
| 406 |
+
to the native library). Libraries for Linux and Windows for both 32/64 bit
|
| 407 |
+
platforms have been compiled and included in the riffa.jar.
|
| 408 |
+
\item Removed the CHNL\_RX\_ERR signal from the channel interface. Error handling now
|
| 409 |
+
ends the transaction gracefully. Errors can be easily detected by comparing
|
| 410 |
+
the number of words received to the CHNL\_RX\_LEN amount. An error will cause
|
| 411 |
+
CHNL\_RX will go low prematurely and not provide the advertised amount of data.
|
| 412 |
+
\item Fixed: Bug in sg\_list\_requester which could cause an unbounded TLP request.
|
| 413 |
+
\item Fixed: Bug in tx\_port\_buffer\_128 which could stall the TX transaction.
|
| 414 |
+
\end{itemize}
|
| 415 |
+
\section{Errata}
|
| 416 |
+
While we have extensively tested the current distribution, we are human and
|
| 417 |
+
cannot eliminate all bugs in our distribution. As a general rule of thumb, if
|
| 418 |
+
you find yourself delving into the RIFFA code, you have gone too far. Contact us
|
| 419 |
+
if you need additional assistance!
|
| 420 |
+
|
| 421 |
+
See the following notes for issues we are currently tracking:
|
| 422 |
+
|
| 423 |
+
\subsection{Windows}
|
| 424 |
+
\subsection{Linux}
|
| 425 |
+
No open issues
|
| 426 |
+
\subsection{Altera}
|
| 427 |
+
|
| 428 |
+
\textbf{Issue 3: No support for the 256-bit, Gen3x8 Interface} Coming soon...
|
| 429 |
+
\subsection{Xilinx (Classic)}
|
| 430 |
+
|
| 431 |
+
\textbf{Issue 1: Missing example designs for ML605} There is no disadvantage to
|
| 432 |
+
using RIFFA 2.1.0 until we return support in a future distribution.
|
| 433 |
+
|
| 434 |
+
\textbf{Issue 2: Missing example design for Spartan 6 LXT Development board} The
|
| 435 |
+
32-bit interface support has been removed from RIFFA 2.2 and may be added back
|
| 436 |
+
in the future. Please use RIFFA 2.1 in the meantime
|
| 437 |
+
|
| 438 |
+
\subsection{Xilinx (Ultrascale)}
|
| 439 |
+
\textbf{Issue 1: No support for the 256-bit, Gen3x8 Interface} Coming soon...
|
| 440 |
+
|
| 441 |
+
\pagebreak
|
| 442 |
+
|
| 443 |
+
\chapter{Installing the RIFFA driver}
|
| 444 |
+
\label{Sec:RIFFA:Installation}
|
| 445 |
+
\section{Linux}
|
| 446 |
+
To install the RIFFA driver in linux, you must build it against your installed
|
| 447 |
+
version of the Linux kernel. RIFFA \RIFFAVer~comes with a makefile that will
|
| 448 |
+
install the necessar linux kernel headers and the driver. This makefile will
|
| 449 |
+
also build and install the C/C++ native library. To install RIFFA \RIFFAVer~in
|
| 450 |
+
linux, follow these instructions:
|
| 451 |
+
|
| 452 |
+
\begin{enumerate}
|
| 453 |
+
\item Open a terminal in linux and navigate to the \Directory{RIFFA \RIFFAVer/source/driver/linux} directory.
|
| 454 |
+
\item Ensure you have the kernel headers installed, run:
|
| 455 |
+
|
| 456 |
+
\TermCmd{sudo make setup}
|
| 457 |
+
|
| 458 |
+
This will attempt to install the kernel headers using your system's package
|
| 459 |
+
manager. You can skip this step if you've already installed the kernel headers.
|
| 460 |
+
\item Compile the driver and C/C++ library:
|
| 461 |
+
|
| 462 |
+
\TermCmd{make}
|
| 463 |
+
|
| 464 |
+
or
|
| 465 |
+
|
| 466 |
+
\TermCmd{make debug}
|
| 467 |
+
|
| 468 |
+
Using make debug will compile in code to output debug messages to the system log
|
| 469 |
+
at runtime. These messages are useful when developing your design. However they
|
| 470 |
+
pollute your system log and incur some overhead. So you may want to install the
|
| 471 |
+
non-debug version after you've completed development.
|
| 472 |
+
\item Install the driver and library:
|
| 473 |
+
|
| 474 |
+
\TermCmd{sudo make install}
|
| 475 |
+
|
| 476 |
+
The system will be configured to load the driver at boot time. The C/C++ library
|
| 477 |
+
will be installed in the default library path. The header files will be placed
|
| 478 |
+
in the default include path. You will need to reboot after you've installed for
|
| 479 |
+
the driver to be (re)loaded.
|
| 480 |
+
\item If the driver is installed and there is a RIFFA \RIFFAVer~configured FPGA when the computer boots, the
|
| 481 |
+
driver will detect it. Output in the system log will provide additional
|
| 482 |
+
information.
|
| 483 |
+
\item The C/C++ code must include the riffa.h header. An example inclusion is
|
| 484 |
+
shown in Listing~\ref{Listing:RIFFA:Include}
|
| 485 |
+
\item When compiling (using GCC/G++, etc.) you must link with the RIFFA
|
| 486 |
+
libraries using the -lriffa flag. For example, when compiling test.c from
|
| 487 |
+
Listing~\ref{Listing:RIFFA:Include}:
|
| 488 |
+
|
| 489 |
+
\TermCmd{gcc -g -c -lriffa -o test.o test.c}
|
| 490 |
+
\item Bindings for other languages can be installed by following the README
|
| 491 |
+
files in their respective directories (See Figure~\ref{Fig:RIFFA:DirStructure}
|
| 492 |
+
\end{enumerate}
|
| 493 |
+
|
| 494 |
+
\section{Windows}
|
| 495 |
+
Currently only Windows 7 (32/64) is supported by RIFFA \RIFFAVer. In the
|
| 496 |
+
\Directory{RIFFA \RIFFAVer/install/windows/} subdirectory use the
|
| 497 |
+
provided setup.exe program to install the RIFFA driver and native C/C++
|
| 498 |
+
library. You can verify that RIFFA \RIFFAVer~installed correctly by checking
|
| 499 |
+
the installation directory in Program Files. After installation, you'll be able
|
| 500 |
+
to install the bindings for other languages.
|
| 501 |
+
|
| 502 |
+
The setup\_dbg.exe installer installs a driver with additional debugging output.
|
| 503 |
+
You can install the setup\_dbg.exe version and then later use setup.exe to
|
| 504 |
+
install the non-debug output version.
|
| 505 |
+
|
| 506 |
+
\begin{lstlisting}[basicstyle=\footnotesize\ttfamily,language=C,
|
| 507 |
+
commentstyle=\color{red},label=Listing:RIFFA:Include,
|
| 508 |
+
caption=Inclusion of the RIFFA header files in a user application,frame=single]
|
| 509 |
+
#include <stdio.h>
|
| 510 |
+
#include <stdlib.h>
|
| 511 |
+
#include <riffa.h>
|
| 512 |
+
#define BUF_SIZE (1*1024*1024)
|
| 513 |
+
|
| 514 |
+
unsigned int buf[BUF_SIZE];
|
| 515 |
+
|
| 516 |
+
int main(int argc, char* argv[]) {
|
| 517 |
+
fpga_t * fpga;
|
| 518 |
+
int fid = 0; // FPGA id
|
| 519 |
+
int channel = 0; // FPGA channel
|
| 520 |
+
|
| 521 |
+
fpga = fpga_open(fid);
|
| 522 |
+
fpga_send(fpga, channel, (void *)buf, BUF_SIZE, 0, 1, 0);
|
| 523 |
+
fpga_recv(fpga, channel, (void *)buf, BUF_SIZE, 0);
|
| 524 |
+
fpga_close(fpga);
|
| 525 |
+
return 0;
|
| 526 |
+
}
|
| 527 |
+
\end{lstlisting}
|
| 528 |
+
|
| 529 |
+
|
| 530 |
+
\chapter{Compiling and using the Xilinx Example Designs}
|
| 531 |
+
Vivado \VivadoVer~was used in all example designs and documentation included in
|
| 532 |
+
this distribution. We highly recommend using \VivadoVer~and all newer versions
|
| 533 |
+
of the software, since we have encountered bugs in previous versions of the
|
| 534 |
+
Vivado (e.g. 2014.2) software. This guide assumes that the end-user has already
|
| 535 |
+
configured their board for PCI Express operation. See the VC709 User Guide
|
| 536 |
+
\footnote{http://www.xilinx.com/support/documentation/boards\_and\_kits/vc709/ug887-vc709-eval-board-v7-fpga.pdf},
|
| 537 |
+
VC707 User Guide
|
| 538 |
+
\footnote{http://www.xilinx.com/support/documentation/boards\_and\_kits/vc707/ug848-VC707-getting-started-guide.pdf}
|
| 539 |
+
or ZC706 User Guide
|
| 540 |
+
\footnote{http://www.xilinx.com/support/documentation/boards\_and\_kits/zc706/ug954-zc706-eval-board-xc7z045-ap-soc.pdf}.
|
| 541 |
+
|
| 542 |
+
While we have not tested all of the current-generation Xilinx development
|
| 543 |
+
boards, we are confident that they can be supported with minimal
|
| 544 |
+
modifications. For more information about supporting new boards, see the
|
| 545 |
+
sections \ref{Sec:7SeriesIntegrated:Generating} and
|
| 546 |
+
\ref{Sec:Gen3Integrated:Generating}. These sections cover the settings used
|
| 547 |
+
in the RIFFA example design IP.
|
| 548 |
+
|
| 549 |
+
The easiset way to use RIFFA is to start with one of the example designs
|
| 550 |
+
included in the distribution. Sections \ref{Sec:7SeriesIntegrated:ExampleDesign}
|
| 551 |
+
and \ref{Sec:Gen3Integrated:ExampleDesign} describe how to use and compile these
|
| 552 |
+
designs for the VC707 and VC709 boards respectively. These example designs are
|
| 553 |
+
ready to compile out of the box, and require no user IP configuration and
|
| 554 |
+
generation. The designs also include pre-compiled bit-files in the
|
| 555 |
+
\Directory{bit} directory of the example project. For advanced users, we also
|
| 556 |
+
describe how we generated the PCIe IP in sections
|
| 557 |
+
\ref{Sec:7SeriesIntegrated:Generating} and
|
| 558 |
+
\ref{Sec:Gen3Integrated:Generating}.
|
| 559 |
+
|
| 560 |
+
\section{Classic - 7 Series Integrated Block for PCI Express - (VC707, ZC706 and older)}
|
| 561 |
+
This is a step by step guide for using RIFFA \RIFFAVer~on a Xilinx FPGA with the
|
| 562 |
+
7 Series Integrated Block for PCI Express Core. This core is supported on the
|
| 563 |
+
ZC706, and VC707 development boards, using the 64-bit and 128-bit AXI
|
| 564 |
+
interfaces.
|
| 565 |
+
|
| 566 |
+
\subsection{VC707 and ZC706 Example Designs}
|
| 567 |
+
\label{Sec:7SeriesIntegrated:ExampleDesign}
|
| 568 |
+
There is one VC707 example design and two ZC706 example designs in the RIFFA
|
| 569 |
+
\RIFFAVer~distribution. The VC707 example design folders are in \Directory{RIFFA
|
| 570 |
+
\RIFFAVer/source/fpga/vc707} and the ZC706 example design folders are in
|
| 571 |
+
\Directory{RIFFA \RIFFAVer/source/fpga/zc706}.
|
| 572 |
+
|
| 573 |
+
\begin{enumerate}
|
| 574 |
+
\item Open Vivado to get the introductory screen shown in
|
| 575 |
+
Figure~\ref{Fig:Vivado:WelcomeScreen}.
|
| 576 |
+
\item Click 'Open an Existing Project' and navigate to your RIFFA
|
| 577 |
+
\RIFFAVer~directory.
|
| 578 |
+
\item In the RIFFA \RIFFAVer~distribution, open \Directory{RIFFA
|
| 579 |
+
\RIFFAVer/source/fpga/xilinx/vc707/} or \Directory{RIFFA
|
| 580 |
+
\RIFFAVer/source/fpga/zc706} and choose from one of the existing example
|
| 581 |
+
design directories for your board. In the example design directory, locate the
|
| 582 |
+
\Directory{prj} folder and open it. Select the .xpr file and click open. This
|
| 583 |
+
will open the example project, as shown in
|
| 584 |
+
Figure~\ref{Fig:7SeriesIntegrated:ExampleDesign:ProjectOpened}.
|
| 585 |
+
\item This project was compiled in Vivado \VivadoVer. The bit file generated can
|
| 586 |
+
be used to test the FPGA system. If you are using a newer version of Vivado,
|
| 587 |
+
recompile the example design or use the programming file provided.
|
| 588 |
+
\begin{itemize}
|
| 589 |
+
\item IP Settings are now packaged as part of the example designs! Users no
|
| 590 |
+
longer need to generate IP.
|
| 591 |
+
\item To recompile the example design, click the generate bitstream button in
|
| 592 |
+
the top left corner as shown in
|
| 593 |
+
Figure~\ref{Fig:7SeriesIntegrated:ExampleDesign:ProjectOpened}.
|
| 594 |
+
\item Recompiling your design will generate a new bitfile in the Xilinx
|
| 595 |
+
project. The bit file in the \Directory{bit} will not be changed.
|
| 596 |
+
\end{itemize}
|
| 597 |
+
\item To program the FPGA, click 'Open Hardware Manager'. New bit files
|
| 598 |
+
(generated by Vivado) will appear in Vivado's internal directory. An example
|
| 599 |
+
bit file is provided in the example design's \Directory{bit}. Load the
|
| 600 |
+
bitstream to your VC707 or ZC706 board and restart your computer.
|
| 601 |
+
\begin{itemize}
|
| 602 |
+
\item Before programming your FPGA, you should install the RIFFA driver. See
|
| 603 |
+
Section~\ref{Sec:RIFFA:Installation}
|
| 604 |
+
\end{itemize}
|
| 605 |
+
\item The example design uses the chnl\_tester (shown in
|
| 606 |
+
Figure~\ref{Fig:Vivado:ExampleDesign:chnl_tester}, which works with
|
| 607 |
+
the example software in the \Directory{source/\{C\_C++,Java,python,matlab\}}
|
| 608 |
+
directories. Replace the chnl\_tester instantiation with any user logic,
|
| 609 |
+
matching the RIFFA interface.
|
| 610 |
+
\item Recompile the design and program the FPGA Device. Changing the
|
| 611 |
+
\RIFFAParameter{C\_NUM\_CHNL} will change the number of independent channel
|
| 612 |
+
interfaces
|
| 613 |
+
\end{enumerate}
|
| 614 |
+
\begin{figure}
|
| 615 |
+
\includegraphics[width=400px,center]{VivadoWelcomeScreen.png}
|
| 616 |
+
\caption{Welcome Screen for Vivado \VivadoVer}
|
| 617 |
+
\label{Fig:Vivado:WelcomeScreen}
|
| 618 |
+
\end{figure}
|
| 619 |
+
\begin{figure}
|
| 620 |
+
\includegraphics[width=400px,center]{7SeriesIntegratedOpenProject.png}
|
| 621 |
+
\caption{Project Splash Screen for 7Series Integrated Block for PCI Express Projects}
|
| 622 |
+
\label{Fig:7SeriesIntegrated:ExampleDesign:ProjectOpened}
|
| 623 |
+
\end{figure}
|
| 624 |
+
\begin{figure}
|
| 625 |
+
\includegraphics[width=400px,trim=500 200 200 250, clip=true,center]{VivadoChnlTesterInstantiation.png}
|
| 626 |
+
\caption{Project Splash Screen for 7Series Integrated Block for PCI Express Projects}
|
| 627 |
+
\label{Fig:Vivado:ExampleDesign:chnl_tester}
|
| 628 |
+
\end{figure}
|
| 629 |
+
|
| 630 |
+
\subsection{Generating the 7 Series Integrated Block for PCI Express}
|
| 631 |
+
\label{Sec:7SeriesIntegrated:Generating}
|
| 632 |
+
The following steps are not required for general users. See the instructions
|
| 633 |
+
above for how to compile RIFFA.
|
| 634 |
+
|
| 635 |
+
Alternatively, it is possible to generate the PCIe Endpoint with different
|
| 636 |
+
settings than those provided in the example design. Modifying the RIFFA
|
| 637 |
+
parameters \RIFFAParameter{C\_PCI\_DATA\_WIDTH},
|
| 638 |
+
\RIFFAParameter{C\_MAX\_PAYLOAD\_BYTES} and \RIFFAParameter{C\_LOG\_NUM\_TAGS},
|
| 639 |
+
change certain settings in the IP Core. The \RIFFAParameter{C\_NUM\_LANES} is a
|
| 640 |
+
parameter in the top level file of each example project. How these parameters
|
| 641 |
+
relate to IP core settings is highlighted in the following figures.
|
| 642 |
+
|
| 643 |
+
If the goal is to generate a RIFFA design completely from scratch, each board
|
| 644 |
+
directory comes with a RIFFA wrapper verilog file and instantiates a
|
| 645 |
+
vendor-specific translation layer. It is highly recommended to re-use these
|
| 646 |
+
files RIFFA wrapper when creating designs from scratch.
|
| 647 |
+
|
| 648 |
+
To generate the PCIe IP select the 7 Series Integrated Block for PCI Express
|
| 649 |
+
after selecting the IP Catalog shown in
|
| 650 |
+
Figure~\ref{Fig:7SeriesIntegrated:ExampleDesign:ProjectOpened}. This will open
|
| 651 |
+
the IP Customization window as shown in
|
| 652 |
+
Figure~\ref{Fig:7SeriesIntegrated:Generating:7SeriesIntegratedTabBasic}
|
| 653 |
+
\begin{figure}[H]
|
| 654 |
+
\includegraphics[width=\figurewidth,center]{7SeriesIntegratedTabBasic.png}
|
| 655 |
+
\caption{Basic settings tab.}
|
| 656 |
+
\label{Fig:7SeriesIntegrated:Generating:7SeriesIntegratedTabBasic}
|
| 657 |
+
\end{figure}
|
| 658 |
+
First, select \ConfigSetting{Mode} to \ConfigSetting{ADVANCED} from the drop
|
| 659 |
+
down menu. This will cause more tabs to appear in the bar. The following tabs
|
| 660 |
+
are not used during customization: Link Registers, Power Mangement,
|
| 661 |
+
Ext. Capabilities, Ext. Capabilities 2, TL Settings and DL/PL Settings.
|
| 662 |
+
|
| 663 |
+
In Figure~\ref{Fig:7SeriesIntegrated:Generating:7SeriesIntegratedTabBasic} , we
|
| 664 |
+
have set the \ConfigSetting{Xilinx Development Board} to \ConfigSetting{VC707},
|
| 665 |
+
selected the PCIe Gen1 rate \ConfigSetting{2.5 GT/s}, and a \ConfigSetting{Lane
|
| 666 |
+
Width} of \ConfigSetting{8} (\RIFFAParameter{C\_NUM\_LANES} = 8). We have
|
| 667 |
+
chosen to set the \ConfigSetting{AXI Interface Width} to \ConfigSetting{64-bits}
|
| 668 |
+
(\RIFFAParameter{C\_PCI\_DATA\_WIDTH} = 64). The choice of Link Rate, Lanes, and
|
| 669 |
+
Interface Width will allow different AXI Interface Frequencies to be
|
| 670 |
+
selected. The RIFFA core will run at this clock frequency, but the user logic
|
| 671 |
+
can run at whatever frequency it desires.
|
| 672 |
+
|
| 673 |
+
Optional: Set the Component Name of the PCI Express block, and the IP
|
| 674 |
+
Location. In our example projects, we use the name template
|
| 675 |
+
PCIeGen\textbf{W}x\textbf{Y}If\textbf{Z} where \textbf{W} is the PCI Express
|
| 676 |
+
Version (\ConfigSetting{Link Speed} in
|
| 677 |
+
Figure~\ref{Fig:7SeriesIntegrated:Generating:7SeriesIntegratedTabBasic}),
|
| 678 |
+
\textbf{Y} is the lane width, and \textbf{Z} is the AXI interface width. The IP
|
| 679 |
+
location is the \Directory{ip} directory in the example project.
|
| 680 |
+
|
| 681 |
+
\begin{figure}[H]
|
| 682 |
+
\includegraphics[width=350px,center]{7SeriesIntegratedTabIDs.png}
|
| 683 |
+
\caption{PCI Express ID Tab.}
|
| 684 |
+
\label{Fig:7SeriesIntegrated:Generating:7SeriesIntegratedTabIDs}
|
| 685 |
+
\end{figure}
|
| 686 |
+
The tab in Figure~\ref{Fig:7SeriesIntegrated:Generating:7SeriesIntegratedTabIDs}
|
| 687 |
+
is optional. Setting the Device ID may assist in identifying different FPGAs in
|
| 688 |
+
a multi-FPGA system. The other options, specifically the Vendor ID, must remain
|
| 689 |
+
the same.
|
| 690 |
+
|
| 691 |
+
\begin{figure}[H]
|
| 692 |
+
\includegraphics[width=350px,center]{7SeriesIntegratedTabBARs.png}
|
| 693 |
+
\caption{PCI Express Base Address Register (BAR) ID Tab.}
|
| 694 |
+
\label{Fig:7SeriesIntegrated:Generating:7SeriesIntegratedTabBARs}
|
| 695 |
+
\end{figure}
|
| 696 |
+
The tab in
|
| 697 |
+
Figure~\ref{Fig:7SeriesIntegrated:Generating:7SeriesIntegratedTabBARs} must be
|
| 698 |
+
configured so that BAR0 is \ConfigSetting{enabled} (checked). Set the
|
| 699 |
+
\ConfigSetting{Type} to \ConfigSetting{Memory}, and \ConfigSetting{Unit}
|
| 700 |
+
\ConfigSetting{Kilobyte}, and \ConfigSetting{Size Value} to \ConfigSetting{1}
|
| 701 |
+
from the dropdown menus. If these values are not set correctly the RIFFA driver
|
| 702 |
+
will not recognize the FPGA device.
|
| 703 |
+
|
| 704 |
+
\begin{figure}[H]
|
| 705 |
+
\includegraphics[width=350px,center]{7SeriesIntegratedTabCapabilities.png}
|
| 706 |
+
\caption{PCI Express Capabilities Tab.}
|
| 707 |
+
\label{Fig:7SeriesIntegrated:Generating:7SeriesIntegratedTabCapabilities}
|
| 708 |
+
\end{figure}
|
| 709 |
+
In this tab select the boxes \ConfigSetting{Buffering Optimized for Bus
|
| 710 |
+
Mastering Applications} and \ConfigSetting{Extended Tag Field}. If the
|
| 711 |
+
\ConfigSetting{Extended Tag Field} is selected
|
| 712 |
+
\RIFFAParameter{C\_LOG\_NUM\_TAGS} = 8, otherwise
|
| 713 |
+
\RIFFAParameter{C\_LOG\_NUM\_TAGS} = 5. Select the \ConfigSetting{Maximum
|
| 714 |
+
Payload Size} from the dropdown menu. Use this to set the RIFFA
|
| 715 |
+
\RIFFAParameter{C\_MAX\_PAYLOAD\_BYTES} parameter.
|
| 716 |
+
|
| 717 |
+
Note: Maximum Payload sizes are typically set by the BIOS, and 256 bytes seems
|
| 718 |
+
to be standard. RIFFA will default to the minimum of
|
| 719 |
+
\RIFFAParameter{C\_MAX\_PAYLOAD\_SIZE} and the setting in your BIOS. Unless your
|
| 720 |
+
BIOS is modified, or can support substantially larger packets, there will be no
|
| 721 |
+
performance benefit to increasing the payload size. Increasing the maximum
|
| 722 |
+
payload size will increase the resources consumed.
|
| 723 |
+
|
| 724 |
+
% \begin{figure}[H]
|
| 725 |
+
% \includegraphics[width=350px,center]{7SeriesIntegratedTabLinkRegisters.png}
|
| 726 |
+
% \label{Fig:7SeriesIntegrated:Generating:7SeriesIntegratedTabLinkRegisters}
|
| 727 |
+
% \end{figure}
|
| 728 |
+
\begin{figure}[H]
|
| 729 |
+
\includegraphics[width=350px,center]{7SeriesIntegratedTabInterrupts.png}
|
| 730 |
+
\caption{PCI Express Interrupts Tab.}
|
| 731 |
+
\label{Fig:7SeriesIntegrated:Generating:7SeriesIntegratedTabInterrupts}
|
| 732 |
+
\end{figure}
|
| 733 |
+
In the Interrupts Tab shown in
|
| 734 |
+
Figure~\ref{Fig:7SeriesIntegrated:Generating:7SeriesIntegratedTabInterrupts}
|
| 735 |
+
\ConfigSetting{clear} the checkbox for \ConfigSetting{Enable INTx} (To disable
|
| 736 |
+
INTx). The remaining options should match those shown in
|
| 737 |
+
Figure~\ref{Fig:7SeriesIntegrated:Generating:7SeriesIntegratedTabInterrupts}
|
| 738 |
+
% \begin{figure}[H]
|
| 739 |
+
% \includegraphics[width=350px,center]{7SeriesIntegratedTabPowerManagement.png}
|
| 740 |
+
% \label{Fig:7SeriesIntegrated:Generating:7SeriesIntegratedTabPowerManagement}
|
| 741 |
+
% \caption{PCI Express Power Manement Tab.}\\
|
| 742 |
+
% \end{figure}
|
| 743 |
+
% \begin{figure}[H]
|
| 744 |
+
% \includegraphics[width=350px,center]{7SeriesIntegratedTabExtCapabilities.png}
|
| 745 |
+
% \label{Fig:7SeriesIntegrated:Generating:7SeriesIntegratedTabExtCapabilities}
|
| 746 |
+
% \end{figure}
|
| 747 |
+
% \begin{figure}[H]
|
| 748 |
+
% \includegraphics[width=350px,center]{7SeriesIntegratedTabExtCapabilities2.png}
|
| 749 |
+
% \label{Fig:7SeriesIntegrated:Generating:7SeriesIntegratedTabExtCapabilities2}
|
| 750 |
+
% \end{figure}
|
| 751 |
+
% \begin{figure}[H]
|
| 752 |
+
% \includegraphics[width=350px,center]{7SeriesIntegratedTabTLSettings.png}
|
| 753 |
+
% \label{Fig:7SeriesIntegrated:Generating:7SeriesIntegratedTabTLSettings}
|
| 754 |
+
% \end{figure}
|
| 755 |
+
% \begin{figure}[H]
|
| 756 |
+
% \includegraphics[width=350px,center]{7SeriesIntegratedTabDLPLSettings.png}
|
| 757 |
+
% \label{Fig:7SeriesIntegrated:Generating:7SeriesIntegratedTabDLPLSettings}
|
| 758 |
+
% \end{figure}
|
| 759 |
+
\begin{figure}[H]
|
| 760 |
+
\includegraphics[width=350px,center]{7SeriesIntegratedTabSharedLogic.png}
|
| 761 |
+
\caption{Shared Logic Tab}
|
| 762 |
+
\label{Fig:7SeriesIntegrated:Generating:7SeriesIntegratedTabSharedLogic}
|
| 763 |
+
\end{figure}
|
| 764 |
+
In the Shared Logic Tab shown in
|
| 765 |
+
Figure~\ref{Fig:7SeriesIntegrated:Generating:7SeriesIntegratedTabSharedLogic}
|
| 766 |
+
\ConfigSetting{clear} all of the checkboxes shown. These settings will not affect the core
|
| 767 |
+
generated, but will affect the example designs generated by Vivado. As a result,
|
| 768 |
+
the Example Design will mirror the RIFFA example design provided.
|
| 769 |
+
\begin{figure}[H]
|
| 770 |
+
\includegraphics[width=350px,center]{7SeriesIntegratedTabCoreInterfaceParameters.png}
|
| 771 |
+
\caption{Core Interface Parameters Tab}
|
| 772 |
+
\label{Fig:7SeriesIntegrated:Generating:7SeriesIntegratedTabInterfaceParameters}
|
| 773 |
+
\end{figure}
|
| 774 |
+
Finally, in the Interface Parameters tab, match the checkboxes shown in
|
| 775 |
+
Figure~\ref{Fig:7SeriesIntegrated:Generating:7SeriesIntegratedTabInterfaceParameters}. These
|
| 776 |
+
options simplify the interface to the generated core
|
| 777 |
+
|
| 778 |
+
\subsection{Creating Constraints files for the VC707 Development Board}
|
| 779 |
+
\label{Sec:7SeriesIntegrated:Generating:Constraints:VC707}
|
| 780 |
+
When generating a design for the VC707 board, the following constraints will
|
| 781 |
+
correctly constrain the clocks. When using a different board, read the user
|
| 782 |
+
guide for appropriate pin placment, or copy the constraints from the PCIe
|
| 783 |
+
Endpoint Example Design. The remaining constraints are contained the generated PCIe IP.
|
| 784 |
+
\begin{lstlisting}[basicstyle=\footnotesize\ttfamily,language=tcl,
|
| 785 |
+
commentstyle=\color{red},label=Listing:7SeriesIntegrated:Generating:Constraints:VC707,
|
| 786 |
+
caption=\Xilinx{.xdc} constraints for the VC707 board,frame=single]
|
| 787 |
+
set_property PACKAGE_PIN AV35 [get_ports PCIE_RESET_N]
|
| 788 |
+
set_property IOSTANDARD LVCMOS18 [get_ports PCIE_RESET_N]
|
| 789 |
+
set_property PULLUP true [get_ports PCIE_RESET_N]
|
| 790 |
+
# The following constraints are BOARD SPECIFIC. This is for the VC707
|
| 791 |
+
set_property LOC IBUFDS_GTE2_X1Y5 [get_cells refclk_ibuf]
|
| 792 |
+
create_clock -period 10.000 -name pcie_refclk [get_pins refclk_ibuf/O]
|
| 793 |
+
set_false_path -from [get_ports PCIE_RESET_N]
|
| 794 |
+
\end{lstlisting}
|
| 795 |
+
|
| 796 |
+
\subsection{Creating Constraints files for the ZC706 Development Board}
|
| 797 |
+
\label{Sec:7SeriesIntegrated:Generating:Constraints:ZC706}
|
| 798 |
+
When generating a design for the ZC706 board, the following constraints will
|
| 799 |
+
correctly constrain the clocks. When using a different board, read the user
|
| 800 |
+
guide for appropriate pin placment, or copy the constraints from the PCIe
|
| 801 |
+
Endpoint Example Design. The remaining constraints are contained the generated PCIe IP.
|
| 802 |
+
\begin{lstlisting}[basicstyle=\footnotesize\ttfamily,language=tcl,
|
| 803 |
+
commentstyle=\color{red},label=Listing:7SeriesIntegrated:Generating:Constraints:ZC706,
|
| 804 |
+
caption=\Xilinx{.xdc} constraints for the ZC706 board,frame=single]
|
| 805 |
+
set_property IOSTANDARD LVCMOS15 [get_ports PCIE_RESET_N]
|
| 806 |
+
set_property PACKAGE_PIN AK23 [get_ports PCIE_RESET_N]
|
| 807 |
+
set_property PULLUP true [get_ports PCIE_RESET_N]
|
| 808 |
+
# The following constraints are BOARD SPECIFIC. This is for the ZC706
|
| 809 |
+
set_property LOC IBUFDS_GTE2_X0Y6 [get_cells refclk_ibuf]
|
| 810 |
+
create_clock -period 10.000 -name pcie_refclk [get_pins refclk_ibuf/O]
|
| 811 |
+
set_false_path -from [get_ports PCIE_RESET_N]
|
| 812 |
+
\end{lstlisting}
|
| 813 |
+
|
| 814 |
+
|
| 815 |
+
\pagebreak
|
| 816 |
+
\section{Ultrascale - Gen3 Integrated Block for PCI Express - (VC709 and newer)}
|
| 817 |
+
This is a step by step guide for building a RIFFA \RIFFAVer~reference design for
|
| 818 |
+
Xilinx FPGA's compatible with the Gen3 Integrated Block for PCI Express. In
|
| 819 |
+
RIFFA \RIFFAVer~there are three example designs for the VC709 board in the
|
| 820 |
+
\Directory{RIFFA \RIFFAVer/source/fpga/vc709} directory:
|
| 821 |
+
\VCSevenOhNineExampleDesignsLong. To use one of these example designs, follow
|
| 822 |
+
the instructions below.
|
| 823 |
+
|
| 824 |
+
\subsection{VC709 Example Designs}
|
| 825 |
+
\label{Sec:Gen3Integrated:ExampleDesign}
|
| 826 |
+
\begin{enumerate}
|
| 827 |
+
\item Open Vivado to get the introductory screen shown in
|
| 828 |
+
Figure~\ref{Fig:Vivado:WelcomeScreen}.
|
| 829 |
+
\item Click 'Open an Existing Project' and navigate to your RIFFA
|
| 830 |
+
\RIFFAVer~directory.
|
| 831 |
+
\item In the RIFFA \RIFFAVer~distribution, open \Directory{RIFFA
|
| 832 |
+
\RIFFAVer/source/fpga/xilinx/vc709/} and choose from one of the existing
|
| 833 |
+
example design directories for your board. In the example design directory,
|
| 834 |
+
locate the \Directory{prj} folder and open it. Select the .xpr file and click
|
| 835 |
+
open. This will open the example project, as shown in
|
| 836 |
+
Figure~\ref{Fig:Gen3Integrated:ExampleDesign:ProjectOpened}.
|
| 837 |
+
\item This project was compiled in Vivado \VivadoVer. The bit file generated can
|
| 838 |
+
be used to test the FPGA system. If you are using a newer version of Vivado,
|
| 839 |
+
recompile the example design or use the programming file provided.
|
| 840 |
+
\begin{itemize}
|
| 841 |
+
\item IP Settings are now packaged as part of the example designs! Users no
|
| 842 |
+
longer need to generate IP.
|
| 843 |
+
\item To recompile the example design, click the generate bitstream button in
|
| 844 |
+
the top left corner as shown in
|
| 845 |
+
Figure~\ref{Fig:Gen3Integrated:ExampleDesign:ProjectOpened}.
|
| 846 |
+
\item Recompiling your design will generate a new bitfile in the Xilinx
|
| 847 |
+
project. The bit file in the \Directory{bit} will not be changed.
|
| 848 |
+
\end{itemize}
|
| 849 |
+
\item To program the FPGA, click 'Open Hardware Manager'. New bit files
|
| 850 |
+
(generated by Vivado) will appear in the Vivado generated directories. An
|
| 851 |
+
example bit file is provided in the example design's \Directory{bit}. Load the
|
| 852 |
+
bitstream to your VC709 board and restart your computer.
|
| 853 |
+
\begin{itemize}
|
| 854 |
+
\item Before programming your FPGA, you should install the RIFFA driver. See
|
| 855 |
+
Section~\ref{Sec:RIFFA:Installation}
|
| 856 |
+
\end{itemize}
|
| 857 |
+
\item The example design uses the chnl\_tester (shown in
|
| 858 |
+
Figure~\ref{Fig:Vivado:ExampleDesign:chnl_tester}, which works with
|
| 859 |
+
the example software in the \Directory{source/\{C\_C++,Java,python,matlab\}}
|
| 860 |
+
directories. Replace the chnl\_tester instantiation with any user logic,
|
| 861 |
+
matching the RIFFA interface.
|
| 862 |
+
\item Recompile the design and program the FPGA Device. Changing the
|
| 863 |
+
\RIFFAParameter{C\_NUM\_CHNL} will change the number of independent channel
|
| 864 |
+
interfaces
|
| 865 |
+
\end{enumerate}
|
| 866 |
+
\begin{figure}
|
| 867 |
+
\includegraphics[width=300px,center]{Gen3IntegratedOpenProject.png}
|
| 868 |
+
\caption{Project Splash Screen for Gen3 Integrated Block for PCI Express Projects}
|
| 869 |
+
\label{Fig:Gen3Integrated:ExampleDesign:ProjectOpened}
|
| 870 |
+
\end{figure}
|
| 871 |
+
\subsection{Generating the Gen3 Integrated Block for PCI Express}
|
| 872 |
+
\label{Sec:Gen3Integrated:Generating}
|
| 873 |
+
The following steps are not required for general users. See the instructions
|
| 874 |
+
above for how to compile RIFFA.
|
| 875 |
+
|
| 876 |
+
Alternatively, it is possible to generate the PCIe Endpoint with different
|
| 877 |
+
settings than those provided in the example design. Changing the endpoint
|
| 878 |
+
settings is required when changing the parameters
|
| 879 |
+
\RIFFAParameter{C\_PCI\_DATA\_WIDTH}, \RIFFAParameter{C\_MAX\_PAYLOAD\_BYTES}
|
| 880 |
+
and \RIFFAParameter{C\_LOG\_NUM\_TAGS}. The \RIFFAParameter{C\_NUM\_LANES} is a
|
| 881 |
+
parameter in the top level file of each example project. How these parameters
|
| 882 |
+
relate to IP core settings is highlighted in the following figures.
|
| 883 |
+
|
| 884 |
+
If the goal is to generate a RIFFA design completely from scratch, each board
|
| 885 |
+
directory comes with a RIFFA wrapper verilog file and instantiates a
|
| 886 |
+
vendor-specific translation layer. It is highly recommended to re-use these
|
| 887 |
+
files RIFFA wrapper when creating designs from scratch.
|
| 888 |
+
|
| 889 |
+
To generate the PCIe IP select the 7 Series Integrated Block for PCI Express
|
| 890 |
+
after selecting the IP Catalog shown in
|
| 891 |
+
Figure~\ref{Fig:Gen3Integrated:ExampleDesign:ProjectOpened}. This will open the
|
| 892 |
+
IP Customization window as shown in
|
| 893 |
+
Figure~\ref{Fig:Gen3Integrated:Generating:Gen3IntegratedTabBasic}
|
| 894 |
+
|
| 895 |
+
\begin{figure}[H]
|
| 896 |
+
\includegraphics[width=\figurewidth,center]{Gen3IntegratedTabBasic.png}
|
| 897 |
+
\caption{Basic settings tab.}
|
| 898 |
+
\label{Fig:Gen3Integrated:Generating:Gen3IntegratedTabBasic}
|
| 899 |
+
\end{figure}
|
| 900 |
+
First, select ``ADVANCED'' from the drop down menu. This will cause more tabs to
|
| 901 |
+
appear in the bar. The following tabs are not used during customization: MSIx Cap (Capabilities),
|
| 902 |
+
Extd. Capabilities 1, and Extd Capabilites 2.
|
| 903 |
+
|
| 904 |
+
In this example, we have set the \ConfigSetting{Xilinx Development Board} to
|
| 905 |
+
\ConfigSetting{VC709}, and selected the PCIe Gen1 rate of \ConfigSetting{2.5
|
| 906 |
+
GT/s}, and a Lane Width of 8 (\RIFFAParameter{C\_NUM\_LANES} = 8). We have
|
| 907 |
+
chosen to set the \ConfigSetting{AXI Interface Width} to \ConfigSetting{64-bits}
|
| 908 |
+
(\RIFFAParameter{C\_PCI\_DATA\_WIDTH} = 64). Finally Clear the
|
| 909 |
+
\ConfigSetting{Disable Client Tag} and \ConfigSetting{PCIe DRP Ports} boxes. The
|
| 910 |
+
choice of \ConfigSetting{Link Rate}, \ConfigSetting{Lanes}, and
|
| 911 |
+
\ConfigSetting{Interface Width} will allow different AXI Interface Frequencies
|
| 912 |
+
to be selected. The RIFFA core will run at this clock frequency, but the user
|
| 913 |
+
logic can run at whatever frequency it desires.
|
| 914 |
+
|
| 915 |
+
Optional: Set the Component Name of the PCI Express block, and the IP
|
| 916 |
+
Location. In our example projects, we use the name template
|
| 917 |
+
PCIeGen\textbf{W}x\textbf{Y}If\textbf{Z} where \textbf{W} is the PCI Express
|
| 918 |
+
Version (\ConfigSetting{Link Speed} in
|
| 919 |
+
Figure~\ref{Fig:Gen3Integrated:Generating:Gen3IntegratedTabBasic}),
|
| 920 |
+
\textbf{Y} is the lane width, and \textbf{Z} is the AXI interface width. The IP
|
| 921 |
+
location is the \Directory{ip} directory in the example project.
|
| 922 |
+
|
| 923 |
+
Note: For RIFFA \RIFFAVer~the 256-bit interface is not supported, however the
|
| 924 |
+
128-bit interface is. This means PCIe Gen2 with 8 lanes, and PCIe Gen3 with 4
|
| 925 |
+
lanes are both supported.
|
| 926 |
+
|
| 927 |
+
\begin{figure}[H]
|
| 928 |
+
\includegraphics[width=350px,center]{Gen3IntegratedTabCapabilities.png}
|
| 929 |
+
\caption{PCI Express Capabilities Tab.}
|
| 930 |
+
\label{Fig:Gen3Integrated:Generating:Gen3IntegratedTabCapabilities}
|
| 931 |
+
\end{figure}
|
| 932 |
+
In the Capabilities tab shown in
|
| 933 |
+
Figure~\ref{Fig:Gen3Integrated:Generating:Gen3IntegratedTabCapabilities} check
|
| 934 |
+
the \ConfigSetting{Extended Tag Field} box. If the \ConfigSetting{Extended Tag
|
| 935 |
+
Field} is selected \RIFFAParameter{C\_LOG\_NUM\_TAGS} = 8, otherwise
|
| 936 |
+
\RIFFAParameter{C\_LOG\_NUM\_TAGS} = 5. Set the \ConfigSetting{PFO Max Payload
|
| 937 |
+
Size} from the dropdown menu; Use this to set the RIFFA
|
| 938 |
+
\RIFFAParameter{C\_MAX\_PAYLOAD\_BYTES} parameter.
|
| 939 |
+
|
| 940 |
+
Note: Maximum Payload sizes are typically set by the BIOS, and 256 bytes seems
|
| 941 |
+
to be standard. RIFFA will default to the minimum of
|
| 942 |
+
\RIFFAParameter{C\_MAX\_PAYLOAD\_SIZE} and the setting in your BIOS. Unless your
|
| 943 |
+
BIOS is modified, or can support substantially larger packets, there will be no
|
| 944 |
+
performance benefit to increasing the payload size. Increasing the maximum
|
| 945 |
+
payload size will increase the resources consumed.
|
| 946 |
+
|
| 947 |
+
\begin{figure}[H]
|
| 948 |
+
\includegraphics[width=350px,center]{Gen3IntegratedTabPF0Ids.png}
|
| 949 |
+
\caption{PCI Express IDs Tab.}
|
| 950 |
+
\label{Fig:Gen3Integrated:Generating:Gen3IntegratedTabPF0Ids}
|
| 951 |
+
\end{figure}
|
| 952 |
+
The tab in Figure~\ref{Fig:Gen3Integrated:Generating:Gen3IntegratedTabPF0Ids}
|
| 953 |
+
is optional. Setting the Device ID may assist in identifying different FPGAs in
|
| 954 |
+
a multi-FPGA system. The other options, specifically the Vendor ID, must remain
|
| 955 |
+
the same.
|
| 956 |
+
\begin{figure}[H]
|
| 957 |
+
\includegraphics[width=350px,center]{Gen3IntegratedTabPF0Bar.png}
|
| 958 |
+
\caption{PCI Express Base Address Registers (BAR) Tab.}
|
| 959 |
+
\label{Fig:Gen3Integrated:Generating:Gen3IntegratedTabPF0Bar}
|
| 960 |
+
\end{figure}
|
| 961 |
+
The tab in Figure~\ref{Fig:Gen3Integrated:Generating:Gen3IntegratedTabPF0Bar}
|
| 962 |
+
must be configured so that BAR0 is \ConfigSetting{enabled}. Select type
|
| 963 |
+
\ConfigSetting{Memory}, and Unit \ConfigSetting{Kilobyte}, and
|
| 964 |
+
\ConfigSetting{Size Value} \ConfigSetting{1} from the dropdown menus. If these
|
| 965 |
+
values are not set correctly the RIFFA driver will not recognize the FPGA
|
| 966 |
+
device.
|
| 967 |
+
\begin{figure}[H]
|
| 968 |
+
\includegraphics[width=350px,center]{Gen3IntegratedTabLegacyMSICap.png}
|
| 969 |
+
\caption{PCI Express Legacy and MSI Interrupts Tab.}
|
| 970 |
+
\label{Fig:Gen3Integrated:Generating:Gen3IntegratedTabLegacyMSICap}
|
| 971 |
+
\end{figure}
|
| 972 |
+
In the Legacy/MSI Capabilites tab shown in
|
| 973 |
+
Figure~\ref{Fig:Gen3Integrated:Generating:Gen3IntegratedTabLegacyMSICap}, select
|
| 974 |
+
\ConfigSetting{None} in the \ConfigSetting{PFO Interrupt Pin Dropdown} menu and
|
| 975 |
+
set the \ConfigSetting{PFO Multiple Message Capable} dropdown menu to
|
| 976 |
+
\ConfigSetting{1 Vector}
|
| 977 |
+
% \begin{figure}[H]
|
| 978 |
+
% \includegraphics[width=350px,center]{Gen3IntegratedTabMSIxCap.png}
|
| 979 |
+
% \label{Fig:Gen3Integrated:Generating:Gen3IntegratedTabMSIxCap}
|
| 980 |
+
% \end{figure}
|
| 981 |
+
\begin{figure}[H]
|
| 982 |
+
\includegraphics[width=350px,center]{Gen3IntegratedTabPowerManagement.png}
|
| 983 |
+
\caption{PCI Express Power Management Tab.}
|
| 984 |
+
\label{Fig:Gen3Integrated:Generating:Gen3IntegratedTabPowerManagement}
|
| 985 |
+
\end{figure}
|
| 986 |
+
In the Power Management tab, shown in
|
| 987 |
+
Figure~\ref{Fig:Gen3Integrated:Generating:Gen3IntegratedTabPowerManagement},
|
| 988 |
+
ensure that the \ConfigSetting{Performance Level} is set to
|
| 989 |
+
\ConfigSetting{Extreme}.
|
| 990 |
+
% \begin{figure}[H]
|
| 991 |
+
% \includegraphics[width=350px,center]{Gen3IntegratedTabExtCapabilities1.png}
|
| 992 |
+
% \label{Fig:Gen3Integrated:Generating:Gen3IntegratedTabExtCapabilities1}
|
| 993 |
+
% \end{figure}
|
| 994 |
+
% \begin{figure}[H]
|
| 995 |
+
% \includegraphics[width=350px,center]{Gen3IntegratedTabExtCapabilities2.png}
|
| 996 |
+
% \label{Fig:Gen3Integrated:Generating:Gen3IntegratedTabExtCapabilities2}
|
| 997 |
+
% \end{figure}
|
| 998 |
+
\begin{figure}[H]
|
| 999 |
+
\includegraphics[width=350px,center]{Gen3IntegratedTabSharedLogic.png}
|
| 1000 |
+
\caption{PCI Express Shared Logic Tab.}
|
| 1001 |
+
\label{Fig:Gen3Integrated:Generating:Gen3IntegratedTabSharedLogic}
|
| 1002 |
+
\end{figure}
|
| 1003 |
+
In the Shared Logic Tab shown in
|
| 1004 |
+
Figure~\ref{Fig:Gen3Integrated:Generating:Gen3IntegratedTabSharedLogic}
|
| 1005 |
+
\ConfigSetting{clear} all of the checkboxes shown. These settings will not
|
| 1006 |
+
affect the core generated, but will affect the example designs generated by the
|
| 1007 |
+
Vivado, and make the Vivado example design mirror the RIFFA Example design.
|
| 1008 |
+
\begin{figure}[H]
|
| 1009 |
+
\includegraphics[width=350px,center]{Gen3IntegratedTabCoreInterfaceParameters.png}
|
| 1010 |
+
\caption{PCI Express Core Interface Parameters Tab.}
|
| 1011 |
+
\label{Fig:Gen3Integrated:Generating:Gen3IntegratedTabCoreInterfaceParameters}
|
| 1012 |
+
\end{figure}
|
| 1013 |
+
Finally, in the Interface Parameters tab, match the checkboxes shown in
|
| 1014 |
+
Figure~\ref{Fig:Gen3Integrated:Generating:Gen3IntegratedTabCoreInterfaceParameters}. These
|
| 1015 |
+
options simplify the interface to the generated core
|
| 1016 |
+
\subsection{Creating Constraints files for the VC709 Development Board}
|
| 1017 |
+
\label{Sec:Gen3Integrated:Generating:Constraints}
|
| 1018 |
+
When generating a design for the VC709 board, the following constraints will
|
| 1019 |
+
correctly constrain the clocks. When using a different board, read the user
|
| 1020 |
+
guide for appropriate pin placment, or copy the constraints from the PCIe
|
| 1021 |
+
Endpoint Example Design.
|
| 1022 |
+
\begin{lstlisting}[basicstyle=\footnotesize\ttfamily,language=tcl,
|
| 1023 |
+
commentstyle=\color{red},label=Listing:7SeriesIntegrated:Generating:Constraints:VC709,
|
| 1024 |
+
caption=\Xilinx{.xdc} constraints for the VC709 board,frame=single]
|
| 1025 |
+
create_clock -period 10.000 -name pcie_refclk [get_pins refclk_ibuf/O]
|
| 1026 |
+
set_false_path -from [get_ports PCIE_RESET_N]
|
| 1027 |
+
|
| 1028 |
+
# The following constraints are BOARD SPECIFIC. This is for the VC709
|
| 1029 |
+
set_property LOC IBUFDS_GTE2_X1Y11 [get_cells refclk_ibuf]
|
| 1030 |
+
set_property PACKAGE_PIN AV35 [get_ports PCIE_RESET_N]
|
| 1031 |
+
set_property IOSTANDARD LVCMOS18 [get_ports PCIE_RESET_N]
|
| 1032 |
+
set_property PULLUP true [get_ports PCIE_RESET_N]
|
| 1033 |
+
\end{lstlisting}
|
| 1034 |
+
|
| 1035 |
+
\pagebreak
|
| 1036 |
+
\chapter{Compiling and using the Altera Example Designs}
|
| 1037 |
+
\label{Chap:Altera}
|
| 1038 |
+
This section describes how to use RIFFA \RIFFAVer~ with Quartus \QuartusVer. The
|
| 1039 |
+
example projects included in this distribution target Terasic DE5Net and DE4
|
| 1040 |
+
boards. We are confident that RIFFA will work on all currently supported Altera
|
| 1041 |
+
devices using the Hard IP for PCI Express (Cyclone V, Arria V and Stratix V)
|
| 1042 |
+
devices, as well as all devices using IP Compiler for PCI Express (Stratix IV
|
| 1043 |
+
and prior). For device support in Quartus \QuartusVer
|
| 1044 |
+
see \footnote{http://dl.altera.com/devices/}
|
| 1045 |
+
|
| 1046 |
+
The FPGA families that we have successfully tested RIFFA \RIFFAVer~are:
|
| 1047 |
+
\begin{itemize}
|
| 1048 |
+
\item Stratix V (DE5-Net)
|
| 1049 |
+
\item Stratix IV (DE4)
|
| 1050 |
+
%\item Cyclone IV (DE2i-150)
|
| 1051 |
+
\end{itemize}
|
| 1052 |
+
There are three options for starting a new RIFFA project:
|
| 1053 |
+
\begin{itemize}
|
| 1054 |
+
\item For first-time users with a DE5 board, we recommend the archived projects
|
| 1055 |
+
provided in the \Directory{RIFFA \RIFFAVer/source/fpga/de5\_qsys} directory. Follow the
|
| 1056 |
+
instructions in Section~\ref{Sec:Altera:QsysMegawizard:Qsys}
|
| 1057 |
+
\item Intermediate and advanced users, or users with a DE4 board, we have
|
| 1058 |
+
provided projects without instantiated IP. For DE5 boards, follow the
|
| 1059 |
+
instructions in Section~\ref{Sec:Altera:QsysMegawizard:Megawizard}. For DE4 boards, follow
|
| 1060 |
+
the instructions in Section~\ref{Sec:Altera:IPCompiler}
|
| 1061 |
+
\item For advanced users, or users wishing to support a new board, we provide
|
| 1062 |
+
full instructions for creating a top level and generating IP. Follow the
|
| 1063 |
+
instructions in Section~\ref{Sec:Altera:QsysMegawizard}
|
| 1064 |
+
\end{itemize}
|
| 1065 |
+
|
| 1066 |
+
\section{Example Designs with Qsys and MegaWizard (Stratix V, Cyclone V and newer)}
|
| 1067 |
+
\label{Sec:Altera:QsysMegawizard}
|
| 1068 |
+
\subsection{Qsys (Stratix V and newer)}
|
| 1069 |
+
\label{Sec:Altera:QsysMegawizard:Qsys}
|
| 1070 |
+
For first-time users with the DE5-Net board, copy one of the archived projects
|
| 1071 |
+
(.qar files) available in the \Directory{de5\_qsys} directory.
|
| 1072 |
+
|
| 1073 |
+
\begin{enumerate}
|
| 1074 |
+
\item Open Quartus to get the introductory screen shown in
|
| 1075 |
+
Figure~\ref{Fig:Quartus:WelcomeScreen}.
|
| 1076 |
+
\item Click 'Open an Existing Project' and navigate to your RIFFA
|
| 1077 |
+
\RIFFAVer~directory.
|
| 1078 |
+
\item In the RIFFA \RIFFAVer~distribution, open \Directory{RIFFA
|
| 1079 |
+
\RIFFAVer/source/fpga/de4/} and choose from one of the existing example design
|
| 1080 |
+
directories for your board. In the example design directory, locate the
|
| 1081 |
+
\Directory{prj} folder and open it. Select the .qpf file and click open. This
|
| 1082 |
+
will open the example project, as shown in
|
| 1083 |
+
Figure~\ref{Fig:Quartus:ExampleDesign:ProjectOpened}.
|
| 1084 |
+
\item This project was compiled in Quartus \QuartusVer. The bit file generated
|
| 1085 |
+
can be used to test the FPGA system. If you are using a newer version of
|
| 1086 |
+
Quartus, recompile the example design or use the programming file provided.
|
| 1087 |
+
\begin{itemize}
|
| 1088 |
+
\item To recompile the example design, click the compile button in the top
|
| 1089 |
+
left corner as shown in
|
| 1090 |
+
Figure~\ref{Fig:Quartus:ExampleDesign:ProjectOpened}.
|
| 1091 |
+
\item Recompiling your design will generate a new bitfile in the
|
| 1092 |
+
\Directory{prj} directory. The bit file in the \Directory{bit} will not be
|
| 1093 |
+
changed.
|
| 1094 |
+
\end{itemize}
|
| 1095 |
+
\item To program the FPGA, click 'Open Programmer'. New bit files (generated by
|
| 1096 |
+
Quartus) will appear in the \Directory{prj/output\_files/} directory. An example
|
| 1097 |
+
bit file is provided in the example design's \Directory{bit} directory.
|
| 1098 |
+
\begin{itemize}
|
| 1099 |
+
\item Before programming your FPGA, you should install the RIFFA driver. See
|
| 1100 |
+
Section~\ref{Sec:RIFFA:Installation}
|
| 1101 |
+
\end{itemize}
|
| 1102 |
+
\item The example design uses the chnl\_tester (shown in
|
| 1103 |
+
Figure~\ref{Fig:Quartus:ExampleDesign:chnl_tester}, which works with
|
| 1104 |
+
the example software in the \Directory{source/\{C\_C++,Java,python,matlab\}}
|
| 1105 |
+
directories. Replace the chnl\_tester instantiation with any user logic,
|
| 1106 |
+
matching the RIFFA interface.
|
| 1107 |
+
\item Recompile the design and program the FPGA Device. Changing the
|
| 1108 |
+
\RIFFAParameter{C\_NUM\_CHNL} will change the number of independent channel
|
| 1109 |
+
interfaces
|
| 1110 |
+
\end{enumerate}
|
| 1111 |
+
\begin{figure}
|
| 1112 |
+
\includegraphics[width=300px,center]{QuartusWelcomeScreen.png}
|
| 1113 |
+
\caption{Welcome Screen for Quartus \QuartusVer}
|
| 1114 |
+
\label{Fig:Quartus:WelcomeScreen}
|
| 1115 |
+
\end{figure}
|
| 1116 |
+
\begin{figure}
|
| 1117 |
+
\includegraphics[width=300px,center]{IPCompileOpenProject.png}
|
| 1118 |
+
\caption{Project Splash Screen for Quartus Projects}
|
| 1119 |
+
\label{Fig:Quartus:ExampleDesign:ProjectOpened}
|
| 1120 |
+
\end{figure}
|
| 1121 |
+
\begin{figure}
|
| 1122 |
+
\includegraphics[width=300px,trim=400 200 300 200, clip=true,center]{QuartusChnlTesterInstantiation.png}
|
| 1123 |
+
\caption{chnl\_tester instantiation in the top level file}
|
| 1124 |
+
\label{Fig:Quartus:ExampleDesign:chnl_tester}
|
| 1125 |
+
\end{figure}
|
| 1126 |
+
|
| 1127 |
+
\subsection{Generating IP using MegaWizard (Stratix V, Cyclone V and newer)}
|
| 1128 |
+
\label{Sec:Altera:QsysMegawizard:Megawizard}
|
| 1129 |
+
In some cases, it may be necessary to generate the PCIe Endpoint IP. For
|
| 1130 |
+
intermediate users, there are project example projects inside of the
|
| 1131 |
+
\Directory{de5} directory without instantiated IP (This is done to avoid
|
| 1132 |
+
licensing problems). For the DE5, the project directories are: DE5Gen1x8If64,
|
| 1133 |
+
DE5Gen2x8If128, DE5Gen3x4If128.
|
| 1134 |
+
|
| 1135 |
+
Modifying the RIFFA parameters \RIFFAParameter{C\_PCI\_DATA\_WIDTH},
|
| 1136 |
+
\RIFFAParameter{C\_MAX\_PAYLOAD\_BYTES} and \RIFFAParameter{C\_LOG\_NUM\_TAGS}
|
| 1137 |
+
require changing certain settings in the IP core file. The paramter
|
| 1138 |
+
\RIFFAParameter{C\_NUM\_LANES} is located in the top level file of each example
|
| 1139 |
+
project. How these parameters relate to IP core settings is highlighted in the
|
| 1140 |
+
following figures.
|
| 1141 |
+
|
| 1142 |
+
For advanced users whose goal is to generate a RIFFA design completely from
|
| 1143 |
+
scratch, we provide instructions for generating the timing constraints and other
|
| 1144 |
+
low level details. Each board directory contains with a RIFFA wrapper verilog
|
| 1145 |
+
file and instantiates a vendor-specific translation layer. It is highly
|
| 1146 |
+
recommended to re-use these files RIFFA wrapper when creating designs from
|
| 1147 |
+
scratch. Users should also use the constraints file (\Altera{.sdc}) in the board
|
| 1148 |
+
directory, and in the \Directory{constr/}, or read the User Guide provided with
|
| 1149 |
+
each board and the instructions for generating constratints in
|
| 1150 |
+
Section~\ref{Sec:Altera:QsysMegawizard:Constraints}.
|
| 1151 |
+
|
| 1152 |
+
As stated in Section~\ref{Sec:Intro:Decoding}, each project directory contains five folders.
|
| 1153 |
+
\begin{itemize}
|
| 1154 |
+
\item The \Directory{prj/} directory contains the project \Altera{.qpf} and \Altera{.qsf} file.
|
| 1155 |
+
\item The \Directory{hdl/} contains the top level file, e.g. DE5Gen2x8If128.v, which instantiates the skeleton IP and the RIFFA Core.
|
| 1156 |
+
\item The \Directory{ip/} directory is empty but will contain Altera IP generated by Quartus
|
| 1157 |
+
in the following guide.
|
| 1158 |
+
\item The \Directory{constr/} directory contains project-specific timing constraint files.
|
| 1159 |
+
\item Finally the \Directory{bit/} directory contains the project .sof, or bit
|
| 1160 |
+
file that we have tested. This bitfile will not be overwritten by subsequent Quartus compilations.
|
| 1161 |
+
\end{itemize}
|
| 1162 |
+
|
| 1163 |
+
Note: The bitfile in the bit directory is not modified by recompilation in
|
| 1164 |
+
Quartus. Quartus will generate a new bitfile (.sof) in the \Directory{prj/}
|
| 1165 |
+
directory for the DE5Net board.
|
| 1166 |
+
|
| 1167 |
+
\begin{figure}[H]
|
| 1168 |
+
\includegraphics[width=350px,center]{QsysPCIExpSystemTrim.png}
|
| 1169 |
+
\caption{Qsys Diagram depicting the connections between the three Altera IP blocks.}
|
| 1170 |
+
\label{Fig:Altera:QsysMegawizard:Megawizard:QsysPCIExpSystemTrim}
|
| 1171 |
+
\end{figure}
|
| 1172 |
+
|
| 1173 |
+
Altera designs require additional IP to drive the PCIe Core Transcievers. For the
|
| 1174 |
+
DE5, these blocks are the Transciever Reconfiguration Controller and the
|
| 1175 |
+
Reconfiguration Driver. When creating a new top level design, these blocks must be
|
| 1176 |
+
connected together with the PCIe Endpoint as shown in
|
| 1177 |
+
Figure~\ref{Fig:Altera:QsysMegawizard:Megawizard:QsysPCIExpSystemTrim}.
|
| 1178 |
+
|
| 1179 |
+
First, we will generate the PCIe Endpoint. Click on the Avalon Streaming
|
| 1180 |
+
Interface for PCI Express in the Quartus IP Catalog.
|
| 1181 |
+
Figure~\ref{Fig:Altera:IPCompiler:PCIeSystemSettingsTab}.
|
| 1182 |
+
|
| 1183 |
+
Optional: Set the Component Name of the PCI Express block, and the IP
|
| 1184 |
+
Location. In our example projects, we typically use the name
|
| 1185 |
+
PCIeGen\textbf{W}x\textbf{Y}If\textbf{Z} where \textbf{W} is the PCI Express
|
| 1186 |
+
Version (\ConfigSetting{Link Speed} in
|
| 1187 |
+
Figure~\ref{Fig:Gen3Integrated:Generating:Gen3IntegratedTabBasic}), \textbf{Y}
|
| 1188 |
+
is the lane width, and \textbf{Z} is the Avalon interface width. The IP location
|
| 1189 |
+
is the \Directory{ip/} directory in the example project.
|
| 1190 |
+
|
| 1191 |
+
\begin{figure}[H]
|
| 1192 |
+
\includegraphics[width=350px,center]{PCIExpressEndpoint1Trim.png}
|
| 1193 |
+
\caption{PCI Express Endpoint Configuration Menu}
|
| 1194 |
+
\label{Fig:Altera:QsysMegawizard:Megawizard:PCIExpressEndpoint1Trim}
|
| 1195 |
+
\end{figure}
|
| 1196 |
+
|
| 1197 |
+
In Figure~\ref{Fig:Altera:QsysMegawizard:Megawizard:PCIExpressEndpoint1Trim},
|
| 1198 |
+
select the \ConfigSetting{Number of Lanes}, which corresponds to the top level
|
| 1199 |
+
parameter \RIFFAParameter{C\_NUM\_LANES}, \ConfigSetting{Lane Rate}, and
|
| 1200 |
+
\ConfigSetting{PCI Express Base Specification} version from the dropdown menus
|
| 1201 |
+
(Choose the highest possible base specification version). Select an
|
| 1202 |
+
\ConfigSetting{Application Interface Width}; This corresponds to the
|
| 1203 |
+
\RIFFAParameter{C\_PCI\_DATA\_WIDTH} parameter in RIFFA. Currently the
|
| 1204 |
+
\ConfigSetting{64-bit} and \ConfigSetting{128-bit} interfaces are supported for
|
| 1205 |
+
all Altera designs. Some widths may not be possible depending on the
|
| 1206 |
+
\ConfigSetting{Lane Rate} and \ConfigSetting{Number of Lanes} selected.
|
| 1207 |
+
|
| 1208 |
+
The choice of \ConfigSetting{Link Rate}, \ConfigSetting{Number of Lanes}, and
|
| 1209 |
+
\ConfigSetting{Interface Width} will set the frequency for the PCI interface,
|
| 1210 |
+
which is clocked by the pld\_clk signal. For the chosen settings, the frequency
|
| 1211 |
+
should be displayed in the messages bar at the bottom of the configuration menu
|
| 1212 |
+
(Messages bar not shown). The RIFFA core will run at this clock frequency, but the
|
| 1213 |
+
user logic can run at whatever frequency it desires.
|
| 1214 |
+
|
| 1215 |
+
In the Base Address Registers Section set BAR0's type to \ConfigSetting{32-bit
|
| 1216 |
+
non-prefetchable memory} and set the size to \ConfigSetting{1 KByte - 10 Bits}.
|
| 1217 |
+
|
| 1218 |
+
There are no required changes in the Device Identification Registers
|
| 1219 |
+
Section. However, in a multiple FPGA system, it may be useful to change the
|
| 1220 |
+
\ConfigSetting{Device ID} to allow identification of different FPGA
|
| 1221 |
+
platforms. The other options, specifically the \ConfigSetting{Vendor ID}, must
|
| 1222 |
+
remain the same.
|
| 1223 |
+
|
| 1224 |
+
Scroll down to view the final two sections shown in
|
| 1225 |
+
Figure~\ref{Fig:Altera:QsysMegawizard:Megawizard:PCIExpressEndpoint2Trim}.
|
| 1226 |
+
\begin{figure}[H]
|
| 1227 |
+
\includegraphics[width=350px,trim=0 0 0 620, clip=true,center]{PCIExpressEndpoint2Trim.png}
|
| 1228 |
+
\caption{PCI Express Endpoint Configuration Menu}
|
| 1229 |
+
\label{Fig:Altera:QsysMegawizard:Megawizard:PCIExpressEndpoint2Trim}
|
| 1230 |
+
\end{figure}
|
| 1231 |
+
In the PCI Express/PCI Capabilities menu, set your desired
|
| 1232 |
+
\ConfigSetting{Maximum Payload Size}, which corresponds to the RIFFA parameter,
|
| 1233 |
+
\RIFFAParameter{C\_MAX\_PAYLOAD\_BYTES} and the \ConfigSetting{Number of Tags
|
| 1234 |
+
Supported}. The log of the \ConfigSetting{Number of Tags Supported} is
|
| 1235 |
+
the \RIFFAParameter{C\_LOG\_NUM\_TAGS} parameter in RIFFA.
|
| 1236 |
+
|
| 1237 |
+
In the MSI Tab, make sure that the number of MSI messages requested is equal to
|
| 1238 |
+
1.
|
| 1239 |
+
|
| 1240 |
+
Note: Maximum Payload sizes are typically set by the BIOS, and 256 bytes seems
|
| 1241 |
+
to be standard. RIFFA will default to the minimum setting
|
| 1242 |
+
\RIFFAParameter{C\_MAX\_PAYLOAD\_SIZE} and the setting in your BIOS. Unless your
|
| 1243 |
+
BIOS is modified, or can support substantially larger packets, there will be no
|
| 1244 |
+
performance benefit to increasing the payload size. Increasing the
|
| 1245 |
+
\ConfigSetting{Maximum Payload Size} will increase the resources consumed.
|
| 1246 |
+
|
| 1247 |
+
Finally, record the number of \ConfigSetting{Transciever Reconfiguration
|
| 1248 |
+
Interfaces} in the messages bar at the bottom of the screen, then close the
|
| 1249 |
+
PCIe IP Generation Menu. A window may ask if you wish to generate the example
|
| 1250 |
+
design. This is optional.
|
| 1251 |
+
\begin{figure}[H]
|
| 1252 |
+
\includegraphics[width=350px,center]{XCVRMenuTrim.png}
|
| 1253 |
+
\caption{Transciever Reconfiguration IP Generation Menu}
|
| 1254 |
+
\label{Fig:Altera:QsysMegawizard:Megawizard:XCVRMenuTrim}
|
| 1255 |
+
\end{figure}
|
| 1256 |
+
Next, generate the Transceiver Reconfiguration Controller by opening MegaWizard
|
| 1257 |
+
and selecting the Transceiver Reconfiguration Controller megafunction.
|
| 1258 |
+
|
| 1259 |
+
Set the appropriate number of \ConfigSetting{Transciever Reconfiguration
|
| 1260 |
+
Interfaces} in the Interface Bundles Menu. In the analog features section,
|
| 1261 |
+
\ConfigSetting{Enable Analog Controls} and \ConfigSetting{Enable Adaptive
|
| 1262 |
+
Equalization} block by clicking the appropriate boxes.
|
| 1263 |
+
|
| 1264 |
+
Optional: Set the Component Name of the Transciever Reconfiguration Controller, and the IP
|
| 1265 |
+
Location. In our example projects, we typically use the name
|
| 1266 |
+
XCVRCtrlGen\ConfigSetting{W}x\ConfigSetting{Y} where \ConfigSetting{W} is the \ConfigSetting{PCI Express Version}
|
| 1267 |
+
(\ConfigSetting{Link Speed} in
|
| 1268 |
+
Figure~\ref{Fig:Altera:QsysMegawizard:Megawizard:PCIExpressEndpoint1Trim}), \ConfigSetting{Y}
|
| 1269 |
+
is the lane width. The IP location is the \Directory{ip/} directory in the
|
| 1270 |
+
example project.
|
| 1271 |
+
|
| 1272 |
+
\begin{figure}[H]
|
| 1273 |
+
\includegraphics[width=350px,center]{ReconfigDriverMenu.png}
|
| 1274 |
+
\caption{Transciever Reconfiguration Driver Menu}
|
| 1275 |
+
\label{Fig:Altera:QsysMegawizard:Megawizard:ReconfigDriverMenu}
|
| 1276 |
+
\end{figure}
|
| 1277 |
+
|
| 1278 |
+
In Qsys, generate the Transciver Reconfiguration Controller. Select the
|
| 1279 |
+
appropriate lane rate for your design, and the number of Reconfiguration
|
| 1280 |
+
Intefaces. These should match the number of reconfiguration interfaces dictated
|
| 1281 |
+
when generating the PCIe IP in
|
| 1282 |
+
Figure~\ref{Fig:Altera:QsysMegawizard:Megawizard:PCIExpressEndpoint1Trim} and
|
| 1283 |
+
the number selected in
|
| 1284 |
+
Figure~\ref{Fig:Altera:QsysMegawizard:Megawizard:XCVRMenuTrim}.
|
| 1285 |
+
|
| 1286 |
+
Optional (in Qsys): Set the Component Name of the Transciever Reconfiguration
|
| 1287 |
+
Driver, and the IP Location. In our example projects, we typically use the name
|
| 1288 |
+
XCVRDrvGen\ConfigSetting{W}x\ConfigSetting{Y} where \ConfigSetting{W} is the
|
| 1289 |
+
\ConfigSetting{PCI Express Version} (\ConfigSetting{Link Speed} in
|
| 1290 |
+
Figure~\ref{Fig:Gen3Integrated:Generating:Gen3IntegratedTabBasic}), and
|
| 1291 |
+
\textbf{Y} is the lane width. The IP location is the \Directory{ip} directory in
|
| 1292 |
+
the example project.
|
| 1293 |
+
|
| 1294 |
+
If you are using Megawizard to instantiate IP, you must manually instantiate the
|
| 1295 |
+
Transciver Reconfiguration Driver in the Top Level design. The instantiation
|
| 1296 |
+
template is shown in
|
| 1297 |
+
Listing~\ref{Listing:Altera:QsysMegawizard:ManualDriverInst} into your top-level
|
| 1298 |
+
file. Match the PCIe generation, and chip generation for your project.
|
| 1299 |
+
\begin{lstlisting}[basicstyle=\footnotesize\ttfamily,language=Verilog,
|
| 1300 |
+
commentstyle=\color{red},label=Listing:Altera:QsysMegawizard:ManualDriverInst,
|
| 1301 |
+
caption=Manual (non-qsys) instantiation of Reconfiguration Driver,frame=single]
|
| 1302 |
+
altpcie_reconfig_driver
|
| 1303 |
+
#(
|
| 1304 |
+
/* These values should match the values used for the PCIe Endpoint */
|
| 1305 |
+
.number_of_reconfig_interfaces(10), /*Set This*/
|
| 1306 |
+
.gen123_lane_rate_mode_hwtcl(``Gen1 (2.5 Gbps)''), /*Set This*/
|
| 1307 |
+
.INTENDED_DEVICE_FAMILY(``Stratix V'')) /*Set This*/
|
| 1308 |
+
XCVRDriverGen2x8_inst
|
| 1309 |
+
(
|
| 1310 |
+
/*Ports Here -- Copy from Example Designs*/
|
| 1311 |
+
);
|
| 1312 |
+
\end{lstlisting}
|
| 1313 |
+
|
| 1314 |
+
\pagebreak
|
| 1315 |
+
\subsection{Creating Constraints files for MegaWizard and QSys Designs}
|
| 1316 |
+
\label{Sec:Altera:QsysMegawizard:Constraints}
|
| 1317 |
+
Advanced users may also want to edit and modify the constraint files. This not
|
| 1318 |
+
required or recommended for novice users. The example designs in the RIFFA
|
| 1319 |
+
\RIFFAVer~distribution contain appropriate constraint files for the example
|
| 1320 |
+
designs. However if the need arises, these constraints are documented below.
|
| 1321 |
+
|
| 1322 |
+
To appropriately constrain your PCIe reference clocks, place the constraints
|
| 1323 |
+
shown in Listing~\ref{Listing:Altera:QsysMegawizard:Constraints} in your
|
| 1324 |
+
\Altera{.sdc} file. Modify the names PCIE\_REFCLK, PCIE\_TX\_OUT and
|
| 1325 |
+
PCIE\_RX\_IN to match your design.
|
| 1326 |
+
\begin{lstlisting}[basicstyle=\footnotesize\ttfamily,language=tcl,
|
| 1327 |
+
commentstyle=\color{red},label=Listing:Altera:QsysMegawizard:Constraints,
|
| 1328 |
+
caption=\Altera{.sdc} constraints for Qsys and Megawizard designs,frame=single]
|
| 1329 |
+
create_clock -name PCIE_REFCLK -period 10.000 [get_ports {PCIE_REFCLK}]
|
| 1330 |
+
derive_pll_clocks -create_base_clocks
|
| 1331 |
+
derive_clock_uncertainty
|
| 1332 |
+
\end{lstlisting}
|
| 1333 |
+
Likewise, copy the constraints in
|
| 1334 |
+
Listing~\ref{Listing:Altera:QsysMegawizard:QSFSettings} into your .qsf file. Copy
|
| 1335 |
+
the location assignment commands for each PCIe Pin in your reference design.
|
| 1336 |
+
|
| 1337 |
+
\begin{lstlisting}[language=tcl,basicstyle=\footnotesize\ttfamily,commentstyle=\color{red},
|
| 1338 |
+
label=Listing:Altera:QsysMegawizard:QSFSettings,
|
| 1339 |
+
caption=\Altera{.qsf} settings for Qsys and Megawizard designs,frame=single]
|
| 1340 |
+
###################################################################
|
| 1341 |
+
# PCIE Connections
|
| 1342 |
+
###################################################################
|
| 1343 |
+
set_location_assignment <PCIE_REFCLK_PIN> -to PCIE_REFCLK
|
| 1344 |
+
set_instance_assignment -name IO_STANDARD HCSL -to PCIE_REFCLK
|
| 1345 |
+
set_location_assignment <PCIE_REFCLK_PIN(n)> -to ``PCIE_REFCLK(n)''
|
| 1346 |
+
set_instance_assignment -name IO_STANDARD HCSL -to ``PCIE_REFCLK(n)''
|
| 1347 |
+
set_location_assignment <PCIE_RESET_N> -to PCIE_RESET_N
|
| 1348 |
+
set_instance_assignment -name IO_STANDARD ``2.5 V'' -to PCIE_RESET_N
|
| 1349 |
+
|
| 1350 |
+
# For each PCIE Lane (L) set the pin locations from the board user guide!
|
| 1351 |
+
######################################################################
|
| 1352 |
+
#PCIE TX_OUT L
|
| 1353 |
+
######################################################################
|
| 1354 |
+
set_location_assignment <TX_LANE[L]_PIN> -to PCIE_TX_OUT[0]
|
| 1355 |
+
set_location_assignment <TX_LANE[L]_PIN(n)> -to ``PCIE_TX_OUT[0](n)''
|
| 1356 |
+
|
| 1357 |
+
###################################################################
|
| 1358 |
+
#PCIE RX_IN L
|
| 1359 |
+
###################################################################
|
| 1360 |
+
set_location_assignment <RX_LANE[L]_PIN> -to PCIE_RX_IN[L]
|
| 1361 |
+
set_location_assignment <RX_LANE[L]_PIN(n)> -to ``PCIE_RX_IN[L](n)''
|
| 1362 |
+
\end{lstlisting}
|
| 1363 |
+
\pagebreak
|
| 1364 |
+
|
| 1365 |
+
\section{IP Compiler for PCI Express (Stratix IV, and older)}
|
| 1366 |
+
\label{Sec:Altera:IPCompiler}
|
| 1367 |
+
To avoid licensing problems, we do not package Altera IP for the DE4
|
| 1368 |
+
board. Manual IP Instantiation is required when using the DE4 Board, and similar
|
| 1369 |
+
devices using the IP Compiler for PCI Express. Changing the endpoint settings
|
| 1370 |
+
described here may change the RIFFA para\-meters
|
| 1371 |
+
\RIFFAParameter{C\_PCI\_DATA\_WIDTH}, \RIFFAParameter{C\_MAX\_PAYLOAD\_BYTES}
|
| 1372 |
+
and \RIFFAParameter{C\_LOG\_NUM\_TAGS}. How these parameters relate to IP core
|
| 1373 |
+
settings is highlighted in the following figures.
|
| 1374 |
+
|
| 1375 |
+
There are sever example projects inside of the \Directory{de4} directory folder
|
| 1376 |
+
without instantiated IP. For the DE4 board, these
|
| 1377 |
+
projects are DE4Gen1x8If64, DE4Gen2x8If128.% and DE2Gen1x1If64 for the DE2i-150
|
| 1378 |
+
board.
|
| 1379 |
+
|
| 1380 |
+
As stated in Section~\ref{Sec:Intro:Decoding}, each project directory contains
|
| 1381 |
+
five folders.
|
| 1382 |
+
\begin{itemize}
|
| 1383 |
+
\item The \Directory{prj/} directory contains the project \Altera{.qpf} and \Altera{.qsf} file.
|
| 1384 |
+
\item The \Directory{hdl/} contains the top level file, e.g. DE5Gen2x8If128.v,
|
| 1385 |
+
which instantiates the skeleton IP and the RIFFA Core.
|
| 1386 |
+
\item The \Directory{ip/} directory is empty but will contain Altera IP generated by Quartus
|
| 1387 |
+
in the following guide.
|
| 1388 |
+
\item The \Directory{constr/} directory contains project-specific timing constraint files.
|
| 1389 |
+
\item Finally the \Directory{bit/} directory contains the project .sof, or bit
|
| 1390 |
+
file that we have tested. This bitfile will not be overwritten by subsequent
|
| 1391 |
+
Quartus compilations.
|
| 1392 |
+
\end{itemize}
|
| 1393 |
+
|
| 1394 |
+
\subsection{Generating IP with IP Compiler for PCI Express (Stratix IV, and older)}
|
| 1395 |
+
\label{Sec:Altera:IPCompiler:Generating}
|
| 1396 |
+
Note: The bitfile in the bit directory is not modified by recompilation in
|
| 1397 |
+
Quartus. Quartus will generate a new bitfile (.sof) in the
|
| 1398 |
+
\Directory{/output\_files} directory for the DE4 board.
|
| 1399 |
+
|
| 1400 |
+
First, we will generate the PCIe Endpoint. Open the Altera IP Catalog and select
|
| 1401 |
+
the IP Compiler for PCI Express. This will open the window shown in
|
| 1402 |
+
Figure~\ref{Fig:Altera:IPCompiler:PCIeSystemSettingsTab}.
|
| 1403 |
+
|
| 1404 |
+
Optional: Set the Component Name of the PCI Express block, and the IP
|
| 1405 |
+
Location. In our example projects, we typically use the name
|
| 1406 |
+
PCIeGen\ConfigSetting{W}x\ConfigSetting{Y}If\ConfigSetting{Z} where \ConfigSetting{W} is the PCI Express
|
| 1407 |
+
Version (Link Speed in
|
| 1408 |
+
Figure~\ref{Fig:Gen3Integrated:Generating:Gen3IntegratedTabBasic}), \ConfigSetting{Y}
|
| 1409 |
+
is the lane width, and \ConfigSetting{Z} is the Avalon interface width. The IP location
|
| 1410 |
+
is the \Directory{ip} directory in the example project.
|
| 1411 |
+
|
| 1412 |
+
In this guide, we will skip the Power Mangement tab shown in
|
| 1413 |
+
Figure~\ref{Fig:Altera:IPCompiler:PCIeSystemSettingsTab}.
|
| 1414 |
+
\begin{figure}[H]
|
| 1415 |
+
\includegraphics[width=350px,center]{IPCompilerPCIeTabSystemSettings.png}
|
| 1416 |
+
\caption{IP Compiler for PCI Express System Settings Tab}
|
| 1417 |
+
\label{Fig:Altera:IPCompiler:PCIeSystemSettingsTab}
|
| 1418 |
+
\end{figure}
|
| 1419 |
+
In the first column of the System Settings Tab, select your \ConfigSetting{Chip
|
| 1420 |
+
Generation/PHY Type} (\ConfigSetting{Stratix IV GX} for the DE4 board),
|
| 1421 |
+
\ConfigSetting{Lanes}, and \ConfigSetting{Max Rate}. The \ConfigSetting{Number
|
| 1422 |
+
of Lanes} is the parameter \RIFFAParameter{C\_NUM\_LANES} in the project top
|
| 1423 |
+
level file. In the second column, select the \ConfigSetting{PCI Express Version}
|
| 1424 |
+
(2.0, or the highest possible) and set the \ConfigSetting{Test Out Width} to
|
| 1425 |
+
\ConfigSetting{0}. In the third column, select the \ConfigSetting{Application Interface
|
| 1426 |
+
Width}. The \ConfigSetting{Application Interface Width} corresponds to the RIFFA parameter
|
| 1427 |
+
\RIFFAParameter{C\_PCI\_DATA\_WIDTH}.
|
| 1428 |
+
|
| 1429 |
+
The choice of \ConfigSetting{Link Rate}, \ConfigSetting{Lanes}, and
|
| 1430 |
+
\ConfigSetting{Interface Width} will set the frequency for the PCI interface,
|
| 1431 |
+
which is clocked by the signal pld\_clk. For the chosen settings, the frequency
|
| 1432 |
+
is determined in the Chip User Guide (though, typically it is one of 62.5, 125,
|
| 1433 |
+
or 256 MHz)
|
| 1434 |
+
|
| 1435 |
+
\begin{figure}[H]
|
| 1436 |
+
\includegraphics[width=350px,center]{IPCompilerPCIeTabPCIRegisters.png}
|
| 1437 |
+
\caption{IP Compiler for PCI Express Registers Tab}
|
| 1438 |
+
\label{Fig:Altera:IPCompiler:PCIRegisters}
|
| 1439 |
+
\end{figure}
|
| 1440 |
+
PCI Registers Tab, shown in Figure~\ref{Fig:Altera:IPCompiler:PCIRegisters}, set
|
| 1441 |
+
BAR0's type to ``32-bit non-prefetchable memory''. Set the size to ``1 KByte -
|
| 1442 |
+
10 Bits''.
|
| 1443 |
+
|
| 1444 |
+
There are no required changes in the PCI Registers Tab. However, in a multiple
|
| 1445 |
+
FPGA system, it may be useful to change the \ConfigSetting{Device ID} to
|
| 1446 |
+
identify different FPGA platforms. The other options, specifically the
|
| 1447 |
+
\ConfigSetting{Vendor ID}, must remain the same.
|
| 1448 |
+
\begin{figure}[H]
|
| 1449 |
+
\includegraphics[width=350px,center]{IPCompilerPCIeTabCapabilities.png}
|
| 1450 |
+
\caption{IP Compiler for PCI Express Capabilities Tab}
|
| 1451 |
+
\label{Fig:Altera:IPCompiler:PCIeCapabilitiesTab}
|
| 1452 |
+
\end{figure}
|
| 1453 |
+
Open the Capabilities Tab shown in
|
| 1454 |
+
Figure~\ref{Fig:Altera:IPCompiler:PCIeCapabilitiesTab}. In the Device
|
| 1455 |
+
Capabilities box, set the \ConfigSetting{Tags Supported} to
|
| 1456 |
+
\ConfigSetting{64}. The log of the maximum number of tags supported is the RIFFA
|
| 1457 |
+
parameter \RIFFAParameter{C\_LOG\_NUM\_TAGS} parameter in RIFFA. In the MSI
|
| 1458 |
+
Capabilities box, set the number of \ConfigSetting{MSI Messages Requested} to
|
| 1459 |
+
\ConfigSetting{1}. All the remaining settings must stay the same.
|
| 1460 |
+
\begin{figure}[H]
|
| 1461 |
+
\includegraphics[width=350px,center]{IPCompilerPCIeTabBufferSetup.png}
|
| 1462 |
+
\caption{IP Compiler for PCI Express Buffer Setup Tab}
|
| 1463 |
+
\label{Fig:Altera:IPCompiler:PCIeBufferSetupTab}
|
| 1464 |
+
\end{figure}
|
| 1465 |
+
In Figure~\ref{Fig:Altera:IPCompiler:PCIeBufferSetupTab} select the
|
| 1466 |
+
\ConfigSetting{Maximum Payload Size} from the dropdown menu. Use this to set the
|
| 1467 |
+
\RIFFAParameter{C\_MAX\_PAYLOAD} parameter. Set the numer of \ConfigSetting{Virtual Channels} to
|
| 1468 |
+
\ConfigSetting{1}.
|
| 1469 |
+
|
| 1470 |
+
Note: \ConfigSetting{Maximum Payload} sizes are typically set by the BIOS, and
|
| 1471 |
+
256 bytes seems to be standard. RIFFA will default to the minimum of
|
| 1472 |
+
\RIFFAParameter{C\_MAX\_PAYLOAD\_SIZE} and the setting in your BIOS. Unless your
|
| 1473 |
+
BIOS is modified, or can support substantially larger packets, there will be no
|
| 1474 |
+
performance benefit to increasing the payload size. Increasing the
|
| 1475 |
+
\ConfigSetting{Maximum Payload} size will increase the resources consumed.
|
| 1476 |
+
|
| 1477 |
+
Next, we need to generate the PLL for the example design. Select the ALTPLL
|
| 1478 |
+
megafunction from the Quartus IP Catalog, to open the window shown in
|
| 1479 |
+
Figure~\ref{Fig:Altera:ALTPLL:TabGeneral}.
|
| 1480 |
+
\begin{figure}[H]
|
| 1481 |
+
\includegraphics[width=350px,center]{ALTPLLTabGeneral.png}
|
| 1482 |
+
\caption{ALTPLL General Settings Tab}
|
| 1483 |
+
\label{Fig:Altera:ALTPLL:TabGeneral}
|
| 1484 |
+
\end{figure}
|
| 1485 |
+
In Figure~\ref{Fig:Altera:ALTPLL:TabGeneral}, select the \ConfigSetting{Speed
|
| 1486 |
+
Grade} that matches your board (Found in the User Guide and online). Next set
|
| 1487 |
+
the input clock frequency. The DE4 board provides 50 MHz clock inputs and we use
|
| 1488 |
+
these for convenience. The remaining settings are unchaged. Click on the
|
| 1489 |
+
Inputs/Lock tab to move on to Figure~\ref{Fig:Altera:ALTPLL:TabInputs}.
|
| 1490 |
+
|
| 1491 |
+
Optional: Set the name of the ALTPLL block. In the example designs we use the
|
| 1492 |
+
name ALTPLL50I50O125O250O, for 50 MHz Input clock, 50, 125, and 250 MHz output
|
| 1493 |
+
clocks. The 125 and 50 MHz Clocks are required for the PCIe Endpoint.
|
| 1494 |
+
|
| 1495 |
+
\begin{figure}[H]
|
| 1496 |
+
\includegraphics[width=350px,center]{ALTPLLTabInputs.png}
|
| 1497 |
+
\caption{ALTPLL Input Settings Tab}
|
| 1498 |
+
\label{Fig:Altera:ALTPLL:TabInputs}
|
| 1499 |
+
\end{figure}
|
| 1500 |
+
Match the settings shown in Figure~\ref{Fig:Altera:ALTPLL:TabInputs}. In the
|
| 1501 |
+
Output Clocks Section, create a 50 MHz output clock, 125 MHz clock, and 250 MHz
|
| 1502 |
+
Clock. Click Finish when done.
|
| 1503 |
+
|
| 1504 |
+
% \begin{figure}[H]
|
| 1505 |
+
% \includegraphics[width=350px,center]{ALTPLLTabBandwidth.png}
|
| 1506 |
+
% \caption{ALTPLL Bandwidth Tab}
|
| 1507 |
+
% \label{Fig:Altera:ALTPLL:TabBandwidth}
|
| 1508 |
+
% \end{figure}
|
| 1509 |
+
% \begin{figure}[H]
|
| 1510 |
+
% \includegraphics[width=350px,center]{ALTPLLTabSwitchover.png}
|
| 1511 |
+
% \caption{ALTPLL Switchover Tab}
|
| 1512 |
+
% \label{Fig:Altera:ALTPLL:TabSwitchover}
|
| 1513 |
+
% \end{figure}
|
| 1514 |
+
|
| 1515 |
+
Finally, we generate the ALTGX\_RECONFIG Megafunction. Select the
|
| 1516 |
+
ALTGX\_RECONFIG megafunction from the Quartus IP Catalog to produce the widown
|
| 1517 |
+
shown in Figure~\ref{Fig:Altera:ALTGX:TabSettings}.
|
| 1518 |
+
\begin{figure}[H]
|
| 1519 |
+
\includegraphics[width=350px,center]{ALTGXReconfigTabSettings.png}
|
| 1520 |
+
\caption{ALTGX Reconfiguration Settings Tab}
|
| 1521 |
+
\label{Fig:Altera:ALTGX:TabSettings}
|
| 1522 |
+
\end{figure}
|
| 1523 |
+
In the Reconfiguration Tab shown in Figure~\ref{Fig:Altera:ALTGX:TabSettings}, set the \ConfigSetting{Number of Channels}. This should be equal to the number of PCIe Lanes at the Top Level. In the Features Section, \ConfigSetting{Enable Analog Controls}. Match the settings in the remaining windows, shown in Figure~\ref{Fig:Altera:ALTGX:TabInputs},Figure~\ref{Fig:Altera:ALTGX:TabChannel}, and Figure~\ref{Fig:Altera:ALTGX:TabError}.
|
| 1524 |
+
|
| 1525 |
+
\begin{figure}[H]
|
| 1526 |
+
\includegraphics[width=350px,center]{ALTGXReconfigTabAnalog.png}
|
| 1527 |
+
\caption{ALTGX Reconfiguration Analog Settings Tab}
|
| 1528 |
+
\label{Fig:Altera:ALTGX:TabInputs}
|
| 1529 |
+
\end{figure}
|
| 1530 |
+
|
| 1531 |
+
\begin{figure}[H]
|
| 1532 |
+
\includegraphics[width=350px,center]{ALTGXReconfigTabChannel.png}
|
| 1533 |
+
\caption{ALTGX Reconfiguration Channel Tab}
|
| 1534 |
+
\label{Fig:Altera:ALTGX:TabChannel}
|
| 1535 |
+
\end{figure}
|
| 1536 |
+
|
| 1537 |
+
\begin{figure}[H]
|
| 1538 |
+
\includegraphics[width=350px,center]{ALTGXReconfigTabError.png}
|
| 1539 |
+
\caption{ALTGX Reconfiguration Error Tab}
|
| 1540 |
+
\label{Fig:Altera:ALTGX:TabError}
|
| 1541 |
+
\end{figure}
|
| 1542 |
+
|
| 1543 |
+
\pagebreak
|
| 1544 |
+
\subsection{Creating Constraints files for IP Compiler Designs}
|
| 1545 |
+
Advanced users may also want to edit and modify the constraint files. This not
|
| 1546 |
+
required or recommended for novice users. The example designs in the RIFFA
|
| 1547 |
+
\RIFFAVer~distribution contain appropriate constraint files for the example
|
| 1548 |
+
designs. However if the need arises, we demonstrate the constraints we used
|
| 1549 |
+
below.
|
| 1550 |
+
|
| 1551 |
+
If the goal is to generate a RIFFA design completely from scratch, each board
|
| 1552 |
+
directory comes with a RIFFA wrapper verilog file and instantiates a
|
| 1553 |
+
vendor-specific translation layer. It is highly recommended to re-use these
|
| 1554 |
+
files RIFFA wrapper when creating designs from scratch. Users should also use
|
| 1555 |
+
the constraints file (\Altera{.sdc}) in the board directory, and in the
|
| 1556 |
+
\Directory{constr/}, or read the User Guide provided with each board.
|
| 1557 |
+
|
| 1558 |
+
To appropriately constrain your PCIe reference clocks, place the constraints
|
| 1559 |
+
shown in Listing~\ref{Listing:Altera:IPCompiler:Constraints} in your
|
| 1560 |
+
\Altera{.sdc} file. Modify the name of the osc\_50MHz and PCIE\_REFCLK ports to
|
| 1561 |
+
match your design
|
| 1562 |
+
\begin{lstlisting}[language=tcl,basicstyle=\footnotesize\ttfamily,commentstyle=\color{red},
|
| 1563 |
+
label=Listing:Altera:IPCompiler:Constraints,
|
| 1564 |
+
caption=\Altera{.sdc} constraints for Qsys and Megawizard designs,frame=single]
|
| 1565 |
+
create_clock -name PCIE_REFCLK -period 10.000 [get_ports {PCIE_REFCLK}]
|
| 1566 |
+
create_clock -name osc_50MHz -period 20.000 [get_ports {OSC_BANK3D_50MHZ}]
|
| 1567 |
+
derive_pll_clocks -create_base_clocks
|
| 1568 |
+
derive_clock_uncertainty
|
| 1569 |
+
# 50 MHZ PLL Clock
|
| 1570 |
+
create_generated_clock -name clk50 -source [get_ports {OSC_50_BANK2}] \
|
| 1571 |
+
[get_nets {*|altpll_component|auto_generated|wire_pll1_clk[0]}]
|
| 1572 |
+
# 125 MHZ PLL Clock
|
| 1573 |
+
create_generated_clock -name clk125 -multiply_by 5 -divide_by 2 -source \
|
| 1574 |
+
[get_ports {OSC_50_BANK2}] \
|
| 1575 |
+
[get_nets {*|altpll_component|auto_generated|wire_pll1_clk[1]}]
|
| 1576 |
+
# 250 MHZ PLL Clock
|
| 1577 |
+
create_generated_clock -name clk250 -multiply_by 5 \
|
| 1578 |
+
-source [get_ports {OSC_50_BANK2}] [get_nets \
|
| 1579 |
+
{*|altpll_component|auto_generated|wire_pll1_clk[2]}]
|
| 1580 |
+
\end{lstlisting}
|
| 1581 |
+
|
| 1582 |
+
Likewise, copy the constraints in
|
| 1583 |
+
Listing~\ref{Listing:Altera:IPCompiler:QSFSettings} into your \Altera{.qsf}
|
| 1584 |
+
file. Copy the location assignment commands for each PCIe Pin in your reference
|
| 1585 |
+
design.
|
| 1586 |
+
\begin{lstlisting}[language=tcl,basicstyle=\footnotesize\ttfamily,
|
| 1587 |
+
commentstyle=\color{red},label=Listing:Altera:IPCompiler:QSFSettings,
|
| 1588 |
+
caption=\Altera{.qsf} settings for IP Compiler Designs,frame=single]
|
| 1589 |
+
###################################################################
|
| 1590 |
+
# PCIE Connections
|
| 1591 |
+
###################################################################
|
| 1592 |
+
set_location_assignment <PCIE_REFCLK_PIN> -to PCIE_REFCLK
|
| 1593 |
+
set_instance_assignment -name IO_STANDARD HCSL -to PCIE_REFCLK
|
| 1594 |
+
set_location_assignment <PCIE_REFCLK_PIN(n)> -to ``PCIE_REFCLK(n)''
|
| 1595 |
+
set_instance_assignment -name IO_STANDARD HCSL -to ``PCIE_REFCLK(n)''
|
| 1596 |
+
set_location_assignment <PCIE_RESET_N> -to PCIE_RESET_N
|
| 1597 |
+
set_instance_assignment -name IO_STANDARD ``2.5 V'' -to PCIE_RESET_N
|
| 1598 |
+
|
| 1599 |
+
# For each PCIE Lane (L) set the pin locations from the board user guide!
|
| 1600 |
+
######################################################################
|
| 1601 |
+
#PCIE TX_OUT L
|
| 1602 |
+
######################################################################
|
| 1603 |
+
set_location_assignment <TX_LANE[L]_PIN> -to PCIE_TX_OUT[L]
|
| 1604 |
+
set_location_assignment <TX_LANE[L]_PIN(n)> -to ``PCIE_TX_OUT[L](n)''
|
| 1605 |
+
###################################################################
|
| 1606 |
+
#PCIE RX_IN L
|
| 1607 |
+
###################################################################
|
| 1608 |
+
set_location_assignment <RX_LANE[L]_PIN> -to PCIE_RX_IN[L]
|
| 1609 |
+
set_location_assignment <RX_LANE[L]_PIN(n)> -to ``PCIE_RX_IN[L](n)''
|
| 1610 |
+
\end{lstlisting}
|
| 1611 |
+
\pagebreak
|
| 1612 |
+
\chapter{Developer Documentation}
|
| 1613 |
+
This chapter describes RIFFA \RIFFAVer~at a level of detail that is useful for
|
| 1614 |
+
RIFFA developers. Users of RIFFA should not read this section until they are
|
| 1615 |
+
comfortable developing for RIFFA or have experience with PCIe and DMA
|
| 1616 |
+
concepts.
|
| 1617 |
+
\section{Architecture Description}
|
| 1618 |
+
\begin{figure}[H]
|
| 1619 |
+
\includegraphics[width=350px,center]{RIFFA.pdf}
|
| 1620 |
+
\caption{High level RIFFA Diagram}
|
| 1621 |
+
\label{Fig:Developer:HighLevel:Full}
|
| 1622 |
+
\end{figure}
|
| 1623 |
+
\begin{itemize}
|
| 1624 |
+
\item \textbf{\color{red}{IP Interfaces}} The Vendor IP interfaces provied
|
| 1625 |
+
low-level access to the PCIe bus. Each vendor provides a set of signals for
|
| 1626 |
+
communicating over PCIe. Xilinx FPGAs without PCIe Gen3 support provide an
|
| 1627 |
+
interface very similar to Altera FPGAs. We call this the ``Classic
|
| 1628 |
+
Interface''. Newer Xilinx devices with PCIe Gen3 support have completely
|
| 1629 |
+
different non-compatible interfaces (CC, CQ, RC, RQ instead of RX and TX). We
|
| 1630 |
+
call this the ``Xilinx Ultrascale Interface''.
|
| 1631 |
+
|
| 1632 |
+
\textit{Files: \Xilinx{*.xci}, \Altera{*.qsys} (And others generated by vendor
|
| 1633 |
+
tools)}
|
| 1634 |
+
|
| 1635 |
+
\item \textbf{\color{orange}{Translation Layer}} The Translation Layer provides
|
| 1636 |
+
a set of vendor-independent interfaces and signal names.
|
| 1637 |
+
|
| 1638 |
+
There is one translation layer for each interface. The ``Classic Translation
|
| 1639 |
+
Layer'' provides a set of interfaces (RX, TX, Interrupt, and Configuration)
|
| 1640 |
+
and vendor independent signal names to higher layers. There is very little
|
| 1641 |
+
logic in these layers, and there should be no timing-critical logic here.
|
| 1642 |
+
|
| 1643 |
+
The ``Ultrascale Translation Layer'' operates on the ultrascale
|
| 1644 |
+
interface. Similar to the classic translation layer, it contains very little
|
| 1645 |
+
logic. It provides the interfaces: RX Completion, RX Request, TX
|
| 1646 |
+
Completion, TX Request, Interrupt, and Configuration.
|
| 1647 |
+
|
| 1648 |
+
\textit{Files: translation\_altera.v, translation\_xilinx.v,
|
| 1649 |
+
txc\_engine\_ultrascale.v,\\ txr\_engine\_ultrascale.v}
|
| 1650 |
+
|
| 1651 |
+
\item \textbf{\color{yellow}{Formatting Engine Layer}} The Formatting Engine
|
| 1652 |
+
Layer is responsible for formatting requests and completions into
|
| 1653 |
+
packets. This layer provides four interfaces: RX Completion (RXC) for
|
| 1654 |
+
receiving completions (responses to memory read requests), RX Request (RXR)
|
| 1655 |
+
for receiving memory read and write requests, TX Completion (TXC) for
|
| 1656 |
+
transmitting completions (reponses to memory read requests), and TX Request
|
| 1657 |
+
(TXR) for transmitting read and write requests.
|
| 1658 |
+
|
| 1659 |
+
The engine layer abstracts vendor specific features, such as Xilinx's
|
| 1660 |
+
Classic-Interface Big-Endian requirement and Altera's Quad-word
|
| 1661 |
+
Alignment. The C\_VENDOR parameter for the engine layer switches between
|
| 1662 |
+
Xilinx, Altera, and Ultrascale logic to produce TLPs (Classic Interface) and
|
| 1663 |
+
AXI Descriptors (Ultrascale Interface).
|
| 1664 |
+
|
| 1665 |
+
The RX path of the engine layer has packet parsers for TLPs and AXI
|
| 1666 |
+
Descriptors. These are parameterized by width, as of RIFFA 2.2. The TX Path of
|
| 1667 |
+
the engine layer has packet formatters for TLPs and AXI Descriptors.
|
| 1668 |
+
|
| 1669 |
+
As alluded to in the Translation Layer, the Classic IP Cores provide only two
|
| 1670 |
+
transmit interfaces (RX, and TX), while the Xilinx Ultrascale IP Core handles
|
| 1671 |
+
RX Demultiplexing and multiplexing internally and provides four interfaces
|
| 1672 |
+
(RXC, RXR, TXC, and TXR). For this reason, the multiplexing/FIFO logic used in
|
| 1673 |
+
the Classic interfaces are not necessary for the Xilinx interface.
|
| 1674 |
+
|
| 1675 |
+
After the Engine-Layer, higher layers should be vendor agnostic, if not bus
|
| 1676 |
+
agnostic. The exception will be sideband signals signals. (How much of this
|
| 1677 |
+
ideal can be achieved remains to be seen)
|
| 1678 |
+
|
| 1679 |
+
Note: The engine layer currently uses word-aligned addresses, and byte-enable
|
| 1680 |
+
signals to specify sub-word addresses. In the future, all addresses will be
|
| 1681 |
+
byte-aligned and word enables will be handled in the formatting logic.
|
| 1682 |
+
|
| 1683 |
+
\textit{Files: engine\_layer.v, schedules.vh, rx\_engine\_classic.v, rxc\_engine\_classic.v,\\
|
| 1684 |
+
rxr\_engine\_classic.v, tx\_engine\_classic.v, txc\_engine\_classic.v,\\
|
| 1685 |
+
txr\_engine\_classic.v, rx\_engine\_ultrascale.v, rxc\_engine\_ultrascale.v,\\
|
| 1686 |
+
rxr\_engine\_ultrascale.v, tx\_engine\_ultrascale.v, txc\_engine\_ultrascale.v, \\
|
| 1687 |
+
txr\_engine\_ultrascale.v}
|
| 1688 |
+
|
| 1689 |
+
\item \textbf{\color{green}{Scatter Gather (SG) DMA Layer}} The Scatter Gather
|
| 1690 |
+
DMA Layer handles reading from and writing to scatter gather lists and
|
| 1691 |
+
providing the addresses found in these lists to the data-request logic in the
|
| 1692 |
+
Data Abstraction layer. In RIFFA, each channel has its own SG DMA list logic.
|
| 1693 |
+
|
| 1694 |
+
The Completion Merge/Reorder buffer handles out-of-order completions. In the
|
| 1695 |
+
PCIe specification, a memory request can be serviced by multiple smaller
|
| 1696 |
+
completions (the responses must remain in order). Completions from different
|
| 1697 |
+
memory requests can be returned in any order. The reorder buffer releases data
|
| 1698 |
+
when all of the responses to a memory request have been received.
|
| 1699 |
+
|
| 1700 |
+
Memory read and write requests to the host are multiplexed by the TX Request
|
| 1701 |
+
Mux. These are serviced fairly in round robin order.
|
| 1702 |
+
|
| 1703 |
+
The Scatter Gather List Readers issue read requests to read data from the
|
| 1704 |
+
Scatter Gather List (SGL) created by the driver. This list contains the
|
| 1705 |
+
address and length of pages containing data to transmit. When an SGL has been
|
| 1706 |
+
exhausted, an interrupt is raised and the SGL is refilled or the transaction
|
| 1707 |
+
is comlete.
|
| 1708 |
+
|
| 1709 |
+
Each element in the SGL 128-bit triple: {32'b0, 32'b Length of Data in 32-bit
|
| 1710 |
+
words, 64'b Address of Page}. The addresses in this list are provided to the
|
| 1711 |
+
DMA Data Read Engine in the Data Abstraction layer. Since the SGL must be a
|
| 1712 |
+
single continuous stream of 128-bit elements regardless of the size of the
|
| 1713 |
+
interface, gaps and mis-alignments due to packet formatting are removed using
|
| 1714 |
+
the Data Packer, which receives its data from the reorder buffer.
|
| 1715 |
+
|
| 1716 |
+
The location of the SGL in host memory is written to the BAR Memory space.
|
| 1717 |
+
The BAR Memory space is partitioned among the channels. Only the host can
|
| 1718 |
+
issue read and write requests to this memory space. Since the memory space is
|
| 1719 |
+
partitioned, the RX Request interface and TX Completion interface do not have
|
| 1720 |
+
demultiplexing or multiplexing logic.
|
| 1721 |
+
|
| 1722 |
+
A more through treatment of the SG DMA Layer can be found in Sec.~\ref{Sec:Developer:Arch:SGDMA}.
|
| 1723 |
+
|
| 1724 |
+
\textit{Files: reorder\_queue*.v, sg\_list\_reader\_*.v, sg\_list\_requester.v \\
|
| 1725 |
+
fifo\_packer\_*.v, registers.v, tx\_multiplexer\_*.v}
|
| 1726 |
+
|
| 1727 |
+
|
| 1728 |
+
\item \textbf{\color{blue}{Data Abstraction / DMA Layer}} The Data Abstraction /
|
| 1729 |
+
DMA Layer is responsible for making requests to read data from, or write data
|
| 1730 |
+
to host memory.
|
| 1731 |
+
|
| 1732 |
+
The read and write addresses are provided by the Scatter Gather list
|
| 1733 |
+
readers. Since RIFFA provides a single continuous stream of 32-bit words
|
| 1734 |
+
regardless of the size of the interface, gaps and mis-alignments due to packet
|
| 1735 |
+
formatting are removed using the Data Packer, which receives its data from the
|
| 1736 |
+
reorder buffer. On the TX side, this is not necessary. However a write buffer,
|
| 1737 |
+
and other transaction tracking logic is necessary for buffering, and removing
|
| 1738 |
+
non-integral data.
|
| 1739 |
+
|
| 1740 |
+
A more through treatment of the Data Abstraction Layer can be found in
|
| 1741 |
+
Sec.~\ref{Sec:Developer:Arch:DataAbstraction}.
|
| 1742 |
+
|
| 1743 |
+
\textit{Files: reorder\_queue*.v, rx\_port\_*.v, rx\_port\_reader.v,\\
|
| 1744 |
+
fifo\_packer\_*.v, tx\_port\_writer.v tx\_port\_buffer\_*.v tx\_port\_monitor\_*.v}
|
| 1745 |
+
|
| 1746 |
+
\item \textbf{\color{purple}{Channel Interface}}
|
| 1747 |
+
\textit{Files: rx\_channel\_gate\_*.v, tx\_channel\_gate\_*.v}
|
| 1748 |
+
\contourlength{.2pt}
|
| 1749 |
+
\item \contour{black}{\textbf{\color{white}{User Logic}}}
|
| 1750 |
+
\end{itemize}
|
| 1751 |
+
\subsection{Scatter Gather DMA Layer}
|
| 1752 |
+
\label{Sec:Developer:Arch:SGDMA}
|
| 1753 |
+
READS from the SG lists are prioritized
|
| 1754 |
+
\subsection{Data Abstraction DMA Layer}
|
| 1755 |
+
\label{Sec:Developer:Arch:DataAbstraction}
|
| 1756 |
+
\section{Software Description}
|
| 1757 |
+
|
| 1758 |
+
\section{FPGA RX Transfer / Host Send}
|
| 1759 |
+
\begin{center}
|
| 1760 |
+
\begin{tabular}{ | l | l |}
|
| 1761 |
+
\hline
|
| 1762 |
+
Parameter & Value \\ \hline
|
| 1763 |
+
Data Transfer Length & 128 (32-bit words)\\ \hline
|
| 1764 |
+
Data Transfer Offsfet & 0\\ \hline
|
| 1765 |
+
Data Transfer Last & 1\\ \hline
|
| 1766 |
+
Data Transfer Channel & 0\\ \hline
|
| 1767 |
+
Data Page Address (DMA) & 0x00000000\_FEED0000\\ \hline
|
| 1768 |
+
SGL Head Address & 0x00000000\_BEEF0000\\ \hline
|
| 1769 |
+
\end{tabular}
|
| 1770 |
+
\end{center}
|
| 1771 |
+
|
| 1772 |
+
\begin{itemize}
|
| 1773 |
+
\item A user makes an call to fpga\_send() to transfer 128 32-bit words of data on Channel 0. \item The RIFFA driver writes \{32'd128\} to Channel 0's RX Length register, and
|
| 1774 |
+
\{31'd0,1'b1\} to Channel 0's RX OffLast register. This notifies the FPGA that a new
|
| 1775 |
+
transfer is happening and will raise CHNL\_RX for the user
|
| 1776 |
+
application. \textit{Files: rxr\_engine\_*.v, registers.v, channel*.v,
|
| 1777 |
+
rx\_port.v rx\_port\_gate.v, rx\_port\_reader.v}
|
| 1778 |
+
\item The RIFFA driver allocates an SGL with 1 element (4 32-bit words) at
|
| 1779 |
+
address \\\{64'h0000\_0000\_BEEF\_0000\}. The driver fills the list with the
|
| 1780 |
+
length and address of the user data:\\
|
| 1781 |
+
\{32'd0,32'd128,64'h0000\_0000\_FEED\_0000\}.
|
| 1782 |
+
\item The RIFFA driver communicates the address and length of the SGL by
|
| 1783 |
+
writing \\\{32'hBEEF0000\} to to Channel 0's RX SGL Address Low register,
|
| 1784 |
+
\{32'd0\} to to Channel 0's RX SGL Address High register, and \{32'd4\} to to
|
| 1785 |
+
Channel 0's RX SGL Length register. Writing the RX SGL Length register
|
| 1786 |
+
notifies the RX SG Engine that a transfer has started, and the low and high
|
| 1787 |
+
portions of the 64-bit RX SGL Address are valid. \textit{Files:
|
| 1788 |
+
rxr\_engine\_*.v, registers.v, channel*.v, rx\_port.v,
|
| 1789 |
+
sg\_list\_requester.v}
|
| 1790 |
+
\item The SG List Requester on the FPGA issues a read request for 4 32-bit
|
| 1791 |
+
words of data starting at address 0xBEEF0000. The FPGA also issues an
|
| 1792 |
+
interrupt. The RIFFA driver reads the Interrupt Status Register of the FPGA
|
| 1793 |
+
and determines that Channel 0 has finished reading the RX SGL. \textit{Files:
|
| 1794 |
+
sg\_list\_requester.v, rx\_port\_requester\_mux.v, rx\_port\_*.v,
|
| 1795 |
+
channel*.v, tx\_multiplexer.v, engine\_layer.v, txr\_engine\_*.v,
|
| 1796 |
+
interrupt.v}
|
| 1797 |
+
\item The FPGA receieves a completion with 4 32-bit words. After being enqueued
|
| 1798 |
+
in the reorder buffer, the completion is delivered to Channel 0, and packed
|
| 1799 |
+
into the SGL RX Fifo. \textit{Files: rxc\_engine\_*.v, engine\_layer.v,
|
| 1800 |
+
reorder\_queue*.v, fifo\_packer\_*.v}
|
| 1801 |
+
\item The RX Port Reader removes the SG element from the FIFO, and issues
|
| 1802 |
+
several read requests to receive all 128 32-bit words. \textit{Files:
|
| 1803 |
+
rx\_port\_reader.v, rx\_port\_*.v, channel*.v, tx\_multiplexer.v,
|
| 1804 |
+
engine\_layer.v, txr\_engine\_*.v, tx\_multiplexer.v}
|
| 1805 |
+
\item The completions return interleaved and are reordered in the reorder
|
| 1806 |
+
buffer. The reorder buffer releases the completions in order to the fifo
|
| 1807 |
+
packer, which puts them in the FIFO. The RX Port Channel Gate issues the data
|
| 1808 |
+
to the user. \textit{Files: rxc\_engine\_*.v, engine\_layer.v, reorder\_queue*.v,
|
| 1809 |
+
fifo\_packer\_*.v, rx\_port\_reader.v, rx\_port\_channel\_gate.v, channel*.v}
|
| 1810 |
+
\item The FPGA raises an interrupt with the last word of data is put into the
|
| 1811 |
+
Main Data Fifo. The RIFFA driver reads the Interrupt Status Register of the
|
| 1812 |
+
FPGA and determines that Channel 0 has finished the RX Transaction. The RIFFA
|
| 1813 |
+
driver reads the RX Words Read register to determine how many words were read
|
| 1814 |
+
during the transaction.
|
| 1815 |
+
\item Control is returned to the user.
|
| 1816 |
+
\end{itemize}
|
| 1817 |
+
\section{TX Transfer}
|
| 1818 |
+
\section{FPGA RX Transfer / Host Send}
|
| 1819 |
+
\begin{center}
|
| 1820 |
+
\begin{tabular}{ | l | l |}
|
| 1821 |
+
\hline
|
| 1822 |
+
Parameter & Value \\ \hline
|
| 1823 |
+
Data Transfer Length & 128 (32-bit words)\\ \hline
|
| 1824 |
+
Data Transfer Offsfet & 0\\ \hline
|
| 1825 |
+
Data Transfer Last & 1\\ \hline
|
| 1826 |
+
Data Transfer Channel & 0\\ \hline
|
| 1827 |
+
Data Page Address (DMA) & 0x00000000\_FEED0000\\ \hline
|
| 1828 |
+
SGL Head Address & 0x00000000\_BEEF0000\\ \hline
|
| 1829 |
+
\end{tabular}
|
| 1830 |
+
\end{center}
|
| 1831 |
+
\begin{itemize}
|
| 1832 |
+
\item A user makes an call to fpga\_recv() to transfer 128 32-bit words of data
|
| 1833 |
+
from Channel 0.
|
| 1834 |
+
\item The RIFFA driver allocates an SGL with 1 element (4 32-bit words) at
|
| 1835 |
+
address\\ \{64'h0000\_0000\_BEEF\_0000\}. The driver fills the list with the
|
| 1836 |
+
length and address of the user data:
|
| 1837 |
+
\{32'd0,32'd128,64'h0000\_0000\_FEED\_0000\}.
|
| 1838 |
+
\item The user application independently raises CHNL\_TX and starts writing data to\\
|
| 1839 |
+
CHNL\_TX\_DATA. RIFFA core logic reads transaction parameters from
|
| 1840 |
+
CHNL\_TX\_OFF, CHNL\_TX\_LAST, and CHNL\_TX\_LEN and acknowledges them with
|
| 1841 |
+
CHNL\_TX\_ACK. \\\textit{Files: tx\_port\_channel\_gate.v}
|
| 1842 |
+
\item An interrupt is raised by the FPGA. The RIFFA driver reads the Interrupt
|
| 1843 |
+
Status Register of the FPGA and determines that Channel 0 wishes to start a
|
| 1844 |
+
new TX Transaction. The driver ISR reads \{32'd128\} from Channel 0's TX
|
| 1845 |
+
Length register, and \{31'd0, 1'b1\} from Channel 0's TX OffLast
|
| 1846 |
+
register. Reading the OffLast register notifies the FPGA that the new
|
| 1847 |
+
transfer has been accepted. \textit{Files: rxr\_engine\_*.v, riffa.v,
|
| 1848 |
+
registers.v, channel*.v, tx\_port\_*.v, tx\_port\_writer.v,
|
| 1849 |
+
tx\_port\_monitor\_*.v, engine\_layer.v, txc\_engine\_*.v}
|
| 1850 |
+
\item The RIFFA driver communicates the address and length of the SGL by
|
| 1851 |
+
writing\\ \{32'hBEEF\_0000\} to to Channel 0's TX SGL Address Low register,
|
| 1852 |
+
\{32'd0\} to to Channel 0's TX SGL Address High register, and \{32'd4\} to to
|
| 1853 |
+
Channel 0's TX SGL Length register. Writing the TX SGL Length register
|
| 1854 |
+
notifies the TX SG Engine that a transfer has started, and the low and high
|
| 1855 |
+
portions of the 64-bit TX SGL Address are valid. \textit{Files:
|
| 1856 |
+
rxr\_engine\_*.v, registers.v, channel*.v, rx\_port.v,
|
| 1857 |
+
sg\_list\_requester.v}
|
| 1858 |
+
\item The SG List Requester on the FPGA issues a read request for 4 32-bit
|
| 1859 |
+
words of data starting at address 0xBEEF0000. The FPGA raises an
|
| 1860 |
+
interrupt. The RIFFA driver reads the Interrupt Status Register of the FPGA
|
| 1861 |
+
and determines that Channel 0 has finished reading the TX SGL. \textit{Files:
|
| 1862 |
+
sg\_list\_requester.v, rx\_port\_requester\_mux.v, rx\_port\_*.v,
|
| 1863 |
+
channel*.v, tx\_multiplexer.v, engine\_layer.v, txr\_engine\_*.v,
|
| 1864 |
+
interrupt.v}
|
| 1865 |
+
\item The FPGA receieves a completion with 4 32-bit words. After being enqueued
|
| 1866 |
+
in the reorder buffer, the completion is delivered to Channel 0, and packed
|
| 1867 |
+
into the SGL TX Fifo. \textit{Files: rxc\_engine\_*.v, engine\_layer.v,
|
| 1868 |
+
reorder\_queue*.v, fifo\_packer\_*.v}
|
| 1869 |
+
\item The TX Port Writer removes the SG element from the FIFO, and issues
|
| 1870 |
+
several write requests to write all 128 32-bit words. \textit{Files:
|
| 1871 |
+
tx\_port\_monitor.v, tx\_port\_writer.v, tx\_port\_*.v, channel*.v, tx\_multiplexer.v,
|
| 1872 |
+
engine\_layer.v, txr\_engine\_*.v, tx\_multiplexer.v}
|
| 1873 |
+
\item When the last write transaction has been accepted by the core, the FPGA
|
| 1874 |
+
raises an interrupt. The RIFFA driver reads the Interrupt Status Register of
|
| 1875 |
+
the FPGA and determines that Channel 0 has finished writing data. The RIFFA
|
| 1876 |
+
driver reads the TX Words Written register to determine how many words were
|
| 1877 |
+
written during the transaction (in case of early termination, or overflow).
|
| 1878 |
+
\textit{Files: rxr\_engine\_*.v, riffa.v, interrupt.v, registers.v, channel*.v,
|
| 1879 |
+
tx\_port\_*.v, tx\_port\_writer.v, engine\_layer.v, txc\_engine\_*.v}
|
| 1880 |
+
\item Control is return to the user because the TX\_LAST signal was set to 1.
|
| 1881 |
+
\end{itemize}
|
| 1882 |
+
%\pagebreak
|
| 1883 |
+
%\chapter{The RIFFA Architecture}
|
| 1884 |
+
%\section{Translation Layer}
|
| 1885 |
+
%\section{Engine Layer}
|
| 1886 |
+
%\section{DMA Layer}
|
| 1887 |
+
%\section{RIFFA}
|
| 1888 |
+
%\section{The DMA Engine Layer}
|
| 1889 |
+
%\chapter{Version Notes}
|
| 1890 |
+
%\section{References, Notes and Reading Material}
|
| 1891 |
+
%\section{Core Diagrams}
|
| 1892 |
+
\end{document}
|