Compare commits

...
Sign in to create a new pull request.

465 commits

Author SHA1 Message Date
Robert Ghilduta
fcf9423325 Bump pillow 2025-10-06 16:06:05 -07:00
Robert Ghilduta
712d49e28f libbladeRF: add RX reordering and prime worker before RX enable
- Add RX buffer sequence tracking with reorder queue to deliver in-order buffers
  despite out-of-order USB completions. Pause submissions when the reorder
  queue holds data to avoid overwriting, and reset tracking on stream start.
- Introduce sync_prime_stream() to start the sync worker and wait until it is
  running. This is used to avoid start-up gaps.
- Call sync_prime_stream() on RX enable paths for bladerf1/bladerf2 boards
  before backend enable, reducing early stream discontinuities (e.g., with
  RX_MUX_32BIT_COUNTER).
- This does not at affect TX code paths.

This improves RX robustness and eliminates potential early out-of-order batches
on some platforms under high sample rates and low compute throughput.
2025-09-28 20:28:22 -07:00
Ryan Thompson
7d7d87f686 libbladeRF: improve RFIC BIST loopback error message
Change from log_debug to log_error and provide clearer message when
RFIC BIST loopback is attempted in FPGA tuning mode. The new message
explicitly states the requirement (HOST mode) and current state (FPGA
mode), making it actionable for users.
2025-07-16 17:52:11 -05:00
Ryan Thompson
2935ce5251 test: added oversample test channel select and disabled channel check
If we see over 40% of the samples at zero, it's likely that a channel
is disabled. Reverting 55b5a0d07c will
get this test to fail.
2025-07-07 12:45:18 -05:00
Ryan Thompson
55b5a0d07c libbladeRF: fix OC register from 0x54 to 0xD4 enabling both RX1 and RX2
This occurs because the OC register (0x003) was set to 0x54, which only
enables RX1 in oversample mode. Now both channels are enabled by default
and appropriately gated at the top level adc_assignment_proc
in hosted.vhd.
2025-07-03 21:38:50 -05:00
Ben Morse
3d647f3db9 host: improve txrx_hwloop test
- fix bug where test would erroneously pass due to negative value
- add gain, better threshold control, png output
- requirements.txt now supports Ubuntu 20.04 and newer
2025-07-03 01:29:26 -07:00
ifrasch17
fa2f917179 bladeRF-fsk: bump version to add configurable sample rate, better test_suite 2025-07-01 17:48:53 -06:00
Ben Morse
7706720f99 docker: fix rocky-9 Docker build 2025-07-01 13:22:22 -07:00
Ben Morse
4494aa41ab host: test_regression can build every bitfile 2025-06-13 15:39:22 -07:00
Ben Morse
a81b7ce4c5 hdl: fix foxhunt build error 2025-06-13 15:39:22 -07:00
Ben Morse
e55e12b889 docker: fix all docker images
- delete many dockers, the rest are fully functioning
- build.bash returns with correct exit code
- base moves to alpine
- add rocky in place of centos
- some platforms require a cmake compile to get modern cmake
- add i686 build to existing i386
2025-06-13 15:39:13 -07:00
Ben Morse
ddc83606ff host: fix test_txrx_hwloop
- fix duty cycle error for subsequent iterations in the test
2025-06-13 15:39:07 -07:00
Ryan Thompson
b2f9503fce bladeRF-power: build: look for brew installed ncurses 2025-06-13 15:39:06 -07:00
Ben Morse
86c5063425 host: Fixes for Windows
- Changes around getopt/getopt_long
- CLOCK_MONOTONIC fix
- link fix
2025-06-13 15:39:00 -07:00
Ben Morse
a93191ae39 bladeRF-fsk: bump
- fix compiler error
- update windows threading
2025-06-13 15:38:48 -07:00
Robert Ghilduta
09efbb40b8 hdl: build_bladerf.sh fixups
Add H optarg, and ensure submodules are initialized prior to synthesis
2025-06-08 12:19:04 -07:00
Robert Ghilduta
35ec3c657f hdl: update libad936x build order 2025-06-07 22:08:15 -07:00
Ben Morse
6d61b4f86f bladeRF-fsk: add cmake flag to build FSK project 2025-06-07 22:04:26 -07:00
Ben Morse
918535854c bladeRF-fsk: host: various errors and compiler warning fixes on multiple platforms 2025-06-07 21:58:57 -07:00
Ryan Thompson
d65b160cd9 hdl: parallel build terminates and cleans up if exit or failure occures 2025-05-20 01:49:34 -07:00
Ryan Thompson
5be9df53a8 test: add libbladeRF oversample test 2025-05-20 01:47:40 -07:00
Ryan Thompson
8f490c0a67 libbladeRF: fix max sample throughput warning for oversample feature 2025-05-20 01:47:21 -07:00
Robert Ghilduta
d77b35c7c5 bladeRF-fsk: unitialized value fixup 2025-05-20 01:43:35 -07:00
Robert Ghilduta
2c12352457 docker: add Ubuntu distributions, update debian distro packages 2025-05-20 01:43:22 -07:00
Robert Ghilduta
761f39e1d7 docker: update from yum to DNF 2025-05-20 00:47:40 -07:00
Robert Ghilduta
8f99003e36 libbladeRF_test: update dependency 2025-05-20 00:32:33 -07:00
Robert Ghilduta
6185546fa9 debian: update control
Add support for libedit and curl
2025-05-20 00:30:22 -07:00
Robert Ghilduta
611e9cbfb3 debian: update RBFs and FX3 images 2025-05-20 00:19:40 -07:00
Robert Ghilduta
85d8d4b22b hdl: add AD9361 and bladeRF 2.0 micro support headers to include path 2025-05-19 23:59:16 -07:00
Robert Ghilduta
cd29f93a58 libladeRF: LTO fix
Fixes libbladeRF LTO compilation error
cmake -DCMAKE_C_FLAGS="-flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing" -DCMAKE_BUILD_TYPE=Release ..
2025-05-19 23:58:10 -07:00
Ryan Thompson
8931d475f3 host: add ifdef for array size macro 2025-05-19 23:57:50 -07:00
Ryan Thompson
a59d95fc80 host: fsk submodule init on make 2025-05-19 23:57:43 -07:00
Robert Ghilduta
bbdfbe1760 fsk: bump submodule to include build library fix 2025-05-14 01:22:16 -07:00
Robert Ghilduta
545f73c5f1 fx3_firmware: include major update in CHANGELOG 2025-05-13 04:37:12 -07:00
Robert Ghilduta
09c8208778 libbladeRF: bump version to 2.6.0
v2.6.0 (2025-05-06)
--------------------------------

This version of libbladeRF is intended for use with:

  FX3 Firmware v2.6.0
  FPGA         v0.16.0

New Features:
 * Added SC16_Q11 packed sample format support, improving sample efficiency
 * Increased FX3 GPIF buffer sizes, significantly boosting USB throughput (~356MB/s)
 * Implemented dynamic Nios base address assignment based on RAM size
 * Added parallel build support for hosted FPGA variants (40, 115, A4, A5, A9)
 * Enabled elf-gdb and gdb-server support for improved FPGA debugging capability
 * Added git revision information to FPGA build outputs
 * bladeRF 2.0: Added support for gain calibration loading, enabling, and management
 * bladeRF 2.0: Introduced bladeRF-power CLI tool for managing gain calibration
 * bladeRF 2.0: Added bladerf_get_gain_target function for gain management
 * bladeRF 2.0: Added bladerf_format_to_string API call
 * bladeRF 2.0: Added bladerf_image_print_metadata API to display image metadata
 * bladeRF 2.0: Improved compatibility checking between FPGA and FX3 firmware GPIF buffers

Improvements:
 * libbladeRF now compiles and runs under MinGW and MSVC on Windows platforms
 * Replaced libpthreadswin32 dependency with native libbladeRF threading macros
 * Improved error handling and reporting for out-of-range frequency and sample rate settings
 * Added detailed logging for USB transfer and Nios access timeouts
 * Updated Doxygen to v1.9.8, adding support for light/dark modes and modernized configuration
 * Improved GPIF buffer alignment handling for larger FX3 buffer sizes
 * Added CMake find_package() support for easier integration into external projects
 * Streamlined internal error checking macros, simplifying codebase
 * Enhanced sync_rx_meta example with additional argument parsing and MIMO support
 * Improved FPGA simulations for bladeRF 1.0 and bladeRF 2.0 micro

Bug Fixes:
 * Fixed delayed sample and off-by-one timestamp issues on bladeRF 1.0
 * Corrected TX meta sample gap issue when timestamp set to META_NOW
 * Resolved corrupted UART buffer in command_uart component
 * Fixed TX deadlock scenarios by refactoring RX/TX DMA prioritization
 * Addressed SC16_Q11 packed RX discontinuity issue on overflow condition
 * Fixed false timing paths and resolved multiple timing violations
 * Fixed calibration load check in bladerf_get_gain_calibration
 * Corrected RX meta packet timestamp and flags assignment
 * Fixed sync TX initialization bug

Miscellaneous:
 * Updated API documentation to reflect larger GPIF buffer sizes
 * Improved FX3 SDK setup instructions in README
 * Minor typo and documentation corrections throughout the codebase
2025-05-11 04:22:46 -07:00
Robert Ghilduta
902fc43305 firmware: bump version to 2.6.0
v2.6.0 (2025-05-06)
--------------------------------
 * Fixed missing break in BLADE_USB_CMD_QUERY_FPGA_SOURCE command handling
 * Improved FX3 SDK setup instructions in README
2025-05-11 04:21:32 -07:00
Robert Ghilduta
f746c5bd13 fpga: bump version to 0.16.0
--------------------------------
v0.16.0 (2025-05-06)
--------------------------------

This version brings significant FPGA improvements including sc16q11 packed mode
support and optimized USB throughput, along with important bug fixes for bladeRF
1.0 and 2.0 micro devices.

 Features:
 * hdl: Added sc16q11 packed mode for improved sample efficiency
 * hdl: Increased FX3 GPIF buffer sizes, boosting USB throughput (~356MB/s)
 * hdl: Implemented dynamic Nios base address assignment based on RAM size
 * hdl: Added parallel build support for hosted FPGA variants (40, 115, A4, A5, A9)
 * nios: Enabled elf-gdb and gdb-server support for improved debugging capability
 * hdl: Added git revision information to FPGA build outputs

 Fixes:
 * hdl: Fixed delayed sample and off-by-one timestamp bugs on bladeRF 1.0
 * hdl: Corrected TX meta sample gap issue when timestamp set to META NOW
 * hdl: Fixed corrupted UART buffer in command_uart component
 * hdl: Resolved TX deadlock scenarios by refactoring RX/TX DMA prioritization
 * hdl: Improved FPGA simulation accuracy for bladeRF 1 and 2 micro models
 * hdl: Fixed false timing paths and resolved multiple timing violations
2025-05-11 04:21:30 -07:00
Robert Ghilduta
e1325c0103 bladeRF-cli: bump version to 1.10.0
v1.10.0 (2025-05-06)
--------------------------------
 * Added sc16q11 packed format support
 * Improved sample format tracking and replaced legacy bit_mode handling
 * Migrated threading to unified libbladeRF thread macros
 * Updated CMake minimum requirement to modernized syntax
 * Fixed RX sample count overflow (issue #941)
 * Return error code when no available devices detected (issue #844)
 * Clarified K/M/G prefixes as powers of 1024 in documentation (issue #840)
 * Updated documentation to reflect sample limit changes
2025-05-11 04:17:01 -07:00
Robert Ghilduta
2003fd968f python: bump version to 1.4.0
v1.4.0 (2025-05-06)
--------------------------------
 * add support for SC16_Q11_META format
 * update Python binding definitions
2025-05-11 04:17:01 -07:00
Robert Ghilduta
5627503b27 matlab: bump version to 1.1.0
v1.1.0 (2025-05-06)
--------------------------------
 * Add bladerf_image_type_to_string API binding
 * Add missing RFIC_BIST loopback type
 * Improve enum string handling and conversion functions
 * Fix module default value handling in calibrate method
 * Standardize version information handling
2025-05-11 04:17:01 -07:00
Robert Ghilduta
20b9810eb0 misc: add missing CHANGELOGs
All CHANGELOGs should be up to date now.
2025-05-11 04:17:01 -07:00
Robert Ghilduta
bcf1f4b888 hdl: build A5s as part of build all hosteds 2025-05-11 04:17:01 -07:00
Robert Ghilduta
5e4da73c1c bladeRF-fsk: add git submodule for bladeRF-fsk repo 2025-05-11 04:17:01 -07:00
Robert Ghilduta
ff812e5305 bladeRF-fsk: move into its own repo 2025-04-24 04:36:36 -07:00
Robert Ghilduta
619e058115 matlab: add missing bladerf_image_type_to_string
Add missing bladerf_image_type_to_string API_EXPORT declaration and also
add it to matlab
2025-04-24 04:36:36 -07:00
Robert Ghilduta
6905c37642 host: finish off cross-platform support for Windows
libbladeRF now compiles under MinGW as well as MSVC under Windows
2025-04-24 04:36:36 -07:00
Robert Ghilduta
352b206044 WIP: momentarily disable bladeRF-fsk on Windows 2025-04-24 04:36:36 -07:00
Robert Ghilduta
d673366f4c host: final pthread migration to make linux compile 2025-04-24 04:36:36 -07:00
Robert Ghilduta
a83f21d525 host: clean up windows build script, remove pthreads 2025-04-24 04:36:36 -07:00
Robert Ghilduta
401d7df2c0 host: clean up README, and misc files to indicate remove libpthreadswin32 2025-04-24 04:36:36 -07:00
Robert Ghilduta
11506a4762 host: fixup windows related files 2025-04-24 04:36:36 -07:00
Robert Ghilduta
34fce67f4f host: remove pthreadswin32 cmake 2025-04-24 04:36:36 -07:00
Robert Ghilduta
7985676d0d host: switch over from using pthread.h to libbladeRF's thread.h 2025-04-24 04:36:36 -07:00
Robert Ghilduta
5863f983a2 host: remove remaining libpthreadswin32 and add fixups to cmake 2025-04-24 04:36:36 -07:00
Robert Ghilduta
1062b40d46 host: begin removing libpthreadswin32 from cmakes 2025-04-24 04:36:36 -07:00
Robert Ghilduta
bb93c07af8 host: libbladeRF's thread.h now compiles and runs.
Lowest level functions should now work. Async/sync functions probably still do
not work.
2025-04-24 04:36:36 -07:00
Robert Ghilduta
ee0e0040b6 libbladeRF_test: change over to libbladeRF thread macros 2025-04-24 04:36:36 -07:00
Robert Ghilduta
03b2481db9 bladeRF-cli: move to libbladeRF thread macros 2025-04-24 04:36:36 -07:00
Robert Ghilduta
5cdcd28e16 host: convert async/sync to libbladeRF thread macros 2025-04-24 04:36:36 -07:00
Robert Ghilduta
1e498900e8 libbladeRF: use libbladeRF thread macros 2025-04-24 04:36:36 -07:00
Robert Ghilduta
dc7accaa38 bladeRF-fsk: add additional gain controls 2025-04-24 04:36:36 -07:00
Ryan Thompson
af0045347f host: update CMake minimum required version format
Update cmake_minimum_required calls to use the 'min...max' version range syntax
 to fix CMake deprecation warnings. Also modernized CMP0115 policy to use the
 NEW behavior instead of OLD.
2025-04-24 04:36:36 -07:00
Ryan Thompson
4fd2a40ae1 host: googletest and abseil version bump 2025-04-24 04:36:36 -07:00
ifrasch17
b137fbdf91 hdl: updated readme with latest information
-removed stale information
-current quartus version to use is 20.1.1
-updated to include info about bladeRF 2 micro in addition to bladeRF 1
2025-04-24 04:36:36 -07:00
ifrasch17
b0aa8dd99c libbladeRF: Update API documentation for new GPIF buffer sizes
-fixed the buffer sizes listed in the descriptions of the bladerf META formats
2025-04-24 04:36:36 -07:00
Ben Morse
7b6a08e943 fx3: more explicit instructions for fx3 SDK 2025-04-24 04:36:36 -07:00
Ryan Thompson
2afc653557 hdl: dynamically set Nios data and instruction base address by ram size 2025-04-24 04:36:36 -07:00
Ryan Thompson
309e5e0266 hdl: fixed corrupted uart buffer with two writes before a read
When in the WAIT_FOR_READ state, the first character in reg_request
continuously is overwritten.
2025-04-24 04:36:36 -07:00
ifrasch17
23de23e55f hdl: Added missing signals to bladeRF2 nios_system model 2025-04-24 04:36:35 -07:00
ifrasch17
4bad3ab2ef hdl: fix delayed samples bug in bladeRF1
-adjusted transition from META_DOWNCOUNT to META_LOAD in attempt to fix delayed
 samples bug in bladeRF1
-Sample FIFO was missing the last read of each block
-Saw that meta_current.meta_time.go needed to be held for 1 extra clock cycle
-adjusted things so the transition only happens when dma_downcount==2 AND
 fifo_read=1
2025-04-24 04:36:35 -07:00
ifrasch17
ea07dad7dc hdl: fix bladeRF1 simulation
added missing files to compile.do, and added missing ports to nios_system.vhd,
 so that compile.do would compile and run without errors
2025-04-24 04:36:35 -07:00
Ryan Thompson
92b14af787 nios: added elf-gdb and gdb-server to the make args wrapping nios cmds 2025-04-24 04:36:35 -07:00
Ryan Thompson
fc0be5f7fb nios: rm --go from nios elf load
--go does not let the Nios core continue as one would assume. Now a gdb
client can connect and continue without issues.
2025-04-24 04:36:35 -07:00
Robert Ghilduta
4ef9a72242 bladeRF-update: upgrade utility for firmware and FPGA updates
This commit introduces a new utility, bladeRF-update, which checks for and
optionally installs updates for the bladeRF firmware and FPGA images. The
utility provides functionality to download, verify, and update firmware and FPGA
files based on version information retrieved from the official Nuand server.
2025-04-24 04:36:35 -07:00
Ryan Thompson
ecbfb99b8a libbladeRF: log sample rate ranges on failed sample rate assignment 2025-04-09 23:17:40 -07:00
Ryan Thompson
50eaaa6e0c libbladeRF: added direction to transfer timeout errors 2025-04-09 23:17:40 -07:00
Ryan Thompson
bd5d06879b build_bladerf: added parallel build for hosted 40, 115, A4, A9 FPGAs
usage:
./build_bladerf.sh -H
2025-04-09 23:17:40 -07:00
Ryan Thompson
90bd8bb9cc doc: update sync config buffer size description 2025-04-09 23:17:40 -07:00
Ryan Thompson
234fcfeebf doc: added Doxygen support for light and dark modes 2025-04-09 23:17:40 -07:00
Ryan Thompson
0e2a978554 doc: Doxygen config update v1.8.8 > v1.9.8
└> doxygen -u Doxyfile.in
warning: Tag 'TCL_SUBST' at line 247 of file 'Doxyfile.in' has become obsolete.
         This tag has been removed.
warning: Tag 'COLS_IN_ALPHA_INDEX' at line 1059 of file 'Doxyfile.in' has become obsolete.
         This tag has been removed.
warning: Tag 'HTML_TIMESTAMP' at line 1194 of file 'Doxyfile.in' has become obsolete.
         This tag has been removed.
warning: Tag 'FORMULA_TRANSPARENT' at line 1475 of file 'Doxyfile.in' has become obsolete.
         This tag has been removed.
warning: Tag 'LATEX_SOURCE_CODE' at line 1749 of file 'Doxyfile.in' has become obsolete.
         This tag has been removed.
warning: Tag 'DOCBOOK_PROGRAMLISTING' at line 1911 of file 'Doxyfile.in' has become obsolete.
         This tag has been removed.
warning: Tag 'PERL_PATH' at line 2090 of file 'Doxyfile.in' has become obsolete.
         This tag has been removed.
warning: Tag 'CLASS_DIAGRAMS' at line 2103 of file 'Doxyfile.in' has become obsolete.
         This tag has been removed.
warning: Tag 'MSCGEN_PATH' at line 2112 of file 'Doxyfile.in' has become obsolete.
         This tag has been removed.
warning: Tag 'DOT_FONTNAME' at line 2154 of file 'Doxyfile.in' has become obsolete.
         This tag has been removed.
warning: Tag 'DOT_FONTSIZE' at line 2161 of file 'Doxyfile.in' has become obsolete.
         This tag has been removed.
warning: Tag 'DOT_TRANSPARENT' at line 2372 of file 'Doxyfile.in' has become obsolete.
         This tag has been removed.
warning: Changing CLASS_GRAPH option to TEXT because obsolete option CLASS_DIAGRAM was found and set to NO.
2025-04-09 23:17:40 -07:00
Ryan Thompson
45e2d8f128 test: bump python requirements.txt versions 2025-04-09 23:17:40 -07:00
Ryan Thompson
79785afcf1 bladeRF-cli: added sc16q11 packed format support 2025-04-09 23:17:40 -07:00
Ryan Thompson
b774f45d38 bladeRF-cli: added sc16q11 packed format support 2025-04-09 23:17:40 -07:00
Ryan Thompson
72db17fa2c libbladeRF: fix packet format async stream to bytes
This fixes the sync interface packet format misalignment when sync
config assumes the sync config buffer is in bytes.
2025-04-09 23:17:40 -07:00
Ryan Thompson
2d2904e880 libbladeRF: added bladerf_format_to_string function 2025-04-09 23:17:40 -07:00
Ryan Thompson
0917d0780b libbladeRF: support for smaller GPIF buffer FPGA and FX3 versions 2025-04-09 23:17:40 -07:00
Ryan Thompson
0b00acac09 libbladeRF: error on GPIF buffer size mismatch between FX3 and HDL
While retaining the original non-fail condition for mismatches, we
throw an error for FPGA and FX3 images that have incompatible buffer
sizes. This prevents operational issues when mixing firmware versions
that support larger USB transfer buffers with FPGA versions that don't,
and vice versa.
2025-04-09 23:17:40 -07:00
Ryan Thompson
d586de33c1 libbladeRF: added legacy GPIF buffer size support for FW < v2.5.0 2025-04-09 23:17:40 -07:00
Ryan Thompson
cc6f329bb8 hdl: refactor RX/TX DMA request prioritization
* fixed TX deadlock when RX requests are not executed
* simplified RX and TX request prioritization
2025-04-09 23:17:40 -07:00
Ryan Thompson
f788085819 hdl: fixed tx sample fifo reset false path assigns for x40 & x115 builds 2025-04-09 23:17:40 -07:00
Ryan Thompson
730094891d hdl: fixed TX meta sample gap every gpif len when timestamp is META NOW 2025-04-09 23:17:40 -07:00
Ryan Thompson
3614c2ccc5 hdl: fixed late exit from TX meta down count state
The expected two cycle passing between meta write and idle states is
independent of the number of streams. Specifically addresses an
off-by-one timestamp error with the bladeRF 1.0.
2025-04-09 23:17:40 -07:00
Ryan Thompson
e8ec849ee7 nios: fix missing break for BLADE_USB_CMD_QUERY_FPGA_SOURCE 2025-04-09 23:17:40 -07:00
Ryan Thompson
3a11ac3b39 hdl: fix fifo reader meta_p_time conditional violation
The conditional that moves the meta state to META_DOWNCOUNT contains a
max value check using the `val+1=0` idiom. We can remove the carry
propagation delay by comparing against a max value constant
assigned (others => '1'). The fixes a setup time violation.
2025-04-09 23:17:40 -07:00
Ryan Thompson
9db41c9faf hdl: optimized sc16q11 packed cycle calculation
Alleviates timing violations from resources allocated by the calibration
signal IP.
2025-04-09 23:17:40 -07:00
Ryan Thompson
b086beee7e libbladeRF: added error print for set frequencies out of range 2025-04-09 23:17:40 -07:00
Ryan Thompson
bfadb91e06 libbladeRF: fixed rx meta packet timestamp and flags assignment 2025-04-09 23:17:40 -07:00
Ryan Thompson
899cd2274f libbladeRF: refactored bladerf_enable_feature
These changes make it much easier to add features to libbladeRF.
The nested ifs have been restructured for a switch and errors leverage
the goto error. The device handle now is also null checked. The mutex
lock has also been removed.

Regression test passed.
2025-04-09 23:17:40 -07:00
Ryan Thompson
0b54c576e3 host: NULL_CHECK made variadic 2025-04-09 23:17:40 -07:00
Ryan Thompson
950189d29d hdl: fix fifo_reader packet mode dma_downcount off-by-one error 2025-04-09 23:17:40 -07:00
Ryan Thompson
16c184b6dc test: added fx3_gpif_iq_packed_tb to regression test 2025-04-09 23:17:40 -07:00
Ryan Thompson
b2d9f969a5 bladeRF-cli: added sc16q11 packed mimo tx example 2025-04-09 23:17:40 -07:00
Ryan Thompson
709d45d853 bladeRF-cli: added sc16q11 packed siso tx example 2025-04-09 23:17:40 -07:00
Ryan Thompson
c407de2c9f bladeRF-cli: added sc16q11 packed mimo rx example 2025-04-09 23:17:40 -07:00
Ryan Thompson
3ae66b49a1 bladeRF-cli: added sc16q11 packed siso rx example 2025-04-09 23:17:40 -07:00
Ryan Thompson
6eab5f6a5e bladeRF-cli: added sc16q11 packed format support 2025-04-09 23:17:40 -07:00
Ryan Thompson
b655422a71 bladeRF-cli: replace cli state member bit_mode_8bit with sample_format
Instead of relying on a bit_mode boolean assignment, we can directly
rely on a bladerf_format state member.
2025-04-09 23:17:40 -07:00
Ryan Thompson
59b68f7bf2 bladeRF-cli: sample format tracked by cli state
This will allow us to track the sample format across the cli and can
replace the bit_mode cli state member.
2025-04-09 23:17:40 -07:00
Ryan Thompson
5ff41748aa libbladeRF: added sc16q11 packed error when initializing async stream
BLADERF_FORMAT_SC16_Q11_PACKED is only supported with the synchronous
interface.
2025-04-09 23:17:40 -07:00
Ryan Thompson
ff1b3d4e97 libbladeRF: added sc16q11 packed tx support 2025-04-09 23:17:40 -07:00
Ryan Thompson
d48f0d568f hdl: added sc16q11 packed tx support 2025-04-09 23:17:40 -07:00
Ryan Thompson
36dddacd27 hdl: added sc16q11 packed format to fx3 model
Every 3 gpif cycles will contain 4 sc12q11 samples when the
packed format is enabled.
2025-04-09 23:17:40 -07:00
Ryan Thompson
057964225f hdl: added sc16q11 packed tx sample drop check 2025-04-09 23:17:40 -07:00
Ryan Thompson
999f632f8c hdl: fixed sc16q11 packed discontinuity on RX overflow
The 12b write cycle and buffer are held constant when in the HOLDOFF
state.
2025-04-09 23:17:40 -07:00
Ryan Thompson
79cae1e87f libbladeRF: added sc16q11 packed sample format
libbladeRF ingests SC12 Q11 samples and expands them to SC16 Q11 before
filling the end buffer. The trade-off is CPU cycles for the 12b to 16b
conversion.
2025-04-09 23:17:40 -07:00
Ryan Thompson
9a22cd26d5 hdl: added sc16q11 packed enable signal from Nios GPIO 2025-04-09 23:17:40 -07:00
Ryan Thompson
6196c71911 hdl: added sc16q11 packed tb 2025-04-09 23:17:40 -07:00
Ryan Thompson
b52f50c1fe hdl: added highly packed mode to fifo writer
Iteratively packs 12b'samples across 3 fifo writes. The meta downcount
operation still needs to be confirmed.
2025-04-09 23:17:40 -07:00
Ryan Thompson
966900a8c1 hdl: added enable signal for highly packed mode 2025-04-09 23:17:40 -07:00
Ryan Thompson
04c1215e02 libbladeRF: test: added packet test 2025-04-09 23:17:40 -07:00
Ryan Thompson
bc6ac13970 doc: updated fx3 firmware folder name 2025-04-09 23:17:40 -07:00
Ryan Thompson
bdd4f39a3d fx3_firmware: rev libbladeRF, hdl, and fx3 for 2048 sample gpif buffers
FX3 GPIF buffers set to 2048 samples and number of buffers reduced to
11 per dma channel. This substantially increases the theoretical USB
SuperSpeed throughput from roughly 228MB/s to 356MB/s.

$ make test_libbladeRF
[       OK ] libbladeRF.scheduled_retune (19755 ms)
[----------] 29 tests from libbladeRF (308802 ms total)

[----------] Global test environment tear-down
[==========] 29 tests from 1 test suite ran. (308802 ms total)
[  PASSED  ] 29 tests.
2025-04-09 23:17:40 -07:00
Ryan Thompson
87e06388d4 hdl: revert jtag timing fixes
SignalTap may throw a "jtag instance not found" error which is sourced
from not meeting timing requirements for the jtag interface. Reverting
previous fixes may resurface some timing issues, but the "instance not
found" error at least goes away and I can use signal tap again.

Sources:
SignalTap-II -> "instance not found" error
https://community.intel.com/t5/Programmable-Devices/SignalTap-II-gt-quot-instance-not-found-quot-error/m-p/238886

How to set timing constraint for JTAG
https://community.intel.com/t5/Programmable-Devices/How-to-set-timing-constraint-for-JTAG/m-p/1379278
2025-04-09 23:17:40 -07:00
Ryan Thompson
d0d6d97eb4 doc: bladeRF-cli: updated sample limit to match buffer limit 2025-04-09 23:17:40 -07:00
Ryan Thompson
a0937cc50c doc: updated buf size limit in examples and tests 2025-04-09 23:17:40 -07:00
Ryan Thompson
a62c1d4903 libbladeRF: support and clamp byte alignment to larger GPIF buffer size
This change also includes a refactor of the redundant format to sample
size conversions found within the synchronous and asynchronous
interfaces.
2025-04-09 23:17:40 -07:00
Ryan Thompson
05ede8f541 fx3_firmware: increase DMA buffer sizes for USB throughput bottleneck
$ make test_hdl
[----------] Global test environment tear-down
[==========] 63 tests from 2 test suites ran. (381209 ms total)
[  PASSED  ] 63 tests.
[100%] Built target test_hdl
2025-04-09 23:17:40 -07:00
Ryan Thompson
2aaa5e2961 hdl: test: added variable gpif buffer length support for 8b testbenches 2025-04-09 23:17:40 -07:00
Ryan Thompson
5d7ff6a0ea hdl: test: added variable gpif buffer length support for gpif meta tb 2025-04-09 23:17:40 -07:00
Ryan Thompson
37d3e0b2e5 hdl: test: added variable gpif buffer length support for fx3_gpif_iq_tb 2025-04-09 23:17:40 -07:00
Ryan Thompson
6a0de33642 hdl: test: variable gpif buf length support added to testbenches 2025-04-09 23:17:40 -07:00
Ryan Thompson
89caa01c12 hdl: test: added variable length gpif support to fx3_model 2025-04-09 23:17:40 -07:00
Ryan Thompson
27fe2f48ea hdl: moved gpif buf size constants to fx3 gpif package
As we add changes to the FX3, it will be much easier to have a single
source of truth for the GPIF DMA sizes. This commit should not introduce
any changes to simulation or synthesis results.
2025-04-09 23:17:40 -07:00
Ryan Thompson
77d234c3bb hdl: leverage full sample depth of sample fifos
We were limiting ourselves to half of the fifo depth and subtracting
4 gpif buffers from that, which is 1/4 of the current fifo depth. No
sign of a full fifo during siso, mimo, meta, and non-meta streaming
tests at low sample rates. The fifo writes are appropriately held off.
2025-04-09 23:17:40 -07:00
Ryan Thompson
367df45e75 hdl: fixed fifo ingestion arithmetic on tx enable toggle
The channel shift would be left at 1 after the state moved to
COMPUTE_ENABLED_CHANNELS. Samples left would be reassigned to 1 in
COMPUTE_OFFSETS. Then channel offset would be assigned 2, an invalid
value.

This change only assigns samples left and channel shift if at the 0th
sample index, which allows for sample continuity.
2025-04-09 23:17:40 -07:00
Ryan Thompson
f230c9dc8d hdl: test: added gpif fifo stress test testbench
This copies the gpif 8b testbench, but with 7 blocks per TX iteration
and 2 subsequent iteration repeats. Run for 4ms to find channel shift
reset failure.
2025-04-09 23:17:40 -07:00
Ryan Thompson
465ea0a49e libbladeRF: test: added streaming test
The streaming test allows for cross testing between MIMO, SISO, TX, RX, meta,
and non-meta configurations.

Example: TX a CW at 50MSPS and at a frequency of (915MHz+50MHz/16) with meta enabled
./output/libbladeRF_test_streaming -te -s 50M

Example: TX and RX at 25MSPS and at a frequency of (915MHz+25MHz/16) without meta enabled
./output/libbladeRF_test_streaming -tr -s 25M
2025-04-09 23:17:40 -07:00
Ryan Thompson
ffd7f52a40 hdl: added git information to build output 2025-04-09 23:17:40 -07:00
Ryan Thompson
a8481c2af7 doc: added packet length warning for BLADERF_FORMAT_PACKET_META
A packet length of (n*256-4) DWORDs will cause the synchronous
buffer it's filled into to indefinitely persist.
2025-04-09 23:17:40 -07:00
Ryan Thompson
73e78639aa doc: fix API sections menu item with Doxygen 1.9.8
The API sections aren't stored as modules anymore. They're topics.
Error likely introduced at doxygen commit: 6d80fc7e5
2025-04-09 23:17:40 -07:00
Ryan Thompson
3cc8e3c54e hdl: fixed late exit from meta down count state
The expected two cycle passing between meta write and idle states is
independent of the number of streams. Specifically addresses an
off-by-one timestamp error with the bladeRF 1.0.
2025-04-09 23:17:40 -07:00
Ryan Thompson
65cdf88994 bladeRF-power: fixed ncurses dep
On macOS, sometimes the ${CURSES_LIBRARIES} variable provided by
 find_package(Curses) doesn't correctly include all the necessary linkage
 information, especially when using wide character support. By explicitly adding
 ncurses to the link libraries for Apple platforms, we ensure that the linker
 can find all the required symbols.
2025-04-09 23:17:33 -07:00
Ryan Thompson
179fe7c600 hdl: corrected bladeRF 1.0 FPGA version number 2025-01-06 13:36:48 -06:00
Semnodime
fe3304d759 hdl: fix readme typo
close #970
2024-08-13 14:56:15 -05:00
Asa Zernik
cbc3d30a27 libbladeRF: Return error code instead of asserting in version_check
Specifically, when there's a missing compat table entry. All callers
specify that they want to be forgiving of version mismatches, so this
seems in the spirit of the call tree.

Ran into this error when playing with a custom-loaded FPGA; if I had
flashed the FPGA instead of simply loading it, this could have bricked
the blade (or at least forced me into a very involved recovery process).
2024-08-13 11:43:21 +03:00
Ryan Thompson
26e91a550e libbladeRF: test: fix gain compare dev init 2024-08-10 18:20:33 -07:00
Ryan Thompson
e1a5c9260d libbladeRF: fix calibration load check for get_gain_calibration
Fixes #981
2024-08-10 18:16:51 -07:00
Ryan Thompson
d746811bd9 cmake: added Clang alternatives to compiler configurations 2024-08-10 18:16:51 -07:00
Ryan Thompson
f81b82aa8e libbladeRF: bump to version 2.5.1
Introduces bladeRF-power cli tool and gain calibration functionality.
2024-08-08 00:15:01 -05:00
Ryan Thompson
b98f385fb4 bladeRF-power: added sample rate assignment 2024-08-08 00:15:01 -05:00
Ryan Thompson
5f64e3f1c4 bladeRF-power: set test gain control to manual when TX 2024-08-07 15:35:55 -05:00
Ryan Thompson
94c08ebc9f bladeRF-power: added channel select 2024-08-07 15:35:55 -05:00
Ryan Thompson
68f396a102 bladeRF-power: added ascii text art for power measurements
█████╗    ███████╗       ██████╗     ██╗         ██████╗ ██████╗ ███╗   ███╗
           ██╔══██╗   ╚════██║       ╚════██╗   ███║         ██╔══██╗██╔══██╗████╗ ████║
███████╗   ╚██████║       ██╔╝        █████╔╝   ╚██║         ██║  ██║██████╔╝██╔████╔██║
            ╚═══██║      ██╔╝        ██╔═══╝     ██║         ██║  ██║██╔══██╗██║╚██╔╝██║
            █████╔╝     ██╔╝      ██╗███████╗    ██║         ██████╔╝██████╔╝██║ ╚═╝ ██║
            ╚════╝      ╚═╝       ╚═╝╚══════╝    ╚═╝         ╚═════╝ ╚═════╝ ╚═╝     ╚═╝
2024-08-07 15:35:55 -05:00
Ryan Thompson
818082947a bladeRF-power: cli: added stderr message viewer 2024-08-07 15:35:55 -05:00
Ryan Thompson
eff35dd799 bladeRF-power: cli: display warning if bladeRF-power window is too small
This actively checks if the window is too small and will provide a
warning when data is being hidden.
2024-08-07 15:35:55 -05:00
Ryan Thompson
d9be3348c3 bladeRF-power: cli: display calibration info when 'i' is pressed 2024-08-07 15:35:55 -05:00
Ryan Thompson
f370c2aef3 bladeRF-power: cli: rm module disable after stream
Closing the bladeRF after the module disable causes some usb interfaces
to fatally crash specifically for the TX interface.

discovery notes:
- Enable module and bladerf_close both call sync_deinit
- Mutex is destroyed in sync_deinit
2024-08-07 15:35:55 -05:00
Ryan Thompson
935ef43fb9 bladeRF-power: cli: added engineering notation suffix ingestion
This allows arguments to be specified with engineering notation.
E.g. bladeRF-power -f 4G
2024-08-07 15:35:55 -05:00
Ryan Thompson
8ec93c517c bladeRF-power: add FIR filter for power equalization across bandwidth
The FIR filter will equalize the noise figure across the bandwidth of
the bladeRF 2.0. After equalization, measurements of off-center CWs and
modulated waveforms are brought within +-1dB of error.
2024-08-07 15:35:55 -05:00
Ryan Thompson
b4e50ac1e4 bladeRF-power: added README.md and appended to utilities README.md 2024-08-07 15:35:55 -05:00
Ryan Thompson
3d350853b9 bladeRF-power: added install target 2024-08-07 15:35:55 -05:00
Ryan Thompson
64e709e885 bladeRF-power: init 2024-08-07 15:35:55 -05:00
Ryan Thompson
5e041d0ada libbladeRF: gain_calibration: added serial number to gain cal table
The gain calibration table will compare the serial number in the CSV
with the serial number of the opened device. A warning will be issued
if the serial numbers do not match.
2024-08-07 15:35:55 -05:00
Ryan Thompson
b185d4c60a libbladeRF: gain_calibration: added cal table valid entry check 2024-08-07 15:35:45 -05:00
Ryan Thompson
125d96f4b1 libbladeRF: gain_calibration: restore gain mode after cal load 2024-08-07 15:32:31 -05:00
Ryan Thompson
2ab7adc676 libbladeRF: gain_calibration: added header check for CSV conversions
This blocks RX gain calibrations from being applied to TX and
vice versa.
2024-08-07 15:31:54 -05:00
Ryan Thompson
3c25f57893 libbladeRF: gain_calibration: added bladerf_get_gain_target
The gain target is either set or calculated based on the gain mode. If
using manual gain control, the gain target from the gain table is
returned. If the AGC is enabled, the gain target is calculated based
on the current gain.
2024-08-07 15:31:54 -05:00
Ryan Thompson
3cef03a0ce libbladeRF: gain_calibration: reassign gain after loading calibration
This ensures the calibration is enabled once the calibration is loaded.
Since gain calibration relies on top level call to set the gain,
bladerf_set_gain(), we have to unlock the mutex and call said function.
2024-08-07 15:31:52 -05:00
Ryan Thompson
b5cfb5b036 libbladeRF: gain_calibration: added null check and gain cal loaded check 2024-08-07 15:19:06 -05:00
Ryan Thompson
eb78b981bd libbladeRF: gain_calibration: added free gain table function 2024-08-07 15:19:06 -05:00
Ryan Thompson
8031b84e59 libbladeRF: gain_calibration: store gain cal file within table 2024-08-07 15:19:06 -05:00
Ryan Thompson
a83272d452 libbladeRF: gain_calibration: added gain cal auto loading support
If the the file location is not specified, using a NULL file location,
then try loading the expected default file name from one of the
find_file locations.

The test renames the files to the default serial based file names and
stores them alongside the binary (one of the find_file locations).
2024-08-07 15:19:06 -05:00
Ryan Thompson
d2579486ce libbladeRF: gain_calibration: added table version check
Gain calibration tables will be denoted with the GAIN_CAL_VERSION macro
defined at the top of device_calibration.c.
2024-08-07 15:19:06 -05:00
Ryan Thompson
361646af41 libbladeRF: test: added gain calibration test to regression test 2024-08-07 15:19:06 -05:00
Ryan Thompson
dbf50d88d0 libbladeRF: gain_calibration: added RX test sweep 2024-08-07 15:19:06 -05:00
Ryan Thompson
b35052dfd7 libbladeRF: gain_calibration: CSV to bladeRF image binary
This changes the method of storing the binary data. Rather than a naive
CSV save, we package the binary in a bladeRF image format containing
metadata along with the power vs. frequency data.
2024-08-07 15:19:06 -05:00
Ryan Thompson
aab04e0a2b libbladeRF: image: print type with metadata
Ex:
Magic: bladeRF
Type: Raw Data
Version: 0.1.0
Timestamp: 655e530f
Serial: 
Address: 0
Length: 0
2024-08-07 15:19:06 -05:00
Ryan Thompson
eb3d128a8d libbladeRF: image: bladerf_image_print_metadata added
Ex:
Magic: bladeRF
Version: 0.1.0
Timestamp: 655e530f
Serial: 
Address: 0
Length: 0
2024-08-07 15:19:06 -05:00
Ryan Thompson
986c3a3353 libbladeRF: gain_calibration: added gain calibration image type 2024-08-07 15:19:06 -05:00
Ryan Thompson
ce634ef649 libbladeRF: gain_calibration: CSV additional parameters supported
The CSV import supports the added parameters and cross test for gain
and channel combinations.
2024-08-07 15:19:06 -05:00
Ryan Thompson
00346bba68 libbladeRF: gain_calibration: new example gain calibration CSVs 2024-08-07 15:19:06 -05:00
Ryan Thompson
afae6bde20 libbladeRF: gain_calibration: free table entries on bladerf_close() 2024-08-07 15:19:06 -05:00
Ryan Thompson
cb9dc300b1 libbladeRF: gain_calibration: gain corr set by bladerf_set_gain() 2024-08-07 15:19:06 -05:00
Ryan Thompson
e94f3c7378 libbladeRF: gain_calibration: gain correction implementation
Initially administered through frequency assignment.
2024-08-07 15:19:06 -05:00
Ryan Thompson
9fb9b19f42 libbladeRF: gain_calibration: added bladerf_get_gain_calibration 2024-08-07 15:19:06 -05:00
Ryan Thompson
d83fd7777d libbladeRF: gain_calibration: check and round macros for gain cal fns 2024-08-07 15:19:06 -05:00
Ryan Thompson
228de95650 libbladeRF: gain_calibration: print function added 2024-08-07 15:19:06 -05:00
Ryan Thompson
9cd7ab7d38 libbladeRF: gain_calibration: normalize correction values
TX=0dBm and RX=-30dBm are measurement targets set by the calibration
setup. These values are not to be changed unless the test measurement
setup has changed.
2024-08-07 15:19:06 -05:00
Ryan Thompson
cdaaa3d915 libbladeRF: gain_calibration: set gain target on load, set_gain, and en 2024-08-07 15:19:06 -05:00
Ryan Thompson
50dd427e49 libbladeRF: gain_calibration: enable function added 2024-08-06 18:47:45 -05:00
Ryan Thompson
b51057d774 libbladeRF: gain_calibration: load gain implementation
+ Automatic csv to bin file conversion
+ Gain tables for each channel
2024-08-06 18:47:45 -05:00
Ryan Thompson
838c177eba libbladeRF: gain_calibration: load function initialized 2024-08-06 18:47:45 -05:00
Ryan Thompson
f41966dcf8 libbladeRF: gain_calibration: example sweeps added 2024-08-06 18:47:45 -05:00
Ryan Thompson
3583aaca8e libbladeRF: gain_calibration: init
Adds the gain calibration tables along with the prototype for
bladerf_load_gain_calibration(). Also copies the stored calibration
references to the output directory.
2024-08-06 18:47:45 -05:00
Ryan Thompson
f8b7de8539 libbladeRF: do not enforce flash byte alignment for placeholder image 2024-08-06 18:47:45 -05:00
Ryan Thompson
fcfd174ca8 libbladeRF: added CHECK_STATUS_GOTO macro for bladerf2 board 2024-08-06 18:47:44 -05:00
Ryan Thompson
1d3fabfe6b libbladeRF: added save_fastlock_profile() to rfic struct 2024-08-06 18:47:44 -05:00
Ryan Thompson
02196a2e9b libbladeRF: bladerf_sync_tx: null check for TX samples
"Invalid operation or parameter" was the bladeRF error code returned
when samples were unallocated. Now, a log error is triggered saying
"bladerf_sync_tx: samples is null" and the return value is a bladeRF
memory error.
2024-08-06 18:47:44 -05:00
Ryan Thompson
ca68dfdb82 libbladeRF: automatically set manual gain control if gain is set 2024-08-06 18:47:44 -05:00
Ryan Thompson
452af25b50 libbladeRF: examples: frequency range sweep 2024-08-06 18:47:44 -05:00
Ryan Thompson
11adedda2e libbladeRF: added CHECK_STATUS macro to bladeRF.c 2024-08-06 18:47:44 -05:00
Ryan Thompson
a91b51974d libbladeRF: added bladerf_print_quick_tune()
Outputs the current quick retune parameters of a bladeRF
device to standard output. It is useful for debugging and verifying the
configuration of quick tune settings.
2024-08-06 18:47:44 -05:00
Ryan Thompson
c5b03ae93f libbladeRF: added CHECK_NULL(...) to bladeRF.c 2024-08-06 18:47:44 -05:00
Ryan Thompson
afc636073e libbladeRF: test: gain_compare: C test added
This isolates the gain differentiation on init from the CLI or Gnuradio.
Refer to the instructions below.

Instructions:

cd bladeRF/host/libraries/libbladeRF_test/test_gain_compare/
python -m venv env
source ./env/bin/activate
pip3 install -r requirements.txt

cd bladeRF/host/build
make -j`nproc` && sudo make install
./output/libbladeRF_test_gain_compare

cd ../libraries/libbladeRF_test/test_gain_compare/
mv ~/code/bladeRF/host/build/dual_test.bin .

python3 view_binary.py -n 2
2024-08-06 17:31:31 -05:00
Ryan Thompson
09fcacc9bc libbladeRF: test: gain_compare: comparing RX power with MIMO and SISO configs
This provides a way to test MIMO and SISO power measurements through
the CLI. The power for both channels under SISO and MIMO should be
about the same.

Instructions
---------------
python -m venv env
source ./env/bin/activate
pip install -r requirements.txt

Ch1 & Ch2:
bladeRF-cli -s bladerf_script_ch12.sh
python view_binary.py -n 2

Ch1:
bladeRF-cli -s bladerf_script_ch1.sh
python view_binary.py -n 1

Ch2:
bladeRF-cli -s bladerf_script_ch2.sh
python view_binary.py -n 1
2024-08-06 17:31:31 -05:00
Ryan Thompson
a87ad2208b libbladeRF: test: null and status checks in test_common.h 2024-08-06 17:31:31 -05:00
Ryan Thompson
f28c665024 libbladeRF: test: fixed "unrecognized option '--gtest_list_tests'" on make 2024-08-06 17:31:31 -05:00
Ryan Thompson
87337ccec0 libbladeRF: test: test_hwloop target added
Builds the python virtual environment for python based bladeRF tests.
2024-08-06 17:31:31 -05:00
Ryan Thompson
8596272391 gitignore: python venvs, build dirs, and vscode 2024-08-06 17:31:31 -05:00
Ryan Thompson
acdb03af43 doc: added bladerf_alloc_image parameter descriptions 2024-08-06 17:31:31 -05:00
Ryan Thompson
50d26e2e53 libbladeRF: issue warning for USB 2.0 clock select assignments 2024-08-06 17:30:40 -05:00
Ryan Thompson
b7a6173edd libbladeRF: added log message for failed FPGA image read 2024-08-06 17:30:40 -05:00
Ryan Thompson
a34f6aaf1b test: added clock select test 2024-08-06 17:30:40 -05:00
Ryan Thompson
ffb55acd05 libbladeRF: added log_debug_8x32_pkt for nios r/w failures 2024-08-06 17:27:32 -05:00
Ryan Thompson
03ccc0028a hdl: nios: debug print on failed pkt_8x32 r/w 2024-08-06 17:27:32 -05:00
Ryan Thompson
effe3eb2df libbladeRF: added error log for failed nios_config_write 2024-08-06 17:27:32 -05:00
Ben Morse
ffe66c5dfa host: update Eclipse instructions for NIOS software development on modern Quartus 20.1 2024-08-02 15:25:59 -05:00
Ryan Thompson
9f2f09fb76 libbladeRF: corrected bladeRF 2.0 gain mode count retrieval
bladerf_get_gain_modes() now returns the number of available
bladeRF 2.0 gain modes when the modes argument is NULL.

Fixes#968
2024-08-02 15:25:59 -05:00
Ryan Thompson
044fb54d61 test: libbladeRF: added bladerf_get_gain_modes to gain test
The bladeRF 1.0 should pass at this commit. The bladeRF 2.0 should pass
on the subsequent commit.
2024-08-02 15:25:59 -05:00
Ryan Thompson
24babc361e hdl: add clock control blocks for system and fx3 plls
Resolves Nios and FX3 lockup when SI53304 clock select assignments are
made. The FX3 pclk and Nios system PLLs lose lock when the SI53304
transitions between clock sources and this prevents invalid cycles from
making it through.
2024-08-02 15:25:59 -05:00
Ryan Thompson
fd5dde022f hdl: nios: add response delay if new clock is selected 2024-08-02 15:25:59 -05:00
Ryan Thompson
fcb33420a0 hdl: fix first sample drop in fifo_writer
This fixes the first sample being dropped in both meta and non-meta modes.
fifo_write is now asserted through procedure and executes on HOLDOFF exit.

Regression test results:

$ make test_libbladeRF
[       OK ] libbladeRF.scheduled_retune (19450 ms)
[----------] 29 tests from libbladeRF (297804 ms total)
[==========] 29 tests from 1 test suite ran. (297804 ms total)
[  PASSED  ] 29 tests.

$ make test_hdl
[----------] 31 tests from hdl (1354828 ms total)
[----------] 32 tests from hdl/verify (2319711 ms total)
[==========] 63 tests from 2 test suites ran. (3674539 ms total)
[  PASSED  ] 63 tests.
2024-08-02 15:25:59 -05:00
Ryan Thompson
58727ab7a1 hdl: init meta_fifo_empty to 1
[==========] 32 tests from 1 test suite ran. (1785986 ms total)
[  PASSED  ] 20 tests.
[  FAILED  ] 12 tests, listed below:
[  FAILED  ] hdl/verify.fx3_gpif_iq_8bit_tb/16b01, where GetParam() = (false, false, true)
[  FAILED  ] hdl/verify.fx3_gpif_iq_8bit_tb/16b10, where GetParam() = (false, true, false)
[  FAILED  ] hdl/verify.fx3_gpif_iq_8bit_tb/16b11, where GetParam() = (false, true, true)
[  FAILED  ] hdl/verify.fx3_gpif_iq_8bit_tb/8b01, where GetParam() = (true, false, true)
[  FAILED  ] hdl/verify.fx3_gpif_iq_8bit_tb/8b10, where GetParam() = (true, true, false)
[  FAILED  ] hdl/verify.fx3_gpif_iq_8bit_tb/8b11, where GetParam() = (true, true, true)
[  FAILED  ] hdl/verify.rx_counter_8bit_tb/16b01, where GetParam() = (false, false, true)
[  FAILED  ] hdl/verify.rx_counter_8bit_tb/16b10, where GetParam() = (false, true, false)
[  FAILED  ] hdl/verify.rx_counter_8bit_tb/16b11, where GetParam() = (false, true, true)
[  FAILED  ] hdl/verify.rx_counter_8bit_tb/8b01, where GetParam() = (true, false, true)
[  FAILED  ] hdl/verify.rx_counter_8bit_tb/8b10, where GetParam() = (true, true, false)
[  FAILED  ] hdl/verify.rx_counter_8bit_tb/8b11, where GetParam() = (true, true, true)

12 FAILED TESTS
2024-08-02 15:25:59 -05:00
Robert Ghilduta
cefdb2887c hdl: fixup more timing issues 2024-08-02 15:25:59 -05:00
Robert Ghilduta
f24abc356a debian: update change 2024-07-12 04:09:00 -04:00
Ryan Thompson
b40cd829be revert "libbladeRF: reinitialize the RFIC on FPGA load"
This reverts commit 0fcb4cfe03.
2024-05-01 16:02:35 -05:00
Robert Ghilduta
2fbae2c38b libbladeRF_test: bump dependency versions 2024-04-15 00:21:31 -07:00
Robert Ghilduta
4b62a41797 hdl: bladeRF-micro redefine JTAG SDC 2024-04-15 00:21:31 -07:00
Robert Ghilduta
473f5f0865 hdl: add false path for timing closure of common_dcfifo
Note: common_dcfifo impacts all bladeRF FIFOs, including sample and meta FIFOs.
2024-04-14 23:18:47 -07:00
Robert Ghilduta
88a1929394 libbladeRF: fix up sync TX initialization bug 2024-04-04 08:21:22 -05:00
Ryan Thompson
ac3e5aeb3f doc: updated default tuning mode to host 2024-04-04 08:21:22 -05:00
Ryan Thompson
0fcb4cfe03 libbladeRF: reinitialize the RFIC on FPGA load
This fixes a silent failure where an FPGA reload will loose
communication to the RFIC.
2024-04-04 08:21:22 -05:00
Ryan Thompson
1034fe0d41 test: added FPGA load test 2024-04-04 08:20:54 -05:00
Ben Morse
e50f28fba3 libbladeRF: fix compliation of regression tests with an older g++ 2024-03-04 14:16:08 -08:00
Ryan Thompson
38ab0517bc test: regression: added cmake version guard for FetchContent 2024-03-01 14:19:44 -06:00
Ryan Thompson
5aa65256a7 hdl: fifo_writer: eight_bit_mode default value set
This fixes the adsb builds.
2024-03-01 13:00:21 -06:00
Ryan Thompson
4ec99ebd9d libbladeRF: added cmake find_package() support
Fixes #418
2024-01-18 16:01:15 -06:00
Ryan Thompson
0c611be416 libbladeRF: force rerun frequency calibration on module enable
Addresses #947
2023-12-06 17:24:35 -06:00
Robert Ghilduta
747b64ee70 cmake: defines for MSVC 2023-12-02 01:28:25 -08:00
Robert Ghilduta
e71bdb391a cmake: defines for MSVC 2023-12-02 01:22:35 -08:00
Ryan Thompson
05dafc8e7e doc: bladeRF-cli: clarify K/M/G as powers of 1024
Fixes #840
2023-11-30 13:06:48 -06:00
Robert Ghilduta
94f2159c87 windows: add a few missing depencies 2023-11-30 05:11:23 -08:00
Robert Ghilduta
82eabb2f0e libbladeRF_test: bump dependency 2023-11-29 13:16:00 -08:00
Ryan Thompson
1a2d9e3e02 test: txrx_hwloop: fix getopt_long warning by changing 'c' to int
Resolved the compiler warning caused by comparing
getopt_long's return value with a char. Changed 'c'
from char to int to correctly handle -1 return values.

Fixes #952
2023-11-28 23:32:11 +00:00
Ryan Thompson
d0fbe05690 test: device test label turned into libbladeRF label
Not really a need to separate tests as libbladeRF is intended to
interface with the device.
2023-10-31 11:01:04 -05:00
Ryan Thompson
2b655e9423 test: python virtual environment setup added to build output
The setup_env.sh and requirements.txt files are copied to build/output.

Ex:
$ ./output/setup_env.sh
$ source nuand/bin/activate
$ python ./output/libbladeRF_test_txrx_hwloop.py
2023-10-31 11:01:04 -05:00
Ryan Thompson
bfabd63566 libbladeRF: fix assignment between very fast and very slow sample rates
Failure info:
Failed going from 48,601,811 -> 1,228,911 MSPS.
Worked when first sample rate is < 40,000,001 MSPS.
Worked when the subsequent sample rate is > 2,083,334 MSPS.

ad9361_validate_enable_fir: Invalid: ratio ADC/2 / TX_SAMPL * 16 > TAPS(max 64, adc 388814480, tx 48601810)
[ERROR @ host/libraries/libbladeRF/src/board/bladerf2/rfic_host.c:888] _rfic_host_set_filter: ad9361_set_tx_fir_en_dis(phy, enable) failed: An unexpected error occurred
[ERROR @ host/libraries/libbladeRF/src/board/bladerf2/bladerf2.c:1100] bladerf2_set_sample_rate: could not set TX filter mode: An unexpected error occurred
2023-10-31 11:00:36 -05:00
Ryan Thompson
d4cdad16ff doc: note that quick_tune must be non-NULL for the bladeRF micro 2.0 2023-10-31 11:00:36 -05:00
Ryan Thompson
75fbcb7cd6 test: test_regression conditionally added with cmake option
This prevents the long build time grabbing googletest and abseil libs.
2023-10-31 11:00:34 -05:00
Ryan Thompson
b33a4a711a test: list available test targets with "make test" 2023-10-31 10:29:54 -05:00
Ryan Thompson
237d6240d4 test: test_general renamed to test_regression 2023-10-31 10:28:21 -05:00
Ryan Thompson
32f1378eec test: regression test synthesizes all FPGA images
Defaults
+---------------+------------+----------------+
|     Board     |  Revision  | Supported Size |
+---------------+------------+----------------+
| bladeRF       | hosted     | 40             |
| bladeRF       | hosted     | 115            |
| bladeRF-micro | hosted     | A4             |
| bladeRF-micro | hosted     | A9             |
| bladeRF-micro | wlan       | A9             |
+---------------+------------+----------------+

All (--gtest_also_run_disabled_tests)
+---------------+------------+----------------+
|     Board     |  Revision  | Supported Size |
+---------------+------------+----------------+
| bladeRF       | hosted     | 40             |
| bladeRF       | hosted     | 115            |
| bladeRF       | adsb       | 40             |
| bladeRF       | adsb       | 115            |
| bladeRF       | atsc_tx    | 40             |
| bladeRF       | atsc_tx    | 115            |
| bladeRF       | fsk_bridge | 40             |
| bladeRF       | fsk_bridge | 115            |
| bladeRF       | headless   | 40             |
| bladeRF       | headless   | 115            |
| bladeRF       | qpsk_tx    | 40             |
| bladeRF       | qpsk_tx    | 115            |
| bladeRF-micro | hosted     | A4             |
| bladeRF-micro | hosted     | A9             |
| bladeRF-micro | adsb       | A4             |
| bladeRF-micro | adsb       | A9             |
| bladeRF-micro | foxhunt    | A4             |
| bladeRF-micro | foxhunt    | A9             |
| bladeRF-micro | wlan       | A9             |
+---------------+------------+----------------+
2023-10-31 10:28:21 -05:00
Ryan Thompson
46f8fc52bd test: rx_timestamp_tb: continuous run support 2023-10-31 10:28:21 -05:00
Ryan Thompson
282859b93c test: rx_timestamp_tb: MIMO support
Divides the expected meta value data by 2 when MIMO enabled.
2023-10-31 10:28:21 -05:00
Ryan Thompson
2928d7fe8f test: rx_timestamp_tb: meta_verify process iteration limit added
This circumvents the rst asserted in the tb.
2023-10-31 10:28:21 -05:00
Ryan Thompson
f046180604 host: CMake minimum version bump to 3.5
Accommodates the following warning issued by CMake v3.27.1.

CMake Deprecation Warning:
  Compatibility with CMake < 3.5 will be removed from a 
  future version of CMake.
2023-10-31 10:28:21 -05:00
Ryan Thompson
fc73ab1c1b test: fx3_gpif_meta_8bit_tb: corrected adc_streams().data_v behavior
adc_streams(0 and 1).data_v engages regardless of which module is
enabled in libbladeRF.
2023-10-31 10:28:21 -05:00
Ryan Thompson
369228a4b1 test: rx_timestamp_tb: removed redudent FIFO tests in other test benches 2023-10-31 10:28:21 -05:00
Ryan Thompson
e18c59ca46 test: fx3_gpif_meta_8bit_tb: last_ts re-initializes after reset asserted
Iterator added to meta spacing check. This allows for last_ts to
re-initialize after the reset to fifo_writer is asserted.
2023-10-31 10:28:21 -05:00
Ryan Thompson
bfd82bfcca hdl: FPGA patch update v0.15.3 2023-10-31 10:28:21 -05:00
Ryan Thompson
4b9906602e hdl: fifo_writer: proper META state transition for exclusive ch1 usage
Addresses an issue where the META state was not transitioning correctly
when only channel 1 (ch1) was enabled. The fix ensures that the META
state now correctly exits the META_WRITE state and enters the
META_DOWNCOUNT state when ch1 is exclusively enabled.
2023-10-31 10:28:21 -05:00
Ryan Thompson
91a34c83c7 test: fx3_gpif_iq_8bit_tb: adc_stream values checked directly for 16b
The 8b samples leave off the last 3 samples of the ADC.
Fixes 16b mode tests.
2023-10-31 10:28:21 -05:00
Ryan Thompson
10ee1f24d8 test: rx_timestamp_tb added to regression test 2023-10-31 10:28:21 -05:00
Ryan Thompson
48e8f84caa test: rx_timestamp_tb: eight_bit_mode_en made into generic 2023-10-31 10:28:21 -05:00
Ryan Thompson
5dccc5cd97 test: rx_counter_8bit_tb added to regression test 2023-10-31 10:28:21 -05:00
Ryan Thompson
714cafd4a2 test: rx_counter_8bit_tb: added 16bit and MIMO config support 2023-10-31 10:28:21 -05:00
Ryan Thompson
c23e8ae1e7 test: rx_counter_8bit_tb: eight_bit_mode_en made into generic 2023-10-31 10:28:21 -05:00
Ryan Thompson
be3f5071c0 test: rx_counter_8bit_tb: count resets when RX disabled 2023-10-31 10:28:21 -05:00
Ryan Thompson
47f1879dad test: loopback_tb added to regression test
No assertions found, therefore the test is empirical at commit. It 
instantiates a sample_stream_tb instance essentially serving as a
sample_stream_tb wrapper.
2023-10-31 10:28:21 -05:00
Ryan Thompson
429c78f1d8 test: fx3_gpif_meta_tb added to regression test 2023-10-31 10:28:21 -05:00
Ryan Thompson
fe9917784e test: fx3_gpif_tb added to regression test 2023-10-31 10:28:21 -05:00
Ryan Thompson
e5e94476e9 test: fx3_gpif_packet_tb added to regression test 2023-10-31 10:28:21 -05:00
Ryan Thompson
e6a0919c3b test: fx3_gpif_meta_tb added to regression test 2023-10-31 10:28:21 -05:00
Ryan Thompson
35a9870239 test: fx3_gpif_meta_8bit_tb: eight_bit_mode_en made into generic 2023-10-31 10:28:21 -05:00
Ryan Thompson
bf2f3c18c7 test: fx3_gpif_iq_tb added to regression test 2023-10-31 10:28:21 -05:00
Ryan Thompson
94988ca2fd test: fx3_gpif_8bit_tb test matrix generated by googletest 2023-10-31 10:28:21 -05:00
Ryan Thompson
f90181373c test: Abseil CMake build 2023-10-31 10:28:21 -05:00
Ryan Thompson
d072e2140c test: verify hdl macro and FX3 IQ 8bit test matrix added
General_test catches vsim failure assertions and runs the
fx3_gpif_iq_8bit_tb test matrix.

Test Matrix
+------+---------+---------+
| Mode |  EN_CH0 |  EN_CH1 |
+------+---------+---------+
| 8b   |       0 |       1 |
| 8b   |       1 |       0 |
| 8b   |       1 |       1 |
| 16b  |       0 |       1 |
| 16b  |       1 |       0 |
| 16b  |       1 |       1 |
+------+---------+---------+
2023-09-27 16:38:58 -05:00
Ryan Thompson
9527cf7d43 test: fx3_gpif_8bit_iq_tb: generics config on startup 2023-09-27 16:38:58 -05:00
Ryan Thompson
623029d407 test: fx3_gpif_iq_8bit_tb: eight_bit_mode_enable changed to generic 2023-09-27 16:38:58 -05:00
Ryan Thompson
9567fd7c27 test: test.do header and usage added 2023-09-27 16:38:58 -05:00
Ryan Thompson
4c2281c91f test: test.do vsim support
Assertion failures are caught by test.do and returns an
EXIT_FAILURE (1).
2023-09-27 16:38:58 -05:00
Ryan Thompson
4ca4f0b306 test: Quartus version check in regression test
Throws an error if the expected nois2_shell_command.sh has been found,
but in a different version of Quartus. Change NIOS2SHELL directive to
the appropriate nios2_shell_command.sh location.
2023-09-27 16:38:58 -05:00
Ryan Thompson
da67a6e27a test: add the rest of the bladeRF micro .do files 2023-09-27 16:38:58 -05:00
Ryan Thompson
9f4b55e626 test: test.do wrapper quits ModelSim if passed .do file has fails
test.do wraps existing .do files. This will exit vsim with a pass (0)
or fail (1) exit code accessible through the nios_command_shell.
Parameters will be passed to the child file.do.

Usage:
    do test.do <file.do> [params]

Example:
    ~/intelFPGA_lite/20.1/nios2eds/nios2_command_shell.sh
    cd ~/bladeRF/hdl/fpga/platforms/bladerf-micro/modelsim
    vsim .
    do test.do compile.do
2023-09-27 16:38:58 -05:00
Ryan Thompson
67059fa6d5 test: test_sync added to regression test 2023-09-27 16:38:57 -05:00
Ryan Thompson
64bbfd3bbc test: rx_scheduled added to regression test 2023-09-27 16:38:57 -05:00
Ryan Thompson
e0cda03288 test: fast test implemented in timestamp rx_scheduled 2023-09-27 16:38:57 -05:00
Ryan Thompson
15ca326537 test: rx_gaps added to regression test 2023-09-27 16:38:57 -05:00
Ryan Thompson
de5263d13c test: fast test implemented in timestamp rx_gaps 2023-09-27 16:38:57 -05:00
Ryan Thompson
7fae389cbf test: print timestamps added to regression test 2023-09-27 16:38:57 -05:00
Ryan Thompson
447a516a38 test: fast parameter added to test_timestamps
Used to limit print, rx_gaps, and rx_scheduled test iterations.
2023-09-27 16:38:57 -05:00
Ryan Thompson
5df19937bd test: scheduled_retune added to regression test
Failing at time of commit.
2023-09-27 16:38:57 -05:00
Ryan Thompson
f784d5000d test: generate hop set if none provided in scheduled retune
Generating a hop set allows us to integrate the test elsewhere.
2023-09-27 16:38:57 -05:00
Ryan Thompson
7df024b240 test: samplerate and threads test added
These two tests are failing at time of commit. Disabling threads test by
default in regression test. Refer to issue #705.
2023-09-27 16:38:57 -05:00
Ryan Thompson
bf097e8546 test: conditionally add the test directory
If the compile time isn't satisfactory, the libbladeRF test output has
been made conditional using TEST_LIBBLADERF option.
2023-09-27 16:38:57 -05:00
Ryan Thompson
587e9cb253 test: gtest populated check added 2023-09-27 16:38:57 -05:00
Ryan Thompson
b1e7b0d789 test: test target added to CMake
"make test" executes the general test after installing libbladeRF.
"make all test" will install and run the test as well.
2023-09-27 16:38:57 -05:00
Ryan Thompson
4f66f0e588 test: test_ctrl sample rate test prints rate hist on fail
Keeps track of the last few sample rate assignments and prints them on
a sample rate assignment failure.
2023-09-27 16:38:57 -05:00
Ryan Thompson
e1cd8a9816 test: fast sample rate test implemented in fast_ctrl 2023-09-27 16:38:57 -05:00
Ryan Thompson
8451e160b9 test: frequency and bandwidth tests added to regression test 2023-09-27 16:38:57 -05:00
Ryan Thompson
5fa474348b test: fast frequency test implemented in fast_ctrl 2023-09-27 16:38:57 -05:00
Ryan Thompson
199eac6e5c libbladeRF: get_samplerate_range returns range of current feature
It makes more sense to return a valid sample rate range in the current
state rather than a potential range.
2023-09-27 16:38:57 -05:00
Ryan Thompson
791598c259 test: fast bandwidth test implemented in fast_ctrl 2023-09-27 16:38:57 -05:00
Ryan Thompson
5ad06c3e2c test: fast option added to test_ctrl 2023-09-27 16:38:57 -05:00
Ryan Thompson
b09acf0d28 test: rx_meta test added to regression test
Performs cross validation across sample formats and SISO/MIMO configs.
2023-09-27 16:38:57 -05:00
Ryan Thompson
3cf456d8dc test: rx_meta example replicated as a test 2023-09-27 16:38:57 -05:00
Ryan Thompson
9b5ef28f49 test: async test added to regression test
Cross validates RX and TX streams.
2023-09-27 16:38:57 -05:00
Ryan Thompson
ad995b06cc test: test_async exit when TX sample count reached
Previously, the TX test relied on SIG_INT exit. Now it relies on the
the [# samples] argument or the pre-defined samples_left.
2023-09-27 16:38:57 -05:00
Ryan Thompson
a53250ff4f test: digital_loopback added to regression test
Performs a cross validation across supported sample formats and
loopback modes.
2023-09-27 16:38:57 -05:00
Ryan Thompson
7611d0619b test: tx_onoff_nowsched test added to regression test 2023-09-27 16:38:57 -05:00
Ryan Thompson
68e981613c test: XB-200 test added to regression test
This test has been left disabled. It can be enabled by passing
--gtest_also_run_disabled_tests.
2023-09-27 16:38:57 -05:00
Ryan Thompson
f2ceb6768d test: loopback, rx_mux, and gain tests added to regression test 2023-09-27 16:38:57 -05:00
Ryan Thompson
aa8348f6d1 test: enable_module added to regression test 2023-09-27 16:38:57 -05:00
Ryan Thompson
52571e8311 test: unused_sync added to regression test 2023-09-27 16:38:57 -05:00
Ryan Thompson
bb209bcc78 test: unused_sync exits on sync_config failure 2023-09-27 16:38:57 -05:00
Ryan Thompson
61bc13ba89 test: tune_timing added to regression test 2023-09-27 16:38:57 -05:00
Ryan Thompson
c706cfdf20 test: tune_timing iteration arg
The iteration argument allows for variable length tests.
2023-09-27 16:38:57 -05:00
Ryan Thompson
9808c17ad7 test: RX discontinuity test added to regression test
Tests 8bit and 16bit modes.
2023-09-27 16:38:57 -05:00
Ryan Thompson
2f7f5e22ee test: iterations added to test_quick_tune 2023-09-27 16:38:57 -05:00
Ryan Thompson
354e8329d6 test: improved argument handling in test_quick_retune
This allows for an easier implementation of the iteration limit.
2023-09-27 16:38:57 -05:00
Ryan Thompson
12b73e7492 test: repeated_stream added to regression test 2023-09-27 16:38:57 -05:00
Ryan Thompson
28bc627611 test: four tests added to regression test
+ parse
+ interleaver
+ freq_hop
+ peripheral timing
2023-09-27 16:38:56 -05:00
Ryan Thompson
c3e709997a test: libbladeRF tests added to regression test
+ version
+ c
+ cpp
2023-09-27 16:38:56 -05:00
Ryan Thompson
b2bfa13ebf test: regression test initialized
The general test leverages the GoogleTest framework and will later
serve as an integration test. The test exclusively executes
libbladeRF_test_open in this commit.
2023-09-27 16:38:56 -05:00
Ryan Thompson
686587fee4 hdl: U_tx signaltap 2023-09-27 16:38:56 -05:00
Ryan Thompson
6db565bb02 test: txrx_hwloop: module disable added to rx_tasks
This rids the RX overrun errors seen using "-v debug."
2023-09-27 16:38:56 -05:00
Ryan Thompson
30955e63fe test: txrx_hwloop: file specifiers corrected 2023-09-27 16:38:56 -05:00
Ryan Thompson
8206009d03 test: txrx_hwloop: separated rising and falling thresholds
This dramatically improved measurement consistency. Arrows on the plot
also show rising and falling edge catches clearly.
2023-09-27 16:38:56 -05:00
Ryan Thompson
0622b25bb8 test: txrx_hwloop: matched TX compare stats to RX stats 2023-09-27 16:38:56 -05:00
Ryan Thompson
a6502e6f57 test: txrx_hwloop: fill error distribution plot added to script 2023-09-27 16:38:56 -05:00
Ryan Thompson
5116281931 test: txrx_hwloop: sample rate arg added to script 2023-09-27 16:38:56 -05:00
Ryan Thompson
5998f459c8 test: txrx_hwloop: sample rate arg added to binary 2023-09-27 16:38:56 -05:00
Ryan Thompson
c29eb7aebf test: txrx_hwloop: sample err added to timestamp and fill predict 2023-09-27 16:38:56 -05:00
Ryan Thompson
6622bba034 test: txrx_hwloop: loaded optimal default params to script
This is assuming the use of a bladeRF 2.0 Micro and bladeRF x115
2023-09-27 16:38:56 -05:00
Ryan Thompson
cfa7a44d28 test: txrx_hwloop: TX and RX device strings accepted
Now the txrx_hwloop test is functional from the timestamp test suite,
although, with the caveat of working with default fill, iteration,
period, and burst values.
2023-09-27 16:38:56 -05:00
Ryan Thompson
229e6aca17 test: txrx_hwloop: ability to pass parameters to test
The user will likely pass parameters through the timestamp command interface if ran through the test_timestamps routine.
2023-09-27 16:38:56 -05:00
Ryan Thompson
41de26d349 test: txrx_hwloop: integration into timestamp test suite 2023-09-27 16:38:56 -05:00
Ryan Thompson
ee62ad5619 test: txrx_hwloop: fill comparison stats added to script 2023-09-27 16:38:56 -05:00
Ryan Thompson
8174c98541 test: txrx_hwloop: loopback compare RX gain set to 30
This resolves the RX AGC locking onto TX noise.
2023-09-27 16:38:56 -05:00
Ryan Thompson
b288a6f53e test: txrx_hwloop: include sample rate in param print 2023-09-27 16:38:56 -05:00
Ryan Thompson
6c396b8f54 test: timestamp loopback tests bladeRF2 block 2023-09-27 16:38:56 -05:00
Ryan Thompson
250c1e40ab test: txrx_hwloop: allow RF loopback on TX device w/o RX device 2023-09-27 16:38:56 -05:00
Ryan Thompson
f37cb0ba70 test: txrx_hwloop: pass -v args from script to binary 2023-09-27 16:38:56 -05:00
Ryan Thompson
f324a92b19 test: txrx_hwloop: removed unnecessary module enables 2023-09-27 16:38:56 -05:00
Ryan Thompson
2a0e45bcc5 test: txrx_hwloop: restructured some rx_task variable declarations 2023-09-27 16:38:56 -05:00
Ryan Thompson
d957c4832f test: txrx_hwloop: clarified thread declarations 2023-09-27 16:38:56 -05:00
Ryan Thompson
a4ec025e65 test: txrx_hwloop: IQ magnitude changed to power 2023-09-27 16:38:56 -05:00
Ryan Thompson
874d83a79f libbladeRF: bladerf_init_stream() timeout and dropped data warning 2023-09-27 16:38:56 -05:00
Ryan Thompson
93cec5db53 test: async invalid parameters errors log as error 2023-09-27 16:38:56 -05:00
Ryan Thompson
7489928624 test: txrx_hwloop: zero sample count stats removed 2023-09-27 16:38:56 -05:00
Ryan Thompson
d8d6b0c9b4 test: txrx_hwloop: -c dictates if the comparison is ran 2023-09-27 16:38:56 -05:00
Ryan Thompson
5532fcd21c test: txrx_hwloop: generalized plot assignments
Also changing y limits to easily witness empirical differences between
tests.
2023-09-27 16:38:56 -05:00
Ryan Thompson
a18dedb218 test: txrx_hwloop: try except for edge count imbalance 2023-09-27 16:38:56 -05:00
Ryan Thompson
93703f6167 test: txrx_hwloop: fill prediction using avg over mode
More reliable edge detector allows us to rely on an average fill rather
than the mode.
2023-09-27 16:38:56 -05:00
Ryan Thompson
2d0002a42d test: txrx_hwloop: much better edge detector added to script
The previous edge detector simply looked for sign flips over a
threshold value. This edge detector includes the separation of falling
and rising thresholds along with a debounce period.
2023-09-27 16:38:55 -05:00
Ryan Thompson
1cf5530e1b test: txrx_hwloop: script displays compare data 2023-09-27 16:38:55 -05:00
Ryan Thompson
d94266c9ea test: txrx_hwloop: compare flag python script pass through 2023-09-27 16:38:55 -05:00
Ryan Thompson
37154b5413 test: txrx_hwloop: compare module enable delayed
Addition of a device channel config function and postponement of the RX
channel enable of the TX device correcting the compare output.
2023-09-27 16:38:55 -05:00
Ryan Thompson
9b67d7de64 test: txrx_hwloop: compare thread file output
The TX device's RX data is now written to "compare.csv".
2023-09-27 16:38:55 -05:00
Ryan Thompson
c774c962a9 test: txrx_hwloop: loopback compare thread spawn
The binary now spawns a compare thread that takes in the RX samples
from the TX device. Currently overwrites the samples.csv that the
RX thread writes to.
2023-09-27 16:38:55 -05:00
Ryan Thompson
9c8c7d6841 test: txrx_hwloop: added enabled mode diagram to binary
Example program output:
$ ./output/libbladeRF_test_txrx_hwloop -lc
fill: 50%
Burst:    500.000k samples || 0.500s
Period:  1000.000k samples || 1.000s
Gap:      500.000k samples || 500.000ms
Mode: TX -> RX (+RF loopback)
    +---------------+       +---------------+
    | TX Device   TX|---┬-->|RX   RX Device |
    |               |   |   |               |
    |             RX|<--┘   |               |
    +---------------+       +---------------+
2023-09-27 16:38:55 -05:00
Ryan Thompson
99449330bd test: txrx_hwloop: compare argument
This is the switch that will kick off a same-device RX capture on the
TX module. Useful for comparing with the RX device capture.
2023-09-27 16:38:55 -05:00
Ryan Thompson
6813713a7b test: txrx_hwloop: python script after build made executable 2023-09-27 16:38:55 -05:00
Ryan Thompson
52b1e97042 test: txrx_hwloop: burst length capped to period length 2023-09-27 16:38:55 -05:00
Ryan Thompson
2832413283 test: txrx_hwloop: script stats output now toggleable through -s 2023-09-27 16:38:55 -05:00
Ryan Thompson
9cc10e0f25 test: txrx_hwloop: device IDs assignable through python script
Addition of --txdev and --rxdev arguments to the python script allowing
TX and RX device string assignments to be passed through to the binary.

Also, script exits on binary failure.
2023-09-27 16:38:55 -05:00
Ryan Thompson
5615d90eec test: txrx_hwloop: binary help includes hardware loopback example 2023-09-27 16:38:55 -05:00
Ryan Thompson
6109eb0efc test: txrx_hwloop: device IDs assignable through binary CLI
Addition of --txdev and --rxdev arguments to the binary CLI allowing
TX and RX device string assignments.
2023-09-27 16:38:55 -05:00
Ryan Thompson
88c86066c3 test: txrx_hwloop: threshold arg added 2023-09-27 16:38:55 -05:00
Ryan Thompson
4aa60ba735 test: txrx_hwloop: initial ts delay moved to test_case struct 2023-09-27 16:38:55 -05:00
Ryan Thompson
fe7629e8d7 test: txrx_hwloop: iterations controllable through script 2023-09-27 16:38:55 -05:00
Ryan Thompson
ef5d49504b test: txrx_hwloop: edge stats output clarified 2023-09-27 16:38:55 -05:00
Ryan Thompson
00e5534c45 test: txrx_hwloop: script arguments added
Essentially an argument pass-through to the hwloop binary.
2023-09-27 16:38:55 -05:00
Ryan Thompson
d94a2a1a58 test: txrx_hwloop: fill prediction changed from samp_count to %
The burst_len is now known given the python script initializes the
stimulus.
2023-09-27 16:38:55 -05:00
Ryan Thompson
182c06aaf9 test: txrx_hwloop: script sets off binary
This localizes the test to one script. Running the python script will
set off the binary and wait for the CSV results. Then, it will validate
the RX data.
2023-09-27 16:38:55 -05:00
Ryan Thompson
ff00946937 test: txrx_hwloop: script moved to /test_timestamps/scripts 2023-09-27 16:38:55 -05:00
Ryan Thompson
bcb48bae8f test: txrx_hwloop: fill prediction added 2023-09-27 16:38:55 -05:00
Ryan Thompson
346cbe22de test: txrx_hwloop: falling edge stats added 2023-09-27 16:38:55 -05:00
Ryan Thompson
a0a3a4e7bd test: txrx_hwloop: python script copies to /build/output 2023-09-27 16:38:55 -05:00
Ryan Thompson
ba76f57cef test: txrx_hwloop: timestamp prediction added 2023-09-27 16:38:55 -05:00
Ryan Thompson
22f5287714 test: txrx_hwloop: ESC closes matplotlib figure 2023-09-27 16:38:55 -05:00
Ryan Thompson
12990df794 test: txrx_hwloop: edge delta measurements added 2023-09-27 16:38:55 -05:00
Ryan Thompson
95b8b20c77 test: txrx_hwloop: edge detector added 2023-09-27 16:38:55 -05:00
Ryan Thompson
89d16aacb5 test: txrx_hwloop: init python IQ analyzer 2023-09-27 16:38:55 -05:00
Ryan Thompson
53b458c3c6 test: txrx_hwloop: RX samples write to file
The RX samples will be further analyzed in a Python script.
2023-09-27 16:38:55 -05:00
Ryan Thompson
5ff6f11977 test: txrx_hwloop: RX capture added
RX device capture of TX samples. Also outputs % of zero samples
read compared to total samples read giving a rough estimate of
the meta mode scheduling performance.
2023-09-27 16:38:55 -05:00
Ryan Thompson
4c02094ea0 test: txrx_hwloop: functions and structs moved to header 2023-09-27 16:38:55 -05:00
Ryan Thompson
11a90c7c11 test: txrx_hwloop: RX device init and deinit with param
An RX device can now be initialized and disabled with the '-l' command.
RX currently only does this.
2023-09-27 16:38:55 -05:00
Ryan Thompson
ecf1cbf981 test: txrx_hwloop: iteration count parameter added 2023-09-27 16:38:55 -05:00
Ryan Thompson
546dfc71d4 test: txrx_hwloop: additional help example and formatting 2023-09-27 16:38:55 -05:00
Ryan Thompson
90fc54708e test: txrx_hwloop: fill, burst, and period defs added to usage 2023-09-27 16:38:55 -05:00
Ryan Thompson
d34ca2345f test: txrx_hwloop: option placeholders added
Currently non-functional.
2023-09-27 16:38:55 -05:00
Ryan Thompson
a20d739863 test: txrx_hwloop: organized device init and RX placeholder added
The device strings must be assigned. RX does not perform any useful
task yet.
2023-09-27 16:38:54 -05:00
Ryan Thompson
b809f00175 test: txrx_hwloop: test case init moved to init_app_params() and dev->dev_tx 2023-09-27 16:38:54 -05:00
Ryan Thompson
0834c35897 test: txrx_hwloop: initialized 2023-09-27 16:38:54 -05:00
Ryan Thompson
01e8ea3b95 test: test_loopback_onoff_rf now loops back successfully
That being said, the test still fails. Most likely requires a
hysteresis region for the pwr threshold when reading RX'd samples.
2023-09-27 16:38:54 -05:00
Ryan Thompson
d0384b2330 test: test_loopback_onoff_rf: RX task added
Needs to be reworked once TX is implemented.
2023-09-27 16:38:54 -05:00
Ryan Thompson
3da84e98b3 test: test_loopback_onoff_rf: device setup added 2023-09-27 16:38:54 -05:00
Ryan Thompson
2d6e476b2b test: test_loopback_onoff_rf placeholder
Copy of test_loopback_onoff
2023-09-27 16:38:54 -05:00
Ryan Thompson
2ea75ae008 test: 1ms TX pulse test added 2023-09-27 16:38:54 -05:00
Robert Ghilduta
9fc57e6c7f libbladeRF: fix typo in sync_tx 2023-09-19 13:23:32 -07:00
Ryan Thompson
cf181d0427 bladeRF-cli: fixes 2**32 sample count overflow in RX config
Fixes #941
2023-09-18 13:43:22 +01:00
Ryan Thompson
0769521902 doc: corrected value pair type to int8_t
fix #939
2023-09-11 11:04:01 -05:00
Ryan Thompson
86d68eedfd libbladeRF: oversample register config set with bladerf_set_sample_rate 2023-08-25 14:40:01 -05:00
Ryan Thompson
452ba280ba host: rm unused variables
Resolves errors thrown by AppleClang 14.0.3.14030022.
2023-08-15 12:11:58 -05:00
Ryan Thompson
3c32966434 libbladeRF: sync_rx: # of enabled channels must divide into num_samples
Otherwise the buffer alignment would flip flop every other sync call.
2023-07-07 15:44:14 -05:00
Ryan Thompson
2e0f1aade3 libbladeRF: test_digital_loopback: 8bit rx_check and tx_callback support 2023-07-07 15:44:14 -05:00
Ryan Thompson
475e4596a8 libbladeRF: sync.c: seek within message based on remaining timestamp
Seek within message needed a timestamp based trigger for when MIMO
is enabled.
2023-07-07 15:44:14 -05:00
Ryan Thompson
6ccf082ccf libbladeRF: sync.c: target timestamp calculation refactor 2023-07-07 15:44:14 -05:00
Ryan Thompson
2274d380a0 libbladeRF: sync_rx_meta: --buflen argument added
Buffer size can now be assigned through an argument.
2023-07-07 15:44:14 -05:00
Ryan Thompson
78ac28ceaf libbladeRF: invalid buffer sizes will now be understood in the log 2023-07-07 15:44:14 -05:00
Ryan Thompson
d609034851 libbladeRF: sync_rx_meta: --numsamples argument added
Number of samples can now be assigned through an argument.
2023-07-07 15:44:14 -05:00
Ryan Thompson
99979934d5 libbladeRF: corrected message-in-buffer calculation
Support
+ 8bit MIMO
+ 8bit SISO
+ 16bit MIMO
+ 16bit SISO
2023-07-07 15:44:14 -05:00
Ryan Thompson
e60687033c libbladeRF: enable both RX/TX channels when layout is MIMO
The rfic_host now checks the stream_config for the channel_layout. If
RX or TX directions are configured for MIMO operation, both respective
channels will be enabled regardless of what channel is passed to
bladerf_enable_module.
2023-07-07 15:44:14 -05:00
Ryan Thompson
366ea46295 libbladeRF: channel2direction function added to conversions 2023-07-07 15:44:14 -05:00
Ryan Thompson
9faea357d0 libbladeRF: rx_count option added 2023-07-07 15:43:10 -05:00
Ryan Thompson
4627a6da6a quartus: signal tap file added for fifo_writer 2023-06-27 13:22:40 -05:00
Ryan Thompson
aa29cda96c libbladeRF: sync_rx_meta: MIMO option functional 2023-06-27 13:22:40 -05:00
Ryan Thompson
f6172a265a libbladeRF: sync_rx_meta: MIMO option added 2023-06-27 13:22:40 -05:00
Ryan Thompson
3e90784670 hdl: FPGA patch update v0.15.2
Corrects RX timestamp when MIMO enabled.
2023-06-26 13:37:36 -05:00
Ryan Thompson
891b4041ab hdl: exit the meta downcount state early if MIMO enabled
Exits the downcount one timestamp early when MIMO is enabled. This fixes
the off-by-one overrun when MIMO is enabled.

Fixes #855
2023-06-26 13:37:36 -05:00
Ryan Thompson
1e8098f383 hdl: meta spacing check in 8bit meta tb
This checks for meta spacing specifically in the first iteration of
the test. Warnings are expected after the first iteration of GPIF
transactions.
2023-06-26 13:37:36 -05:00
Ryan Thompson
c123d8398e libbladeRF: oversample gain restrictions removed
Gain assignments with the oversample feature enabled has been
stabilized across the entire gain range in the previous commit.
2023-06-08 08:49:01 -05:00
Ryan Thompson
01a8d0e8ce libbladeRF: gain assignments stabilized for oversample feature
Fixes #902
2023-06-08 08:49:01 -05:00
Ryan Thompson
7ec824fbbd libbladeRF: oversample register config moved to function 2023-06-08 08:49:01 -05:00
Ryan Thompson
c424eae9e6 libbladeRF: lower bound set for oversample gain 2023-06-07 12:38:05 -05:00
Ryan Thompson
48763b01c3 libbladeRF: oversample feature gain > 39 permitted
Still having problems from [12:38]. Starting from 39, spectrum operates
as expected.
2023-06-05 14:36:09 -05:00
Ryan Thompson
dfd8549d74 libbladeRF: bandwidth assignments in oversample mode issue log warning
Fixes #920
2023-06-05 13:44:25 -05:00
Ryan Thompson
c45e6b1a18 bladeRF-cli: return error(1) if no available devices
The CLI will only error out if the interactive shell has not been
invoked using the -i flag.

Fixes #844
2023-06-02 17:32:04 -05:00
Ryan Thompson
78457730dd host: jpynb iq sample analysis
Checks for dropped samples with single and dual RX channels enabled.
Currently only works for SC16_Q11 files. Expects a CW.
2023-05-16 11:40:01 -05:00
Ryan Thompson
368f0ac9e8 libbladeRF: FPGA load timeout increase
The longer timeout accommodates longer interface enable times. A test
script has been provided in case custom timeouts have been added
to usb.c.
2023-05-16 11:40:01 -05:00
Ryan Thompson
3a79fef1bd libbladeRF: correct documented SC8_Q7 range
Fixes #921
2023-05-11 16:50:46 -05:00
Ryan Thompson
86410e2721 hdl: FPGA patch update v0.15.1
+ 8bit RX timestamp correction
+ 8bit support signal_generator.vhd
2023-05-11 16:44:28 -05:00
Brian 'redbeard' Harrington
b0c940194f typo: libbladerf/CMakeLists.txt typo in libusb
In `host/libraries/libbladerf/CMakeLists.txt` there was typo in the
diagnostic instructing a user to install "libusb" and instead said
"lisusb"
2023-05-09 01:47:04 -07:00
Mike Ryan
2b90ed3976 libbladerf: correctly report num_samples for SC8_Q7 in async api
The async API has two codepaths for reporting samples to a user-provided
callback depending on whether packet metadata is requested. In the path
where it is requested, the code correctly uses bytes_to_samples() to
report num_samples. In the path where no metadata is requested, the code
uses the previously hardcoded call to bytes_to_sc16q11(), which
underreports num_samples by half for SC8_Q7 format samples. This appears
to have been an oversight, and this patch corrects the non-metadata path
to match the metadata path.
2023-04-11 03:18:16 -07:00
Ryan Thompson
aab9d26373 hdl: timestamp delay added for 8bit format addressing
Fixes #913
2023-03-31 17:25:49 -05:00
Ryan Thompson
4b9f9db756 Revert "libbladeRF: issue#913 SW workaround"
This reverts commit 447fc3da7bfeb98e190fa1bcebc36ca7e48b6dfc.
2023-03-31 17:18:01 -05:00
Ryan Thompson
aa0b530e81 hdl: init rx_timstamp_tb 2023-03-31 17:18:01 -05:00
Ryan Thompson
3f18c4de33 libbladeRF: sync_rx_meta format and rx_count printout 2023-03-31 17:18:01 -05:00
Ryan Thompson
4851a104cf libbladeRF: issue#913 SW workaround
The timestamp increment pattern has been discovered. The fix will
ultimately requires an HDL change.
2023-03-31 17:18:01 -05:00
Ryan Thompson
5d3f69271e libbladeRF: rx_count option added 2023-03-31 17:18:01 -05:00
Ryan Thompson
26d381a52b libbladeRF: sync_rx: SC8_Q7_META in meta and target timestamp init 2023-03-31 17:18:01 -05:00
Ryan Thompson
bf74e157a1 libbladeRF: test_rx_discont error formatting and max discont. to exit 2023-03-31 17:18:01 -05:00
Ryan Thompson
2d0da855a4 libbladeRF: test_rx_discont 8bit format passing
Doubled num_samples parameter to sync_rx and adjusted counter for 8bit
format. So long overruns!
2023-03-31 17:18:01 -05:00
Ryan Thompson
e6c68c05a4 hdl: signal generator shifts left 32bit count by 4
Left shifting the signal generator samples by 4 allows the 8bit packing
in fifo_writer to catch the LSBs.
2023-03-31 17:18:01 -05:00
Ryan Thompson
6c2a9dff8e hdl: rx_counter_8bit_tb 16bit check implemented
Still needs 8bit support within signal_generator.vhd
2023-03-31 17:18:01 -05:00
Ryan Thompson
f8fe3b8dfb hdl: init rx_counter_8bit_tb 2023-03-31 17:18:01 -05:00
Ryan Thompson
21d0489a40 libbladeRF: test_rx_discont GPIO assignment clarification 2023-03-31 17:18:01 -05:00
Ryan Thompson
3172f78c4c libbladeRF: test_rx_discont bitmode sel added
The 8bit bladeRF format currently triggers discontinuities. This makes
it easier to toggle between 16bit and 8bit tests.
2023-03-31 17:18:01 -05:00
Ryan Thompson
f04d3a8eed libbladeRF: sync_rx_meta logging 2023-03-31 17:18:01 -05:00
Ryan Thompson
cd0e18769d libbladeRF: example options revamped and bitmode sel added 2023-03-31 17:18:01 -05:00
Ryan Thompson
77f079ae7b libbladeRF: example RX meta assigns format through init parameter 2023-03-31 17:18:01 -05:00
Ryan Thompson
04cc3df992 doxygen: recursive search enabled 2023-03-31 17:18:01 -05:00
Ryan Thompson
7825ae5c5e libbladeRF: changed xb200 quick tune param recommendation
XB-200 quick tune parameter recommendation now considered log info rather 
than an error.

Fix #882
2023-03-31 17:18:01 -05:00
Robert Ghilduta
5235a58f12 foxhunt: fixup instantiation of gpif, rx, tx modules 2023-03-17 01:39:05 -07:00
Robert Ghilduta
9045fd9e82 hdl: increase bladeRF 1.0 TX buffer size 2023-03-09 04:15:39 -08:00
Robert Ghilduta
0aa59721d1 Revert "hdl: use a smaller TX fifo headroom to fully saturate buffers"
This reverts commit b69ce1f331.
2023-03-09 04:08:48 -08:00
Robert Ghilduta
b69ce1f331 hdl: use a smaller TX fifo headroom to fully saturate buffers 2023-03-09 04:06:14 -08:00
Robert Ghilduta
b0338b4a47 Cmake: provide more verbose messages when no backends can be enabled 2023-03-09 01:09:08 -08:00
Robert Ghilduta
8a7b41ae52 libbladeRF: conditionally set CMake policy
Allow for backward compatiblity with pre 3.20 versions of CMake by conditionally
setting CMake policy CMP0115
2023-03-04 00:40:14 -08:00
Robert Ghilduta
7e26f5a5b6 doxygen: provide more clarity for config file search paths 2023-02-28 04:49:41 -08:00
Robert Ghilduta
14aaebcc66 bladeRF-cli: clear up nomeclature in set samplerate 2023-02-28 04:43:00 -08:00
Robert Ghilduta
7c19e72837 libbladeRF: add cmake_policy exception to stop .in file warnings 2023-02-28 03:33:08 -08:00
Robert Ghilduta
2caac5afd5 libbladeRF: make FPGA loading optional
Some config options require the FPGA to be loaded and initialized. However
config options are set in bladerf_open(). Attempting to set such config options
should not block bladerf_open() from completing.
2023-02-28 03:27:47 -08:00
374 changed files with 49677 additions and 10948 deletions

14
.gitignore vendored
View file

@ -34,9 +34,7 @@ hdl/quartus/qpsk_txx*
fx3_firmware/make/toolchain.mk fx3_firmware/make/toolchain.mk
fx3_firmware/build/* fx3_firmware/build/*
build/* build/
host/build/*
host/examples/gnuradio/frs/bladeRF_frs.py host/examples/gnuradio/frs/bladeRF_frs.py
@ -54,3 +52,13 @@ host/misc/windows/scripts/work
**/modelsim/*.wlf **/modelsim/*.wlf
**/modelsim/work/ **/modelsim/work/
**/modelsim/nuand/ **/modelsim/nuand/
# Common Python virtual environment names
env/
venv/
ENV/
__pycache__/
*.py[cod]
*$py.class
.vscode/

3
.gitmodules vendored
View file

@ -1,3 +1,6 @@
[submodule "thirdparty/analogdevicesinc/no-OS"] [submodule "thirdparty/analogdevicesinc/no-OS"]
path = thirdparty/analogdevicesinc/no-OS path = thirdparty/analogdevicesinc/no-OS
url = https://github.com/analogdevicesinc/no-OS/ url = https://github.com/analogdevicesinc/no-OS/
[submodule "host/utilities/bladeRF-fsk"]
path = host/utilities/bladeRF-fsk
url = https://github.com/Nuand/bladeRF-fsk

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.12) cmake_minimum_required(VERSION 3.10...3.27)
project(bladeRF CXX C) project(bladeRF CXX C)
# Indicate that this is a top-level build # Indicate that this is a top-level build
set(BLADERF_TOP_LEVEL_BUILD ON) set(BLADERF_TOP_LEVEL_BUILD ON)

View file

@ -1,7 +1,7 @@
#!/bin/sh -e #!/bin/sh -e
UPSTREAM='https://www.nuand.com/fx3/bladeRF_fw_v2.4.0.img' UPSTREAM='https://www.nuand.com/fx3/bladeRF_fw_v2.6.0.img'
CHECKSUM='337f570f2e3fdb26abde0f0765196d92' CHECKSUM='7cc51b4eedebf54dd01be83745d1c59f'
DATAFILE='/usr/share/Nuand/bladeRF/bladeRF_fw.img' DATAFILE='/usr/share/Nuand/bladeRF/bladeRF_fw.img'
DESCRIPT='firmware' DESCRIPT='firmware'
MYNAMEIS='bladerf-firmware-fx3' MYNAMEIS='bladerf-firmware-fx3'

View file

@ -1,7 +1,7 @@
#!/bin/sh -e #!/bin/sh -e
UPSTREAM='https://www.nuand.com/fpga/v0.14.0/hostedx115.rbf' UPSTREAM='https://www.nuand.com/fpga/v0.16.0/hostedx115.rbf'
CHECKSUM='94ee5c7f68abe5c3392202246789fedd' CHECKSUM='a7f25be8abdab3835e734599eb846ea4'
DATAFILE='/usr/share/Nuand/bladeRF/hostedx115.rbf' DATAFILE='/usr/share/Nuand/bladeRF/hostedx115.rbf'
DESCRIPT='FPGA bitstream' DESCRIPT='FPGA bitstream'
MYNAMEIS='bladerf-fpga-hostedx115' MYNAMEIS='bladerf-fpga-hostedx115'

View file

@ -1,7 +1,7 @@
#!/bin/sh -e #!/bin/sh -e
UPSTREAM='https://www.nuand.com/fpga/v0.14.0/hostedx40.rbf' UPSTREAM='https://www.nuand.com/fpga/v0.16.0/hostedx40.rbf'
CHECKSUM='25f402b3734c9aa0d37db9531f93335c' CHECKSUM='f3d0e55aa4cae485df6d3c20004b7742'
DATAFILE='/usr/share/Nuand/bladeRF/hostedx40.rbf' DATAFILE='/usr/share/Nuand/bladeRF/hostedx40.rbf'
DESCRIPT='FPGA bitstream' DESCRIPT='FPGA bitstream'
MYNAMEIS='bladerf-fpga-hostedx40' MYNAMEIS='bladerf-fpga-hostedx40'

View file

@ -1,7 +1,7 @@
#!/bin/sh -e #!/bin/sh -e
UPSTREAM='https://www.nuand.com/fpga/v0.14.0/hostedxA4.rbf' UPSTREAM='https://www.nuand.com/fpga/v0.16.0/hostedxA4.rbf'
CHECKSUM='c24af70cf56b13123295125a22d5e921' CHECKSUM='276a74b748d699a9fc348babd34af19c'
DATAFILE='/usr/share/Nuand/bladeRF/hostedxA4.rbf' DATAFILE='/usr/share/Nuand/bladeRF/hostedxA4.rbf'
DESCRIPT='FPGA bitstream' DESCRIPT='FPGA bitstream'
MYNAMEIS='bladerf-fpga-hostedxa4' MYNAMEIS='bladerf-fpga-hostedxa4'

View file

@ -1,7 +1,7 @@
#!/bin/sh -e #!/bin/sh -e
UPSTREAM='https://www.nuand.com/fpga/v0.14.0/hostedxA5.rbf' UPSTREAM='https://www.nuand.com/fpga/v0.16.0/hostedxA5.rbf'
CHECKSUM='ae6391cc3fd467bbb07868450612ce17' CHECKSUM='be0909dc27b48a08c54db33675130f27'
DATAFILE='/usr/share/Nuand/bladeRF/hostedxA5.rbf' DATAFILE='/usr/share/Nuand/bladeRF/hostedxA5.rbf'
DESCRIPT='FPGA bitstream' DESCRIPT='FPGA bitstream'
MYNAMEIS='bladerf-fpga-hostedxa5' MYNAMEIS='bladerf-fpga-hostedxa5'

View file

@ -1,7 +1,7 @@
#!/bin/sh -e #!/bin/sh -e
UPSTREAM='https://www.nuand.com/fpga/v0.14.0/hostedxA9.rbf' UPSTREAM='https://www.nuand.com/fpga/v0.16.0/hostedxA9.rbf'
CHECKSUM='7dfe8c32f260d43a14b9583375a1a6eb' CHECKSUM='1ab3bc8bdcf16a5f0ddf3fcdbaa6556b'
DATAFILE='/usr/share/Nuand/bladeRF/hostedxA9.rbf' DATAFILE='/usr/share/Nuand/bladeRF/hostedxA9.rbf'
DESCRIPT='FPGA bitstream' DESCRIPT='FPGA bitstream'
MYNAMEIS='bladerf-fpga-hostedxa9' MYNAMEIS='bladerf-fpga-hostedxa9'

6
debian/changelog vendored
View file

@ -1,3 +1,9 @@
bladerf (2024.07) noble; urgency=medium
* 2024.07 Release 2024.07
-- Robert Ghilduta (Nuand LLC) <robert.ghilduta@nuand.com> Fri, 12 Jul 2024 03:32:13 -0400
bladerf (2021.10) unstable; urgency=low bladerf (2021.10) unstable; urgency=low
* Release for 2021.10 tag * Release for 2021.10 tag

4
debian/control vendored
View file

@ -2,8 +2,8 @@ Source: bladerf
Priority: optional Priority: optional
Maintainer: Nuand LLC <bladeRF@nuand.com> Maintainer: Nuand LLC <bladeRF@nuand.com>
Build-Depends: debhelper (>=9), cmake (>= 2.8.5), pkg-config, doxygen, Build-Depends: debhelper (>=9), cmake (>= 2.8.5), pkg-config, doxygen,
libusb-1.0-0-dev (>= 1.0.12), libtecla-dev | libtecla1-dev, libncurses5-dev, libusb-1.0-0-dev (>= 1.0.12), libedit-dev, libncurses5-dev,
git, help2man, pandoc git, help2man, pandoc, libcurl4-openssl-dev
Standards-Version: 4.1.4 Standards-Version: 4.1.4
Section: comm Section: comm
Homepage: https://www.nuand.com/bladeRF Homepage: https://www.nuand.com/bladeRF

11
debian/copyright vendored
View file

@ -60,17 +60,6 @@ License: OpenCores-I2C
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
Files: host/cmake/modules/FindLibPThreadsWin32.cmake
Copyright: 2008-2009 Hendrik Sattler
2013-2018 Nuand LLC
License: GPL-2+
Comment: This is file is based off of the FindLibUSB.cmake file written by
Hendrik Sattler, from the OpenOBEX project (licensed GPLv2/LGPL). (If
this is not correct, please contact us so we can attribute the author
appropriately.)
https://github.com/zuckschwerdt/openobex/blob/master/CMakeModules/FindLibUSB.cmake
http://dev.zuckschwerdt.org/openobex/
Files: host/cmake/modules/FindLibUSB.cmake Files: host/cmake/modules/FindLibUSB.cmake
Copyright: 2008-2009 Hendrik Sattler Copyright: 2008-2009 Hendrik Sattler
2013-2018 Nuand LLC 2013-2018 Nuand LLC

View file

@ -29,6 +29,8 @@
#include <inttypes.h> #include <inttypes.h>
#include <stdbool.h> #include <stdbool.h>
#include <ad9361_api.h>
/** /**
* The purpose of this header file is to allow the use of libad9361 without * The purpose of this header file is to allow the use of libad9361 without
* including all of the unnecessary defines, etc, used during compilation. * including all of the unnecessary defines, etc, used during compilation.
@ -46,15 +48,6 @@
* From common.h * From common.h
******************************************************************************/ ******************************************************************************/
struct clk_onecell_data {
struct clk **clks;
uint32_t clk_num;
};
/******************************************************************************
* From ad9361.h
******************************************************************************/
#define AD936X_REG_TX1_OUT_1_PHASE_CORR 0x08E #define AD936X_REG_TX1_OUT_1_PHASE_CORR 0x08E
#define AD936X_REG_TX1_OUT_1_GAIN_CORR 0x08F #define AD936X_REG_TX1_OUT_1_GAIN_CORR 0x08F
#define AD936X_REG_TX2_OUT_1_PHASE_CORR 0x090 #define AD936X_REG_TX2_OUT_1_PHASE_CORR 0x090
@ -98,681 +91,6 @@ struct clk_onecell_data {
#define AD936X_CNT(x) ((((x)-1) & 0x7) << 12) #define AD936X_CNT(x) ((((x)-1) & 0x7) << 12)
#define AD936X_ADDR(x) ((x)&0x3FF) #define AD936X_ADDR(x) ((x)&0x3FF)
enum dev_id { ID_AD9361, ID_AD9364, ID_AD9363A };
enum ad9361_clocks {
BB_REFCLK,
RX_REFCLK,
TX_REFCLK,
BBPLL_CLK,
ADC_CLK,
R2_CLK,
R1_CLK,
CLKRF_CLK,
RX_SAMPL_CLK,
DAC_CLK,
T2_CLK,
T1_CLK,
CLKTF_CLK,
TX_SAMPL_CLK,
RX_RFPLL_INT,
TX_RFPLL_INT,
RX_RFPLL_DUMMY,
TX_RFPLL_DUMMY,
RX_RFPLL,
TX_RFPLL,
NUM_AD9361_CLKS,
EXT_REF_CLK,
};
enum rx_gain_table_name {
TBL_200_1300_MHZ,
TBL_1300_4000_MHZ,
TBL_4000_6000_MHZ,
RXGAIN_TBLS_END,
};
enum rx_gain_table_type {
RXGAIN_FULL_TBL,
RXGAIN_SPLIT_TBL,
};
struct rx_gain_info {
enum rx_gain_table_type tbl_type;
int32_t starting_gain_db;
int32_t max_gain_db;
int32_t gain_step_db;
int32_t max_idx;
int32_t idx_step_offset;
};
enum ad9361_pdata_rx_freq {
BBPLL_FREQ,
ADC_FREQ,
R2_FREQ,
R1_FREQ,
CLKRF_FREQ,
RX_SAMPL_FREQ,
NUM_RX_CLOCKS,
};
enum ad9361_pdata_tx_freq {
IGNORE_FREQ,
DAC_FREQ,
T2_FREQ,
T1_FREQ,
CLKTF_FREQ,
TX_SAMPL_FREQ,
NUM_TX_CLOCKS,
};
struct ad9361_fastlock_entry {
//#define FASTLOOK_INIT 1
uint8_t flags;
uint8_t alc_orig;
uint8_t alc_written;
};
struct ad9361_fastlock {
uint8_t save_profile;
uint8_t current_profile[2];
struct ad9361_fastlock_entry entry[2][8];
};
enum ad9361_bist_mode {
BIST_DISABLE,
BIST_INJ_TX,
BIST_INJ_RX,
};
enum ad9361_clkout {
CLKOUT_DISABLE,
BUFFERED_XTALN_DCXO,
ADC_CLK_DIV_2,
ADC_CLK_DIV_3,
ADC_CLK_DIV_4,
ADC_CLK_DIV_8,
ADC_CLK_DIV_16,
};
enum rf_gain_ctrl_mode {
RF_GAIN_MGC,
RF_GAIN_FASTATTACK_AGC,
RF_GAIN_SLOWATTACK_AGC,
RF_GAIN_HYBRID_AGC
};
enum f_agc_target_gain_index_type {
MAX_GAIN,
SET_GAIN,
OPTIMIZED_GAIN,
NO_GAIN_CHANGE,
};
enum rssi_restart_mode {
AGC_IN_FAST_ATTACK_MODE_LOCKS_THE_GAIN,
EN_AGC_PIN_IS_PULLED_HIGH,
ENTERS_RX_MODE,
GAIN_CHANGE_OCCURS,
SPI_WRITE_TO_REGISTER,
GAIN_CHANGE_OCCURS_OR_EN_AGC_PIN_PULLED_HIGH,
};
struct rssi_control {
enum rssi_restart_mode restart_mode;
bool rssi_unit_is_rx_samples;
uint32_t rssi_delay;
uint32_t rssi_wait;
uint32_t rssi_duration;
};
struct port_control {
uint8_t pp_conf[3];
uint8_t rx_clk_data_delay;
uint8_t tx_clk_data_delay;
uint8_t digital_io_ctrl;
uint8_t lvds_bias_ctrl;
uint8_t lvds_invert[2];
uint8_t clk_out_drive;
uint8_t dataclk_drive;
uint8_t data_port_drive;
uint8_t clk_out_slew;
uint8_t dataclk_slew;
uint8_t data_port_slew;
};
struct ctrl_outs_control {
uint8_t index;
uint8_t en_mask;
};
struct elna_control {
uint16_t gain_mdB;
uint16_t bypass_loss_mdB;
uint32_t settling_delay_ns;
bool elna_1_control_en;
bool elna_2_control_en;
bool elna_in_gaintable_all_index_en;
};
struct auxadc_control {
int8_t offset;
uint32_t temp_time_inteval_ms;
uint32_t temp_sensor_decimation;
bool periodic_temp_measuremnt;
uint32_t auxadc_clock_rate;
uint32_t auxadc_decimation;
};
struct auxdac_control {
uint16_t dac1_default_value;
uint16_t dac2_default_value;
bool auxdac_manual_mode_en;
bool dac1_in_rx_en;
bool dac1_in_tx_en;
bool dac1_in_alert_en;
bool dac2_in_rx_en;
bool dac2_in_tx_en;
bool dac2_in_alert_en;
uint8_t dac1_rx_delay_us;
uint8_t dac1_tx_delay_us;
uint8_t dac2_rx_delay_us;
uint8_t dac2_tx_delay_us;
};
struct gpo_control {
bool gpo0_inactive_state_high_en;
bool gpo1_inactive_state_high_en;
bool gpo2_inactive_state_high_en;
bool gpo3_inactive_state_high_en;
bool gpo0_slave_rx_en;
bool gpo0_slave_tx_en;
bool gpo1_slave_rx_en;
bool gpo1_slave_tx_en;
bool gpo2_slave_rx_en;
bool gpo2_slave_tx_en;
bool gpo3_slave_rx_en;
bool gpo3_slave_tx_en;
uint8_t gpo0_rx_delay_us;
uint8_t gpo0_tx_delay_us;
uint8_t gpo1_rx_delay_us;
uint8_t gpo1_tx_delay_us;
uint8_t gpo2_rx_delay_us;
uint8_t gpo2_tx_delay_us;
uint8_t gpo3_rx_delay_us;
uint8_t gpo3_tx_delay_us;
};
struct tx_monitor_control {
bool tx_mon_track_en;
bool one_shot_mode_en;
uint32_t low_high_gain_threshold_mdB;
uint8_t low_gain_dB;
uint8_t high_gain_dB;
uint16_t tx_mon_delay;
uint16_t tx_mon_duration;
uint8_t tx1_mon_front_end_gain;
uint8_t tx2_mon_front_end_gain;
uint8_t tx1_mon_lo_cm;
uint8_t tx2_mon_lo_cm;
};
struct gain_control {
enum rf_gain_ctrl_mode rx1_mode;
enum rf_gain_ctrl_mode rx2_mode;
uint8_t adc_ovr_sample_size;
uint8_t adc_small_overload_thresh;
uint8_t adc_large_overload_thresh;
uint16_t lmt_overload_high_thresh;
uint16_t lmt_overload_low_thresh;
uint16_t dec_pow_measuremnt_duration;
uint8_t low_power_thresh;
bool dig_gain_en;
uint8_t max_dig_gain;
bool mgc_rx1_ctrl_inp_en;
bool mgc_rx2_ctrl_inp_en;
uint8_t mgc_inc_gain_step;
uint8_t mgc_dec_gain_step;
uint8_t mgc_split_table_ctrl_inp_gain_mode;
uint8_t agc_attack_delay_extra_margin_us;
uint8_t agc_outer_thresh_high;
uint8_t agc_outer_thresh_high_dec_steps;
uint8_t agc_inner_thresh_high;
uint8_t agc_inner_thresh_high_dec_steps;
uint8_t agc_inner_thresh_low;
uint8_t agc_inner_thresh_low_inc_steps;
uint8_t agc_outer_thresh_low;
uint8_t agc_outer_thresh_low_inc_steps;
uint8_t adc_small_overload_exceed_counter;
uint8_t adc_large_overload_exceed_counter;
uint8_t adc_large_overload_inc_steps;
bool adc_lmt_small_overload_prevent_gain_inc;
uint8_t lmt_overload_large_exceed_counter;
uint8_t lmt_overload_small_exceed_counter;
uint8_t lmt_overload_large_inc_steps;
uint8_t dig_saturation_exceed_counter;
uint8_t dig_gain_step_size;
bool sync_for_gain_counter_en;
uint32_t gain_update_interval_us;
bool immed_gain_change_if_large_adc_overload;
bool immed_gain_change_if_large_lmt_overload;
uint32_t f_agc_dec_pow_measuremnt_duration;
uint32_t f_agc_state_wait_time_ns;
bool f_agc_allow_agc_gain_increase;
uint8_t f_agc_lp_thresh_increment_time;
uint8_t f_agc_lp_thresh_increment_steps;
uint8_t f_agc_lock_level;
bool f_agc_lock_level_lmt_gain_increase_en;
uint8_t f_agc_lock_level_gain_increase_upper_limit;
uint8_t f_agc_lpf_final_settling_steps;
uint8_t f_agc_lmt_final_settling_steps;
uint8_t f_agc_final_overrange_count;
bool f_agc_gain_increase_after_gain_lock_en;
enum f_agc_target_gain_index_type f_agc_gain_index_type_after_exit_rx_mode;
bool f_agc_use_last_lock_level_for_set_gain_en;
uint8_t f_agc_optimized_gain_offset;
bool f_agc_rst_gla_stronger_sig_thresh_exceeded_en;
uint8_t f_agc_rst_gla_stronger_sig_thresh_above_ll;
bool f_agc_rst_gla_engergy_lost_sig_thresh_exceeded_en;
bool f_agc_rst_gla_engergy_lost_goto_optim_gain_en;
uint8_t f_agc_rst_gla_engergy_lost_sig_thresh_below_ll;
uint8_t f_agc_energy_lost_stronger_sig_gain_lock_exit_cnt;
bool f_agc_rst_gla_large_adc_overload_en;
bool f_agc_rst_gla_large_lmt_overload_en;
bool f_agc_rst_gla_en_agc_pulled_high_en;
enum f_agc_target_gain_index_type f_agc_rst_gla_if_en_agc_pulled_high_mode;
uint8_t f_agc_power_measurement_duration_in_state5;
};
struct ad9361_phy_platform_data {
bool rx2tx2;
bool fdd;
bool fdd_independent_mode;
bool split_gt;
bool use_extclk;
bool ensm_pin_pulse_mode;
bool ensm_pin_ctrl;
bool debug_mode;
bool tdd_use_dual_synth;
bool tdd_skip_vco_cal;
bool use_ext_rx_lo;
bool use_ext_tx_lo;
bool rx1rx2_phase_inversion_en;
bool qec_tracking_slow_mode_en;
uint8_t dc_offset_update_events;
uint8_t dc_offset_attenuation_high;
uint8_t dc_offset_attenuation_low;
uint8_t rf_dc_offset_count_high;
uint8_t rf_dc_offset_count_low;
uint8_t dig_interface_tune_skipmode;
uint8_t dig_interface_tune_fir_disable;
uint32_t dcxo_coarse;
uint32_t dcxo_fine;
uint32_t rf_rx_input_sel;
uint32_t rf_tx_output_sel;
uint32_t rx1tx1_mode_use_rx_num;
uint32_t rx1tx1_mode_use_tx_num;
uint32_t rx_path_clks[NUM_RX_CLOCKS];
uint32_t tx_path_clks[NUM_TX_CLOCKS];
uint32_t trx_synth_max_fref;
uint64_t rx_synth_freq;
uint64_t tx_synth_freq;
uint32_t rf_rx_bandwidth_Hz;
uint32_t rf_tx_bandwidth_Hz;
int32_t tx_atten;
bool update_tx_gain_via_alert;
uint32_t rx_fastlock_delay_ns;
uint32_t tx_fastlock_delay_ns;
bool trx_fastlock_pinctrl_en[2];
enum ad9361_clkout ad9361_clkout_mode;
struct gain_control gain_ctrl;
struct rssi_control rssi_ctrl;
struct port_control port_ctrl;
struct ctrl_outs_control ctrl_outs_ctrl;
struct elna_control elna_ctrl;
struct auxadc_control auxadc_ctrl;
struct auxdac_control auxdac_ctrl;
struct gpo_control gpo_ctrl;
struct tx_monitor_control txmon_ctrl;
int32_t gpio_resetb;
int32_t gpio_sync;
int32_t gpio_cal_sw1;
int32_t gpio_cal_sw2;
};
struct ad9361_rf_phy {
enum dev_id dev_sel;
uint8_t id_no;
struct spi_device *spi;
struct gpio_device *gpio;
struct clk *clk_refin;
struct clk *clks[NUM_AD9361_CLKS];
struct refclk_scale *ref_clk_scale[NUM_AD9361_CLKS];
struct clk_onecell_data clk_data;
uint32_t (*ad9361_rfpll_ext_recalc_rate)(struct refclk_scale *clk_priv);
int32_t (*ad9361_rfpll_ext_round_rate)(struct refclk_scale *clk_priv,
uint32_t rate);
int32_t (*ad9361_rfpll_ext_set_rate)(struct refclk_scale *clk_priv,
uint32_t rate);
struct ad9361_phy_platform_data *pdata;
uint8_t prev_ensm_state;
uint8_t curr_ensm_state;
uint8_t cached_rx_rfpll_div;
uint8_t cached_tx_rfpll_div;
struct rx_gain_info rx_gain[RXGAIN_TBLS_END];
enum rx_gain_table_name current_table;
bool ensm_pin_ctl_en;
bool auto_cal_en;
uint64_t last_tx_quad_cal_freq;
uint32_t last_tx_quad_cal_phase;
uint64_t current_tx_lo_freq;
uint64_t current_rx_lo_freq;
bool current_tx_use_tdd_table;
bool current_rx_use_tdd_table;
uint32_t flags;
uint32_t cal_threshold_freq;
uint32_t current_rx_bw_Hz;
uint32_t current_tx_bw_Hz;
uint32_t rxbbf_div;
uint32_t rate_governor;
bool bypass_rx_fir;
bool bypass_tx_fir;
bool rx_eq_2tx;
bool filt_valid;
uint32_t filt_rx_path_clks[NUM_RX_CLOCKS];
uint32_t filt_tx_path_clks[NUM_TX_CLOCKS];
uint32_t filt_rx_bw_Hz;
uint32_t filt_tx_bw_Hz;
uint8_t tx_fir_int;
uint8_t tx_fir_ntaps;
uint8_t rx_fir_dec;
uint8_t rx_fir_ntaps;
uint8_t agc_mode[2];
bool rfdc_track_en;
bool bbdc_track_en;
bool quad_track_en;
bool txmon_tdd_en;
uint16_t auxdac1_value;
uint16_t auxdac2_value;
uint32_t tx1_atten_cached;
uint32_t tx2_atten_cached;
struct ad9361_fastlock fastlock;
struct axiadc_converter *adc_conv;
struct axiadc_state *adc_state;
int32_t bist_loopback_mode;
enum ad9361_bist_mode bist_prbs_mode;
enum ad9361_bist_mode bist_tone_mode;
uint32_t bist_tone_freq_Hz;
uint32_t bist_tone_level_dB;
uint32_t bist_tone_mask;
bool bbpll_initialized;
};
struct rf_rx_gain {
uint32_t ant;
int32_t gain_db;
uint32_t fgt_lmt_index;
uint32_t lmt_gain;
uint32_t lpf_gain;
uint32_t digital_gain;
uint32_t lna_index;
uint32_t tia_index;
uint32_t mixer_index;
};
struct rf_rssi {
uint32_t ant;
uint32_t symbol;
uint32_t preamble;
int32_t multiplier;
uint8_t duration;
};
int32_t ad9361_get_rx_gain(struct ad9361_rf_phy *phy,
uint32_t rx_id,
struct rf_rx_gain *rx_gain);
int32_t ad9361_spi_read(struct spi_device *spi, uint32_t reg);
int32_t ad9361_spi_write(struct spi_device *spi, uint32_t reg, uint32_t val);
void ad9361_get_bist_loopback(struct ad9361_rf_phy *phy, int32_t *mode);
int32_t ad9361_bist_loopback(struct ad9361_rf_phy *phy, int32_t mode);
/******************************************************************************
* From ad9361_api.h
******************************************************************************/
typedef struct {
enum dev_id dev_sel;
uint8_t id_no;
uint32_t reference_clk_rate;
uint8_t two_rx_two_tx_mode_enable;
uint8_t one_rx_one_tx_mode_use_rx_num;
uint8_t one_rx_one_tx_mode_use_tx_num;
uint8_t frequency_division_duplex_mode_enable;
uint8_t frequency_division_duplex_independent_mode_enable;
uint8_t tdd_use_dual_synth_mode_enable;
uint8_t tdd_skip_vco_cal_enable;
uint32_t tx_fastlock_delay_ns;
uint32_t rx_fastlock_delay_ns;
uint8_t rx_fastlock_pincontrol_enable;
uint8_t tx_fastlock_pincontrol_enable;
uint8_t external_rx_lo_enable;
uint8_t external_tx_lo_enable;
uint8_t dc_offset_tracking_update_event_mask;
uint8_t dc_offset_attenuation_high_range;
uint8_t dc_offset_attenuation_low_range;
uint8_t dc_offset_count_high_range;
uint8_t dc_offset_count_low_range;
uint8_t split_gain_table_mode_enable;
uint32_t trx_synthesizer_target_fref_overwrite_hz;
uint8_t qec_tracking_slow_mode_enable;
uint8_t ensm_enable_pin_pulse_mode_enable;
uint8_t ensm_enable_txnrx_control_enable;
uint64_t rx_synthesizer_frequency_hz;
uint64_t tx_synthesizer_frequency_hz;
uint32_t rx_path_clock_frequencies[6];
uint32_t tx_path_clock_frequencies[6];
uint32_t rf_rx_bandwidth_hz;
uint32_t rf_tx_bandwidth_hz;
uint32_t rx_rf_port_input_select;
uint32_t tx_rf_port_input_select;
int32_t tx_attenuation_mdB;
uint8_t update_tx_gain_in_alert_enable;
uint8_t xo_disable_use_ext_refclk_enable;
uint32_t dcxo_coarse_and_fine_tune[2];
uint32_t clk_output_mode_select;
uint8_t gc_rx1_mode;
uint8_t gc_rx2_mode;
uint8_t gc_adc_large_overload_thresh;
uint8_t gc_adc_ovr_sample_size;
uint8_t gc_adc_small_overload_thresh;
uint16_t gc_dec_pow_measurement_duration;
uint8_t gc_dig_gain_enable;
uint16_t gc_lmt_overload_high_thresh;
uint16_t gc_lmt_overload_low_thresh;
uint8_t gc_low_power_thresh;
uint8_t gc_max_dig_gain;
uint8_t mgc_dec_gain_step;
uint8_t mgc_inc_gain_step;
uint8_t mgc_rx1_ctrl_inp_enable;
uint8_t mgc_rx2_ctrl_inp_enable;
uint8_t mgc_split_table_ctrl_inp_gain_mode;
uint8_t agc_adc_large_overload_exceed_counter;
uint8_t agc_adc_large_overload_inc_steps;
uint8_t agc_adc_lmt_small_overload_prevent_gain_inc_enable;
uint8_t agc_adc_small_overload_exceed_counter;
uint8_t agc_dig_gain_step_size;
uint8_t agc_dig_saturation_exceed_counter;
uint32_t agc_gain_update_interval_us;
uint8_t agc_immed_gain_change_if_large_adc_overload_enable;
uint8_t agc_immed_gain_change_if_large_lmt_overload_enable;
uint8_t agc_inner_thresh_high;
uint8_t agc_inner_thresh_high_dec_steps;
uint8_t agc_inner_thresh_low;
uint8_t agc_inner_thresh_low_inc_steps;
uint8_t agc_lmt_overload_large_exceed_counter;
uint8_t agc_lmt_overload_large_inc_steps;
uint8_t agc_lmt_overload_small_exceed_counter;
uint8_t agc_outer_thresh_high;
uint8_t agc_outer_thresh_high_dec_steps;
uint8_t agc_outer_thresh_low;
uint8_t agc_outer_thresh_low_inc_steps;
uint32_t agc_attack_delay_extra_margin_us;
uint8_t agc_sync_for_gain_counter_enable;
uint32_t fagc_dec_pow_measuremnt_duration;
uint32_t fagc_state_wait_time_ns;
uint8_t fagc_allow_agc_gain_increase;
uint32_t fagc_lp_thresh_increment_time;
uint32_t fagc_lp_thresh_increment_steps;
uint8_t fagc_lock_level_lmt_gain_increase_en;
uint32_t fagc_lock_level_gain_increase_upper_limit;
uint32_t fagc_lpf_final_settling_steps;
uint32_t fagc_lmt_final_settling_steps;
uint32_t fagc_final_overrange_count;
uint8_t fagc_gain_increase_after_gain_lock_en;
uint32_t fagc_gain_index_type_after_exit_rx_mode;
uint8_t fagc_use_last_lock_level_for_set_gain_en;
uint8_t fagc_rst_gla_stronger_sig_thresh_exceeded_en;
uint32_t fagc_optimized_gain_offset;
uint32_t fagc_rst_gla_stronger_sig_thresh_above_ll;
uint8_t fagc_rst_gla_engergy_lost_sig_thresh_exceeded_en;
uint8_t fagc_rst_gla_engergy_lost_goto_optim_gain_en;
uint32_t fagc_rst_gla_engergy_lost_sig_thresh_below_ll;
uint32_t fagc_energy_lost_stronger_sig_gain_lock_exit_cnt;
uint8_t fagc_rst_gla_large_adc_overload_en;
uint8_t fagc_rst_gla_large_lmt_overload_en;
uint8_t fagc_rst_gla_en_agc_pulled_high_en;
uint32_t fagc_rst_gla_if_en_agc_pulled_high_mode;
uint32_t fagc_power_measurement_duration_in_state5;
uint32_t rssi_delay;
uint32_t rssi_duration;
uint8_t rssi_restart_mode;
uint8_t rssi_unit_is_rx_samples_enable;
uint32_t rssi_wait;
uint32_t aux_adc_decimation;
uint32_t aux_adc_rate;
uint8_t aux_dac_manual_mode_enable;
uint32_t aux_dac1_default_value_mV;
uint8_t aux_dac1_active_in_rx_enable;
uint8_t aux_dac1_active_in_tx_enable;
uint8_t aux_dac1_active_in_alert_enable;
uint32_t aux_dac1_rx_delay_us;
uint32_t aux_dac1_tx_delay_us;
uint32_t aux_dac2_default_value_mV;
uint8_t aux_dac2_active_in_rx_enable;
uint8_t aux_dac2_active_in_tx_enable;
uint8_t aux_dac2_active_in_alert_enable;
uint32_t aux_dac2_rx_delay_us;
uint32_t aux_dac2_tx_delay_us;
uint32_t temp_sense_decimation;
uint16_t temp_sense_measurement_interval_ms;
int8_t temp_sense_offset_signed;
uint8_t temp_sense_periodic_measurement_enable;
uint8_t ctrl_outs_enable_mask;
uint8_t ctrl_outs_index;
uint32_t elna_settling_delay_ns;
uint32_t elna_gain_mdB;
uint32_t elna_bypass_loss_mdB;
uint8_t elna_rx1_gpo0_control_enable;
uint8_t elna_rx2_gpo1_control_enable;
uint8_t elna_gaintable_all_index_enable;
uint8_t digital_interface_tune_skip_mode;
uint8_t digital_interface_tune_fir_disable;
uint8_t pp_tx_swap_enable;
uint8_t pp_rx_swap_enable;
uint8_t tx_channel_swap_enable;
uint8_t rx_channel_swap_enable;
uint8_t rx_frame_pulse_mode_enable;
uint8_t two_t_two_r_timing_enable;
uint8_t invert_data_bus_enable;
uint8_t invert_data_clk_enable;
uint8_t fdd_alt_word_order_enable;
uint8_t invert_rx_frame_enable;
uint8_t fdd_rx_rate_2tx_enable;
uint8_t swap_ports_enable;
uint8_t single_data_rate_enable;
uint8_t lvds_mode_enable;
uint8_t half_duplex_mode_enable;
uint8_t single_port_mode_enable;
uint8_t full_port_enable;
uint8_t full_duplex_swap_bits_enable;
uint32_t delay_rx_data;
uint32_t rx_data_clock_delay;
uint32_t rx_data_delay;
uint32_t tx_fb_clock_delay;
uint32_t tx_data_delay;
uint32_t lvds_bias_mV;
uint8_t lvds_rx_onchip_termination_enable;
uint8_t rx1rx2_phase_inversion_en;
uint8_t lvds_invert1_control;
uint8_t lvds_invert2_control;
uint8_t clk_out_drive;
uint8_t dataclk_drive;
uint8_t data_port_drive;
uint8_t clk_out_slew;
uint8_t dataclk_slew;
uint8_t data_port_slew;
uint8_t gpo0_inactive_state_high_enable;
uint8_t gpo1_inactive_state_high_enable;
uint8_t gpo2_inactive_state_high_enable;
uint8_t gpo3_inactive_state_high_enable;
uint8_t gpo0_slave_rx_enable;
uint8_t gpo0_slave_tx_enable;
uint8_t gpo1_slave_rx_enable;
uint8_t gpo1_slave_tx_enable;
uint8_t gpo2_slave_rx_enable;
uint8_t gpo2_slave_tx_enable;
uint8_t gpo3_slave_rx_enable;
uint8_t gpo3_slave_tx_enable;
uint8_t gpo0_rx_delay_us;
uint8_t gpo0_tx_delay_us;
uint8_t gpo1_rx_delay_us;
uint8_t gpo1_tx_delay_us;
uint8_t gpo2_rx_delay_us;
uint8_t gpo2_tx_delay_us;
uint8_t gpo3_rx_delay_us;
uint8_t gpo3_tx_delay_us;
uint32_t low_high_gain_threshold_mdB;
uint32_t low_gain_dB;
uint32_t high_gain_dB;
uint8_t tx_mon_track_en;
uint8_t one_shot_mode_en;
uint32_t tx_mon_delay;
uint32_t tx_mon_duration;
uint32_t tx1_mon_front_end_gain;
uint32_t tx2_mon_front_end_gain;
uint32_t tx1_mon_lo_cm;
uint32_t tx2_mon_lo_cm;
int32_t gpio_resetb;
int32_t gpio_sync;
int32_t gpio_cal_sw1;
int32_t gpio_cal_sw2;
uint32_t (*ad9361_rfpll_ext_recalc_rate)(struct refclk_scale *clk_priv);
int32_t (*ad9361_rfpll_ext_round_rate)(struct refclk_scale *clk_priv,
uint32_t rate);
int32_t (*ad9361_rfpll_ext_set_rate)(struct refclk_scale *clk_priv,
uint32_t rate);
} AD9361_InitParam;
typedef struct {
uint32_t rx; /* 1, 2, 3(both) */
int32_t rx_gain; /* -12, -6, 0, 6 */
uint32_t rx_dec; /* 1, 2, 4 */
int16_t rx_coef[128];
uint8_t rx_coef_size;
uint32_t rx_path_clks[6];
uint32_t rx_bandwidth;
} AD9361_RXFIRConfig;
typedef struct {
uint32_t tx; /* 1, 2, 3(both) */
int32_t tx_gain; /* -6, 0 */
uint32_t tx_int; /* 1, 2, 4 */
int16_t tx_coef[128];
uint8_t tx_coef_size;
uint32_t tx_path_clks[6];
uint32_t tx_bandwidth;
} AD9361_TXFIRConfig;
#define AD936X_A_BALANCED 0 #define AD936X_A_BALANCED 0
#define AD936X_B_BALANCED 1 #define AD936X_B_BALANCED 1
#define AD936X_C_BALANCED 2 #define AD936X_C_BALANCED 2
@ -789,70 +107,5 @@ typedef struct {
#define AD936X_TXA 0 #define AD936X_TXA 0
#define AD936X_TXB 1 #define AD936X_TXB 1
int32_t ad9361_init(struct ad9361_rf_phy **ad9361_phy,
AD9361_InitParam *init_param,
void *userdata);
int32_t ad9361_deinit(struct ad9361_rf_phy *phy);
int32_t ad9361_set_rx_rf_gain(struct ad9361_rf_phy *phy,
uint8_t ch,
int32_t gain_db);
int32_t ad9361_set_rx_rf_bandwidth(struct ad9361_rf_phy *phy,
uint32_t bandwidth_hz);
int32_t ad9361_get_rx_rf_bandwidth(struct ad9361_rf_phy *phy,
uint32_t *bandwidth_hz);
int32_t ad9361_set_rx_sampling_freq(struct ad9361_rf_phy *phy,
uint32_t sampling_freq_hz);
int32_t ad9361_get_rx_sampling_freq(struct ad9361_rf_phy *phy,
uint32_t *sampling_freq_hz);
int32_t ad9361_set_rx_lo_freq(struct ad9361_rf_phy *phy, uint64_t lo_freq_hz);
int32_t ad9361_get_rx_lo_freq(struct ad9361_rf_phy *phy, uint64_t *lo_freq_hz);
int32_t ad9361_get_rx_rssi(struct ad9361_rf_phy *phy,
uint8_t ch,
struct rf_rssi *rssi);
int32_t ad9361_set_rx_gain_control_mode(struct ad9361_rf_phy *phy,
uint8_t ch,
uint8_t gc_mode);
int32_t ad9361_get_rx_gain_control_mode(struct ad9361_rf_phy *phy,
uint8_t ch,
uint8_t *gc_mode);
int32_t ad9361_set_rx_fir_config(struct ad9361_rf_phy *phy,
AD9361_RXFIRConfig fir_cfg);
int32_t ad9361_set_rx_fir_en_dis(struct ad9361_rf_phy *phy, uint8_t en_dis);
int32_t ad9361_set_rx_rf_port_input(struct ad9361_rf_phy *phy, uint32_t mode);
int32_t ad9361_get_rx_rf_port_input(struct ad9361_rf_phy *phy, uint32_t *mode);
int32_t ad9361_set_tx_attenuation(struct ad9361_rf_phy *phy,
uint8_t ch,
uint32_t attenuation_mdb);
int32_t ad9361_get_tx_attenuation(struct ad9361_rf_phy *phy,
uint8_t ch,
uint32_t *attenuation_mdb);
int32_t ad9361_set_tx_rf_bandwidth(struct ad9361_rf_phy *phy,
uint32_t bandwidth_hz);
int32_t ad9361_get_tx_rf_bandwidth(struct ad9361_rf_phy *phy,
uint32_t *bandwidth_hz);
int32_t ad9361_set_tx_sampling_freq(struct ad9361_rf_phy *phy,
uint32_t sampling_freq_hz);
int32_t ad9361_get_tx_sampling_freq(struct ad9361_rf_phy *phy,
uint32_t *sampling_freq_hz);
int32_t ad9361_set_tx_lo_freq(struct ad9361_rf_phy *phy, uint64_t lo_freq_hz);
int32_t ad9361_get_tx_lo_freq(struct ad9361_rf_phy *phy, uint64_t *lo_freq_hz);
int32_t ad9361_set_tx_fir_config(struct ad9361_rf_phy *phy,
AD9361_TXFIRConfig fir_cfg);
int32_t ad9361_set_tx_fir_en_dis(struct ad9361_rf_phy *phy, uint8_t en_dis);
int32_t ad9361_get_tx_rssi(struct ad9361_rf_phy *phy,
uint8_t ch,
uint32_t *rssi_db_x_1000);
int32_t ad9361_set_tx_rf_port_output(struct ad9361_rf_phy *phy, uint32_t mode);
int32_t ad9361_get_tx_rf_port_output(struct ad9361_rf_phy *phy, uint32_t *mode);
int32_t ad9361_get_temp(struct ad9361_rf_phy *phy);
int32_t ad9361_rx_fastlock_store(struct ad9361_rf_phy *phy, uint32_t profile);
int32_t ad9361_rx_fastlock_save(struct ad9361_rf_phy *phy,
uint32_t profile,
uint8_t *values);
int32_t ad9361_tx_fastlock_store(struct ad9361_rf_phy *phy, uint32_t profile);
int32_t ad9361_tx_fastlock_save(struct ad9361_rf_phy *phy,
uint32_t profile,
uint8_t *values);
int32_t ad9361_set_no_ch_mode(struct ad9361_rf_phy *phy, uint8_t no_ch_mode);
#endif // AD936X_H_ #endif // AD936X_H_

View file

@ -118,6 +118,33 @@
#define NIOS_PKT_8x32_FLAG_WRITE (1 << 0) #define NIOS_PKT_8x32_FLAG_WRITE (1 << 0)
#define NIOS_PKT_8x32_FLAG_SUCCESS (1 << 1) #define NIOS_PKT_8x32_FLAG_SUCCESS (1 << 1)
/* Function to convert target ID to string */
static inline const char* target2str(uint8_t target_id) {
switch (target_id) {
case NIOS_PKT_8x32_TARGET_VERSION:
return "FPGA Version";
case NIOS_PKT_8x32_TARGET_CONTROL:
return "FPGA Control/Config Register";
case NIOS_PKT_8x32_TARGET_ADF4351:
return "XB-200 ADF4351 Register (Write-Only)";
case NIOS_PKT_8x32_TARGET_RFFE_CSR:
return "RFFE Control & Status GPIO";
case NIOS_PKT_8x32_TARGET_ADF400X:
return "ADF400x Config";
case NIOS_PKT_8x32_TARGET_FASTLOCK:
return "AD9361 Fast Lock Profile";
/* Reserved for user customizations */
case NIOS_PKT_8x32_TARGET_USR1:
return "User Defined 1";
case NIOS_PKT_8x32_TARGET_USR128:
return "User Defined 128";
default:
return "Unknown Target ID";
}
}
/* Pack the request buffer */ /* Pack the request buffer */
static inline void nios_pkt_8x32_pack(uint8_t *buf, uint8_t target, bool write, static inline void nios_pkt_8x32_pack(uint8_t *buf, uint8_t target, bool write,
uint8_t addr, uint32_t data) uint8_t addr, uint32_t data)

View file

@ -5,6 +5,16 @@ For more detailed information, please see the git change log and issue tracker
hosted on GitHub: https://github.com/nuand/bladeRF hosted on GitHub: https://github.com/nuand/bladeRF
================================================================================ ================================================================================
v2.6.0 (2025-05-06)
--------------------------------
* Increase GPIF buffer size for increase performance
* Fixed missing break in BLADE_USB_CMD_QUERY_FPGA_SOURCE command handling
* Improved FX3 SDK setup instructions in README
v2.5.0 (2024-07-30)
--------------------------------
* Bumped GPIF DMA buffer size to 8192 bytes
* Reduced the number of GPIF DMA buffers to 11 per channel
v2.4.0 (2020-08-01) v2.4.0 (2020-08-01)
-------------------------------- --------------------------------

View file

@ -1,7 +1,7 @@
################################################################################ ################################################################################
# Build bladeRF FX3 Firmware # Build bladeRF FX3 Firmware
################################################################################ ################################################################################
cmake_minimum_required(VERSION 2.8.12) cmake_minimum_required(VERSION 3.5)
project(bladeRF_fw C) project(bladeRF_fw C)
################################################################################ ################################################################################
@ -33,7 +33,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../host/cmake/modules)
# Update these definitions when updating the firmware version # Update these definitions when updating the firmware version
set(VERSION_INFO_MAJOR 2) set(VERSION_INFO_MAJOR 2)
set(VERSION_INFO_MINOR 4) set(VERSION_INFO_MINOR 6)
set(VERSION_INFO_PATCH 0) set(VERSION_INFO_PATCH 0)
if(NOT DEFINED VERSION_INFO_EXTRA) if(NOT DEFINED VERSION_INFO_EXTRA)

View file

@ -18,7 +18,7 @@ Building the FX3 firmware first requires the download of the [Cypress FX3 SDK][c
**This firmware build requires FX3 SDK version 1.3.3 or later** **This firmware build requires FX3 SDK version 1.3.3 or later**
[cypress_sdk]: http://www.cypress.com/?rID=57990 (Cypress FX3 SDK) [cypress_sdk]: http://www.cypress.com/?rID=57990 (Cypress FX3 SDK) (downloaded file is `ezusbfx3sdk_1.3.5_Linux_x32-x64.tar.gz`)
[CMake](https://cmake.org) is used to configure the build. There are two locations that we must provide to CMake when configuring the build: [CMake](https://cmake.org) is used to configure the build. There are two locations that we must provide to CMake when configuring the build:
@ -27,6 +27,24 @@ Building the FX3 firmware first requires the download of the [Cypress FX3 SDK][c
### Command Line-Based Build (Recommended for Linux Users) ### ### Command Line-Based Build (Recommended for Linux Users) ###
#### Setting up the FX3 SDK on Linux ####
1. Extract the contents of `ezusbfx3sdk_1.3.5_Linux_x32-x64.tar.gz` (the contents are 5 .tar.gz files)
2. Extract and arrange two of them such that these folders exist:
- `/opt/cypress/ARM_GCC/arm-2013.11/`
- `/opt/cypress/fx3_firmware_linux/cyfx3sdk/`
##### Ubuntu 20.04 Dependencies #####
On Ubuntu 20.04, you'll need to install 32-bit libraries:
```
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install libc6:i386 libstdc++6:i386 libncurses5:i386
```
#### Building the Firmware ####
Below are instructions for building the FX3 firmware from the command-line. This assumes that `cmake` and `make` Below are instructions for building the FX3 firmware from the command-line. This assumes that `cmake` and `make`
are in your `PATH`, and is best suited for Linux developers. are in your `PATH`, and is best suited for Linux developers.
@ -38,7 +56,7 @@ Adjust the paths as necessary on your system, depending where you installed the
``` ```
$ mkdir build $ mkdir build
$ cd build $ cd build
$ cmake -DFX3_INSTALL_PATH=/opt/cypress/fx3_sdk -DCMAKE_TOOLCHAIN_FILE=../cmake/fx3-toolchain.cmake ../ $ cmake -DFX3_INSTALL_PATH=/opt/cypress/fx3_firmware_linux -DCMAKE_TOOLCHAIN_FILE=../cmake/fx3-toolchain.cmake ../
$ make $ make
``` ```

View file

@ -8,7 +8,7 @@
# #
# #
################################################################################ ################################################################################
cmake_minimum_required(VERSION 2.8.12) cmake_minimum_required(VERSION 3.5)
################################################################################ ################################################################################
# FX3 SDK paths and files # FX3 SDK paths and files

View file

@ -468,6 +468,7 @@ CyBool_t NuandHandleVendorRequest(
case BLADE_USB_CMD_QUERY_FPGA_SOURCE: case BLADE_USB_CMD_QUERY_FPGA_SOURCE:
ret = (unsigned int)NuandGetFpgaConfigSource(); ret = (unsigned int)NuandGetFpgaConfigSource();
CyU3PUsbSendRetCode(ret); CyU3PUsbSendRetCode(ret);
break;
case BLADE_USB_CMD_SET_LOOPBACK: case BLADE_USB_CMD_SET_LOOPBACK:
NuandRFLinkLoopBack(wValue); NuandRFLinkLoopBack(wValue);

View file

@ -290,8 +290,8 @@ static void NuandRFLinkStart(void)
} }
CyU3PMemSet((uint8_t *)&dmaCfg, 0, sizeof(dmaCfg)); CyU3PMemSet((uint8_t *)&dmaCfg, 0, sizeof(dmaCfg));
dmaCfg.size = size * 2; dmaCfg.size = size * 8;
dmaCfg.count = 22; dmaCfg.count = 11;
dmaCfg.prodSckId = BLADE_RF_SAMPLE_EP_PRODUCER_USB_SOCKET; dmaCfg.prodSckId = BLADE_RF_SAMPLE_EP_PRODUCER_USB_SOCKET;
dmaCfg.consSckId = CY_U3P_PIB_SOCKET_3; dmaCfg.consSckId = CY_U3P_PIB_SOCKET_3;
dmaCfg.dmaMode = CY_U3P_DMA_MODE_BYTE; dmaCfg.dmaMode = CY_U3P_DMA_MODE_BYTE;

View file

@ -1,7 +1,7 @@
################################################################################ ################################################################################
# Build for FX3 elf2img utility # Build for FX3 elf2img utility
################################################################################ ################################################################################
cmake_minimum_required(VERSION 2.8.12) cmake_minimum_required(VERSION 3.5)
project(elf2img C) project(elf2img C)
if(WIN32) if(WIN32)

View file

@ -5,6 +5,61 @@ For more detailed information, please see the git change log and issue tracker
hosted on GitHub: https://github.com/nuand/bladeRF hosted on GitHub: https://github.com/nuand/bladeRF
================================================================================ ================================================================================
--------------------------------
v0.16.0 (2025-05-06)
--------------------------------
This version brings significant FPGA improvements including sc16q11 packed mode
support and optimized USB throughput, along with important bug fixes for bladeRF
1.0 and 2.0 micro devices.
Features:
* hdl: Added sc16q11 packed mode for improved sample efficiency
* hdl: Increased FX3 GPIF buffer sizes, boosting USB throughput (~356MB/s)
* hdl: Implemented dynamic Nios base address assignment based on RAM size
* hdl: Added parallel build support for hosted FPGA variants (40, 115, A4, A5, A9)
* nios: Enabled elf-gdb and gdb-server support for improved debugging capability
* hdl: Added git revision information to FPGA build outputs
Fixes:
* hdl: Fixed delayed sample and off-by-one timestamp bugs on bladeRF 1.0
* hdl: Corrected TX meta sample gap issue when timestamp set to META NOW
* hdl: Fixed corrupted UART buffer in command_uart component
* hdl: Resolved TX deadlock scenarios by refactoring RX/TX DMA prioritization
* hdl: Improved FPGA simulation accuracy for bladeRF 1 and 2 micro models
* hdl: Fixed false timing paths and resolved multiple timing violations
--------------------------------
v0.15.3 (2023-08-09)
--------------------------------
Addresses an issue where the META state was not transitioning correctly
when only channel 1 (ch1) was enabled. The fix ensures that the META
state now correctly exits the META_WRITE state and enters the
META_DOWNCOUNT state when ch1 is exclusively enabled.
Fixes:
* hdl: fifo_writer: proper META state transition for exclusive ch1 usage
--------------------------------
v0.15.2 (2023-06-26)
--------------------------------
Corrects RX timestamp when MIMO enabled.
Fixes:
* hdl: MIMO RX timestamp correction
--------------------------------
v0.15.1 (2023-04-03)
--------------------------------
Fixes timestamps and signal generator when 8bit format enabled.
Fixes:
* hdl: 8bit support for signal_generator.vhd
* hdl: 8bit RX timestamp correction
-------------------------------- --------------------------------
v0.15.0 (2023-02-13) v0.15.0 (2023-02-13)
-------------------------------- --------------------------------

View file

@ -1,5 +1,5 @@
# bladeRF HDL Source # # bladeRF HDL Source #
The Cyclone IV FPGA is at the heart of the bladeRF. It interfaces to the Cypress FX3, Lime Micro LMS6002D RF transceiver, Si5338 clock generator chip, and VCTCXO trim DAC. It has an input to read NMEA from a GPS as well as a 1pps input for time synchronization of signals and has a reference input for a reference clock to tame the VCTCXO. Lastly, it connects directly to the expansion header for controlling GPIO or any other interfaces that may reside on the expansion board. The Cyclone FPGA is at the heart of the bladeRF. It interfaces to the Cypress FX3, Analog Devices AD9361 (bladeRF 2.0 micro) or Lime Micro LMS6002D (bladeRF 1) RF transceiver, Silicon Labs clock generator chip, and VCTCXO trim DAC. It has an input to read NMEA from a GPS as well as a 1pps input for time synchronization of signals and has a reference input for a reference clock to tame the VCTCXO. Lastly, it connects directly to the expansion header for controlling GPIO or any other interfaces that may reside on the expansion board.
The HDL is separated out into two different sections: The HDL is separated out into two different sections:
@ -18,16 +18,17 @@ Some FPGA binaries are available for [download][download]. Please note the md5
[download]: https://www.nuand.com/fpga/ (nuand/FPGA Images) [download]: https://www.nuand.com/fpga/ (nuand/FPGA Images)
## Required Software ## ## Required Software ##
We use an [Intel (Altera)][intel] [Cyclone IV E FPGA][cive]. The size of the FPGA is the only difference between the x40 and x115 models. Intel provides their [Quartus Prime][quartus] software for synthesizing designs for their FPGAs. The Lite Edition is free of charge, but not open source, and may require registering on their site to download the software. We use an [Intel (Altera)][intel] [Cyclone V E FPGA][cve] for bladeRF 2.0 micro and a [Cyclone IV E FPGA][cive] for bladeRF 1 (classic). The size of the FPGA is the only difference between different bladeRF models of the same generation (x40 vs x115, xA4 vs xA9). Intel provides their [Quartus Prime][quartus] software for synthesizing designs for their FPGAs. The Lite Edition is free of charge, but not open source, and may require registering on their site to download the software.
**Important Note:** Be sure to download and install [Quartus Prime version 17.1][quartus], which the bladeRF project files are based upon. Updates to Quartus Prime are not guaranteed to be reverse-compatible with earlier Quartus versions, nor will future versions necessarily be reverse-compatible. **Important Note:** Be sure to download and install [Quartus Prime version 20.1.1][quartus], which the bladeRF project files are based upon. Updates to Quartus Prime are not guaranteed to be reverse-compatible with earlier Quartus versions, nor will future versions necessarily be reverse-compatible. Particularly, newer versions of Quartus may not support older generation bladeRF 1 devices or the Nios II processor used on all bladeRF devices.
[intel]: https://www.altera.com/ (Altera, part of the Intel Programmable Solutions Group) [intel]: https://www.altera.com/ (Altera, part of the Intel Programmable Solutions Group)
[quartus]: https://dl.altera.com/17.1/?edition=lite (Quartus Prime Lite Edition v17.1) [quartus]: https://www.intel.com/content/www/us/en/software-kit/660904/intel-quartus-prime-lite-edition-design-software-version-20-1-1-for-linux.html (Quartus Prime Lite Edition v20.1.1)
[cive]: https://www.altera.com/products/fpga/cyclone-series/cyclone-iv/overview.html [cve]: https://www.intel.com/content/www/us/en/products/details/fpga/cyclone/v.html
[cive]: https://www.intel.com/content/www/us/en/products/details/fpga/cyclone/iv.html
## HDL Structure ## ## HDL Structure ##
Since the FPGA is connected and soldered down to the board, it makes sense to have a single top level which defines where the pins go, their IO levels and their genera directionality. We use a single `bladerf.vhd` top level to define a VHDL entity called `bladerf` that defines these pins. Since the FPGA is connected and soldered down to the board, it makes sense to have a single top level which defines where the pins go, their IO levels and their general directionality. We use a single `bladerf.vhd` top level to define a VHDL entity called `bladerf` that defines these pins.
We realize people will want to change the internal guts of the FPGA for their own programmable logic reasons. Because of this, we decided to differentiate the implementations using a feature of the Quartus Prime project file called Revisions. Revisions can take a base design (top level entity, a part and pins) and duplicate that project, recording any source level changes you wish to make to the project. This way, a user must only create their own architecture that is the new implementation of the `bladerf` top level. We realize people will want to change the internal guts of the FPGA for their own programmable logic reasons. Because of this, we decided to differentiate the implementations using a feature of the Quartus Prime project file called Revisions. Revisions can take a base design (top level entity, a part and pins) and duplicate that project, recording any source level changes you wish to make to the project. This way, a user must only create their own architecture that is the new implementation of the `bladerf` top level.
@ -41,21 +42,25 @@ This technique can be seen with the currently supported architectures:
## Building the Project ## ## Building the Project ##
The Quartus Prime build tools supports TCL as a scripting language which we utilize to not only create the project file, but build the system without requiring the need of the GUI. Currently, the `build_bladerf.sh` performs some environment checks, builds the NIOS BSP and software, and then kicks off TCL scripts to build the FPGA image. The Quartus Prime build tools supports TCL as a scripting language which we utilize to not only create the project file, but build the system without requiring the need of the GUI. Currently, the `build_bladerf.sh` performs some environment checks, builds the NIOS BSP and software, and then kicks off TCL scripts to build the FPGA image.
To support multiple versions of Quartus Prime on the same machine and to ensure the environment is appropriately setup, please use the `nios2_command_shell.sh` script to get into an appropriate Quartus Prime environment. Note that this shell script is usually located in the `nios2eds` directory of your Quartus Prime install directory. Also note that this is the preferred method regardless of using Windows or Linux to build. If you're using pybombs, make sure you haven't run `setup_env.sh`, as it prevents `nios2_command_shell.sh` from working properly. To support multiple versions of Quartus Prime on the same machine and to ensure the environment is appropriately setup, please run the `nios2_command_shell.sh` script to get into an appropriate Quartus Prime environment. Note that this shell script is usually located in the `nios2eds` directory of your Quartus Prime install directory (e.g. `~/intelFPGA_lite/20.1/nios2eds/nios2_command_shell.sh`). Also note that this is the preferred method regardless of using Windows or Linux to build. If you're using pybombs, make sure you haven't run `setup_env.sh`, as it prevents `nios2_command_shell.sh` from working properly.
1. Take note of which Cyclone device you have. (The EP4CE40 is 40 kLE, and the EP4CE115 is 115 kLE.) You'll need this size below. 1. Take note of your bladeRF model (bladeRF micro, bladeRF classic) and its corresponding FPGA size (x40, xA9, etc). You'll need this info below.
2. Enter the `quartus` directory 2. Enter the `quartus` directory
3. Execute, from inside an appropriate NIOS II command shell, `./build_bladerf.sh -h` to view the usage for the build script. Note the size and revision options. Also note any items you'll need to add to your PATH before continuing. 3. Execute, from inside an appropriate NIOS II command shell, `./build_bladerf.sh -h` to view the usage for the build script. Note the board, size, and revision options. Also note any items you'll need to add to your PATH before continuing.
4. Execute, from inside an appropriate NIOS II command shell, `./build_bladerf.sh -s <size> -r <revision>`, with the relevant size for your bladeRF, and the desired revision. This will create the NIOS system and software associated with the FPGA build needed by the internal RAM for execution. 4. Execute, from inside an appropriate NIOS II command shell, `./build_bladerf.sh -b <board> -s <size> -r <revision>`, with your bladeRF board model, the relevant size for your bladeRF, and the desired revision. This will create the NIOS system and software associated with the FPGA build needed by the internal RAM for execution.
5. The output of the build will be stored in a directory named in the form, `<revision>x<size>-<build time>`. This directory will contain the bitstream, summaries, and reports. 5. The output of the build will be stored in a directory named in the form, `<revision>x<size>-<build time>`. This directory will contain the bitstream, summaries, and reports.
Note that there will be a _lot_ of information displayed from notes to critical warnings. Some of these are benign and others are, in fact, critical. Note that there will be a _lot_ of information displayed from notes to critical warnings. Some of these are benign and others are, in fact, critical.
## Adding Signal Tap ## Ex: Build the bladeRF 2.0 micro xA4 with the default `hosted` architecture
For advanced users who want to use Signal Tap internal logic analyzer in their design, the `build.tcl` file can be passed a `-stp` flag which will add the Signal Tap file to the project before building it:
``` ```
quartus_sh -t ../build.tcl -rev hosted -size 115 -stp ../signaltap/debug_rx.stp ./build_bladerf.sh -b bladeRF-micro -s A4 -r hosted
```
## Adding Signal Tap ##
For advanced users who want to use Signal Tap internal logic analyzer in their design, use the `-a` flag to add the Signal Tap file to the project before building it:
```
./build_bladerf.sh -b bladeRF-micro -s A4 -r hosted -a ../signaltap/debug_rx.stp
``` ```
Note that to use Signal Tap with the Quartus Prime Lite Edition software, the TalkBack feature must be enabled. The build script tries to 'fake' this out by setting the TalkBack feature to be on, compiling the project, then turning it off immediately afterward. If this behavior is not desired, don't try to add a Signal Tap file to the project. Note that to use Signal Tap with the Quartus Prime Lite Edition software, the TalkBack feature must be enabled. The build script tries to 'fake' this out by setting the TalkBack feature to be on, compiling the project, then turning it off immediately afterward. If this behavior is not desired, don't try to add a Signal Tap file to the project.

View file

@ -0,0 +1,61 @@
-- Copyright (c) 2024 Nuand LLC
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-- THE SOFTWARE.
library ieee;
use ieee.std_logic_1164.all;
use ieee.math_real.all;
entity clk_ctrl is
port (
inclk :in std_logic;
ena :in std_logic;
outclk :out std_logic
);
end entity clk_ctrl;
architecture rtl of clk_ctrl is
component altclkctrl
generic (
clock_type : string := "Auto";
ena_register_mode : string := "none";
number_of_clocks : integer := 1
);
port (
inclk : in std_logic_vector(0 downto 0);
ena : in std_logic;
outclk : out std_logic
);
end component;
signal clk_ctrl_out : std_logic;
begin
clkctrl : altclkctrl
port map (
inclk => (0 => inclk),
ena => ena,
outclk => clk_ctrl_out
);
outclk <= clk_ctrl_out;
end architecture rtl;

View file

@ -134,6 +134,10 @@ end entity;
architecture arch of common_dcfifo is architecture arch of common_dcfifo is
attribute ALTERA_ATTRIBUTE : string;
attribute ALTERA_ATTRIBUTE of arch : architecture is "-name SDC_STATEMENT ""set_false_path -to [get_registers {*fifo_gen:U_dcfifo_mixed_widths|dcfifo_*:auto_generated|dffpipe_*:wraclr|dffe*a[0]}] """;
function valid_width_ratio( width : natural; width_r : natural ) return boolean is function valid_width_ratio( width : natural; width_r : natural ) return boolean is
variable r : natural := 0; variable r : natural := 0;
variable rv : boolean := false; variable rv : boolean := false;

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.12) cmake_minimum_required(VERSION 3.5)
project(ad936x C) project(ad936x C)
message(STATUS "libad936x: Configuring build...") message(STATUS "libad936x: Configuring build...")

View file

@ -6,7 +6,7 @@
# #
# #
################################################################################ ################################################################################
cmake_minimum_required(VERSION 2.8.12) cmake_minimum_required(VERSION 3.5)
if(NOT "$ENV{QUARTUS_ROOTDIR}" STREQUAL "") if(NOT "$ENV{QUARTUS_ROOTDIR}" STREQUAL "")
set(QUARTUS_ROOTDIR "$ENV{QUARTUS_ROOTDIR}") set(QUARTUS_ROOTDIR "$ENV{QUARTUS_ROOTDIR}")

View file

@ -184,7 +184,7 @@ begin
count := 0 ; count := 0 ;
irq <= '0' ; irq <= '0' ;
elsif( rising_edge(clock) ) then elsif( rising_edge(clock) ) then
if( sin_we = '1' ) then if( sin_we = '1' and state /= WAIT_FOR_READ ) then
reg_request(count*8+7 downto count*8) <= sin_data ; reg_request(count*8+7 downto count*8) <= sin_data ;
end if ; end if ;
case state is case state is

View file

@ -4,6 +4,7 @@ proc compile_fx3_gpif { root } {
vlib work vlib work
vcom -2008 -work work [file join $root ./synthesis/set_clear_ff.vhd] vcom -2008 -work work [file join $root ./synthesis/set_clear_ff.vhd]
vcom -2008 -work work [file join $root ../../platforms/common/bladerf/vhdl/fx3_gpif_p.vhd]
vcom -2008 -work work [file join $root ../../platforms/common/bladerf/vhdl/fx3_gpif.vhd] vcom -2008 -work work [file join $root ../../platforms/common/bladerf/vhdl/fx3_gpif.vhd]
vcom -2008 -work work [file join $root ./simulation/util.vhd] vcom -2008 -work work [file join $root ./simulation/util.vhd]
vcom -2008 -work work [file join $root ./simulation/fx3_model.vhd] vcom -2008 -work work [file join $root ./simulation/fx3_model.vhd]

View file

@ -42,6 +42,7 @@ proc compile_nuand { root platform } {
vcom -work nuand -2008 [file join $root ./synthesis/tb/atsc_tx_tb.vhd] vcom -work nuand -2008 [file join $root ./synthesis/tb/atsc_tx_tb.vhd]
vcom -work nuand -2008 [file join $root ../../platforms/common/bladerf/vhdl/fx3_gpif_p.vhd]
vcom -work nuand -2008 [file join $root ./simulation/fx3_model.vhd] vcom -work nuand -2008 [file join $root ./simulation/fx3_model.vhd]
vcom -work nuand -2008 [file join $root ./simulation/lms6002d_model.vhd] vcom -work nuand -2008 [file join $root ./simulation/lms6002d_model.vhd]

View file

@ -26,6 +26,8 @@ library ieee;
library work; library work;
use work.util.all; use work.util.all;
use work.fx3_gpif_p.all;
entity fx3_model is entity fx3_model is
port ( port (
@ -40,6 +42,7 @@ entity fx3_model is
fx3_tx_en : in std_logic; fx3_tx_en : in std_logic;
fx3_tx_meta_en : in std_logic; fx3_tx_meta_en : in std_logic;
eight_bit_mode_en : in std_logic := '0'; eight_bit_mode_en : in std_logic := '0';
packed_mode_en : in std_logic := '0';
done : out boolean done : out boolean
); );
end entity ; -- fx3_model end entity ; -- fx3_model
@ -102,7 +105,7 @@ begin
done <= rx_done and tx_done; done <= rx_done and tx_done;
rx_sample_stream : process rx_sample_stream : process
constant BLOCK_SIZE : natural := 512; constant BLOCK_SIZE : natural := GPIF_BUF_SIZE_SS;
variable count : natural := START_COUNT; variable count : natural := START_COUNT;
variable req_time : time; variable req_time : time;
begin begin
@ -155,7 +158,7 @@ begin
end process; end process;
tx_sample_stream : process tx_sample_stream : process
constant BLOCK_SIZE : natural := 512; constant BLOCK_SIZE : natural := GPIF_BUF_SIZE_SS;
variable count : natural := START_COUNT; variable count : natural := START_COUNT;
variable timestamp_cntr : natural := 80; variable timestamp_cntr : natural := 80;
variable header_len : natural := 0; variable header_len : natural := 0;
@ -201,7 +204,7 @@ begin
data_out := x"12341234"; data_out := x"12341234";
when 2 => when 2 =>
data_out(31 downto 0) := std_logic_vector(to_signed(timestamp_cntr, 32)); data_out(31 downto 0) := std_logic_vector(to_signed(timestamp_cntr, 32));
timestamp_cntr := timestamp_cntr + 508 * 2; timestamp_cntr := timestamp_cntr + (GPIF_BUF_SIZE_SS-4) * 2;
when 3 => when 3 =>
data_out := (others => '0'); data_out := (others => '0');
when 4 => when 4 =>

View file

@ -28,6 +28,7 @@ library nuand ;
use nuand.fifo_readwrite_p.all; use nuand.fifo_readwrite_p.all;
use nuand.common_dcfifo_p.all; use nuand.common_dcfifo_p.all;
use nuand.bladerf_p.all; use nuand.bladerf_p.all;
use nuand.fx3_gpif_p.all;
library std ; library std ;
use std.env.all ; use std.env.all ;
@ -435,8 +436,8 @@ begin
wait until reset = '0' ; wait until reset = '0' ;
end if ; end if ;
while true loop while true loop
wait until rising_edge(fx3_clock) and unsigned(rx_sample_fifo.rused) > 512 ; wait until rising_edge(fx3_clock) and unsigned(rx_sample_fifo.rused) > GPIF_BUF_SIZE_SS;
for i in 1 to 512 loop for i in 1 to GPIF_BUF_SIZE_SS loop
rx_sample_fifo.rreq <= '1' ; rx_sample_fifo.rreq <= '1' ;
nop( fx3_clock, 1 ) ; nop( fx3_clock, 1 ) ;
if( CHECK_OVERFLOW ) then if( CHECK_OVERFLOW ) then

View file

@ -24,6 +24,7 @@ library ieee;
library work; library work;
use work.fifo_readwrite_p.all; use work.fifo_readwrite_p.all;
use work.fx3_gpif_p.all;
entity fifo_reader is entity fifo_reader is
generic ( generic (
@ -43,6 +44,7 @@ entity fifo_reader is
meta_en : in std_logic; meta_en : in std_logic;
packet_en : in std_logic; packet_en : in std_logic;
eight_bit_mode_en : in std_logic; eight_bit_mode_en : in std_logic;
highly_packed_mode_en : in std_logic;
timestamp : in unsigned(63 downto 0); timestamp : in unsigned(63 downto 0);
fifo_usedw : in std_logic_vector(FIFO_USEDW_WIDTH-1 downto 0); fifo_usedw : in std_logic_vector(FIFO_USEDW_WIDTH-1 downto 0);
@ -71,8 +73,9 @@ end entity;
architecture simple of fifo_reader is architecture simple of fifo_reader is
constant DMA_BUF_SIZE_SS : natural := 512; constant DMA_BUF_SIZE_SS : natural := GPIF_BUF_SIZE_SS;
constant DMA_BUF_SIZE_HS : natural := 256; constant DMA_BUF_SIZE_HS : natural := GPIF_BUF_SIZE_HS;
constant MAX_TIMESTAMP : unsigned(timestamp'high downto timestamp'low) := (others => '1');
signal dma_buf_size : natural range DMA_BUF_SIZE_HS to DMA_BUF_SIZE_SS := DMA_BUF_SIZE_SS; signal dma_buf_size : natural range DMA_BUF_SIZE_HS to DMA_BUF_SIZE_SS := DMA_BUF_SIZE_SS;
signal underflow_detected : std_logic := '0'; signal underflow_detected : std_logic := '0';
@ -92,7 +95,10 @@ architecture simple of fifo_reader is
meta_read : std_logic; meta_read : std_logic;
meta_cache : std_logic_vector(META_FIFO_DATA_WIDTH-1 downto 0); meta_cache : std_logic_vector(META_FIFO_DATA_WIDTH-1 downto 0);
meta_p_time : unsigned(63 downto 0); meta_p_time : unsigned(63 downto 0);
meta_p_time_r : unsigned(63 downto 0);
meta_time_go : std_logic; meta_time_go : std_logic;
meta_fifo_empty : std_logic;
meta_fifo_data : std_logic_vector(META_FIFO_DATA_WIDTH-1 downto 0);
end record; end record;
constant META_FSM_RESET_VALUE : meta_fsm_t := ( constant META_FSM_RESET_VALUE : meta_fsm_t := (
@ -104,7 +110,10 @@ architecture simple of fifo_reader is
meta_read => '0', meta_read => '0',
meta_cache => (others => '0'), meta_cache => (others => '0'),
meta_p_time => (others => '-'), meta_p_time => (others => '-'),
meta_time_go => '0' meta_p_time_r => (others => '-'),
meta_time_go => '0',
meta_fifo_empty => '1',
meta_fifo_data => (others => '0')
); );
signal meta_current : meta_fsm_t := META_FSM_RESET_VALUE; signal meta_current : meta_fsm_t := META_FSM_RESET_VALUE;
@ -135,6 +144,10 @@ architecture simple of fifo_reader is
fifo_read : std_logic; fifo_read : std_logic;
out_samples : sample_streams_t(out_samples'range); out_samples : sample_streams_t(out_samples'range);
eight_bit_sample_sel: std_logic; eight_bit_sample_sel: std_logic;
-- Highly packed mode signals
packed_buffer : std_logic_vector(47 downto 0);
packed_cycle : integer range 0 to 4;
end record; end record;
constant FIFO_FSM_RESET_VALUE : fifo_fsm_t := ( constant FIFO_FSM_RESET_VALUE : fifo_fsm_t := (
@ -150,7 +163,9 @@ architecture simple of fifo_reader is
packet_data_cache => (others => '0'), packet_data_cache => (others => '0'),
fifo_read => '0', fifo_read => '0',
out_samples => (others => ZERO_SAMPLE), out_samples => (others => ZERO_SAMPLE),
eight_bit_sample_sel => '0' eight_bit_sample_sel => '0',
packed_buffer => (others => '0'),
packed_cycle => 0
); );
signal fifo_current : fifo_fsm_t := FIFO_FSM_RESET_VALUE; signal fifo_current : fifo_fsm_t := FIFO_FSM_RESET_VALUE;
@ -193,11 +208,13 @@ begin
end if; end if;
end process; end process;
packet_empty <= '1' when ( meta_fifo_empty = '1' and meta_current.state /= META_WAIT ) else '0' ; packet_empty <= '1' when ( meta_current.meta_fifo_empty = '1' and meta_current.state /= META_WAIT ) else '0' ;
-- Meta FIFO combinatorial process -- Meta FIFO combinatorial process
meta_fsm_comb : process( all ) meta_fsm_comb : process( all )
constant META_NOW : unsigned(63 downto 0) := (others => '1');
variable meta_time : unsigned(63 downto 0); variable meta_time : unsigned(63 downto 0);
variable packet_len : integer;
begin begin
meta_future <= meta_current; meta_future <= meta_current;
@ -205,26 +222,29 @@ begin
meta_future.meta_read <= '0'; meta_future.meta_read <= '0';
meta_future.meta_pkt_sop <= '0'; meta_future.meta_pkt_sop <= '0';
meta_future.meta_pkt_eop <= '0'; meta_future.meta_pkt_eop <= '0';
meta_future.meta_fifo_empty <= meta_fifo_empty;
meta_future.meta_fifo_data <= meta_fifo_data;
meta_time := unsigned(meta_current.meta_fifo_data(95 downto 32)) - 1;
meta_future.meta_p_time_r <= meta_time;
case meta_current.state is case meta_current.state is
when META_LOAD => when META_LOAD =>
meta_future.skip_padding <= '0'; meta_future.skip_padding <= '0';
meta_time := unsigned(meta_fifo_data(95 downto 32)) - 1; meta_future.meta_p_time <= meta_current.meta_p_time_r;
meta_future.meta_p_time <= meta_time; meta_future.meta_cache <= meta_current.meta_fifo_data;
meta_future.meta_cache <= meta_fifo_data;
if( meta_current.dma_downcount = NUM_STREAMS ) then if( meta_current.dma_downcount = NUM_STREAMS ) then
meta_future.dma_downcount <= 0; meta_future.dma_downcount <= 0;
end if; end if;
if( fifo_current.ch_shift = 0 ) then if( fifo_current.ch_shift = 0 ) then
if( meta_fifo_empty = '0' and (packet_en = '0' or if( meta_current.meta_fifo_empty = '0' and (packet_en = '0' or
(packet_en = '1' and packet_ready = '1') ) ) then (packet_en = '1' and packet_ready = '1') ) ) then
meta_future.meta_read <= '1'; meta_future.meta_read <= '1';
meta_future.state <= META_WAIT; meta_future.state <= META_WAIT;
if( packet_en = '1' or meta_time /= timestamp ) then if( packet_en = '1' or (meta_current.meta_p_time_r > timestamp and meta_current.meta_p_time_r /= META_NOW) ) then
meta_future.meta_time_go <= '0'; meta_future.meta_time_go <= '0';
else else
meta_future.meta_time_go <= '1'; meta_future.meta_time_go <= '1';
@ -237,12 +257,13 @@ begin
when META_WAIT => when META_WAIT =>
if( packet_en = '1' ) then if( packet_en = '1' ) then
meta_future.dma_downcount <= to_integer(unsigned(meta_current.meta_cache(15 downto 0))); packet_len := to_integer(unsigned(meta_current.meta_cache(15 downto 0)));
meta_future.dma_downcount <= packet_len - 1;
else else
meta_future.dma_downcount <= dma_buf_size - 4; meta_future.dma_downcount <= dma_buf_size - 4;
end if; end if;
if( (timestamp >= meta_current.meta_p_time or meta_current.meta_p_time + 1 = 0) if( (timestamp >= meta_current.meta_p_time or meta_current.meta_p_time = MAX_TIMESTAMP)
and ( packet_en = '0' or ( packet_en = '1' and packet_ready = '1' ) ) ) then and ( packet_en = '0' or ( packet_en = '1' and packet_ready = '1' ) ) ) then
meta_future.meta_time_go <= '1'; meta_future.meta_time_go <= '1';
meta_future.state <= META_DOWNCOUNT; meta_future.state <= META_DOWNCOUNT;
@ -257,12 +278,12 @@ begin
if( packet_en = '0' ) then if( packet_en = '0' ) then
if( fifo_current.fifo_read = '1') then if( fifo_current.fifo_read = '1') then
meta_future.dma_downcount <= meta_current.dma_downcount - NUM_STREAMS; meta_future.dma_downcount <= meta_current.dma_downcount - NUM_STREAMS;
end if; if( meta_current.dma_downcount <= 2 ) then
if( meta_current.dma_downcount <= NUM_STREAMS ) then
-- Look for 2 because of the 2 cycles passing -- Look for 2 because of the 2 cycles passing
-- through META_LOAD and META_WAIT after this. -- through META_LOAD and META_WAIT after this.
meta_future.state <= META_LOAD; meta_future.state <= META_LOAD;
end if; end if;
end if;
else else
if( fifo_current.packet_control.data_valid = '1') then if( fifo_current.packet_control.data_valid = '1') then
meta_future.dma_downcount <= meta_current.dma_downcount - 1; meta_future.dma_downcount <= meta_current.dma_downcount - 1;
@ -409,6 +430,67 @@ begin
return rv; return rv;
end function; end function;
-- --------------------------------------------------------------------
-- MIMO UNPACKER: STEP 1 of 5 (SC12Q11 Highly Packed Mode)
-- --------------------------------------------------------------------
-- The sample FIFO output is a wide data bus that contains multiple
-- 12-bit I/Q samples packed across multiple cycles. This procedure unpacks
-- data from a 64-bit wide bus across three cycles to extract eight 12-bit I/Q pairs.
--
-- The packing scheme for 12-bit samples across three 64-bit cycles:
-- Cycle 1: | 63:60 | 59:48 | 47:36 | 35:24 | 23:12 | 11:0 | Bit indices
-- | Q0' | I0 | Q1 | I1 | Q0 | I0 | Samples
-- [-----][--------full 12-bit samples-----------]
-- 4-bit
-- overlap
--
-- Cycle 2: | 63:56 | 55:44 | 43:32 | 31:20 | 19:8 | 7:0 | Bit indices
-- | I1' | Q0 | I0 | Q1 | I1 | Q0' | Samples
-- [-----][--------full 12-bit samples--------][---]
-- 8-bit 8-bit
-- overlap overlap
--
-- Cycle 3: | 63:52 | 51:40 | 39:28 | 27:16 | 15:4 | 3:0 | Bit indices
-- | Q1 | I1 | Q0 | I0 | Q1 | I1' | Samples
-- [--------full 12-bit samples-----------][-----]
-- 4-bit
-- overlap
--
-- Note: Samples with apostrophes (') indicate partial samples that span
-- across cycle boundaries. The complete samples are reconstructed by
-- combining these partial segments from different cycles.
procedure unpack_sc12q11(
signal data : in std_logic_vector(63 downto 0);
signal previous_data : in std_logic_vector(47 downto 0);
signal cycle : in integer;
variable rv : out sample_streams_t
) is
constant OFFSET_UNIT : natural := 24;
begin
for i in rv'range loop
rv(i).data_i := resize(signed(shift_right(unsigned(data),i*OFFSET_UNIT)(11 downto 0)),rv(i).data_i'length);
rv(i).data_q := resize(signed(shift_right(unsigned(data),i*OFFSET_UNIT)(23 downto 12)),rv(i).data_q'length);
rv(i).data_v := '0';
end loop;
if (cycle = 1) then
rv(0).data_i := resize(signed(previous_data(43 downto 32)),rv(0).data_i'length);
rv(0).data_q := resize(signed(data(7 downto 0) & previous_data(47 downto 44)),rv(0).data_q'length);
rv(1).data_i := resize(signed(shift_right(unsigned(data),8)(11 downto 0)),rv(1).data_i'length);
rv(1).data_q := resize(signed(shift_right(unsigned(data),8)(23 downto 12)),rv(1).data_q'length);
elsif (cycle = 2) then
rv(0).data_i := resize(signed(previous_data(27 downto 16)),rv(0).data_i'length);
rv(0).data_q := resize(signed(previous_data(39 downto 28)),rv(0).data_q'length);
rv(1).data_i := resize(signed(fifo_data(3 downto 0) & previous_data(47 downto 40)), rv(1).data_i'length);
rv(1).data_q := resize(signed(fifo_data(15 downto 4)), rv(1).data_q'length);
elsif (cycle = 3) then
rv(0).data_i := resize(signed(previous_data(11 downto 0)),rv(0).data_i'length);
rv(0).data_q := resize(signed(previous_data(23 downto 12)),rv(0).data_q'length);
rv(1).data_i := resize(signed(previous_data(35 downto 24)),rv(0).data_i'length);
rv(1).data_q := resize(signed(previous_data(47 downto 36)),rv(0).data_q'length);
end if;
end procedure;
-- -------------------------------------------------------------------- -- --------------------------------------------------------------------
-- MIMO UNPACKER: STEP 3 of 5 -- MIMO UNPACKER: STEP 3 of 5
-- -------------------------------------------------------------------- -- --------------------------------------------------------------------
@ -449,7 +531,14 @@ begin
fifo_future.packet_control.data_valid <= '0'; fifo_future.packet_control.data_valid <= '0';
-- MIMO UNPACKER: STEP 1 of 5 -- MIMO UNPACKER: STEP 1 of 5
if( eight_bit_mode_en = '1') then if (highly_packed_mode_en = '1' and NUM_STREAMS = 2) then
unpack_sc12q11(
data => fifo_data,
previous_data => fifo_current.packed_buffer,
cycle => fifo_current.packed_cycle,
rv => unpacked
);
elsif (eight_bit_mode_en = '1') then
unpacked := unpack_eight_bit_mode(fifo_current.sample_controls_reg, fifo_data, fifo_current.eight_bit_sample_sel); unpacked := unpack_eight_bit_mode(fifo_current.sample_controls_reg, fifo_data, fifo_current.eight_bit_sample_sel);
else else
unpacked := unpack(fifo_current.sample_controls_reg, fifo_data); unpacked := unpack(fifo_current.sample_controls_reg, fifo_data);
@ -484,7 +573,11 @@ begin
-- still need to be processed (not including the first). This becomes the number of clock -- still need to be processed (not including the first). This becomes the number of clock
-- cycles to wait before asserting the FIFO read request to get a new batch of samples. -- cycles to wait before asserting the FIFO read request to get a new batch of samples.
fifo_future.samples_left_init <= NUM_STREAMS - fifo_current.enabled_channels; fifo_future.samples_left_init <= NUM_STREAMS - fifo_current.enabled_channels;
if (fifo_current.samples_left = FIFO_FSM_RESET_VALUE.samples_left) then
fifo_future.samples_left <= NUM_STREAMS - fifo_current.enabled_channels; fifo_future.samples_left <= NUM_STREAMS - fifo_current.enabled_channels;
fifo_future.ch_shift <= 0;
end if;
if( packet_en = '1' ) then if( packet_en = '1' ) then
fifo_future.state <= READ_PACKET; fifo_future.state <= READ_PACKET;
@ -552,11 +645,17 @@ begin
if( fifo_current.samples_left = 0 ) then if( fifo_current.samples_left = 0 ) then
fifo_future.samples_left <= fifo_current.samples_left_init; fifo_future.samples_left <= fifo_current.samples_left_init;
fifo_future.ch_shift <= 0; fifo_future.ch_shift <= 0;
fifo_future.fifo_read <= read_req;
if( eight_bit_mode_en = '1' ) then if( eight_bit_mode_en = '1' ) then
fifo_future.fifo_read <= read_req and fifo_current.eight_bit_sample_sel; fifo_future.fifo_read <= read_req and fifo_current.eight_bit_sample_sel;
fifo_future.eight_bit_sample_sel <= not fifo_current.eight_bit_sample_sel; fifo_future.eight_bit_sample_sel <= not fifo_current.eight_bit_sample_sel;
else elsif (highly_packed_mode_en = '1' and NUM_STREAMS = 2) then
fifo_future.fifo_read <= read_req; fifo_future.packed_cycle <= (fifo_current.packed_cycle + 1);
fifo_future.packed_buffer <= fifo_data(fifo_data'high downto fifo_data'high-47);
if fifo_current.packed_cycle = 3 then
fifo_future.packed_cycle <= 0;
fifo_future.fifo_read <= '0';
end if;
end if; end if;
else else
-- MIMO UNPACKER: STEP 5 of 5 -- MIMO UNPACKER: STEP 5 of 5

View file

@ -24,6 +24,7 @@ library ieee;
library work; library work;
use work.fifo_readwrite_p.all; use work.fifo_readwrite_p.all;
use work.fx3_gpif_p.all;
entity fifo_writer is entity fifo_writer is
generic ( generic (
@ -41,7 +42,8 @@ entity fifo_writer is
usb_speed : in std_logic; usb_speed : in std_logic;
meta_en : in std_logic; meta_en : in std_logic;
packet_en : in std_logic; packet_en : in std_logic;
eight_bit_mode_en : in std_logic; eight_bit_mode_en : in std_logic := '0';
highly_packed_mode_en : in std_logic;
timestamp : in unsigned(63 downto 0); timestamp : in unsigned(63 downto 0);
mini_exp : in std_logic_vector(1 downto 0); mini_exp : in std_logic_vector(1 downto 0);
@ -70,8 +72,8 @@ end entity;
architecture simple of fifo_writer is architecture simple of fifo_writer is
constant DMA_BUF_SIZE_SS : natural := 512; constant DMA_BUF_SIZE_SS : natural := GPIF_BUF_SIZE_SS;
constant DMA_BUF_SIZE_HS : natural := 256; constant DMA_BUF_SIZE_HS : natural := GPIF_BUF_SIZE_HS;
signal dma_buf_size : natural range DMA_BUF_SIZE_HS to DMA_BUF_SIZE_SS := DMA_BUF_SIZE_SS; signal dma_buf_size : natural range DMA_BUF_SIZE_HS to DMA_BUF_SIZE_SS := DMA_BUF_SIZE_SS;
@ -118,7 +120,11 @@ architecture simple of fifo_writer is
fifo_clear : std_logic; fifo_clear : std_logic;
fifo_write : std_logic; fifo_write : std_logic;
fifo_data : unsigned(fifo_data'range); fifo_data : unsigned(fifo_data'range);
fifo_12b_buf : unsigned(95 downto 0);
write_cycle : natural range 0 to 3;
samples_left : natural range 0 to in_sample_controls'length; samples_left : natural range 0 to in_sample_controls'length;
in_sample_controls_r: sample_controls_t(0 to NUM_STREAMS-1);
in_samples_r : sample_streams_t(0 to NUM_STREAMS-1);
eight_bit_delay : std_logic; eight_bit_delay : std_logic;
end record; end record;
@ -127,7 +133,11 @@ architecture simple of fifo_writer is
fifo_clear => '1', fifo_clear => '1',
fifo_write => '0', fifo_write => '0',
fifo_data => (others => '-'), fifo_data => (others => '-'),
fifo_12b_buf => (others => '-'),
write_cycle => 0,
samples_left => 0, samples_left => 0,
in_sample_controls_r=> (others => SAMPLE_CONTROL_DISABLE),
in_samples_r => (others => ZERO_SAMPLE),
eight_bit_delay => '0' eight_bit_delay => '0'
); );
@ -136,6 +146,9 @@ architecture simple of fifo_writer is
signal sync_mini_exp: std_logic_vector(1 downto 0); signal sync_mini_exp: std_logic_vector(1 downto 0);
signal meta_fifo_used_v_r : unsigned(meta_fifo_usedw'length downto 0) := (others => '0');
signal fifo_used_v_r : unsigned(fifo_usedw'length downto 0) := (others => '0');
begin begin
-- Throw an error if port widths don't make sense -- Throw an error if port widths don't make sense
@ -167,11 +180,21 @@ begin
if( reset = '1' ) then if( reset = '1' ) then
fifo_enough <= false; fifo_enough <= false;
fifo_used_v := (others => '0'); fifo_used_v := (others => '0');
meta_fifo_used_v_r <= (others => '0');
fifo_used_v_r <= (others => '0');
elsif( rising_edge(clock) ) then elsif( rising_edge(clock) ) then
-- the outputs of the dcfifo are not registered so give the long combinatorial
-- data path, let's register the values. one extra clock cycle will not change
-- the fidelity of the result. the meta_fifo represents at minimum 204 timestamps.
-- there is no way for an off by 1 clock cycle timing to overflow the meta fifo
-- when the buffer leaves 4 full meta buffers empty
fifo_used_v := unsigned(fifo_full & fifo_usedw); fifo_used_v := unsigned(fifo_full & fifo_usedw);
fifo_used_v_r <= fifo_used_v;
meta_fifo_used_v := unsigned(meta_fifo_full & meta_fifo_usedw); meta_fifo_used_v := unsigned(meta_fifo_full & meta_fifo_usedw);
if( fifo_full = '0' and ((FIFO_MAX - fifo_used_v) > ( dma_buf_size * 4 )) and meta_fifo_used_v_r <= meta_fifo_used_v;
( ( meta_en = '1' and meta_fifo_full = '0' and ( META_MAX - 4 ) > meta_fifo_used_v )
if( fifo_full = '0' and ((FIFO_MAX - fifo_used_v_r) > ( dma_buf_size )) and
( ( meta_en = '1' and meta_fifo_full = '0' and ( META_MAX - 4 ) > meta_fifo_used_v_r )
or (meta_en = '0') ) ) then or (meta_en = '0') ) ) then
fifo_enough <= true; fifo_enough <= true;
else else
@ -262,11 +285,13 @@ begin
when META_WRITE => when META_WRITE =>
if( (meta_fifo_full = '0') and (in_samples(in_samples'low).data_v = '1') ) then for i in in_samples'range loop
if (meta_fifo_full = '0' and in_samples(i).data_v = '1') then
meta_future.meta_write <= '1'; meta_future.meta_write <= '1';
meta_future.meta_written <= '1'; meta_future.meta_written <= '1';
meta_future.state <= META_DOWNCOUNT; meta_future.state <= META_DOWNCOUNT;
end if; end if;
end loop;
when META_DOWNCOUNT => when META_DOWNCOUNT =>
@ -274,9 +299,26 @@ begin
meta_future.dma_downcount <= meta_current.dma_downcount - NUM_STREAMS; meta_future.dma_downcount <= meta_current.dma_downcount - NUM_STREAMS;
end if; end if;
if( meta_current.dma_downcount <= NUM_STREAMS ) then if( meta_current.dma_downcount <= 2 ) then
-- Look for 2 because of the 2 cycles passing -- Look for 2 because of the 2 cycles passing
-- through IDLE and META_WRITE after this. -- through IDLE and META_WRITE after this.
-- 8bit format requires an additional 2 cycle delay.
if( eight_bit_mode_en = '1' ) then
if( fifo_future.eight_bit_delay = '1' and fifo_future.samples_left = 0) then
meta_future.state <= IDLE;
end if;
else
meta_future.state <= IDLE;
end if;
end if;
-- Patches the late meta write for MIMO mode
if( in_sample_controls'length = 2 and
in_sample_controls(0).enable = '1' and
in_sample_controls(1).enable = '1' and
eight_bit_mode_en = '0' and
meta_current.dma_downcount <= NUM_STREAMS + 2 )
then
meta_future.state <= IDLE; meta_future.state <= IDLE;
end if; end if;
@ -395,6 +437,106 @@ begin
end function; end function;
-- --------------------------------------------------------------------
-- MIMO PACKER: STEP 1 of 3 (SC12Q11 Highly Packed Mode)
-- --------------------------------------------------------------------
-- This block receives samples as an array of sample streams, one
-- element per channel. These streams need to be packed into a single,
-- wide bus that is written to a FIFO and delivered to the host.
-- For SC12Q11 (SC16_Q11_PACKED) format, each I and Q sample is 12 bits wide.
--
-- This packing scheme efficiently utilizes the available bandwidth
-- for the SC12Q11 format, allowing for 8 complete IQ pairs every 3 cycles.
--
-- The packing process fills 3 cycles of a 64-bit buffer with 8 24b IQ pairs:
-- Cycle 1: | 63:60 | 59:48 | 47:36 | 35:24 | 23:12 | 11:0 | Bit indices
-- | Q0' | I0 | Q1 | I1 | Q0 | I0 | Samples
-- [-----][--------full 12-bit samples-----------]
-- 4-bit
-- overlap
--
-- Cycle 2: | 63:56 | 55:44 | 43:32 | 31:20 | 19:8 | 7:0 | Bit indices
-- | I1' | Q0 | I0 | Q1 | I1 | Q0' | Samples
-- [-----][--------full 12-bit samples--------][---]
-- 8-bit 8-bit
-- overlap overlap
--
-- Cycle 3: | 63:52 | 51:40 | 39:28 | 27:16 | 15:4 | 3:0 | Bit indices
-- | Q1 | I1 | Q0 | I0 | Q1 | I1' | Samples
-- [--------full 12-bit samples-----------][-----]
-- 4-bit
-- overlap
--
-- Note: Samples with apostrophes (') indicate partial samples that span
-- across cycle boundaries. The complete samples are reconstructed by
-- combining these partial segments from different cycles.
function pack_sc12q11( sc : sample_controls_t;
ss : sample_streams_t;
d : unsigned ) return unsigned is
constant IQ_PAIR_LEN : positive := 24;
variable rv : unsigned(d'range) := (others => '0');
begin
rv := d;
for i in sc'range loop
if( (sc(i).enable = '1') and (ss(i).data_v = '1') ) then
rv := unsigned(ss(i).data_q(11 downto 0)) &
unsigned(ss(i).data_i(11 downto 0)) &
rv(rv'high downto rv'low+IQ_PAIR_LEN);
end if;
end loop;
return rv;
end function;
procedure handle_fifo_write(
signal fifo_current : in fifo_fsm_t;
signal meta_current : in meta_fsm_t;
signal meta_en : in std_logic;
signal eight_bit_mode_en : in std_logic;
variable write_req : out std_logic;
signal fifo_future : out fifo_fsm_t
) is
variable in_sample_controls : sample_controls_t(0 to NUM_STREAMS-1);
variable in_samples : sample_streams_t(0 to NUM_STREAMS-1);
begin
in_sample_controls := fifo_current.in_sample_controls_r;
in_samples := fifo_current.in_samples_r;
if( ((meta_current.meta_written = '1') or (meta_en = '0')) ) then
-- Check for valid data
write_req := '0';
for i in in_sample_controls'range loop
if( in_sample_controls(i).enable = '1' ) then
write_req := write_req or in_samples(i).data_v;
end if;
end loop;
-- Received valid data
if( write_req = '1' ) then
if( fifo_current.samples_left = 0 ) then
fifo_future.samples_left <= NUM_STREAMS - count_enabled_channels(in_sample_controls);
fifo_future.fifo_write <= write_req;
if( eight_bit_mode_en = '1' ) then
fifo_future.fifo_write <= write_req and fifo_current.eight_bit_delay;
fifo_future.eight_bit_delay <= not fifo_current.eight_bit_delay;
end if;
if( highly_packed_mode_en = '1' ) then
fifo_future.write_cycle <= (fifo_current.write_cycle + 1) mod 4;
if fifo_current.write_cycle = 0 then
fifo_future.fifo_write <= '0';
end if;
end if;
else
-- MIMO PACKER: STEP 3 of 3
fifo_future.samples_left <= fifo_current.samples_left - 1;
end if;
end if;
else
fifo_future.fifo_write <= '0';
end if;
end;
variable write_req : std_logic := '0'; variable write_req : std_logic := '0';
begin begin
@ -404,12 +546,38 @@ begin
fifo_future.fifo_clear <= '0'; fifo_future.fifo_clear <= '0';
fifo_future.fifo_write <= '0'; fifo_future.fifo_write <= '0';
fifo_future.in_samples_r <= in_samples;
fifo_future.in_sample_controls_r <= in_sample_controls;
-- MIMO PACKER: STEP 1 of 3 -- MIMO PACKER: STEP 1 of 3
if( packet_en = '0' ) then if( packet_en = '0' ) then
fifo_future.fifo_data <= pack(fifo_current.in_sample_controls_r,
fifo_current.in_samples_r,
fifo_current.fifo_data);
if( highly_packed_mode_en = '1' ) then
fifo_future.fifo_12b_buf <= pack_sc12q11(
sc => in_sample_controls,
ss => in_samples,
d => fifo_current.fifo_12b_buf
);
if fifo_current.write_cycle = 1 then
fifo_future.fifo_data <= fifo_current.fifo_12b_buf(
fifo_data'length-1 downto fifo_current.fifo_12b_buf'low);
elsif fifo_current.write_cycle = 2 then
fifo_future.fifo_data <= fifo_current.fifo_12b_buf(
fifo_data'length-1+16 downto fifo_current.fifo_12b_buf'low+16);
elsif fifo_current.write_cycle = 3 then
fifo_future.fifo_data <= fifo_current.fifo_12b_buf(
fifo_data'length-1+32 downto fifo_current.fifo_12b_buf'low+32);
end if;
end if;
if( eight_bit_mode_en = '1' ) then if( eight_bit_mode_en = '1' ) then
fifo_future.fifo_data <= pack_eight_bit_mode(in_sample_controls, in_samples, fifo_current.fifo_data); fifo_future.fifo_data <= pack_eight_bit_mode(fifo_current.in_sample_controls_r,
else fifo_current.in_samples_r,
fifo_future.fifo_data <= pack(in_sample_controls, in_samples, fifo_current.fifo_data); fifo_current.fifo_data);
end if; end if;
end if; end if;
@ -479,44 +647,37 @@ begin
when WRITE_SAMPLES => when WRITE_SAMPLES =>
if( ((meta_current.meta_written = '1') or (meta_en = '0')) ) then handle_fifo_write(
fifo_current => fifo_current,
-- Check for valid data meta_current => meta_current,
write_req := '0'; meta_en => meta_en,
for i in in_sample_controls'range loop eight_bit_mode_en => eight_bit_mode_en,
if( in_sample_controls(i).enable = '1' ) then write_req => write_req,
write_req := write_req or in_samples(i).data_v; fifo_future => fifo_future
end if; );
end loop;
-- Received valid data
if( write_req = '1' ) then
if( fifo_current.samples_left = 0 ) then
fifo_future.samples_left <= NUM_STREAMS - count_enabled_channels(in_sample_controls);
if( eight_bit_mode_en = '1' ) then
fifo_future.fifo_write <= write_req and fifo_current.eight_bit_delay;
fifo_future.eight_bit_delay <= not fifo_current.eight_bit_delay;
else
fifo_future.fifo_write <= write_req;
end if;
else
-- MIMO PACKER: STEP 3 of 3
fifo_future.samples_left <= fifo_current.samples_left - 1;
end if;
end if;
else
fifo_future.fifo_write <= '0';
end if;
if( fifo_full = '1' or ( meta_current.meta_written = '0' and meta_en = '1') ) then if( fifo_full = '1' or ( meta_current.meta_written = '0' and meta_en = '1') ) then
fifo_future.fifo_write <= '0'; fifo_future.fifo_write <= '0';
fifo_future.state <= HOLDOFF; fifo_future.state <= HOLDOFF;
fifo_future.write_cycle <= fifo_current.write_cycle;
fifo_future.fifo_12b_buf <= fifo_current.fifo_12b_buf;
end if; end if;
when HOLDOFF => when HOLDOFF =>
fifo_future.write_cycle <= fifo_current.write_cycle;
fifo_future.fifo_12b_buf <= fifo_current.fifo_12b_buf;
if( fifo_enough ) then if( fifo_enough ) then
fifo_future.state <= WRITE_SAMPLES; fifo_future.state <= WRITE_SAMPLES;
handle_fifo_write(
fifo_current => fifo_current,
meta_current => meta_current,
meta_en => meta_en,
eight_bit_mode_en => eight_bit_mode_en,
write_req => write_req,
fifo_future => fifo_future
);
end if; end if;
when others => when others =>

View file

@ -9,6 +9,7 @@ entity signal_generator is
enable : in std_logic ; enable : in std_logic ;
mode : in std_logic ; mode : in std_logic ;
eightbit_en : in std_logic := '0';
sample_i : out signed(15 downto 0) ; sample_i : out signed(15 downto 0) ;
sample_q : out signed(15 downto 0) ; sample_q : out signed(15 downto 0) ;
@ -38,6 +39,11 @@ begin
else else
sample_i <= signed(std_logic_vector(count32(15 downto 0))) ; sample_i <= signed(std_logic_vector(count32(15 downto 0))) ;
sample_q <= signed(std_logic_vector(count32(31 downto 16))) ; sample_q <= signed(std_logic_vector(count32(31 downto 16))) ;
if eightbit_en = '1' then
sample_i <= signed(std_logic_vector(shift_left(resize(count32(8 downto 0), 16), 4)));
sample_q <= signed(std_logic_vector(shift_left(resize(count32(15 downto 8), 16), 4)));
end if;
end if ; end if ;
if( enable = '0' ) then if( enable = '0' ) then

View file

@ -36,6 +36,7 @@ set_global_assignment -name QIP_FILE [file normalize [file join $nuand_ip pll_r
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip ps_sync/vhdl/ps_sync.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip ps_sync/vhdl/ps_sync.vhd]]
# Implementation Details # Implementation Details
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif_p.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/tx.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/tx.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/rx-adsb.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/rx-adsb.vhd]]

View file

@ -33,6 +33,7 @@ set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip ps_sy
set_global_assignment -name QIP_FILE [file normalize [file join $nuand_ip tone_generator/tone_generator.qip]] set_global_assignment -name QIP_FILE [file normalize [file join $nuand_ip tone_generator/tone_generator.qip]]
# Implementation Details # Implementation Details
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif_p.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/tx.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/tx.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/rx.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/rx.vhd]]

View file

@ -8,6 +8,7 @@ set opencores_ip [file normalize [file join $here ../../ip/opencores]]
# Altera IP # Altera IP
set_global_assignment -name VHDL_FILE [file normalize [file join $altera_ip common_dcfifo/common_dcfifo.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $altera_ip common_dcfifo/common_dcfifo.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $altera_ip clk_ctrl/clk_ctrl.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/wrappers/tx_fifo.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/wrappers/tx_fifo.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/wrappers/tx_meta_fifo.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/wrappers/tx_meta_fifo.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/wrappers/rx_fifo.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/wrappers/rx_fifo.vhd]]
@ -33,6 +34,7 @@ set_global_assignment -name QIP_FILE [file normalize [file join $nuand_ip pll_r
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip ps_sync/vhdl/ps_sync.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip ps_sync/vhdl/ps_sync.vhd]]
# Implementation Details # Implementation Details
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif_p.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/tx.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/tx.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/rx.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/rx.vhd]]

View file

@ -36,6 +36,7 @@ set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synth
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip rfic_spi_controller/vhdl/rfic_spi_controller.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip rfic_spi_controller/vhdl/rfic_spi_controller.vhd]]
# Implementation Details # Implementation Details
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif_p.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/tx.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/tx.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/rx.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/rx.vhd]]

View file

@ -33,6 +33,10 @@ if { [info exists platform_revision] == 0 } {
puts "platform revision: ${platform_revision}" puts "platform revision: ${platform_revision}"
} }
# RAM base address is equal to the RAM size
set ram_base_addr "0x[format %08x $ram_size]"
puts "RAM size: ${ram_size}, base address: ${ram_base_addr}"
# Instances and instance parameters # Instances and instance parameters
# (disabled instances are intentionally culled) # (disabled instances are intentionally culled)
add_instance axi_ad9361_0 axi_ad9361 1.0 add_instance axi_ad9361_0 axi_ad9361 1.0
@ -496,7 +500,7 @@ set_connection_parameter_value nios2.data_master/peripheral_spi.spi_control_port
add_connection nios2.data_master ram.s1 add_connection nios2.data_master ram.s1
set_connection_parameter_value nios2.data_master/ram.s1 arbitrationPriority {1} set_connection_parameter_value nios2.data_master/ram.s1 arbitrationPriority {1}
set_connection_parameter_value nios2.data_master/ram.s1 baseAddress {0x00020000} set_connection_parameter_value nios2.data_master/ram.s1 baseAddress ${ram_base_addr}
set_connection_parameter_value nios2.data_master/ram.s1 defaultConnection {0} set_connection_parameter_value nios2.data_master/ram.s1 defaultConnection {0}
add_connection nios2.data_master rffe_spi.spi_control_port add_connection nios2.data_master rffe_spi.spi_control_port
@ -556,7 +560,7 @@ set_connection_parameter_value nios2.instruction_master/nios2.debug_mem_slave de
add_connection nios2.instruction_master ram.s1 add_connection nios2.instruction_master ram.s1
set_connection_parameter_value nios2.instruction_master/ram.s1 arbitrationPriority {1} set_connection_parameter_value nios2.instruction_master/ram.s1 arbitrationPriority {1}
set_connection_parameter_value nios2.instruction_master/ram.s1 baseAddress {0x00020000} set_connection_parameter_value nios2.instruction_master/ram.s1 baseAddress ${ram_base_addr}
set_connection_parameter_value nios2.instruction_master/ram.s1 defaultConnection {0} set_connection_parameter_value nios2.instruction_master/ram.s1 defaultConnection {0}
add_connection nios2.irq command_uart.interrupt add_connection nios2.irq command_uart.interrupt

View file

@ -3,6 +3,7 @@ compile_nuand ../../../ip/nuand bladerf-micro
vcom -work nuand -2008 ../vhdl/tb/nios_system.vhd vcom -work nuand -2008 ../vhdl/tb/nios_system.vhd
vcom -work nuand -2008 ../../../platforms/common/bladerf/vhdl/fx3_gpif_p.vhd
vcom -work nuand -2008 ../../../platforms/common/bladerf/vhdl/fx3_gpif.vhd vcom -work nuand -2008 ../../../platforms/common/bladerf/vhdl/fx3_gpif.vhd
vcom -work nuand -2008 ../vhdl/bladerf_p.vhd vcom -work nuand -2008 ../vhdl/bladerf_p.vhd

View file

@ -0,0 +1,12 @@
source ../../../ip/nuand/nuand.do
vcom -work nuand -2008 ../vhdl/rx.vhd
vcom -work nuand -2008 ../vhdl/tx.vhd
vlib rtl_work
vcom -work rtl_work -2008 ../../../ip/altera/fx3_pll/fx3_pll.vhd
compile_nuand ../../../ip/nuand bladerf-micro
vcom -work nuand -2008 ../vhdl/tb/fx3_model_fifo_stress.vhd
vcom -work nuand -2008 ../vhdl/tb/fx3_gpif_iq_8bit_fifo_stress_tb.vhd

View file

@ -0,0 +1,13 @@
source ../../../ip/nuand/nuand.do
# vcom -work nuand -2008 ../vhdl/rx.vhd
# vcom -work nuand -2008 ../vhdl/tx.vhd
# vlib rtl_work
# vcom -work rtl_work -2008 ../../../ip/altera/fx3_pll/fx3_pll.vhd
# compile_nuand ../../../ip/nuand bladerf-micro
vcom -work nuand -2008 ../../../ip/nuand/simulation/fx3_model.vhd
vcom -work nuand -2008 ../vhdl/tb/fx3_model.vhd
vcom -work nuand -2008 ../vhdl/tb/fx3_gpif_iq_packed_tb.vhd

View file

@ -0,0 +1,12 @@
source ../../../ip/nuand/nuand.do
vcom -work nuand -2008 ../vhdl/rx.vhd
vcom -work nuand -2008 ../vhdl/tx.vhd
vlib rtl_work
vcom -work rtl_work -2008 ../../../ip/altera/fx3_pll/fx3_pll.vhd
compile_nuand ../../../ip/nuand bladerf-micro
vcom -work nuand -2008 ../vhdl/tb/fx3_model.vhd
vcom -work nuand -2008 ../vhdl/tb/rx_counter_8bit_tb.vhd

View file

@ -0,0 +1,12 @@
source ../../../ip/nuand/nuand.do
vcom -work nuand -2008 ../vhdl/rx.vhd
vcom -work nuand -2008 ../vhdl/tx.vhd
vlib rtl_work
vcom -work rtl_work -2008 ../../../ip/altera/fx3_pll/fx3_pll.vhd
compile_nuand ../../../ip/nuand bladerf-micro
vcom -work nuand -2008 ../vhdl/tb/fx3_model.vhd
vcom -work nuand -2008 ../vhdl/tb/rx_timestamp_tb.vhd

View file

@ -0,0 +1,82 @@
################################################################################
# This file is part of the bladeRF project:
# http://www.github.com/nuand/bladeRF
# Copyright (C) 2023 Nuand LLC
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
################################################################################
################################################################################
# Runs testbench simulations or executes "do" files.
# Exit Status: The script exits with the status code indicating success (0) or failure (1).
################################################################################
set status 0
if {$argc == 0 || $1 == "-h" || $1 == "--help"} {
# If "-h" is passed, print the usage information and exit
puts "Usage: do test.do vsim <testbench_name> \[testbench parameters\] <time_in_microseconds>"
puts " do test.do do <file_name> \[additional_parameters\]"
puts ""
puts "Arguments:"
puts " vsim: Run a testbench simulation."
puts " do: Execute a 'do' file with parameters."
puts " -h: Print this help message."
return
}
set params ""
for {set i 2} {$i <= 9} {incr i} {
if {[info exists $i]} {
append params [eval set $i]
append params " "
}
}
if { $1 == "vsim" } {
set testbench [lindex $params 0]
set tb_args [lrange $params 1 end-1]
set time_us [lindex $params end]
set assertion_log log.txt
vsim $testbench -assertfile $assertion_log {*}$tb_args; run ${time_us}us;
set f [open $assertion_log]
set file_content [read $f]
close $f
if {[catch {exec grep -c Failure << $file_content} result]} {
set fail_count 0
} else {
set fail_count $result
}
echo "fail_count:" $fail_count
if { $fail_count > 0 } {
set status 1
echo "\nSee log.txt for failure\n"
} else {
exec rm $assertion_log
}
} else {
onerror {set status 1}
set do_file $1
do $do_file {*}$params
}
quit -code $status

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,226 @@
onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate -color Pink /rx_timestamp_tb/U_rx/U_fifo_writer/eight_bit_mode_en
add wave -noupdate /rx_timestamp_tb/U_fx3_gpif/pclk
add wave -noupdate /rx_timestamp_tb/U_fx3_gpif/gpif_out
add wave -noupdate /rx_timestamp_tb/U_fx3_gpif/gpif_oe
add wave -noupdate /rx_timestamp_tb/U_rx/U_fifo_writer/clock
add wave -noupdate -radix decimal /rx_timestamp_tb/U_rx/U_fifo_writer/timestamp
add wave -noupdate -expand -subitemconfig {/rx_timestamp_tb/U_rx/U_fifo_writer/meta_current.dma_downcount {-color {Cornflower Blue} -height 17} /rx_timestamp_tb/U_rx/U_fifo_writer/meta_current.meta_write {-color Salmon -height 17}} /rx_timestamp_tb/U_rx/U_fifo_writer/meta_current
add wave -noupdate -expand -subitemconfig {/rx_timestamp_tb/U_rx/U_fifo_writer/fifo_current.fifo_write {-color {Steel Blue} -height 17} /rx_timestamp_tb/U_rx/U_fifo_writer/fifo_current.samples_left {-color Gold} /rx_timestamp_tb/U_rx/U_fifo_writer/fifo_current.eight_bit_delay {-color Gold -height 17}} /rx_timestamp_tb/U_rx/U_fifo_writer/fifo_current
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/pclk
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/reset
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/usb_speed
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/gpif_in
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/ctl_in
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/meta_enable
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/packet_enable
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_fifo_full
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_fifo_empty
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_fifo_usedw
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_timestamp
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_meta_fifo_full
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_meta_fifo_empty
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_meta_fifo_usedw
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_fifo_full
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_fifo_empty
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_fifo_usedw
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_fifo_data
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_meta_fifo_full
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_meta_fifo_empty
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_meta_fifo_usedr
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_meta_fifo_data
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/current
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/future
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/can_rx
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/should_rx
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/can_tx
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/should_tx
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_fifo_enough
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_fifo_enough
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_fifo_critical
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/underrun
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/dma_req
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/gpif_buf_size
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/dma3_tx_reqx
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/dma2_tx_reqx
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/dma1_rx_reqx
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/dma0_rx_reqx
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/dma_idle
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/dma_tx_enable
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/dma_rx_enable
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/dma3_tx_ack
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/dma2_tx_ack
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/dma1_rx_ack
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/dma0_rx_ack
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/gpif_out
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/gpif_oe
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/ctl_out
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/ctl_oe
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_enable
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_enable
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_fifo_write
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_fifo_data
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_meta_fifo_write
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_meta_fifo_data
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_fifo_read
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_meta_fifo_read
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/pclk
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/reset
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/usb_speed
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/gpif_in
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/ctl_in
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/meta_enable
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/packet_enable
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_fifo_full
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_fifo_empty
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_fifo_usedw
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_timestamp
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_meta_fifo_full
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_meta_fifo_empty
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_meta_fifo_usedw
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_fifo_full
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_fifo_empty
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_fifo_usedw
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_fifo_data
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_meta_fifo_full
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_meta_fifo_empty
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_meta_fifo_usedr
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_meta_fifo_data
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/current
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/future
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/can_rx
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/should_rx
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/can_tx
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/should_tx
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_fifo_enough
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_fifo_enough
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_fifo_critical
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/underrun
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/dma_req
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/gpif_buf_size
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/dma3_tx_reqx
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/dma2_tx_reqx
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/dma1_rx_reqx
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/dma0_rx_reqx
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/dma_idle
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/dma_tx_enable
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/dma_rx_enable
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/dma3_tx_ack
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/dma2_tx_ack
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/dma1_rx_ack
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/dma0_rx_ack
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/gpif_out
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/gpif_oe
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/ctl_out
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/ctl_oe
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_enable
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_enable
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_fifo_write
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_fifo_data
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_meta_fifo_write
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/tx_meta_fifo_data
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_fifo_read
add wave -noupdate -group fx3_gpif /rx_timestamp_tb/U_fx3_gpif/rx_meta_fifo_read
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/clock
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/NUM_STREAMS
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/FIFO_USEDW_WIDTH
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/FIFO_DATA_WIDTH
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/META_FIFO_USEDW_WIDTH
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/META_FIFO_DATA_WIDTH
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/reset
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/enable
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/usb_speed
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/meta_en
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/packet_en
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/eight_bit_mode_en
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/timestamp
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/mini_exp
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/in_sample_controls
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/in_samples
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/fifo_usedw
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/fifo_full
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/packet_control
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/meta_fifo_full
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/meta_fifo_usedw
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/overflow_duration
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/dma_buf_size
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/fifo_enough
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/overflow_detected
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/meta_current
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/meta_future
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/fifo_current
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/fifo_future
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/sync_mini_exp
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/DMA_BUF_SIZE_SS
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/DMA_BUF_SIZE_HS
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/META_FSM_RESET_VALUE
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/FIFO_FSM_RESET_VALUE
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/fifo_clear
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/fifo_write
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/fifo_data
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/packet_ready
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/meta_fifo_data
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/meta_fifo_write
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/overflow_led
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/overflow_count
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/clock
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/NUM_STREAMS
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/FIFO_USEDW_WIDTH
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/FIFO_DATA_WIDTH
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/META_FIFO_USEDW_WIDTH
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/META_FIFO_DATA_WIDTH
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/reset
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/enable
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/usb_speed
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/meta_en
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/packet_en
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/eight_bit_mode_en
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/timestamp
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/mini_exp
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/in_sample_controls
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/in_samples
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/fifo_usedw
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/fifo_full
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/packet_control
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/meta_fifo_full
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/meta_fifo_usedw
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/overflow_duration
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/dma_buf_size
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/fifo_enough
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/overflow_detected
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/meta_current
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/meta_future
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/fifo_current
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/fifo_future
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/sync_mini_exp
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/DMA_BUF_SIZE_SS
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/DMA_BUF_SIZE_HS
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/META_FSM_RESET_VALUE
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/FIFO_FSM_RESET_VALUE
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/fifo_clear
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/fifo_write
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/fifo_data
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/packet_ready
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/meta_fifo_data
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/meta_fifo_write
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/overflow_led
add wave -noupdate -expand -group fifo_writer /rx_timestamp_tb/U_rx/U_fifo_writer/overflow_count
TreeUpdate [SetDefaultTree]
WaveRestoreCursors {{Cursor 11} {42111448 ps} 1} {{Cursor 2} {42555896 ps} 1} {{Meta_wr expected} {267335472 ps} 1} {{Cursor 4} {492979686 ps} 0}
quietly wave cursor active 4
configure wave -namecolwidth 165
configure wave -valuecolwidth 106
configure wave -justifyvalue left
configure wave -signalnamewidth 1
configure wave -snapdistance 10
configure wave -datasetprefix 0
configure wave -rowmargin 4
configure wave -childrowmargin 2
configure wave -gridoffset 0
configure wave -gridperiod 1
configure wave -griddelta 40
configure wave -timeline 0
configure wave -timelineunits us
update
WaveRestoreZoom {492180935 ps} {508008039 ps}

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -36,7 +36,9 @@ LIBAD936X_DIR := ../../../../fpga/ip/analogdevicesinc/no_OS
INC_DIRS += $(LIBAD936X_BUILDDIR) \ INC_DIRS += $(LIBAD936X_BUILDDIR) \
../$(LIBAD936X_DIR)/include \ ../$(LIBAD936X_DIR)/include \
../../../../../../host/common/include ../../../../../../host/common/include \
../../../../../../host/build/common/thirdparty/ad936x/ \
../../../../../../thirdparty/analogdevicesinc/no-OS_local/platform_bladerf2/
LIB_DIRS += $(LIBAD936X_BUILDDIR) LIB_DIRS += $(LIBAD936X_BUILDDIR)
LDDEPS += $(LIBAD936X_BUILDDIR)/libad936x.a LDDEPS += $(LIBAD936X_BUILDDIR)/libad936x.a
@ -80,3 +82,6 @@ $(LIBAD936X_BUILDDIR)/Makefile: $(LIBAD936X_MAKE_DEP)
$(LIBAD936X_BUILDDIR)/libad936x.a: $(LIBAD936X_BUILD_DEP) $(LIBAD936X_BUILDDIR)/libad936x.a: $(LIBAD936X_BUILD_DEP)
@$(ECHO) Info: Building libad936x @$(ECHO) Info: Building libad936x
@$(MAKE) --no-print-directory -C $(LIBAD936X_BUILDDIR) ad936x @$(MAKE) --no-print-directory -C $(LIBAD936X_BUILDDIR) ad936x
# Ensure libad936x is built before the application objects that depend on its headers
$(APP_OBJS): $(LIBAD936X_BUILDDIR)/libad936x.a

View file

@ -7,7 +7,7 @@
#define FPGA_VERSION_ID 0x7777 #define FPGA_VERSION_ID 0x7777
#define FPGA_VERSION_MAJOR 0 #define FPGA_VERSION_MAJOR 0
#define FPGA_VERSION_MINOR 15 #define FPGA_VERSION_MINOR 16
#define FPGA_VERSION_PATCH 0 #define FPGA_VERSION_PATCH 0
#define FPGA_VERSION ((uint32_t)( FPGA_VERSION_MAJOR | \ #define FPGA_VERSION ((uint32_t)( FPGA_VERSION_MAJOR | \
(FPGA_VERSION_MINOR << 8) | \ (FPGA_VERSION_MINOR << 8) | \

View file

@ -38,7 +38,8 @@ LIBAD936X_DIR := ../../../../fpga/ip/analogdevicesinc/no_OS
INC_DIRS += $(LIBAD936X_BUILDDIR) \ INC_DIRS += $(LIBAD936X_BUILDDIR) \
../$(LIBAD936X_DIR)/include \ ../$(LIBAD936X_DIR)/include \
../../../../../../host/common/include ../../../../../../host/common/include \
../../../../../../thirdparty/analogdevicesinc/no-OS_local/platform_bladerf2/
LIB_DIRS += $(LIBAD936X_BUILDDIR) LIB_DIRS += $(LIBAD936X_BUILDDIR)
LDDEPS += $(LIBAD936X_BUILDDIR)/libad936x.a LDDEPS += $(LIBAD936X_BUILDDIR)/libad936x.a

View file

@ -252,6 +252,13 @@ architecture foxhunt_bladerf of bladerf is
); );
end component; end component;
signal tx_packet_control : packet_control_t ;
signal rx_packet_control : packet_control_t := PACKET_CONTROL_DEFAULT ;
signal rx_packet_ready : std_logic;
signal tx_packet_ready : std_logic;
signal tx_packet_empty : std_logic;
begin begin
-- ======================================================================== -- ========================================================================
@ -333,6 +340,7 @@ begin
usb_speed => usb_speed_pclk, usb_speed => usb_speed_pclk,
meta_enable => meta_en_pclk, meta_enable => meta_en_pclk,
packet_enable => '0',
rx_enable => rx_enable_pclk, rx_enable => rx_enable_pclk,
tx_enable => tx_enable_pclk, tx_enable => tx_enable_pclk,
@ -610,6 +618,15 @@ begin
trigger_master => tx_trigger_ctl.master, trigger_master => tx_trigger_ctl.master,
trigger_line => tx_trigger_line, trigger_line => tx_trigger_line,
-- Eightbit mode
eight_bit_mode_en => '0',
-- Packet FIFO
packet_en => '0',
packet_empty => tx_packet_empty,
packet_control => tx_packet_control,
packet_ready => tx_packet_ready,
-- Samples from host via FX3 -- Samples from host via FX3
sample_fifo_wclock => fx3_pclk_pll, sample_fifo_wclock => fx3_pclk_pll,
sample_fifo_wreq => '0', sample_fifo_wreq => '0',
@ -680,6 +697,14 @@ begin
trigger_master => rx_trigger_ctl.master, trigger_master => rx_trigger_ctl.master,
trigger_line => rx_trigger_line, trigger_line => rx_trigger_line,
-- Eightbit mode
eight_bit_mode_en => '0',
-- Packet FIFO
packet_en => '0',
packet_control => rx_packet_control,
packet_ready => rx_packet_ready,
-- Samples to host via FX3 -- Samples to host via FX3
sample_fifo_rclock => fx3_pclk_pll, sample_fifo_rclock => fx3_pclk_pll,
sample_fifo_raclr => '1', sample_fifo_raclr => '1',

View file

@ -39,10 +39,12 @@ architecture hosted_bladerf of bladerf is
signal sys_reset : std_logic; signal sys_reset : std_logic;
signal sys_clock : std_logic; signal sys_clock : std_logic;
signal sys_clock_out : std_logic;
signal sys_pll_locked : std_logic; signal sys_pll_locked : std_logic;
signal sys_pll_reset : std_logic; signal sys_pll_reset : std_logic;
signal fx3_pclk_pll : std_logic; signal fx3_pclk_pll : std_logic;
signal fx3_pclk_pll_out : std_logic;
signal fx3_pclk_pll_locked : std_logic; signal fx3_pclk_pll_locked : std_logic;
signal fx3_pclk_pll_reset : std_logic; signal fx3_pclk_pll_reset : std_logic;
@ -91,6 +93,8 @@ architecture hosted_bladerf of bladerf is
signal eightbit_en_tx : std_logic; signal eightbit_en_tx : std_logic;
signal eightbit_en_rx : std_logic; signal eightbit_en_rx : std_logic;
signal highly_packed_en_txrx : std_logic;
signal packet_en_pclk : std_logic; signal packet_en_pclk : std_logic;
signal packet_en_tx : std_logic; signal packet_en_tx : std_logic;
signal packet_en_rx : std_logic; signal packet_en_rx : std_logic;
@ -202,10 +206,17 @@ begin
port map ( port map (
refclk => c5_clock2, refclk => c5_clock2,
rst => sys_pll_reset, rst => sys_pll_reset,
outclk_0 => sys_clock, outclk_0 => sys_clock_out,
locked => sys_pll_locked locked => sys_pll_locked
); );
U_system_pll_ctrl : component clk_ctrl
port map (
inclk => sys_clock_out,
ena => sys_pll_locked,
outclk => sys_clock
);
U_pll_reset_pll : entity work.pll_reset U_pll_reset_pll : entity work.pll_reset
generic map ( generic map (
SYS_CLOCK_FREQ_HZ => 38_400_000, SYS_CLOCK_FREQ_HZ => 38_400_000,
@ -223,10 +234,17 @@ begin
port map ( port map (
refclk => fx3_pclk, refclk => fx3_pclk,
rst => fx3_pclk_pll_reset, rst => fx3_pclk_pll_reset,
outclk_0 => fx3_pclk_pll, outclk_0 => fx3_pclk_pll_out,
locked => fx3_pclk_pll_locked locked => fx3_pclk_pll_locked
); );
U_fx3_pll_ctrl : component clk_ctrl
port map (
inclk => fx3_pclk_pll_out,
ena => fx3_pclk_pll_locked,
outclk => fx3_pclk_pll
);
U_pll_reset_fx3_pll : entity work.pll_reset U_pll_reset_fx3_pll : entity work.pll_reset
generic map ( generic map (
SYS_CLOCK_FREQ_HZ => 100_000_000, SYS_CLOCK_FREQ_HZ => 100_000_000,
@ -551,6 +569,7 @@ begin
-- Eightbit mode -- Eightbit mode
eight_bit_mode_en => eightbit_en_tx, eight_bit_mode_en => eightbit_en_tx,
highly_packed_mode_en => highly_packed_en_txrx,
-- Packet FIFO -- Packet FIFO
packet_en => packet_en_tx, packet_en => packet_en_tx,
@ -625,8 +644,9 @@ begin
trigger_master => rx_trigger_ctl.master, trigger_master => rx_trigger_ctl.master,
trigger_line => rx_trigger_line, trigger_line => rx_trigger_line,
-- Eightbit mode -- Packed modes
eight_bit_mode_en => eightbit_en_rx, eight_bit_mode_en => eightbit_en_rx,
highly_packed_mode_en => highly_packed_en_txrx,
-- Packet FIFO -- Packet FIFO
packet_en => packet_en_rx, packet_en => packet_en_rx,
@ -843,6 +863,17 @@ begin
sync => eightbit_en_tx sync => eightbit_en_tx
); );
U_sync_highly_packed_en_txrx : entity work.synchronizer
generic map (
RESET_LEVEL => '0'
)
port map (
reset => '0',
clock => ad9361.clock,
async => nios_gpio.o.highly_packed_en,
sync => highly_packed_en_txrx
);
U_sync_packet_en_pclk : entity work.synchronizer U_sync_packet_en_pclk : entity work.synchronizer
generic map ( generic map (
RESET_LEVEL => '0' RESET_LEVEL => '0'

View file

@ -50,6 +50,14 @@ package bladerf_p is
); );
end component; end component;
component clk_ctrl
port (
inclk :in std_logic;
ena :in std_logic;
outclk :out std_logic
);
end component;
component nios_system is component nios_system is
port ( port (
clk_clk : in std_logic := 'X'; clk_clk : in std_logic := 'X';
@ -160,11 +168,11 @@ package bladerf_p is
constant TX_FIFO_WWIDTH : natural := 32; -- write side data width constant TX_FIFO_WWIDTH : natural := 32; -- write side data width
constant TX_FIFO_RWIDTH : natural := 64; -- read side data width constant TX_FIFO_RWIDTH : natural := 64; -- read side data width
constant TX_FIFO_LENGTH : natural := 16384; -- samples constant TX_FIFO_LENGTH : natural := 8192; -- samples
constant RX_FIFO_WWIDTH : natural := 64; -- write side data width constant RX_FIFO_WWIDTH : natural := 64; -- write side data width
constant RX_FIFO_RWIDTH : natural := 32; -- read side data width constant RX_FIFO_RWIDTH : natural := 32; -- read side data width
constant RX_FIFO_LENGTH : natural := 4096; -- samples constant RX_FIFO_LENGTH : natural := 8192; -- samples
constant ADSB_FIFO_WWIDTH : natural := 128; -- write side data width constant ADSB_FIFO_WWIDTH : natural := 128; -- write side data width
constant ADSB_FIFO_RWIDTH : natural := 32; -- read side data width constant ADSB_FIFO_RWIDTH : natural := 32; -- read side data width
@ -176,11 +184,11 @@ package bladerf_p is
constant META_FIFO_TX_WWIDTH : natural := 32; -- write side data width constant META_FIFO_TX_WWIDTH : natural := 32; -- write side data width
constant META_FIFO_TX_RWIDTH : natural := 128; -- read side data width constant META_FIFO_TX_RWIDTH : natural := 128; -- read side data width
constant META_FIFO_TX_LENGTH : natural := 512; -- 32-bit words constant META_FIFO_TX_LENGTH : natural := 2048; -- 32-bit words
constant META_FIFO_RX_WWIDTH : natural := 128; -- write side data width constant META_FIFO_RX_WWIDTH : natural := 128; -- write side data width
constant META_FIFO_RX_RWIDTH : natural := 32; -- read side data width constant META_FIFO_RX_RWIDTH : natural := 32; -- read side data width
constant META_FIFO_RX_LENGTH : natural := 512; -- 32-bit words constant META_FIFO_RX_LENGTH : natural := 2048; -- 32-bit words
type tx_fifo_t is record type tx_fifo_t is record
aclr : std_logic; aclr : std_logic;
@ -299,6 +307,7 @@ package bladerf_p is
type nios_gpo_t is record type nios_gpo_t is record
xb_mode : std_logic_vector(1 downto 0); xb_mode : std_logic_vector(1 downto 0);
eightbit_en : std_logic; eightbit_en : std_logic;
highly_packed_en: std_logic;
packet_en : std_logic; packet_en : std_logic;
si_clock_sel : std_logic; si_clock_sel : std_logic;
ufl_clock_oe : std_logic; ufl_clock_oe : std_logic;
@ -510,6 +519,7 @@ package body bladerf_p is
variable rv : std_logic_vector(31 downto 0) := (others => 'U'); variable rv : std_logic_vector(31 downto 0) := (others => 'U');
begin begin
rv(31 downto 30) := x.xb_mode; rv(31 downto 30) := x.xb_mode;
rv(21) := x.highly_packed_en;
rv(20) := x.eightbit_en; rv(20) := x.eightbit_en;
rv(19) := x.packet_en; rv(19) := x.packet_en;
rv(18) := x.si_clock_sel; rv(18) := x.si_clock_sel;
@ -589,6 +599,7 @@ package body bladerf_p is
variable rv : nios_gpo_t; variable rv : nios_gpo_t;
begin begin
rv.xb_mode := x(31 downto 30); rv.xb_mode := x(31 downto 30);
rv.highly_packed_en:= x(21);
rv.eightbit_en := x(20); rv.eightbit_en := x(20);
rv.packet_en := x(19); rv.packet_en := x(19);
rv.si_clock_sel := x(18); rv.si_clock_sel := x(18);

View file

@ -51,6 +51,7 @@ entity rx is
-- 8-bit mode -- 8-bit mode
eight_bit_mode_en : in std_logic := '0'; eight_bit_mode_en : in std_logic := '0';
highly_packed_mode_en : in std_logic := '0';
-- Packet to host via FX3 -- Packet to host via FX3
packet_en : in std_logic; packet_en : in std_logic;
@ -251,6 +252,7 @@ begin
packet_ready => packet_ready, packet_ready => packet_ready,
eight_bit_mode_en => eight_bit_mode_en, eight_bit_mode_en => eight_bit_mode_en,
highly_packed_mode_en => highly_packed_mode_en,
meta_fifo_full => meta_fifo.wfull, meta_fifo_full => meta_fifo.wfull,
meta_fifo_usedw => meta_fifo.wused, meta_fifo_usedw => meta_fifo.wused,
@ -353,6 +355,7 @@ begin
enable => rx_enable, enable => rx_enable,
mode => rx_gen_mode, mode => rx_gen_mode,
eightbit_en => eight_bit_mode_en,
sample_i => rx_gen_i, sample_i => rx_gen_i,
sample_q => rx_gen_q, sample_q => rx_gen_q,

View file

@ -0,0 +1,840 @@
-- Copyright (c) 2024 Nuand LLC
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-- THE SOFTWARE.
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library rtl_work;
library altera_lnsim;
use altera_lnsim.altera_pll;
library nuand;
use nuand.util.all ;
use nuand.fifo_readwrite_p.all;
use nuand.common_dcfifo_p.all;
use nuand.bladerf_p.all;
entity fx3_gpif_iq_8bit_fifo_stress is
generic (
-- For bladeRF2 (2x2 MIMO):
NUM_MIMO_STREAMS : natural := 2;
FIFO_READER_READ_THROTTLE : natural := 0;
ENABLE_CHANNEL_0 : std_logic := '1';
ENABLE_CHANNEL_1 : std_logic := '0';
EIGHT_BIT_MODE_EN : std_logic := '1'
);
end entity;
architecture arch of fx3_gpif_iq_8bit_fifo_stress is
-- bladerf-hosted uses ad9361.clock (125 MHz) for rx_clock and tx_clock
constant SYSCLK_HALF_PERIOD : time := 1 sec * (1.0/125.0e6/2.0);
-- For reasons unknown, simulation of this system in ModelSim requires that
-- wrreq and data be asserted shortly before the rising clock edge. Sigh...
constant FIFO_WORKAROUND : time := 1 ps;
type fx3_control_t is record
usb_speed : std_logic;
tx_enable : std_logic;
rx_enable : std_logic;
meta_enable : std_logic;
packet : std_logic;
end record;
type fx3_gpif_t is record
gpif_in : std_logic_vector(31 downto 0);
gpif_out : std_logic_vector(31 downto 0);
gpif_oe : std_logic;
ctl_in : std_logic_vector(12 downto 0);
ctl_out : std_logic_vector(12 downto 0);
ctl_oe : std_logic_vector(12 downto 0);
end record;
signal sys_rst : std_logic := '1';
signal done : boolean := false;
signal fx3_pclk : std_logic := '1';
signal fx3_pclk_pll : std_logic := '1';
signal sys_clk : std_logic := '1';
signal pll_reset : std_logic := '0';
signal pll_locked : std_logic := '0';
signal fx3_control : fx3_control_t;
signal fx3_gpif : fx3_gpif_t;
signal fx3_gpif_i : std_logic_vector(31 downto 0);
signal fx3_ctl_i : std_logic_vector(12 downto 0);
-- Control mapping
alias dma0_rx_ack is fx3_ctl_i( 0);
alias dma1_rx_ack is fx3_ctl_i( 1);
alias dma2_tx_ack is fx3_ctl_i( 2);
alias dma3_tx_ack is fx3_ctl_i( 3);
alias dma_rx_enable is fx3_ctl_i( 4);
alias dma_tx_enable is fx3_ctl_i( 5);
alias dma_idle is fx3_ctl_i( 6);
alias system_reset is fx3_ctl_i( 7);
alias dma0_rx_reqx is fx3_ctl_i( 8);
alias dma1_rx_reqx is fx3_ctl_i(12); -- due to 9 being connected to dclk
alias dma2_tx_reqx is fx3_ctl_i(10);
alias dma3_tx_reqx is fx3_ctl_i(11);
signal loopback_i : signed(15 downto 0) := (others =>'0');
signal loopback_q : signed(15 downto 0) := (others =>'0');
signal loopback_valid : std_logic := '0';
signal loopback_enabled : std_logic := '0';
signal tx_clock : std_logic := '1' ;
signal rx_clock : std_logic := '1' ;
signal rx_sample_fifo : rx_fifo_t := RX_FIFO_T_DEFAULT;
signal tx_sample_fifo : tx_fifo_t := TX_FIFO_T_DEFAULT;
signal loopback_fifo : loopback_fifo_t := LOOPBACK_FIFO_T_DEFAULT;
signal rx_meta_fifo : meta_fifo_rx_t := META_FIFO_RX_T_DEFAULT;
signal tx_meta_fifo : meta_fifo_tx_t := META_FIFO_TX_T_DEFAULT;
signal rx_mux_i : signed(15 downto 0);
signal rx_mux_q : signed(15 downto 0);
signal rx_mux_valid : std_logic;
signal tx_timestamp : unsigned(63 downto 0) := ( others => '0' );
signal rx_timestamp : unsigned(63 downto 0) := ( others => '0' );
constant FX3_HALF_PERIOD : time := 1.0/(100.0e6)/2.0*1 sec ;
constant TX_HALF_PERIOD : time := 1.0/(9.0e6)/2.0*1 sec ;
constant RX_HALF_PERIOD : time := 1.0/(9.0e6)/2.0*1 sec ;
signal dac_controls : sample_controls_t(0 to NUM_MIMO_STREAMS-1) := (others => SAMPLE_CONTROL_DISABLE);
signal dac_streams : sample_streams_t(dac_controls'range) := (others => ZERO_SAMPLE);
signal adc_controls : sample_controls_t(0 to NUM_MIMO_STREAMS-1) := (others => SAMPLE_CONTROL_DISABLE);
signal adc_streams : sample_streams_t(adc_controls'range) := (others => ZERO_SAMPLE);
signal tx_reset : std_logic := '0';
signal tx_ts_reset : std_logic := '0';
signal rx_reset : std_logic := '0';
signal rx_ts_reset : std_logic := '0';
signal meta_en_tx : std_logic := '0';
signal meta_en_rx : std_logic := '0';
signal rx_packet_control : packet_control_t := PACKET_CONTROL_DEFAULT;
signal tx_packet_control : packet_control_t;
signal trigger_signal_sync_tb : std_logic;
signal adc_stream_val_at_rx_enable : signed(15 downto 0) := ( others => '0' );
function data_gen (count : natural) return std_logic_vector is
variable msw, lsw : std_logic_vector(15 downto 0);
begin
msw := std_logic_vector(to_signed(count, 16));
lsw := std_logic_vector(to_signed(-count, 16));
return (msw & lsw);
end function data_gen;
signal rx_packet_ready : std_logic;
begin
-- ========================================================================
-- Brief summary of data flow
-- ========================================================================
--
-- Simulated samples flow from fx3_model's TX side to its RX side. The
-- validity of the data is checked there.
--
-- entity U_fx3_model FX3 model, TX process
-- signal fx3_gpif_i fx3_gpif.gpif_oe is '0'
-- process register_gpif
-- signal fx3_gpif.gpif_in Demuxed GPIF interface (FX3 -> FPGA)
-- entity U_fx3_gpif GPIF implementation, write side
-- signal tx_sample_fifo.w* TX fifo, write side
-- entity U_tx_sample_fifo
-- signal tx_sample_fifo.r* TX fifo, read side
-- process tx_mux
-- signal loopback_fifo.w* Loopback fifo, write side
-- entity U_rx_loopback_fifo
-- signal loopback_fifo.r* Loopback fifo, read side
-- process loopback_fifo_control
-- signal loopback_{i,q,valid}
-- process rx_mux
-- signal rx_mux_{i,q,valid}
-- entity U_fifo_writer
-- signal rx_sample_fifo.w* RX fifo, write side
-- entity U_rx_sample_fifo
-- signal rx_sample_fifo.r* RX fifo, read side
-- entity U_fx3_gpif GPIF implementation, read side
-- signal fx3_gpif.gpif_out Demuxed GPIF interface (FPGA -> FX3)
-- process register_gpif
-- signal fx3_gpif_i fx3_gpif.gpif_oe is '1'
-- entity U_fx3_model FX3 model, RX process
-- ========================================================================
-- Instantiations
-- ========================================================================
-- Unit under test
-- Clock domain: fx3_pclk_pll
U_fx3_gpif : entity nuand.fx3_gpif
port map (
pclk => fx3_pclk_pll,
reset => sys_rst,
usb_speed => fx3_control.usb_speed,
gpif_in => fx3_gpif.gpif_in,
gpif_out => fx3_gpif.gpif_out,
gpif_oe => fx3_gpif.gpif_oe,
ctl_in => fx3_gpif.ctl_in,
ctl_out => fx3_gpif.ctl_out,
ctl_oe => fx3_gpif.ctl_oe,
tx_enable => fx3_control.tx_enable,
rx_enable => fx3_control.rx_enable,
meta_enable => fx3_control.meta_enable,
packet_enable => fx3_control.packet,
tx_fifo_write => tx_sample_fifo.wreq,
tx_fifo_full => tx_sample_fifo.wfull,
tx_fifo_empty => tx_sample_fifo.wempty,
tx_fifo_usedw => tx_sample_fifo.wused,
tx_fifo_data => tx_sample_fifo.wdata,
tx_timestamp => tx_timestamp,
tx_meta_fifo_write => tx_meta_fifo.wreq,
tx_meta_fifo_full => tx_meta_fifo.wfull,
tx_meta_fifo_empty => tx_meta_fifo.wempty,
tx_meta_fifo_usedw => tx_meta_fifo.wused,
tx_meta_fifo_data => tx_meta_fifo.wdata,
rx_fifo_read => rx_sample_fifo.rreq,
rx_fifo_full => rx_sample_fifo.rfull,
rx_fifo_empty => rx_sample_fifo.rempty,
rx_fifo_usedw => rx_sample_fifo.rused,
rx_fifo_data => rx_sample_fifo.rdata,
rx_meta_fifo_read => rx_meta_fifo.rreq,
rx_meta_fifo_full => rx_meta_fifo.rfull,
rx_meta_fifo_empty => rx_meta_fifo.rempty,
rx_meta_fifo_usedr => rx_meta_fifo.rused,
rx_meta_fifo_data => rx_meta_fifo.rdata
);
-- Discrete control signals for fx3_gpif
fx3_control.usb_speed <= '0';
fx3_control.meta_enable <= '0';
fx3_control.packet <= '0';
U_pkt_gen : entity nuand.rx_packet_generator
port map(
rx_clock => rx_clock,
rx_reset => rx_reset,
rx_enable => fx3_control.rx_enable,
rx_packet_enable => fx3_control.packet,
rx_packet_ready => rx_packet_ready,
rx_packet_control => rx_packet_control
);
meta_en_tx <= fx3_control.meta_enable;
meta_en_rx <= fx3_control.meta_enable;
increment_tx_ts : process(tx_clock)
variable ping : boolean := true ;
begin
if( rising_edge(tx_clock) ) then
ping := not ping ;
if( ping = true ) then
tx_timestamp <= tx_timestamp + 1 ;
end if ;
end if ;
end process ;
increment_rx_ts : process(rx_clock)
variable ping : boolean := true ;
begin
if( rising_edge(rx_clock) ) then
ping := not ping ;
if( ping = true ) then
rx_timestamp <= rx_timestamp + 1 ;
end if ;
end if ;
end process ;
-- Model of FX3's GPIF interface
-- Clock domain: fx3_pclk (source)
U_fx3_model : entity nuand.fx3_model(micro_dma_fifo_stress)
port map (
fx3_pclk => fx3_pclk,
fx3_gpif => fx3_gpif_i,
fx3_ctl => fx3_ctl_i,
fx3_uart_rxd => '0',
fx3_uart_txd => open,
fx3_uart_cts => open,
fx3_rx_en => '1',
fx3_rx_meta_en => meta_en_rx,
fx3_tx_en => '1',
fx3_tx_meta_en => meta_en_tx,
eight_bit_mode_en => EIGHT_BIT_MODE_EN,
done => done
);
-- Generate phase-shifted PLL clock
U_fx3_pll : entity rtl_work.fx3_pll
port map (
inclk0 => fx3_pclk,
areset => pll_reset,
c0 => fx3_pclk_pll,
locked => pll_locked
);
tx_clock <= not tx_clock after TX_HALF_PERIOD ;
rx_clock <= not rx_clock after RX_HALF_PERIOD ;
-- Reset handler
sys_rst <= '0' after 100 ns;
-- Generate system clock
sys_clk <= not sys_clk after SYSCLK_HALF_PERIOD when not done else '0';
tx_reset <= sys_rst;
tx_ts_reset <= sys_rst;
rx_reset <= sys_rst;
rx_ts_reset <= sys_rst;
meta_en_tx <= fx3_control.meta_enable;
meta_en_rx <= fx3_control.meta_enable;
-- TX Submodule
U_tx : entity work.tx
generic map (
NUM_STREAMS => dac_controls'length
)
port map (
tx_reset => tx_reset,
tx_clock => tx_clock,
tx_enable => fx3_control.tx_enable,
meta_en => meta_en_tx,
timestamp_reset => tx_ts_reset,
usb_speed => fx3_control.usb_speed,
tx_underflow_led => open,
tx_timestamp => tx_timestamp,
-- Triggering
trigger_arm => '0',
trigger_fire => '0',
trigger_master => '0',
trigger_line => open,
-- Packet FIFO
packet_en => fx3_control.packet,
packet_empty => open,
packet_control => tx_packet_control,
packet_ready => '1',
-- 8-bit mode
eight_bit_mode_en => EIGHT_BIT_MODE_EN,
-- Samples from host via FX3
sample_fifo_wclock => fx3_pclk_pll,
sample_fifo_wreq => tx_sample_fifo.wreq,
sample_fifo_wdata => tx_sample_fifo.wdata,
sample_fifo_wempty => tx_sample_fifo.wempty,
sample_fifo_wfull => tx_sample_fifo.wfull,
sample_fifo_wused => tx_sample_fifo.wused,
-- Metadata from host via FX3
meta_fifo_wclock => fx3_pclk_pll,
meta_fifo_wreq => tx_meta_fifo.wreq,
meta_fifo_wdata => tx_meta_fifo.wdata,
meta_fifo_wempty => tx_meta_fifo.wempty,
meta_fifo_wfull => tx_meta_fifo.wfull,
meta_fifo_wused => tx_meta_fifo.wused,
-- Digital Loopback Interface
loopback_enabled => '0',
loopback_fifo_wdata => loopback_fifo.wdata,
loopback_fifo_wreq => loopback_fifo.wreq,
loopback_fifo_wfull => loopback_fifo.wfull,
loopback_fifo_wused => loopback_fifo.wused,
-- RFFE Interface
dac_controls => dac_controls,
dac_streams => dac_streams
);
-- RX Submodule
U_rx : entity work.rx
generic map (
NUM_STREAMS => adc_controls'length
)
port map (
rx_reset => rx_reset,
rx_clock => rx_clock,
rx_enable => fx3_control.rx_enable,
meta_en => meta_en_rx,
timestamp_reset => rx_ts_reset,
usb_speed => fx3_control.usb_speed,
rx_mux_sel => to_unsigned(0, 3),
rx_overflow_led => open,
rx_timestamp => rx_timestamp,
-- Triggering
trigger_arm => '0',
trigger_fire => '0',
trigger_master => '0',
trigger_line => open,
trigger_signal_sync_tb => trigger_signal_sync_tb,
-- Packet FIFO
packet_en => fx3_control.packet,
packet_control => rx_packet_control,
packet_ready => rx_packet_ready,
-- 8-bit mode
eight_bit_mode_en => EIGHT_BIT_MODE_EN,
-- Samples to host via FX3
sample_fifo_rclock => fx3_pclk_pll,
sample_fifo_raclr => not fx3_control.rx_enable,
sample_fifo_rreq => rx_sample_fifo.rreq,
sample_fifo_rdata => rx_sample_fifo.rdata,
sample_fifo_rempty => rx_sample_fifo.rempty,
sample_fifo_rfull => rx_sample_fifo.rfull,
sample_fifo_rused => rx_sample_fifo.rused,
-- Mini expansion signals
mini_exp => "00",
-- Metadata to host via FX3
meta_fifo_rclock => fx3_pclk_pll,
meta_fifo_raclr => not fx3_control.rx_enable,
meta_fifo_rreq => rx_meta_fifo.rreq,
meta_fifo_rdata => rx_meta_fifo.rdata,
meta_fifo_rempty => rx_meta_fifo.rempty,
meta_fifo_rfull => rx_meta_fifo.rfull,
meta_fifo_rused => rx_meta_fifo.rused,
-- Digital Loopback Interface
loopback_fifo_wenabled => open,
loopback_fifo_wreset => tx_reset,
loopback_fifo_wclock => tx_clock,
loopback_fifo_wdata => loopback_fifo.wdata,
loopback_fifo_wreq => loopback_fifo.wreq,
loopback_fifo_wfull => loopback_fifo.wfull,
loopback_fifo_wused => loopback_fifo.wused,
-- RFFE Interface
adc_controls => adc_controls,
adc_streams => adc_streams
);
-- ========================================================================
-- Data converters
-- ========================================================================
gen_dac_controls : if( NUM_MIMO_STREAMS > 1 ) generate
-- The TX side of the AD9361 HDL is a FIFO pull interface
-- that expects a readahead FIFO. It toggles the data request
-- signal every other cycle. This behavior is mimicked here.
process( tx_clock, sys_rst )
begin
if( sys_rst = '1' ) then
dac_controls <= (
0 => (enable => ENABLE_CHANNEL_0, data_req => '1'),
1 => (enable => ENABLE_CHANNEL_1, data_req => '1')
);
elsif( rising_edge(tx_clock) ) then
for i in dac_controls'range loop
dac_controls(i) <= (
enable => dac_controls(i).enable,
data_req => not dac_controls(i).data_req );
end loop;
end if;
end process;
else generate
dac_controls <= (others => SAMPLE_CONTROL_ENABLE);
end generate;
gen_adc_controls : if( NUM_MIMO_STREAMS > 1 ) generate
process( rx_clock, sys_rst )
constant SIGMA_DELTA_BITS : signed (3 downto 0) := "0000";
constant COUNT_RESET : integer := 0;
variable count : integer range -2047 to 2047 := COUNT_RESET;
begin
if( sys_rst = '1' ) then
count := COUNT_RESET;
adc_controls <= (
0 => (enable => ENABLE_CHANNEL_0, data_req => '1'),
1 => (enable => ENABLE_CHANNEL_1, data_req => '1')
);
elsif( rising_edge(rx_clock) ) then
for i in adc_controls'range loop
adc_controls(i) <= (
enable => adc_controls(i).enable,
data_req => not adc_controls(i).data_req );
if( adc_controls(i).enable = '1') then
if( adc_streams(i).data_v = '1' ) then
if( EIGHT_BIT_MODE_EN = '1' ) then
adc_streams(i).data_i <= "0000" & to_signed(count, 8) & SIGMA_DELTA_BITS;
adc_streams(i).data_q <= "0000" & to_signed(-count, 8) & SIGMA_DELTA_BITS;
count := (count + 1) mod 128;
else
adc_streams(i).data_i <= to_signed(count, 16);
adc_streams(i).data_q <= to_signed(-count, 16);
count := (count + 1) mod 2048;
end if;
end if;
adc_streams(i).data_v <= not adc_streams(i).data_v;
end if;
end loop;
end if;
end process;
else generate
adc_controls <= (others => SAMPLE_CONTROL_ENABLE);
end generate;
-- ========================================================================
-- Processes
-- ========================================================================
-- FX3 GPIF bidirectional signal control
-- Adapted from same process in bladerf-hosted.vhd
register_gpif : process(sys_rst, fx3_pclk_pll)
begin
if( sys_rst = '1' ) then
fx3_gpif_i <= (others => 'Z');
fx3_gpif.gpif_in <= (others => 'Z');
elsif( rising_edge(fx3_pclk_pll) ) then
fx3_gpif.gpif_in <= fx3_gpif_i;
if( fx3_gpif.gpif_oe = '1' ) then
fx3_gpif_i <= fx3_gpif.gpif_out;
else
fx3_gpif_i <= (others =>'Z');
end if;
end if;
end process;
-- FX3 CTL bidirectional signals
-- Adapted from same generator in bladerf-hosted.vhd
generate_ctl : for i in fx3_ctl_i'range generate
fx3_ctl_i(i) <= fx3_gpif.ctl_out(i) when fx3_gpif.ctl_oe(i) = '1' else 'Z';
end generate;
fx3_gpif.ctl_in <= fx3_ctl_i;
-- Controller for loopback FIFO
-- Stripped-down version of same process from rx.vhd
loopback_fifo_control : process( sys_rst, loopback_fifo.rclock )
begin
if( sys_rst = '1' ) then
loopback_enabled <= '0';
loopback_fifo.rreq <= '0';
loopback_i <= (others => '0');
loopback_q <= (others => '0');
loopback_valid <= '0';
elsif( rising_edge(loopback_fifo.rclock) ) then
loopback_enabled <= '0';
loopback_fifo.rreq <= '0';
loopback_i <= loopback_i;
loopback_q <= loopback_q;
loopback_valid <= '0';
-- Is loopback enabled?
loopback_enabled <= fx3_control.rx_enable;
-- Do the loopback
loopback_i <= resize(signed(loopback_fifo.rdata(15 downto 0)), loopback_i'length);
loopback_q <= resize(signed(loopback_fifo.rdata(31 downto 16)), loopback_q'length);
loopback_valid <= loopback_fifo.rreq and not loopback_fifo.rempty;
-- Read from the FIFO if req'd
loopback_fifo.rreq <= loopback_enabled and (not loopback_fifo.rempty);
end if;
end process;
-- RX multiplexer
-- Stripped-down version of same process from rx.vhd
rx_mux : process(sys_rst, sys_clk)
begin
if( sys_rst = '1' ) then
rx_mux_i <= (others =>'0');
rx_mux_q <= (others =>'0');
rx_mux_valid <= '0';
elsif( rising_edge(sys_clk) ) then
rx_mux_i <= loopback_i;
rx_mux_q <= loopback_q;
rx_mux_valid <= loopback_valid;
end if;
end process;
-- TX multiplexer
-- Stripped-down version of mimo_channel_sel_mux from tx.vhd
--tx_mux : process( sys_clk )
--begin
-- if( rising_edge(sys_clk) ) then
-- tx_sample_fifo.rreq <= not tx_sample_fifo.rempty;
-- loopback_fifo.wdata <= tx_sample_fifo.rdata;
-- loopback_fifo.wreq <= tx_sample_fifo.rreq and not tx_sample_fifo.rempty;
-- end if;
--end process;
-- ========================================================================
-- Verification
-- ========================================================================
print_config: process
begin
wait until rising_edge(fx3_control.tx_enable);
report lf&
"[CONFIG] EIGHT_BIT_MODE_EN: " & std_logic'image(EIGHT_BIT_MODE_EN) &lf&
"[CONFIG] ENABLE_CHANNEL_0: " & std_logic'image(ENABLE_CHANNEL_0) &lf&
"[CONFIG] ENABLE_CHANNEL_1: " & std_logic'image(ENABLE_CHANNEL_1);
end process print_config;
--
-- Check for metavalues
-- We should never see metavalues written to the FIFOs
--
check_fifo_write : process(fx3_pclk_pll) is
begin
if( rising_edge(fx3_pclk_pll) ) then
if( tx_sample_fifo.wreq = '1' and fx3_control.meta_enable = '0' ) then
for i in tx_sample_fifo.wdata'range loop
assert tx_sample_fifo.wdata(i) = '0' or tx_sample_fifo.wdata(i) = '1'
severity failure;
end loop;
end if;
end if;
end process;
check_fifo_read : process(fx3_pclk_pll) is
begin
if( rising_edge(fx3_pclk_pll) ) then
if( rx_sample_fifo.rreq = '1' ) then
for i in rx_sample_fifo.rdata'range loop
assert rx_sample_fifo.rdata(i) = '0' or rx_sample_fifo.rdata(i) = '1'
severity failure;
end loop;
end if;
end if;
end process check_fifo_read;
--
-- Check for fullness on FIFOs
--
assert(rx_sample_fifo.wfull = '0') report "rx_sample_fifo full (write)" severity warning;
assert(tx_sample_fifo.wfull = '0') report "tx_sample_fifo full (write)" severity warning;
assert(loopback_fifo.wfull = '0') report "loopback_fifo full (write)" severity warning;
--
-- Tx Sample Check
--
look_for_dropped_tx_samples : process(tx_clock) is
constant MESSAGES_PER_ITERATION : natural := 7; --Provided in fx3_model
constant SIGMA_DELTA_BITS : signed (3 downto 0) := "0000";
variable current_message_count : natural := 1;
variable iq_value : signed (15 downto 0) := x"0000";
variable expected_sample_i : signed (15 downto 0);
variable expected_sample_q : signed (15 downto 0);
variable failure_count : natural := 0;
begin
for i in dac_controls'range loop
if( rising_edge(tx_clock)
and dac_controls(i).enable = '1'
and dac_streams(i).data_v = '1'
and fx3_control.tx_enable = '1' )
then
if( EIGHT_BIT_MODE_EN = '1' ) then
expected_sample_i := iq_value (11 downto 0) & SIGMA_DELTA_BITS;
expected_sample_q := iq_value (11 downto 0) + 1 & SIGMA_DELTA_BITS;
assert ( dac_streams(i).data_i = expected_sample_i )
report "dac_streams("&to_string(i)&").data_i: " & to_hstring(dac_streams(i).data_i) & " | " &
"expected_sample_i: " & to_hstring(expected_sample_i)
severity warning;
assert ( dac_streams(i).data_q = expected_sample_q )
report "dac_streams("&to_string(i)&").data_q: " & to_hstring(dac_streams(i).data_q) & " | " &
"expected_sample_q: " & to_hstring(expected_sample_q)
severity warning;
if ( dac_streams(i).data_i /= expected_sample_i or dac_streams(i).data_q /= expected_sample_q ) then
failure_count := failure_count + 1;
if ( failure_count >= 6 ) then
report "tx fail count tolerance exceeded" severity failure;
end if;
end if;
iq_value := (iq_value + 2) mod 128;
else
expected_sample_i := iq_value;
expected_sample_q := to_signed(current_message_count, 8) & (iq_value(7 downto 0) + 1);
assert(dac_streams(i).data_i = expected_sample_i)
report "dac_streams("&to_string(i)&").data_i: " & to_hstring(dac_streams(i).data_i) & " | " &
"expected_sample_i: " & to_hstring(expected_sample_i)
severity failure;
assert(dac_streams(i).data_q = expected_sample_q)
report "dac_streams("&to_string(i)&").data_q: " & to_hstring(dac_streams(i).data_q) & " | " &
"expected_sample_q: " & to_hstring(expected_sample_q)
severity failure;
-- Set iq values based on blocks received
-- See tx_sample_stream's encoding scheme in fx3_model.vhd
if( iq_value = x"03FE" ) then
iq_value := x"0000";
if( current_message_count < MESSAGES_PER_ITERATION ) then
current_message_count := current_message_count + 1;
else
current_message_count := 1;
end if;
else
iq_value := (iq_value + 2) mod 2048;
end if;
end if;
end if;
end loop;
end process look_for_dropped_tx_samples;
--
-- Rx Sample Check
--
first_rx_val_at_mux: process
-- Catches and saves the first sample of
-- each rx enabled burst seen by the mux
begin
for i in adc_controls'range loop
if( adc_controls(i).enable = '1') then
if( ENABLE_CHANNEL_0 = '1' and ENABLE_CHANNEL_1 = '1' ) then
adc_stream_val_at_rx_enable <= adc_streams(i).data_i - 1;
else
adc_stream_val_at_rx_enable <= adc_streams(i).data_i;
end if;
end if;
end loop;
wait until rising_edge(trigger_signal_sync_tb);
end process first_rx_val_at_mux;
look_for_dropped_rx_samples: process(fx3_pclk_pll)
variable rx_val : integer := 0;
variable q_expected : std_logic_vector (15 downto 0);
variable i_expected : std_logic_vector (15 downto 0);
variable q_out : std_logic_vector (15 downto 0);
variable i_out : std_logic_vector (15 downto 0);
variable q0_expected_eight_bit_mode : std_logic_vector (7 downto 0);
variable i0_expected_eight_bit_mode : std_logic_vector (7 downto 0);
variable q1_expected_eight_bit_mode : std_logic_vector (7 downto 0);
variable i1_expected_eight_bit_mode : std_logic_vector (7 downto 0);
variable q0_out_eight_bit_mode : std_logic_vector (7 downto 0);
variable i0_out_eight_bit_mode : std_logic_vector (7 downto 0);
variable q1_out_eight_bit_mode : std_logic_vector (7 downto 0);
variable i1_out_eight_bit_mode : std_logic_vector (7 downto 0);
variable previous_adc_stream_val_at_rx_enable : signed (15 downto 0) := ( others => '0');
variable fail_count: natural := 0;
variable both_channels_en : std_logic;
begin
if( previous_adc_stream_val_at_rx_enable /= adc_stream_val_at_rx_enable ) then
rx_val := to_integer(adc_stream_val_at_rx_enable (15 downto 4)) when EIGHT_BIT_MODE_EN else
to_integer(adc_stream_val_at_rx_enable);
previous_adc_stream_val_at_rx_enable := adc_stream_val_at_rx_enable;
end if;
if( rising_edge(fx3_pclk_pll)
and fx3_gpif.gpif_oe = '1'
and fx3_control.rx_enable = '1' ) then
if( EIGHT_BIT_MODE_EN = '1') then
-- The +-1 ch1 offset in SISO mode will not reach 128
both_channels_en := ENABLE_CHANNEL_0 and ENABLE_CHANNEL_1;
q1_expected_eight_bit_mode := std_logic_vector(to_signed(-rx_val - 1, 8)) when both_channels_en else
std_logic_vector(to_signed(-((rx_val + 1) mod 128), 8));
i1_expected_eight_bit_mode := std_logic_vector(to_signed(rx_val + 1, 8)) when both_channels_en else
std_logic_vector(to_signed((rx_val + 1) mod 128, 8));
q0_expected_eight_bit_mode := std_logic_vector(to_signed(-rx_val, 8));
i0_expected_eight_bit_mode := std_logic_vector(to_signed(rx_val, 8));
q1_out_eight_bit_mode := fx3_gpif.gpif_out(31 downto 24);
i1_out_eight_bit_mode := fx3_gpif.gpif_out(23 downto 16);
q0_out_eight_bit_mode := fx3_gpif.gpif_out(15 downto 8);
i0_out_eight_bit_mode := fx3_gpif.gpif_out(7 downto 0);
if( q1_out_eight_bit_mode /= q1_expected_eight_bit_mode or
i1_out_eight_bit_mode /= i1_expected_eight_bit_mode or
q0_out_eight_bit_mode /= q0_expected_eight_bit_mode or
i0_out_eight_bit_mode /= i0_expected_eight_bit_mode) then
fail_count := fail_count + 1;
report "-----------------------------";
if( fail_count > 3 ) then
report "rx fail count tolerance exceeded" severity failure;
end if;
end if;
assert ( q1_out_eight_bit_mode = q1_expected_eight_bit_mode )
report "data_q1: " & to_hstring(q1_out_eight_bit_mode) & " | " &
"expected: " & to_hstring(q1_expected_eight_bit_mode)
severity warning;
assert ( i1_out_eight_bit_mode = i1_expected_eight_bit_mode )
report "data_i1: " & to_hstring(i1_out_eight_bit_mode) & " | " &
"expected: " & to_hstring(i1_expected_eight_bit_mode)
severity warning;
assert ( q0_out_eight_bit_mode = q0_expected_eight_bit_mode )
report "data_q0: " & to_hstring(q0_out_eight_bit_mode) & " | " &
"expected: " & to_hstring(q0_expected_eight_bit_mode)
severity warning;
assert ( i0_out_eight_bit_mode = i0_expected_eight_bit_mode )
report "data_i0: " & to_hstring(i0_out_eight_bit_mode) & " | " &
"expected: " & to_hstring(i0_expected_eight_bit_mode)
severity warning;
-- 128 limit set by gen_adc_controls above
rx_val := (rx_val + 2) mod 128;
else
q_expected := std_logic_vector(to_signed(-rx_val, 16));
i_expected := std_logic_vector(to_signed(rx_val, 16));
q_out := fx3_gpif.gpif_out(31 downto 16);
i_out := fx3_gpif.gpif_out(15 downto 0);
assert(q_out = q_expected)
report "data_q: " & to_hstring(q_out) & " | " &
"expected: " & to_hstring(q_expected)
severity failure;
assert(i_out = i_expected)
report "data_i: " & to_hstring(i_out) & " | " &
"expected: " & to_hstring(i_expected)
severity failure;
-- 2047 limit set by gen_adc_controls above
rx_val := (rx_val + 1) mod 2048;
end if;
end if;
end process look_for_dropped_rx_samples;
end architecture;

View file

@ -32,6 +32,7 @@ library nuand;
use nuand.fifo_readwrite_p.all; use nuand.fifo_readwrite_p.all;
use nuand.common_dcfifo_p.all; use nuand.common_dcfifo_p.all;
use nuand.bladerf_p.all; use nuand.bladerf_p.all;
use nuand.fx3_gpif_p.all;
entity fx3_gpif_iq_8bit_tb is entity fx3_gpif_iq_8bit_tb is
generic ( generic (
@ -40,7 +41,8 @@ entity fx3_gpif_iq_8bit_tb is
FIFO_READER_READ_THROTTLE : natural := 0; FIFO_READER_READ_THROTTLE : natural := 0;
ENABLE_CHANNEL_0 : std_logic := '1'; ENABLE_CHANNEL_0 : std_logic := '1';
ENABLE_CHANNEL_1 : std_logic := '1' ENABLE_CHANNEL_1 : std_logic := '1';
EIGHT_BIT_MODE_EN : std_logic := '1'
); );
end entity; end entity;
@ -142,8 +144,6 @@ architecture arch of fx3_gpif_iq_8bit_tb is
signal trigger_signal_sync_tb : std_logic; signal trigger_signal_sync_tb : std_logic;
signal adc_stream_val_at_rx_enable : signed(15 downto 0) := ( others => '0' ); signal adc_stream_val_at_rx_enable : signed(15 downto 0) := ( others => '0' );
signal eight_bit_mode_en : std_logic;
function data_gen (count : natural) return std_logic_vector is function data_gen (count : natural) return std_logic_vector is
variable msw, lsw : std_logic_vector(15 downto 0); variable msw, lsw : std_logic_vector(15 downto 0);
begin begin
@ -239,7 +239,6 @@ begin
fx3_control.usb_speed <= '0'; fx3_control.usb_speed <= '0';
fx3_control.meta_enable <= '0'; fx3_control.meta_enable <= '0';
fx3_control.packet <= '0'; fx3_control.packet <= '0';
eight_bit_mode_en <= '1';
U_pkt_gen : entity nuand.rx_packet_generator U_pkt_gen : entity nuand.rx_packet_generator
port map( port map(
@ -295,7 +294,7 @@ begin
fx3_rx_meta_en => meta_en_rx, fx3_rx_meta_en => meta_en_rx,
fx3_tx_en => '1', fx3_tx_en => '1',
fx3_tx_meta_en => meta_en_tx, fx3_tx_meta_en => meta_en_tx,
eight_bit_mode_en => eight_bit_mode_en, eight_bit_mode_en => EIGHT_BIT_MODE_EN,
done => done done => done
); );
@ -356,7 +355,7 @@ begin
packet_ready => '1', packet_ready => '1',
-- 8-bit mode -- 8-bit mode
eight_bit_mode_en => eight_bit_mode_en, eight_bit_mode_en => EIGHT_BIT_MODE_EN,
-- Samples from host via FX3 -- Samples from host via FX3
sample_fifo_wclock => fx3_pclk_pll, sample_fifo_wclock => fx3_pclk_pll,
@ -416,7 +415,7 @@ begin
packet_ready => rx_packet_ready, packet_ready => rx_packet_ready,
-- 8-bit mode -- 8-bit mode
eight_bit_mode_en => eight_bit_mode_en, eight_bit_mode_en => EIGHT_BIT_MODE_EN,
-- Samples to host via FX3 -- Samples to host via FX3
sample_fifo_rclock => fx3_pclk_pll, sample_fifo_rclock => fx3_pclk_pll,
@ -499,7 +498,7 @@ begin
data_req => not adc_controls(i).data_req ); data_req => not adc_controls(i).data_req );
if( adc_controls(i).enable = '1') then if( adc_controls(i).enable = '1') then
if( adc_streams(i).data_v = '1' ) then if( adc_streams(i).data_v = '1' ) then
if( eight_bit_mode_en = '1' ) then if( EIGHT_BIT_MODE_EN = '1' ) then
adc_streams(i).data_i <= "0000" & to_signed(count, 8) & SIGMA_DELTA_BITS; adc_streams(i).data_i <= "0000" & to_signed(count, 8) & SIGMA_DELTA_BITS;
adc_streams(i).data_q <= "0000" & to_signed(-count, 8) & SIGMA_DELTA_BITS; adc_streams(i).data_q <= "0000" & to_signed(-count, 8) & SIGMA_DELTA_BITS;
count := (count + 1) mod 128; count := (count + 1) mod 128;
@ -609,6 +608,15 @@ begin
-- ======================================================================== -- ========================================================================
-- Verification -- Verification
-- ======================================================================== -- ========================================================================
print_config: process
begin
wait until rising_edge(fx3_control.tx_enable);
report lf&
"[CONFIG] EIGHT_BIT_MODE_EN: " & std_logic'image(EIGHT_BIT_MODE_EN) &lf&
"[CONFIG] ENABLE_CHANNEL_0: " & std_logic'image(ENABLE_CHANNEL_0) &lf&
"[CONFIG] ENABLE_CHANNEL_1: " & std_logic'image(ENABLE_CHANNEL_1);
end process print_config;
-- --
-- Check for metavalues -- Check for metavalues
@ -652,6 +660,7 @@ begin
constant MESSAGES_PER_ITERATION : natural := 3; --Provided in fx3_model constant MESSAGES_PER_ITERATION : natural := 3; --Provided in fx3_model
constant SIGMA_DELTA_BITS : signed (3 downto 0) := "0000"; constant SIGMA_DELTA_BITS : signed (3 downto 0) := "0000";
variable current_message_count : natural := 1; variable current_message_count : natural := 1;
variable valid_sample_count : natural := 0;
variable iq_value : signed (15 downto 0) := x"0000"; variable iq_value : signed (15 downto 0) := x"0000";
variable expected_sample_i : signed (15 downto 0); variable expected_sample_i : signed (15 downto 0);
variable expected_sample_q : signed (15 downto 0); variable expected_sample_q : signed (15 downto 0);
@ -663,7 +672,8 @@ begin
and dac_streams(i).data_v = '1' and dac_streams(i).data_v = '1'
and fx3_control.tx_enable = '1' ) and fx3_control.tx_enable = '1' )
then then
if( eight_bit_mode_en = '1' ) then valid_sample_count := valid_sample_count + 1;
if( EIGHT_BIT_MODE_EN = '1' ) then
expected_sample_i := iq_value (11 downto 0) & SIGMA_DELTA_BITS; expected_sample_i := iq_value (11 downto 0) & SIGMA_DELTA_BITS;
expected_sample_q := iq_value (11 downto 0) + 1 & SIGMA_DELTA_BITS; expected_sample_q := iq_value (11 downto 0) + 1 & SIGMA_DELTA_BITS;
@ -699,7 +709,7 @@ begin
-- Set iq values based on blocks received -- Set iq values based on blocks received
-- See tx_sample_stream's encoding scheme in fx3_model.vhd -- See tx_sample_stream's encoding scheme in fx3_model.vhd
if( iq_value = x"03FE" ) then if( valid_sample_count mod GPIF_BUF_SIZE_SS = 0 ) then
iq_value := x"0000"; iq_value := x"0000";
if( current_message_count < MESSAGES_PER_ITERATION ) then if( current_message_count < MESSAGES_PER_ITERATION ) then
current_message_count := current_message_count + 1; current_message_count := current_message_count + 1;
@ -756,14 +766,15 @@ begin
variable both_channels_en : std_logic; variable both_channels_en : std_logic;
begin begin
if( previous_adc_stream_val_at_rx_enable /= adc_stream_val_at_rx_enable ) then if( previous_adc_stream_val_at_rx_enable /= adc_stream_val_at_rx_enable ) then
rx_val := to_integer(adc_stream_val_at_rx_enable (15 downto 4)); rx_val := to_integer(adc_stream_val_at_rx_enable (15 downto 4)) when EIGHT_BIT_MODE_EN else
to_integer(adc_stream_val_at_rx_enable);
previous_adc_stream_val_at_rx_enable := adc_stream_val_at_rx_enable; previous_adc_stream_val_at_rx_enable := adc_stream_val_at_rx_enable;
end if; end if;
if( rising_edge(fx3_pclk_pll) if( rising_edge(fx3_pclk_pll)
and fx3_gpif.gpif_oe = '1' and fx3_gpif.gpif_oe = '1'
and fx3_control.rx_enable = '1' ) then and fx3_control.rx_enable = '1' ) then
if( eight_bit_mode_en = '1') then if( EIGHT_BIT_MODE_EN = '1') then
-- The +-1 ch1 offset in SISO mode will not reach 128 -- The +-1 ch1 offset in SISO mode will not reach 128
both_channels_en := ENABLE_CHANNEL_0 and ENABLE_CHANNEL_1; both_channels_en := ENABLE_CHANNEL_0 and ENABLE_CHANNEL_1;
q1_expected_eight_bit_mode := std_logic_vector(to_signed(-rx_val - 1, 8)) when both_channels_en else q1_expected_eight_bit_mode := std_logic_vector(to_signed(-rx_val - 1, 8)) when both_channels_en else

View file

@ -0,0 +1,681 @@
-- Copyright (c) 2024 Nuand LLC
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-- THE SOFTWARE.
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library rtl_work;
library altera_lnsim;
use altera_lnsim.altera_pll;
library nuand;
use nuand.util.all ;
use nuand.fifo_readwrite_p.all;
use nuand.common_dcfifo_p.all;
use nuand.bladerf_p.all;
use nuand.fx3_gpif_p.all;
entity fx3_gpif_iq_packed_tb is
generic (
-- For bladeRF2 (2x2 MIMO):
NUM_MIMO_STREAMS : natural := 2;
FIFO_READER_READ_THROTTLE : natural := 0;
ENABLE_CHANNEL_0 : std_logic := '1';
ENABLE_CHANNEL_1 : std_logic := '1'
);
end entity;
architecture arch of fx3_gpif_iq_packed_tb is
-- bladerf-hosted uses ad9361.clock (125 MHz) for rx_clock and tx_clock
constant SYSCLK_HALF_PERIOD : time := 1 sec * (1.0/125.0e6/2.0);
-- For reasons unknown, simulation of this system in ModelSim requires that
-- wrreq and data be asserted shortly before the rising clock edge. Sigh...
constant FIFO_WORKAROUND : time := 1 ps;
type fx3_control_t is record
usb_speed : std_logic;
tx_enable : std_logic;
rx_enable : std_logic;
meta_enable : std_logic;
packet : std_logic;
highly_packed_mode : std_logic;
end record;
type fx3_gpif_t is record
gpif_in : std_logic_vector(31 downto 0);
gpif_out : std_logic_vector(31 downto 0);
gpif_oe : std_logic;
ctl_in : std_logic_vector(12 downto 0);
ctl_out : std_logic_vector(12 downto 0);
ctl_oe : std_logic_vector(12 downto 0);
end record;
signal sys_rst : std_logic := '1';
signal done : boolean := false;
signal fx3_pclk : std_logic := '1';
signal fx3_pclk_pll : std_logic := '1';
signal sys_clk : std_logic := '1';
signal pll_reset : std_logic := '0';
signal pll_locked : std_logic := '0';
signal fx3_control : fx3_control_t;
signal fx3_gpif : fx3_gpif_t;
signal fx3_gpif_i : std_logic_vector(31 downto 0);
signal fx3_ctl_i : std_logic_vector(12 downto 0);
-- Control mapping
alias dma0_rx_ack is fx3_ctl_i( 0);
alias dma1_rx_ack is fx3_ctl_i( 1);
alias dma2_tx_ack is fx3_ctl_i( 2);
alias dma3_tx_ack is fx3_ctl_i( 3);
alias dma_rx_enable is fx3_ctl_i( 4);
alias dma_tx_enable is fx3_ctl_i( 5);
alias dma_idle is fx3_ctl_i( 6);
alias system_reset is fx3_ctl_i( 7);
alias dma0_rx_reqx is fx3_ctl_i( 8);
alias dma1_rx_reqx is fx3_ctl_i(12); -- due to 9 being connected to dclk
alias dma2_tx_reqx is fx3_ctl_i(10);
alias dma3_tx_reqx is fx3_ctl_i(11);
signal loopback_i : signed(15 downto 0) := (others =>'0');
signal loopback_q : signed(15 downto 0) := (others =>'0');
signal loopback_valid : std_logic := '0';
signal loopback_enabled : std_logic := '0';
signal tx_clock : std_logic := '1' ;
signal rx_clock : std_logic := '1' ;
signal rx_sample_fifo : rx_fifo_t := RX_FIFO_T_DEFAULT;
signal tx_sample_fifo : tx_fifo_t := TX_FIFO_T_DEFAULT;
signal loopback_fifo : loopback_fifo_t := LOOPBACK_FIFO_T_DEFAULT;
signal rx_meta_fifo : meta_fifo_rx_t := META_FIFO_RX_T_DEFAULT;
signal tx_meta_fifo : meta_fifo_tx_t := META_FIFO_TX_T_DEFAULT;
signal rx_mux_i : signed(15 downto 0);
signal rx_mux_q : signed(15 downto 0);
signal rx_mux_valid : std_logic;
signal tx_timestamp : unsigned(63 downto 0) := ( others => '0' );
signal rx_timestamp : unsigned(63 downto 0) := ( others => '0' );
constant FX3_HALF_PERIOD : time := 1.0/(100.0e6)/2.0*1 sec ;
constant TX_HALF_PERIOD : time := 1.0/(9.0e6)/2.0*1 sec ;
constant RX_HALF_PERIOD : time := 1.0/(9.0e6)/2.0*1 sec ;
signal dac_controls : sample_controls_t(0 to NUM_MIMO_STREAMS-1) := (others => SAMPLE_CONTROL_DISABLE);
signal dac_streams : sample_streams_t(dac_controls'range) := (others => ZERO_SAMPLE);
signal adc_controls : sample_controls_t(0 to NUM_MIMO_STREAMS-1) := (others => SAMPLE_CONTROL_DISABLE);
signal adc_streams : sample_streams_t(adc_controls'range) := (others => ZERO_SAMPLE);
signal tx_reset : std_logic := '0';
signal tx_ts_reset : std_logic := '0';
signal rx_reset : std_logic := '0';
signal rx_ts_reset : std_logic := '0';
signal meta_en_tx : std_logic := '0';
signal meta_en_rx : std_logic := '0';
signal rx_packet_control : packet_control_t := PACKET_CONTROL_DEFAULT;
signal tx_packet_control : packet_control_t;
signal trigger_signal_sync_tb : std_logic;
signal dac_stream_val_at_rx_enable : signed(15 downto 0) := ( others => '0' );
function data_gen (count : natural) return std_logic_vector is
variable msw, lsw : std_logic_vector(15 downto 0);
begin
msw := std_logic_vector(to_signed(count, 16));
lsw := std_logic_vector(to_signed(-count, 16));
return (msw & lsw);
end function data_gen;
signal rx_packet_ready : std_logic;
begin
-- ========================================================================
-- Brief summary of data flow
-- ========================================================================
--
-- Simulated samples flow from fx3_model's TX side to its RX side. The
-- validity of the data is checked there.
--
-- entity U_fx3_model FX3 model, TX process
-- signal fx3_gpif_i fx3_gpif.gpif_oe is '0'
-- process register_gpif
-- signal fx3_gpif.gpif_in Demuxed GPIF interface (FX3 -> FPGA)
-- entity U_fx3_gpif GPIF implementation, write side
-- signal tx_sample_fifo.w* TX fifo, write side
-- entity U_tx_sample_fifo
-- signal tx_sample_fifo.r* TX fifo, read side
-- process tx_mux
-- signal loopback_fifo.w* Loopback fifo, write side
-- entity U_rx_loopback_fifo
-- signal loopback_fifo.r* Loopback fifo, read side
-- process loopback_fifo_control
-- signal loopback_{i,q,valid}
-- process rx_mux
-- signal rx_mux_{i,q,valid}
-- entity U_fifo_writer
-- signal rx_sample_fifo.w* RX fifo, write side
-- entity U_rx_sample_fifo
-- signal rx_sample_fifo.r* RX fifo, read side
-- entity U_fx3_gpif GPIF implementation, read side
-- signal fx3_gpif.gpif_out Demuxed GPIF interface (FPGA -> FX3)
-- process register_gpif
-- signal fx3_gpif_i fx3_gpif.gpif_oe is '1'
-- entity U_fx3_model FX3 model, RX process
-- ========================================================================
-- Instantiations
-- ========================================================================
-- Unit under test
-- Clock domain: fx3_pclk_pll
U_fx3_gpif : entity nuand.fx3_gpif
port map (
pclk => fx3_pclk_pll,
reset => sys_rst,
usb_speed => fx3_control.usb_speed,
gpif_in => fx3_gpif.gpif_in,
gpif_out => fx3_gpif.gpif_out,
gpif_oe => fx3_gpif.gpif_oe,
ctl_in => fx3_gpif.ctl_in,
ctl_out => fx3_gpif.ctl_out,
ctl_oe => fx3_gpif.ctl_oe,
tx_enable => fx3_control.tx_enable,
rx_enable => fx3_control.rx_enable,
meta_enable => fx3_control.meta_enable,
packet_enable => fx3_control.packet,
tx_fifo_write => tx_sample_fifo.wreq,
tx_fifo_full => tx_sample_fifo.wfull,
tx_fifo_empty => tx_sample_fifo.wempty,
tx_fifo_usedw => tx_sample_fifo.wused,
tx_fifo_data => tx_sample_fifo.wdata,
tx_timestamp => tx_timestamp,
tx_meta_fifo_write => tx_meta_fifo.wreq,
tx_meta_fifo_full => tx_meta_fifo.wfull,
tx_meta_fifo_empty => tx_meta_fifo.wempty,
tx_meta_fifo_usedw => tx_meta_fifo.wused,
tx_meta_fifo_data => tx_meta_fifo.wdata,
rx_fifo_read => rx_sample_fifo.rreq,
rx_fifo_full => rx_sample_fifo.rfull,
rx_fifo_empty => rx_sample_fifo.rempty,
rx_fifo_usedw => rx_sample_fifo.rused,
rx_fifo_data => rx_sample_fifo.rdata,
rx_meta_fifo_read => rx_meta_fifo.rreq,
rx_meta_fifo_full => rx_meta_fifo.rfull,
rx_meta_fifo_empty => rx_meta_fifo.rempty,
rx_meta_fifo_usedr => rx_meta_fifo.rused,
rx_meta_fifo_data => rx_meta_fifo.rdata
);
-- Discrete control signals for fx3_gpif
fx3_control.usb_speed <= '0';
fx3_control.meta_enable <= '0';
fx3_control.packet <= '0';
fx3_control.highly_packed_mode <= '1';
U_pkt_gen : entity nuand.rx_packet_generator
port map(
rx_clock => rx_clock,
rx_reset => rx_reset,
rx_enable => fx3_control.rx_enable,
rx_packet_enable => fx3_control.packet,
rx_packet_ready => rx_packet_ready,
rx_packet_control => rx_packet_control
);
meta_en_tx <= fx3_control.meta_enable;
meta_en_rx <= fx3_control.meta_enable;
increment_tx_ts : process(tx_clock)
variable ping : boolean := true ;
begin
if( rising_edge(tx_clock) ) then
ping := not ping ;
if( ping = true ) then
tx_timestamp <= tx_timestamp + 1 ;
end if ;
end if ;
end process ;
increment_rx_ts : process(rx_clock)
variable ping : boolean := true ;
begin
if( rising_edge(rx_clock) ) then
ping := not ping ;
if( ping = true ) then
rx_timestamp <= rx_timestamp + 1 ;
end if ;
end if ;
end process ;
-- Model of FX3's GPIF interface
-- Clock domain: fx3_pclk (source)
U_fx3_model : entity nuand.fx3_model(micro_dma)
port map (
fx3_pclk => fx3_pclk,
fx3_gpif => fx3_gpif_i,
fx3_ctl => fx3_ctl_i,
fx3_uart_rxd => '0',
fx3_uart_txd => open,
fx3_uart_cts => open,
fx3_rx_en => '1',
fx3_rx_meta_en => meta_en_rx,
fx3_tx_en => '1',
fx3_tx_meta_en => meta_en_tx,
packed_mode_en => fx3_control.highly_packed_mode,
done => done
);
-- Generate phase-shifted PLL clock
U_fx3_pll : entity rtl_work.fx3_pll
port map (
inclk0 => fx3_pclk,
areset => pll_reset,
c0 => fx3_pclk_pll,
locked => pll_locked
);
tx_clock <= not tx_clock after TX_HALF_PERIOD ;
rx_clock <= not rx_clock after RX_HALF_PERIOD ;
-- Reset handler
sys_rst <= '0' after 100 ns;
-- Generate system clock
sys_clk <= not sys_clk after SYSCLK_HALF_PERIOD when not done else '0';
tx_reset <= sys_rst;
tx_ts_reset <= sys_rst;
rx_reset <= sys_rst;
rx_ts_reset <= sys_rst;
meta_en_tx <= fx3_control.meta_enable;
meta_en_rx <= fx3_control.meta_enable;
-- TX Submodule
U_tx : entity work.tx
generic map (
NUM_STREAMS => dac_controls'length
)
port map (
tx_reset => tx_reset,
tx_clock => tx_clock,
tx_enable => fx3_control.tx_enable,
meta_en => meta_en_tx,
timestamp_reset => tx_ts_reset,
usb_speed => fx3_control.usb_speed,
tx_underflow_led => open,
tx_timestamp => tx_timestamp,
-- Packing modes
highly_packed_mode_en => fx3_control.highly_packed_mode,
-- Triggering
trigger_arm => '0',
trigger_fire => '0',
trigger_master => '0',
trigger_line => open,
-- Packet FIFO
packet_en => fx3_control.packet,
packet_empty => open,
packet_control => tx_packet_control,
packet_ready => '1',
-- Samples from host via FX3
sample_fifo_wclock => fx3_pclk_pll,
sample_fifo_wreq => tx_sample_fifo.wreq,
sample_fifo_wdata => tx_sample_fifo.wdata,
sample_fifo_wempty => tx_sample_fifo.wempty,
sample_fifo_wfull => tx_sample_fifo.wfull,
sample_fifo_wused => tx_sample_fifo.wused,
-- Metadata from host via FX3
meta_fifo_wclock => fx3_pclk_pll,
meta_fifo_wreq => tx_meta_fifo.wreq,
meta_fifo_wdata => tx_meta_fifo.wdata,
meta_fifo_wempty => tx_meta_fifo.wempty,
meta_fifo_wfull => tx_meta_fifo.wfull,
meta_fifo_wused => tx_meta_fifo.wused,
-- Digital Loopback Interface
loopback_enabled => '0',
loopback_fifo_wdata => loopback_fifo.wdata,
loopback_fifo_wreq => loopback_fifo.wreq,
loopback_fifo_wfull => loopback_fifo.wfull,
loopback_fifo_wused => loopback_fifo.wused,
-- RFFE Interface
dac_controls => dac_controls,
dac_streams => dac_streams
);
-- RX Submodule
U_rx : entity work.rx
generic map (
NUM_STREAMS => adc_controls'length
)
port map (
highly_packed_mode_en => fx3_control.highly_packed_mode,
rx_reset => rx_reset,
rx_clock => rx_clock,
rx_enable => fx3_control.rx_enable,
meta_en => meta_en_rx,
timestamp_reset => rx_ts_reset,
usb_speed => fx3_control.usb_speed,
rx_mux_sel => to_unsigned(0, 3),
rx_overflow_led => open,
rx_timestamp => rx_timestamp,
-- Triggering
trigger_arm => '0',
trigger_fire => '0',
trigger_master => '0',
trigger_line => open,
trigger_signal_sync_tb => trigger_signal_sync_tb,
-- Packet FIFO
packet_en => fx3_control.packet,
packet_control => rx_packet_control,
packet_ready => rx_packet_ready,
-- Samples to host via FX3
sample_fifo_rclock => fx3_pclk_pll,
sample_fifo_raclr => not fx3_control.rx_enable,
sample_fifo_rreq => rx_sample_fifo.rreq,
sample_fifo_rdata => rx_sample_fifo.rdata,
sample_fifo_rempty => rx_sample_fifo.rempty,
sample_fifo_rfull => rx_sample_fifo.rfull,
sample_fifo_rused => rx_sample_fifo.rused,
-- Mini expansion signals
mini_exp => "00",
-- Metadata to host via FX3
meta_fifo_rclock => fx3_pclk_pll,
meta_fifo_raclr => not fx3_control.rx_enable,
meta_fifo_rreq => rx_meta_fifo.rreq,
meta_fifo_rdata => rx_meta_fifo.rdata,
meta_fifo_rempty => rx_meta_fifo.rempty,
meta_fifo_rfull => rx_meta_fifo.rfull,
meta_fifo_rused => rx_meta_fifo.rused,
-- Digital Loopback Interface
loopback_fifo_wenabled => open,
loopback_fifo_wreset => tx_reset,
loopback_fifo_wclock => tx_clock,
loopback_fifo_wdata => loopback_fifo.wdata,
loopback_fifo_wreq => loopback_fifo.wreq,
loopback_fifo_wfull => loopback_fifo.wfull,
loopback_fifo_wused => loopback_fifo.wused,
-- RFFE Interface
adc_controls => adc_controls,
adc_streams => adc_streams
);
-- ========================================================================
-- Data converters
-- ========================================================================
gen_dac_controls : if( NUM_MIMO_STREAMS > 1 ) generate
-- The TX side of the AD9361 HDL is a FIFO pull interface
-- that expects a readahead FIFO. It toggles the data request
-- signal every other cycle. This behavior is mimicked here.
process( tx_clock, sys_rst )
begin
if( sys_rst = '1' ) then
dac_controls <= (
0 => (enable => ENABLE_CHANNEL_0, data_req => '1'),
1 => (enable => ENABLE_CHANNEL_1, data_req => '1')
);
elsif( rising_edge(tx_clock) ) then
for i in dac_controls'range loop
dac_controls(i) <= (
enable => dac_controls(i).enable,
data_req => not dac_controls(i).data_req );
end loop;
end if;
end process;
else generate
dac_controls <= (others => SAMPLE_CONTROL_ENABLE);
end generate;
gen_adc_controls : if( NUM_MIMO_STREAMS > 1 ) generate
process( rx_clock, sys_rst )
constant COUNT_RESET : integer := 0;
variable count : integer range -2047 to 2047 := COUNT_RESET;
begin
if( sys_rst = '1' ) then
count := COUNT_RESET;
adc_controls <= (
0 => (enable => ENABLE_CHANNEL_0, data_req => '1'),
1 => (enable => ENABLE_CHANNEL_1, data_req => '1')
);
elsif( rising_edge(rx_clock) ) then
for i in adc_controls'range loop
adc_controls(i) <= (
enable => adc_controls(i).enable,
data_req => not adc_controls(i).data_req );
if( adc_controls(i).enable = '1') then
if( adc_streams(i).data_v = '1' ) then
adc_streams(i).data_i <= to_signed(count, 16);
adc_streams(i).data_q <= to_signed(-count, 16);
if( count < 2047 ) then
count := count + 1;
else
count := COUNT_RESET;
end if;
end if;
adc_streams(i).data_v <= not adc_streams(i).data_v;
end if;
end loop;
end if;
end process;
else generate
adc_controls <= (others => SAMPLE_CONTROL_ENABLE);
end generate;
-- ========================================================================
-- Processes
-- ========================================================================
-- FX3 GPIF bidirectional signal control
-- Adapted from same process in bladerf-hosted.vhd
register_gpif : process(sys_rst, fx3_pclk_pll)
begin
if( sys_rst = '1' ) then
fx3_gpif_i <= (others => 'Z');
fx3_gpif.gpif_in <= (others => 'Z');
elsif( rising_edge(fx3_pclk_pll) ) then
fx3_gpif.gpif_in <= fx3_gpif_i;
if( fx3_gpif.gpif_oe = '1' ) then
fx3_gpif_i <= fx3_gpif.gpif_out;
else
fx3_gpif_i <= (others =>'Z');
end if;
end if;
end process;
-- FX3 CTL bidirectional signals
-- Adapted from same generator in bladerf-hosted.vhd
generate_ctl : for i in fx3_ctl_i'range generate
fx3_ctl_i(i) <= fx3_gpif.ctl_out(i) when fx3_gpif.ctl_oe(i) = '1' else 'Z';
end generate;
fx3_gpif.ctl_in <= fx3_ctl_i;
-- Controller for loopback FIFO
-- Stripped-down version of same process from rx.vhd
loopback_fifo_control : process( sys_rst, loopback_fifo.rclock )
begin
if( sys_rst = '1' ) then
loopback_enabled <= '0';
loopback_fifo.rreq <= '0';
loopback_i <= (others => '0');
loopback_q <= (others => '0');
loopback_valid <= '0';
elsif( rising_edge(loopback_fifo.rclock) ) then
loopback_enabled <= '0';
loopback_fifo.rreq <= '0';
loopback_i <= loopback_i;
loopback_q <= loopback_q;
loopback_valid <= '0';
-- Is loopback enabled?
loopback_enabled <= fx3_control.rx_enable;
-- Do the loopback
loopback_i <= resize(signed(loopback_fifo.rdata(15 downto 0)), loopback_i'length);
loopback_q <= resize(signed(loopback_fifo.rdata(31 downto 16)), loopback_q'length);
loopback_valid <= loopback_fifo.rreq and not loopback_fifo.rempty;
-- Read from the FIFO if req'd
loopback_fifo.rreq <= loopback_enabled and (not loopback_fifo.rempty);
end if;
end process;
-- RX multiplexer
-- Stripped-down version of same process from rx.vhd
rx_mux : process(sys_rst, sys_clk)
begin
if( sys_rst = '1' ) then
rx_mux_i <= (others =>'0');
rx_mux_q <= (others =>'0');
rx_mux_valid <= '0';
elsif( rising_edge(sys_clk) ) then
rx_mux_i <= loopback_i;
rx_mux_q <= loopback_q;
rx_mux_valid <= loopback_valid;
end if;
end process;
-- TX multiplexer
-- Stripped-down version of mimo_channel_sel_mux from tx.vhd
--tx_mux : process( sys_clk )
--begin
-- if( rising_edge(sys_clk) ) then
-- tx_sample_fifo.rreq <= not tx_sample_fifo.rempty;
-- loopback_fifo.wdata <= tx_sample_fifo.rdata;
-- loopback_fifo.wreq <= tx_sample_fifo.rreq and not tx_sample_fifo.rempty;
-- end if;
--end process;
-- ========================================================================
-- Verification
-- ========================================================================
--
-- Check for fullness on FIFOs
--
assert (rx_sample_fifo.wfull = '0') report "rx_sample_fifo full (write)" severity warning;
assert (tx_sample_fifo.wfull = '0') report "tx_sample_fifo full (write)" severity warning;
assert (loopback_fifo.wfull = '0') report "loopback_fifo full (write)" severity warning;
-- Every three gpif transfers will contain 4 samples.
-- Let's fill and check a 4 sample buffer every 3 pclk cycles.
--
-- Note: Failure expected after each fx3_model iteration since we lose
-- sample continuity when fifo writer is disabled.
look_for_dropped_rx_samples: process(fx3_pclk_pll)
variable rx_val : integer;
variable gpif_buffer_idx : integer range 0 to 2 := 0;
variable buf_sc12q11 : std_logic_vector(3*fx3_gpif.gpif_out'length-1 downto 0) := (others => '0');
begin
-- Init rx_val
if sys_rst = '1' then
rx_val := 16#172# when ENABLE_CHANNEL_0 and ENABLE_CHANNEL_1 else 16#B9#;
end if;
if (rising_edge(fx3_pclk_pll)
and fx3_gpif.gpif_oe = '1'
and fx3_control.rx_enable = '1') then
-- Shift in the new samples
buf_sc12q11 := fx3_gpif.gpif_out & buf_sc12q11(buf_sc12q11'length-1 downto fx3_gpif.gpif_out'length);
-- Checks the 4 sample buffer every 3 pclk cycles
if gpif_buffer_idx = 2 then
for i in 0 to 3 loop
assert(signed(buf_sc12q11(11+24*i downto 24*i))) = to_signed(rx_val, 12)
report "I expected: " & integer'image(rx_val) & ", Actual: " & integer'image(to_integer(signed(buf_sc12q11(11+24*i downto 24*i))))
severity failure;
assert(signed(buf_sc12q11(23+24*i downto 12+24*i))) = to_signed(-1*rx_val, 12)
report "Q expected: " & integer'image(-1*rx_val) & ", Actual: " & integer'image(to_integer(signed(buf_sc12q11(23+24*i downto 12+24*i))))
severity failure;
rx_val := (rx_val + 1) mod 2048;
end loop;
end if;
gpif_buffer_idx := (gpif_buffer_idx + 1) mod 3;
end if;
end process look_for_dropped_rx_samples;
look_for_dropped_tx_samples: process(tx_clock)
variable tx_val : integer := 0;
variable message_count : integer := 1;
variable q_expected : integer := 0;
variable valid_tx_count : integer := 0;
begin
if rising_edge(tx_clock) then
for i in dac_controls'range loop
if dac_streams(i).data_v = '1' then
q_expected := tx_val+1 when fx3_control.highly_packed_mode = '1'
else to_integer(to_signed(message_count,8) & to_signed(tx_val+1, 8));
assert(dac_streams(i).data_i = to_signed(tx_val, 16))
report "TX("&integer'image(i)&") I expected: " & integer'image(tx_val) & ", Actual: " & integer'image(to_integer(signed(dac_streams(i).data_i)))
severity failure;
assert(dac_streams(i).data_q = q_expected)
report "TX("&integer'image(i)&") Q expected: " & integer'image(q_expected) & ", Actual: " & integer'image(to_integer(signed(dac_streams(i).data_q)))
severity failure;
-- A new message is received every 2048 samples
valid_tx_count := valid_tx_count + 1;
if valid_tx_count mod 2048 = 0 then
message_count := message_count + 1;
end if;
tx_val := (tx_val + 2) when tx_val < 2046 else -2048;
end if;
end loop;
end if;
end process look_for_dropped_tx_samples;
end architecture;

View file

@ -32,6 +32,7 @@ library nuand;
use nuand.fifo_readwrite_p.all; use nuand.fifo_readwrite_p.all;
use nuand.common_dcfifo_p.all; use nuand.common_dcfifo_p.all;
use nuand.bladerf_p.all; use nuand.bladerf_p.all;
use nuand.fx3_gpif_p.all;
entity fx3_gpif_iq_tb is entity fx3_gpif_iq_tb is
generic ( generic (
@ -638,6 +639,7 @@ begin
look_for_dropped_tx_samples : process(tx_clock) is look_for_dropped_tx_samples : process(tx_clock) is
constant MESSAGES_PER_ITERATION : natural := 3; --Provided in fx3_model constant MESSAGES_PER_ITERATION : natural := 3; --Provided in fx3_model
variable current_message_count : natural := 1; variable current_message_count : natural := 1;
variable valid_sample_count : natural := 0;
variable iq_value : signed (15 downto 0) := x"0000"; variable iq_value : signed (15 downto 0) := x"0000";
variable expected_sample_q : signed (15 downto 0); variable expected_sample_q : signed (15 downto 0);
variable expected_sample_i : signed (15 downto 0); variable expected_sample_i : signed (15 downto 0);
@ -648,6 +650,7 @@ begin
and dac_streams(i).data_v = '1' and dac_streams(i).data_v = '1'
and fx3_control.tx_enable = '1' ) and fx3_control.tx_enable = '1' )
then then
valid_sample_count := valid_sample_count + 1;
expected_sample_i := iq_value; expected_sample_i := iq_value;
expected_sample_q := to_signed(current_message_count, 8) & (iq_value(7 downto 0) + 1); expected_sample_q := to_signed(current_message_count, 8) & (iq_value(7 downto 0) + 1);
@ -662,7 +665,7 @@ begin
-- Set iq values based on blocks received -- Set iq values based on blocks received
-- See tx_sample_stream's encoding scheme in fx3_model.vhd -- See tx_sample_stream's encoding scheme in fx3_model.vhd
if( iq_value = x"03FE" ) then if( valid_sample_count mod GPIF_BUF_SIZE_SS = 0 ) then
iq_value := x"0000"; iq_value := x"0000";
if( current_message_count < MESSAGES_PER_ITERATION ) then if( current_message_count < MESSAGES_PER_ITERATION ) then
current_message_count := current_message_count + 1; current_message_count := current_message_count + 1;

View file

@ -32,6 +32,7 @@ library nuand;
use nuand.fifo_readwrite_p.all; use nuand.fifo_readwrite_p.all;
use nuand.common_dcfifo_p.all; use nuand.common_dcfifo_p.all;
use nuand.bladerf_p.all; use nuand.bladerf_p.all;
use nuand.fx3_gpif_p.all;
entity fx3_gpif_meta_8bit_tb is entity fx3_gpif_meta_8bit_tb is
generic ( generic (
@ -40,7 +41,8 @@ entity fx3_gpif_meta_8bit_tb is
FIFO_READER_READ_THROTTLE : natural := 0; FIFO_READER_READ_THROTTLE : natural := 0;
ENABLE_CHANNEL_0 : std_logic := '1'; ENABLE_CHANNEL_0 : std_logic := '1';
ENABLE_CHANNEL_1 : std_logic := '1' ENABLE_CHANNEL_1 : std_logic := '1';
EIGHT_BIT_MODE_EN : std_logic := '1'
); );
end entity; end entity;
@ -142,8 +144,6 @@ architecture arch of fx3_gpif_meta_8bit_tb is
signal trigger_signal_sync_tb : std_logic; signal trigger_signal_sync_tb : std_logic;
signal adc_stream_val_at_rx_enable : signed(15 downto 0) := ( others => '0' ); signal adc_stream_val_at_rx_enable : signed(15 downto 0) := ( others => '0' );
signal eight_bit_mode_en : std_logic;
function data_gen (count : natural) return std_logic_vector is function data_gen (count : natural) return std_logic_vector is
variable msw, lsw : std_logic_vector(15 downto 0); variable msw, lsw : std_logic_vector(15 downto 0);
begin begin
@ -239,7 +239,6 @@ begin
fx3_control.usb_speed <= '0'; fx3_control.usb_speed <= '0';
fx3_control.meta_enable <= '1'; fx3_control.meta_enable <= '1';
fx3_control.packet <= '0'; fx3_control.packet <= '0';
eight_bit_mode_en <= '1';
U_pkt_gen : entity nuand.rx_packet_generator U_pkt_gen : entity nuand.rx_packet_generator
port map( port map(
@ -295,7 +294,7 @@ begin
fx3_rx_meta_en => meta_en_rx, fx3_rx_meta_en => meta_en_rx,
fx3_tx_en => '1', fx3_tx_en => '1',
fx3_tx_meta_en => meta_en_tx, fx3_tx_meta_en => meta_en_tx,
eight_bit_mode_en => eight_bit_mode_en, EIGHT_BIT_MODE_EN => EIGHT_BIT_MODE_EN,
done => done done => done
); );
@ -356,7 +355,7 @@ begin
packet_ready => '1', packet_ready => '1',
-- 8-bit mode -- 8-bit mode
eight_bit_mode_en => eight_bit_mode_en, EIGHT_BIT_MODE_EN => EIGHT_BIT_MODE_EN,
-- Samples from host via FX3 -- Samples from host via FX3
sample_fifo_wclock => fx3_pclk_pll, sample_fifo_wclock => fx3_pclk_pll,
@ -416,7 +415,7 @@ begin
packet_ready => rx_packet_ready, packet_ready => rx_packet_ready,
-- 8-bit mode -- 8-bit mode
eight_bit_mode_en => eight_bit_mode_en, EIGHT_BIT_MODE_EN => EIGHT_BIT_MODE_EN,
-- Samples to host via FX3 -- Samples to host via FX3
sample_fifo_rclock => fx3_pclk_pll, sample_fifo_rclock => fx3_pclk_pll,
@ -499,7 +498,7 @@ begin
data_req => not adc_controls(i).data_req ); data_req => not adc_controls(i).data_req );
if( adc_controls(i).enable = '1') then if( adc_controls(i).enable = '1') then
if( adc_streams(i).data_v = '1' ) then if( adc_streams(i).data_v = '1' ) then
if( eight_bit_mode_en = '1' ) then if( EIGHT_BIT_MODE_EN = '1' ) then
adc_streams(i).data_i <= "0000" & to_signed(count, 8) & SIGMA_DELTA_BITS; adc_streams(i).data_i <= "0000" & to_signed(count, 8) & SIGMA_DELTA_BITS;
adc_streams(i).data_q <= "0000" & to_signed(-count, 8) & SIGMA_DELTA_BITS; adc_streams(i).data_q <= "0000" & to_signed(-count, 8) & SIGMA_DELTA_BITS;
count := (count + 1) mod 128; count := (count + 1) mod 128;
@ -509,8 +508,8 @@ begin
count := (count + 1) mod 2048; count := (count + 1) mod 2048;
end if; end if;
end if; end if;
adc_streams(i).data_v <= not adc_streams(i).data_v;
end if; end if;
adc_streams(i).data_v <= not adc_streams(i).data_v;
end loop; end loop;
end if; end if;
end process; end process;
@ -698,7 +697,8 @@ begin
look_for_dropped_tx_samples : process(tx_clock) is look_for_dropped_tx_samples : process(tx_clock) is
constant MESSAGES_PER_ITERATION : natural := 3; --Provided in fx3_model constant MESSAGES_PER_ITERATION : natural := 3; --Provided in fx3_model
constant SIGMA_DELTA_BITS : signed (3 downto 0) := "0000"; constant SIGMA_DELTA_BITS : signed (3 downto 0) := "0000";
variable dac_stream_back_to_0 : natural := 0; constant HEADER_LEN : natural := 4; -- In clk cycles
variable valid_sample_count : natural := 0;
variable current_message_count : natural := 1; variable current_message_count : natural := 1;
variable iq_value : signed (15 downto 0) := x"0000"; variable iq_value : signed (15 downto 0) := x"0000";
variable expected_sample_i : signed (15 downto 0); variable expected_sample_i : signed (15 downto 0);
@ -711,7 +711,8 @@ begin
and dac_streams(i).data_v = '1' and dac_streams(i).data_v = '1'
and fx3_control.tx_enable = '1' ) and fx3_control.tx_enable = '1' )
then then
if( eight_bit_mode_en = '1' ) then valid_sample_count := valid_sample_count + 1;
if( EIGHT_BIT_MODE_EN = '1' ) then
expected_sample_i := iq_value (11 downto 0) & SIGMA_DELTA_BITS; expected_sample_i := iq_value (11 downto 0) & SIGMA_DELTA_BITS;
expected_sample_q := iq_value (11 downto 0) + 1 & SIGMA_DELTA_BITS; expected_sample_q := iq_value (11 downto 0) + 1 & SIGMA_DELTA_BITS;
@ -731,9 +732,16 @@ begin
end if; end if;
end if; end if;
dac_stream_back_to_0 := dac_stream_back_to_0 + 1 when iq_value = 0; if( valid_sample_count mod (2*GPIF_BUF_SIZE_SS - 8) = 0 ) then
iq_value := (iq_value + 2) mod 128 when dac_stream_back_to_0 mod 16 /= 0 else iq_value := x"0000";
(iq_value + 2) mod 112; if( current_message_count < MESSAGES_PER_ITERATION ) then
current_message_count := current_message_count + 1;
else
current_message_count := 1;
end if;
else
iq_value := (iq_value + 2) mod 128;
end if;
else else
expected_sample_i := iq_value; expected_sample_i := iq_value;
expected_sample_q := to_signed(current_message_count, 8) & (iq_value(7 downto 0) + 1); expected_sample_q := to_signed(current_message_count, 8) & (iq_value(7 downto 0) + 1);
@ -749,7 +757,7 @@ begin
-- Set iq values based on blocks received -- Set iq values based on blocks received
-- See tx_sample_stream's encoding scheme in fx3_model.vhd -- See tx_sample_stream's encoding scheme in fx3_model.vhd
if( iq_value = x"03F6" ) then if( valid_sample_count mod (GPIF_BUF_SIZE_SS - HEADER_LEN) = 0 ) then
iq_value := x"0000"; iq_value := x"0000";
if( current_message_count < MESSAGES_PER_ITERATION ) then if( current_message_count < MESSAGES_PER_ITERATION ) then
current_message_count := current_message_count + 1; current_message_count := current_message_count + 1;
@ -818,7 +826,7 @@ begin
if( fx3_control.meta_enable = '1' and header_downcount /= 0 ) then if( fx3_control.meta_enable = '1' and header_downcount /= 0 ) then
header_downcount := header_downcount - 1; header_downcount := header_downcount - 1;
else else
if( eight_bit_mode_en = '1' ) then if( EIGHT_BIT_MODE_EN = '1' ) then
-- The +-1 ch1 offset in SISO mode will not reach 128 -- The +-1 ch1 offset in SISO mode will not reach 128
both_channels_en := ENABLE_CHANNEL_0 and ENABLE_CHANNEL_1; both_channels_en := ENABLE_CHANNEL_0 and ENABLE_CHANNEL_1;
q1_expected_eight_bit_mode := std_logic_vector(to_signed(-rx_val - 1, 8)) when both_channels_en else q1_expected_eight_bit_mode := std_logic_vector(to_signed(-rx_val - 1, 8)) when both_channels_en else
@ -887,4 +895,45 @@ begin
end if; end if;
end process look_for_dropped_rx_samples; end process look_for_dropped_rx_samples;
meta_spacing: process
procedure wait_for_gpif_ts( signal clk: in std_logic; signal en: in std_logic ) is
begin
wait until rising_edge(en);
wait until rising_edge(clk);
wait until rising_edge(clk);
end;
variable ts_increment : integer := 0;
variable last_ts : unsigned (31 downto 0) := 32x"BB"; -- First timestamp
variable iteration : natural := 1;
begin
wait_for_gpif_ts(fx3_pclk, fx3_gpif.gpif_oe);
assert fx3_gpif.gpif_out = std_logic_vector(last_ts + ts_increment)
report LF&
"Unexpected ts: " & to_hstring(fx3_gpif.gpif_out) &LF&
"Expected ts: " & to_hstring(last_ts + ts_increment)
severity failure;
last_ts := unsigned(fx3_gpif.gpif_out);
-- Allows a 0 increment for the first ts assertion
if( ENABLE_CHANNEL_0 = '1' and ENABLE_CHANNEL_1 = '1') then
ts_increment := (GPIF_BUF_SIZE_SS-4)/2 when EIGHT_BIT_MODE_EN = '0'
else (GPIF_BUF_SIZE_SS-4);
else
ts_increment := (GPIF_BUF_SIZE_SS -4) when EIGHT_BIT_MODE_EN = '0'
else 2*(GPIF_BUF_SIZE_SS -4);
end if;
iteration := iteration + 1;
if (iteration > 3) then
wait_for_gpif_ts(fx3_pclk, fx3_gpif.gpif_oe);
last_ts := unsigned(fx3_gpif.gpif_out);
iteration := 2;
end if;
end process meta_spacing;
end architecture; end architecture;

View file

@ -32,6 +32,7 @@ library nuand;
use nuand.fifo_readwrite_p.all; use nuand.fifo_readwrite_p.all;
use nuand.common_dcfifo_p.all; use nuand.common_dcfifo_p.all;
use nuand.bladerf_p.all; use nuand.bladerf_p.all;
use nuand.fx3_gpif_p.all;
entity fx3_gpif_meta_tb is entity fx3_gpif_meta_tb is
generic ( generic (
@ -683,8 +684,10 @@ begin
end process tx_sample_start_check; end process tx_sample_start_check;
look_for_dropped_tx_samples : process(tx_clock) is look_for_dropped_tx_samples : process(tx_clock) is
constant HEADER_LEN : integer := 4; -- In clk cycles
constant MESSAGES_PER_ITERATION : natural := 3; --Provided in fx3_model constant MESSAGES_PER_ITERATION : natural := 3; --Provided in fx3_model
variable current_message_count : natural := 1; variable current_message_count : natural := 1;
variable valid_sample_count : natural := 0;
variable iq_value : signed (15 downto 0) := x"0000"; variable iq_value : signed (15 downto 0) := x"0000";
variable expected_sample_q : signed (15 downto 0); variable expected_sample_q : signed (15 downto 0);
variable expected_sample_i : signed (15 downto 0); variable expected_sample_i : signed (15 downto 0);
@ -695,6 +698,7 @@ begin
and dac_streams(i).data_v = '1' and dac_streams(i).data_v = '1'
and fx3_control.tx_enable = '1' ) and fx3_control.tx_enable = '1' )
then then
valid_sample_count := valid_sample_count + 1;
expected_sample_i := iq_value; expected_sample_i := iq_value;
expected_sample_q := to_signed(current_message_count, 8) & (iq_value(7 downto 0) + 1); expected_sample_q := to_signed(current_message_count, 8) & (iq_value(7 downto 0) + 1);
@ -709,7 +713,7 @@ begin
-- Set iq values based on blocks received -- Set iq values based on blocks received
-- See tx_sample_stream's encoding scheme in fx3_model.vhd -- See tx_sample_stream's encoding scheme in fx3_model.vhd
if( iq_value = x"03F6" ) then if( valid_sample_count mod (GPIF_BUF_SIZE_SS-HEADER_LEN) = 0 ) then
iq_value := x"0000"; iq_value := x"0000";
if( current_message_count < MESSAGES_PER_ITERATION ) then if( current_message_count < MESSAGES_PER_ITERATION ) then
current_message_count := current_message_count + 1; current_message_count := current_message_count + 1;

View file

@ -700,7 +700,7 @@ begin
-- Change the iq values based on blocks received -- Change the iq values based on blocks received
-- See tx_sample_stream's encoding scheme in fx3_model.vhd -- See tx_sample_stream's encoding scheme in fx3_model.vhd
if( iq_value(7 downto 0) = tx_packet_len ) then if( iq_value(7 downto 0) = tx_packet_len - 1 ) then
iq_value := x"0000"; iq_value := x"0000";
if( current_block_count <= BLOCKS_PER_ITERATION ) then if( current_block_count <= BLOCKS_PER_ITERATION ) then
current_block_count := current_block_count + 1; current_block_count := current_block_count + 1;

View file

@ -26,6 +26,7 @@ library ieee;
library work; library work;
use work.util.all; use work.util.all;
use work.fx3_gpif_p.all;
architecture micro_dma of fx3_model is architecture micro_dma of fx3_model is
@ -57,6 +58,32 @@ architecture micro_dma of fx3_model is
signal rx_data : std_logic_vector(31 downto 0); signal rx_data : std_logic_vector(31 downto 0);
signal tx_data : std_logic_vector(31 downto 0); signal tx_data : std_logic_vector(31 downto 0);
-- Generates packed samples
-- The host will pack SC16Q11 samples into an SC12Q11 format. Every 3 gpif_in
-- cycles contain 4 SC12Q11 IQ pairs.
--
-- Packing order:
-- Buffer 1: [--Sample1(8)--|----------Sample0(24)----------]
-- Buffer 2: [------Sample2(16)------|------Sample1(16)-----]
-- Buffer 3: [----------Sample3(24)----------|--Sample2(8)--]
function data_gen_packed(cycle : natural) return std_logic_vector is
variable four_sample_buffer : std_logic_vector(95 downto 0) := (others => '0');
variable buffer_offset : integer := 0;
variable sample_value_ref : integer := 0;
variable I : std_logic_vector(11 downto 0) := (others => '0');
variable Q : std_logic_vector(11 downto 0) := (others => '0');
begin
sample_value_ref := cycle / 3;
for j in 0 to 3 loop
Q := std_logic_vector(to_signed(8*sample_value_ref+2*j+1, 12));
I := std_logic_vector(to_signed(8*sample_value_ref+2*j, 12));
four_sample_buffer := Q & I & four_sample_buffer(95 downto 24);
end loop;
buffer_offset := (cycle mod 3) * 32;
return four_sample_buffer(31+buffer_offset downto buffer_offset);
end function data_gen_packed;
impure function data_gen (count : natural) return std_logic_vector is impure function data_gen (count : natural) return std_logic_vector is
variable eight_bit_msw_i : std_logic_vector(7 downto 0); variable eight_bit_msw_i : std_logic_vector(7 downto 0);
variable eight_bit_msw_q : std_logic_vector(7 downto 0); variable eight_bit_msw_q : std_logic_vector(7 downto 0);
@ -98,7 +125,7 @@ begin
done <= rx_done and tx_done; done <= rx_done and tx_done;
rx_sample_stream : process rx_sample_stream : process
constant BLOCK_SIZE : natural := 512; constant BLOCK_SIZE : natural := GPIF_BUF_SIZE_SS;
variable count : natural := START_COUNT; variable count : natural := START_COUNT;
variable req_time : time; variable req_time : time;
begin begin
@ -151,9 +178,10 @@ begin
end process; end process;
tx_sample_stream : process tx_sample_stream : process
constant TIME_BETWEEN_ITERATIONS : natural := 4593; constant TIME_BETWEEN_ITERATIONS : natural := 7000;
constant BLOCK_SIZE : natural := 512; constant BLOCK_SIZE : natural := GPIF_BUF_SIZE_SS;
variable count : natural := START_COUNT; variable count : natural := START_COUNT;
variable cycle : natural := 0;
variable timestamp_cntr : natural := 400; variable timestamp_cntr : natural := 400;
variable header_len : natural := 0; variable header_len : natural := 0;
variable data_out : std_logic_vector(31 downto 0); variable data_out : std_logic_vector(31 downto 0);
@ -223,7 +251,11 @@ begin
for i in 1 to (BLOCK_SIZE - header_len) loop for i in 1 to (BLOCK_SIZE - header_len) loop
gpif_state_tx <= TX_SAMPLES; gpif_state_tx <= TX_SAMPLES;
data_out := data_gen(count); data_out := data_gen(count);
if( eight_bit_mode_en = '1' ) then if packed_mode_en = '1' then
data_out := data_gen_packed(cycle);
end if;
if( eight_bit_mode_en = '1' or packed_mode_en = '1' ) then
fx3_gpif <= data_out; fx3_gpif <= data_out;
tx_data <= data_out; tx_data <= data_out;
else else
@ -232,6 +264,7 @@ begin
end if; end if;
wait until rising_edge( fx3_pclk ); wait until rising_edge( fx3_pclk );
cycle := cycle + 1;
count := (count + 4) mod 128 when eight_bit_mode_en = '1' else count := (count + 4) mod 128 when eight_bit_mode_en = '1' else
(count + 2) mod 2048; (count + 2) mod 2048;
gpif_state_tx <= IDLE; gpif_state_tx <= IDLE;
@ -242,7 +275,7 @@ begin
nop(fx3_pclk, 10); nop(fx3_pclk, 10);
end loop; end loop;
wait for 1 ms; wait for 1.5 ms;
dma_tx_enable <= '0'; dma_tx_enable <= '0';
wait for 10 us; wait for 10 us;
end loop; end loop;
@ -333,7 +366,7 @@ begin
done <= rx_done and tx_done; done <= rx_done and tx_done;
rx_sample_stream : process rx_sample_stream : process
constant BLOCK_SIZE : natural := 512; constant BLOCK_SIZE : natural := GPIF_BUF_SIZE_SS;
variable count : natural := START_COUNT; variable count : natural := START_COUNT;
variable req_time : time; variable req_time : time;
begin begin
@ -387,7 +420,7 @@ begin
tx_sample_stream : process tx_sample_stream : process
constant TIME_BETWEEN_ITERATIONS : natural := 4556; constant TIME_BETWEEN_ITERATIONS : natural := 4556;
constant BLOCK_SIZE : natural := 512; constant BLOCK_SIZE : natural := GPIF_BUF_SIZE_SS;
variable count : natural := START_COUNT; variable count : natural := START_COUNT;
variable timestamp_cntr : natural := 250; variable timestamp_cntr : natural := 250;
variable header_len : natural := 0; variable header_len : natural := 0;

View file

@ -0,0 +1,280 @@
-- Copyright (c) 2024 Nuand LLC
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-- THE SOFTWARE.
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.math_real.all;
use ieee.math_complex.all;
library work;
use work.util.all;
use work.fx3_gpif_p.all;
architecture micro_dma_fifo_stress of fx3_model is
constant PCLK_HALF_PERIOD : time := 1 sec * (1.0/100.0e6/2.0);
constant START_COUNT : natural := 32;
constant BLOCKS_PER_ITERATION : natural := 7;
constant ITERATIONS : natural := 4;
-- Control mapping
alias dma0_rx_ack is fx3_ctl( 0);
alias dma1_rx_ack is fx3_ctl( 1);
alias dma2_tx_ack is fx3_ctl( 2);
alias dma3_tx_ack is fx3_ctl( 3);
alias dma_rx_enable is fx3_ctl( 4);
alias dma_tx_enable is fx3_ctl( 5);
alias dma_idle is fx3_ctl( 6);
alias system_reset is fx3_ctl( 7);
alias dma0_rx_reqx is fx3_ctl( 8);
alias dma1_rx_reqx is fx3_ctl(12); -- due to 9 being connected to dclk
alias dma2_tx_reqx is fx3_ctl(10);
alias dma3_tx_reqx is fx3_ctl(11);
type gpif_state_t is (IDLE, TX_META, TX_SAMPLES, RX_SAMPLES);
signal gpif_state_rx, gpif_state_tx : gpif_state_t;
signal rx_done : boolean := false;
signal tx_done : boolean := false;
signal rx_data : std_logic_vector(31 downto 0);
signal tx_data : std_logic_vector(31 downto 0);
impure function data_gen (count : natural) return std_logic_vector is
variable eight_bit_msw_i : std_logic_vector(7 downto 0);
variable eight_bit_msw_q : std_logic_vector(7 downto 0);
variable eight_bit_lsw_i : std_logic_vector(7 downto 0);
variable eight_bit_lsw_q : std_logic_vector(7 downto 0);
variable msw, lsw : std_logic_vector(15 downto 0);
begin
if( eight_bit_mode_en = '1' ) then
eight_bit_lsw_i := std_logic_vector(to_unsigned(count, 8));
eight_bit_lsw_q := std_logic_vector(to_unsigned(count+1, 8));
eight_bit_msw_i := std_logic_vector(to_unsigned(count+2, 8));
eight_bit_msw_q := std_logic_vector(to_unsigned(count+3, 8));
lsw := eight_bit_lsw_q & eight_bit_lsw_i;
msw := eight_bit_msw_q & eight_bit_msw_i;
else
msw := std_logic_vector(to_signed(count+1, 16));
lsw := std_logic_vector(to_signed(count, 16));
end if;
return (msw & lsw);
end function data_gen;
impure function data_check (count : natural ; rxdata : std_logic_vector(31 downto 0)) return boolean is
begin
return (rxdata = data_gen(count));
end function data_check;
begin
-- DCLK which isn't used
fx3_ctl(9) <= '0';
fx3_ctl(3 downto 0) <= (others => 'Z');
-- Create a 100MHz clock output
fx3_pclk <= not fx3_pclk after PCLK_HALF_PERIOD when (not rx_done or not tx_done) else '0';
-- Doneness
done <= rx_done and tx_done;
rx_sample_stream : process
constant BLOCK_SIZE : natural := GPIF_BUF_SIZE_SS;
variable count : natural := START_COUNT;
variable req_time : time;
begin
gpif_state_rx <= IDLE;
dma0_rx_reqx <= '1';
dma1_rx_reqx <= '1';
dma_rx_enable <= '0';
rx_data <= (others => 'U');
wait until rising_edge(fx3_pclk) and system_reset = '0';
nop(fx3_pclk, 1000);
wait until rising_edge(fx3_pclk) and fx3_rx_en = '1';
wait for 30 us;
for j in 1 to ITERATIONS loop
dma_rx_enable <= '1';
for i in 1 to BLOCKS_PER_ITERATION loop
dma0_rx_reqx <= '0';
req_time := now;
wait until rising_edge( fx3_pclk ) and dma0_rx_ack = '1';
wait until rising_edge( fx3_pclk );
dma0_rx_reqx <= '1';
report "RX iteration " & to_string(j) & " block " & to_string(i) & " delay " & to_string(now - req_time);
for i in 1 to BLOCK_SIZE loop
gpif_state_rx <= RX_SAMPLES;
rx_data <= fx3_gpif;
wait until rising_edge( fx3_pclk );
--assert data_check(count, rx_data) severity failure;
count := (count + 1) mod 2048;
gpif_state_rx <= IDLE;
rx_data <= (others => 'X');
end loop;
end loop;
dma_rx_enable <= '0';
wait for 10 us;
end loop;
report "Done with RX sample stream";
rx_done <= true;
wait;
end process;
tx_sample_stream : process
constant TIME_BETWEEN_ITERATIONS : natural := 4593;
constant BLOCK_SIZE : natural := GPIF_BUF_SIZE_SS;
variable count : natural := START_COUNT;
variable timestamp_cntr : natural := 400;
variable header_len : natural := 0;
variable data_out : std_logic_vector(31 downto 0);
variable req_time : time;
begin
gpif_state_tx <= IDLE;
dma2_tx_reqx <= '1';
dma3_tx_reqx <= '1';
dma_tx_enable <= '0';
fx3_gpif <= (others =>'Z');
wait until rising_edge(fx3_pclk) and system_reset = '0';
nop(fx3_pclk, 1000);
wait until rising_edge(fx3_pclk) and fx3_tx_en = '1';
wait for 30 us;
for k in 1 to ITERATIONS loop
dma_tx_enable <= '1';
for fifo_stress_idx in 1 to 3 loop
for j in 1 to BLOCKS_PER_ITERATION loop
header_len := 0;
dma3_tx_reqx <= '0';
req_time := now;
wait until rising_edge( fx3_pclk ) and dma3_tx_ack = '1';
wait until rising_edge( fx3_pclk );
wait until rising_edge( fx3_pclk );
wait until rising_edge( fx3_pclk );
dma3_tx_reqx <= '1';
report "TX iteration " & to_string(k) & " block " & to_string(j) & " delay " & to_string(now - req_time);
if( fx3_tx_meta_en = '1') then
header_len := 4;
for i in 1 to 4 loop
case (i) is
when 1 =>
data_out := x"00000000";
when 2 =>
data_out(31 downto 0) := std_logic_vector(to_signed(timestamp_cntr, 32));
if (j = BLOCKS_PER_ITERATION) then
timestamp_cntr := timestamp_cntr + TIME_BETWEEN_ITERATIONS;
else
timestamp_cntr := timestamp_cntr + 254;
end if;
when 3 =>
data_out := (others => '0');
when 4 =>
data_out := (others => '1');
end case;
gpif_state_tx <= TX_META;
fx3_gpif <= data_out;
tx_data <= data_out;
wait until rising_edge( fx3_pclk );
gpif_state_tx <= IDLE;
tx_data <= (others => 'X');
end loop;
end if;
count := 0;
for i in 1 to (BLOCK_SIZE - header_len) loop
gpif_state_tx <= TX_SAMPLES;
data_out := data_gen(count);
if( eight_bit_mode_en = '1' ) then
fx3_gpif <= data_out;
tx_data <= data_out;
else
fx3_gpif <= std_logic_vector(to_unsigned(j, 8)) & data_out(23 downto 0);
tx_data <= std_logic_vector(to_unsigned(j, 8)) & data_out(23 downto 0);
end if;
wait until rising_edge( fx3_pclk );
count := (count + 4) mod 128 when eight_bit_mode_en = '1' else
(count + 2) mod 2048;
gpif_state_tx <= IDLE;
tx_data <= (others => 'X');
end loop;
fx3_gpif <= (others =>'Z');
nop(fx3_pclk, 10);
end loop;
wait for 10 us;
end loop;
wait for 2 ms;
dma_tx_enable <= '0';
wait for 10 us;
end loop;
report "Done with TX sample stream";
tx_done <= true;
wait;
end process;
reset_system : process
begin
system_reset <= '1';
dma_idle <= '0';
nop( fx3_pclk, 100 );
system_reset <= '0';
nop( fx3_pclk, 10 );
dma_idle <= '1';
wait;
end process;
-- TODO: UART Interface
fx3_uart_txd <= '1';
fx3_uart_cts <= '1';
assert (gpif_state_tx = IDLE and gpif_state_rx /= IDLE)
or (gpif_state_rx = IDLE and gpif_state_tx /= IDLE)
or (gpif_state_rx = IDLE and gpif_state_tx = IDLE)
report "gpif_state_rx and gpif_state_tx cannot both be non-idle"
severity failure;
end architecture micro_dma_fifo_stress;

View file

@ -108,7 +108,20 @@ entity nios_system is
tx_trigger_ctl_out_port : out std_logic_vector(7 downto 0); -- out_port tx_trigger_ctl_out_port : out std_logic_vector(7 downto 0); -- out_port
xb_gpio_in_port : in std_logic_vector(31 downto 0) := (others => 'X'); -- in_port xb_gpio_in_port : in std_logic_vector(31 downto 0) := (others => 'X'); -- in_port
xb_gpio_out_port : out std_logic_vector(31 downto 0); -- out_port xb_gpio_out_port : out std_logic_vector(31 downto 0); -- out_port
xb_gpio_dir_export : out std_logic_vector(31 downto 0) -- export xb_gpio_dir_export : out std_logic_vector(31 downto 0); -- export
arbiter_request : in std_logic_vector(1 downto 0) := (others => 'X'); -- request
arbiter_granted : out std_logic_vector(1 downto 0); -- granted
arbiter_ack : in std_logic_vector(1 downto 0) := (others => 'X'); -- ack
wbm_wb_clk_i : in std_logic := 'X'; -- clk_i
wbm_wb_rst_i : in std_logic := 'X'; -- rst_i
wbm_wb_adr_o : out std_logic_vector(31 downto 0); -- adr_o
wbm_wb_dat_o : out std_logic_vector(31 downto 0); -- dat_o
wbm_wb_dat_i : in std_logic_vector(31 downto 0) := (others => 'X'); -- dat_i
wbm_wb_we_o : out std_logic; -- we_o
wbm_wb_sel_o : out std_logic; -- sel_o
wbm_wb_stb_o : out std_logic; -- stb_o
wbm_wb_ack_i : in std_logic := 'X'; -- ack_i
wbm_wb_cyc_o : out std_logic -- cyc_o
); );
end entity ; end entity ;
@ -142,5 +155,14 @@ begin
xb_gpio_out_port <= (others =>'0') ; xb_gpio_out_port <= (others =>'0') ;
xb_gpio_dir_export <= (others =>'0') ; xb_gpio_dir_export <= (others =>'0') ;
arbiter_granted <= (others => '0');
wbm_wb_adr_o <= (others => '0');
wbm_wb_dat_o <= (others => '0');
wbm_wb_we_o <= '0';
wbm_wb_sel_o <= '0';
wbm_wb_stb_o <= '0';
wbm_wb_cyc_o <= '0';
end architecture ; end architecture ;

View file

@ -0,0 +1,706 @@
-- Copyright (c) 2022 Nuand LLC
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-- THE SOFTWARE.
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library rtl_work;
library altera_lnsim;
use altera_lnsim.altera_pll;
library nuand;
use nuand.util.all ;
use nuand.fifo_readwrite_p.all;
use nuand.common_dcfifo_p.all;
use nuand.bladerf_p.all;
entity rx_counter_8bit_tb is
generic (
-- For bladeRF2 (2x2 MIMO):
NUM_MIMO_STREAMS : natural := 2;
FIFO_READER_READ_THROTTLE : natural := 0;
ENABLE_CHANNEL_0 : std_logic := '1';
ENABLE_CHANNEL_1 : std_logic := '0';
EIGHT_BIT_MODE_EN : std_logic := '1'
);
end entity;
architecture arch of rx_counter_8bit_tb is
-- bladerf-hosted uses ad9361.clock (125 MHz) for rx_clock and tx_clock
constant SYSCLK_HALF_PERIOD : time := 1 sec * (1.0/125.0e6/2.0);
-- For reasons unknown, simulation of this system in ModelSim requires that
-- wrreq and data be asserted shortly before the rising clock edge. Sigh...
constant FIFO_WORKAROUND : time := 1 ps;
type fx3_control_t is record
usb_speed : std_logic;
tx_enable : std_logic;
rx_enable : std_logic;
meta_enable : std_logic;
packet : std_logic;
end record;
type fx3_gpif_t is record
gpif_in : std_logic_vector(31 downto 0);
gpif_out : std_logic_vector(31 downto 0);
gpif_oe : std_logic;
ctl_in : std_logic_vector(12 downto 0);
ctl_out : std_logic_vector(12 downto 0);
ctl_oe : std_logic_vector(12 downto 0);
end record;
type rx_mux_mode_t is (
RX_MUX_NORMAL,
RX_MUX_12BIT_COUNTER,
RX_MUX_32BIT_COUNTER,
RX_MUX_ENTROPY,
RX_MUX_DIGITAL_LOOPBACK
);
signal sys_rst : std_logic := '1';
signal done : boolean := false;
signal fx3_pclk : std_logic := '1';
signal fx3_pclk_pll : std_logic := '1';
signal sys_clk : std_logic := '1';
signal pll_reset : std_logic := '0';
signal pll_locked : std_logic := '0';
signal fx3_control : fx3_control_t;
signal fx3_gpif : fx3_gpif_t;
signal fx3_gpif_i : std_logic_vector(31 downto 0);
signal fx3_ctl_i : std_logic_vector(12 downto 0);
-- Control mapping
alias dma0_rx_ack is fx3_ctl_i( 0);
alias dma1_rx_ack is fx3_ctl_i( 1);
alias dma2_tx_ack is fx3_ctl_i( 2);
alias dma3_tx_ack is fx3_ctl_i( 3);
alias dma_rx_enable is fx3_ctl_i( 4);
alias dma_tx_enable is fx3_ctl_i( 5);
alias dma_idle is fx3_ctl_i( 6);
alias system_reset is fx3_ctl_i( 7);
alias dma0_rx_reqx is fx3_ctl_i( 8);
alias dma1_rx_reqx is fx3_ctl_i(12); -- due to 9 being connected to dclk
alias dma2_tx_reqx is fx3_ctl_i(10);
alias dma3_tx_reqx is fx3_ctl_i(11);
signal loopback_i : signed(15 downto 0) := (others =>'0');
signal loopback_q : signed(15 downto 0) := (others =>'0');
signal loopback_valid : std_logic := '0';
signal loopback_enabled : std_logic := '0';
signal tx_clock : std_logic := '1' ;
signal rx_clock : std_logic := '1' ;
signal rx_sample_fifo : rx_fifo_t := RX_FIFO_T_DEFAULT;
signal tx_sample_fifo : tx_fifo_t := TX_FIFO_T_DEFAULT;
signal loopback_fifo : loopback_fifo_t := LOOPBACK_FIFO_T_DEFAULT;
signal rx_meta_fifo : meta_fifo_rx_t := META_FIFO_RX_T_DEFAULT;
signal tx_meta_fifo : meta_fifo_tx_t := META_FIFO_TX_T_DEFAULT;
signal rx_mux_i : signed(15 downto 0);
signal rx_mux_q : signed(15 downto 0);
signal rx_mux_valid : std_logic;
signal rx_mux_mode : rx_mux_mode_t := RX_MUX_32BIT_COUNTER;
signal tx_timestamp : unsigned(63 downto 0) := ( others => '0' );
signal rx_timestamp : unsigned(63 downto 0) := ( others => '0' );
constant FX3_HALF_PERIOD : time := 1.0/(100.0e6)/2.0*1 sec ;
constant TX_HALF_PERIOD : time := 1.0/(9.0e6)/2.0*1 sec ;
constant RX_HALF_PERIOD : time := 1.0/(9.0e6)/2.0*1 sec ;
signal dac_controls : sample_controls_t(0 to NUM_MIMO_STREAMS-1) := (others => SAMPLE_CONTROL_DISABLE);
signal dac_streams : sample_streams_t(dac_controls'range) := (others => ZERO_SAMPLE);
signal adc_controls : sample_controls_t(0 to NUM_MIMO_STREAMS-1) := (others => SAMPLE_CONTROL_DISABLE);
signal adc_streams : sample_streams_t(adc_controls'range) := (others => ZERO_SAMPLE);
signal tx_reset : std_logic := '0';
signal tx_ts_reset : std_logic := '0';
signal rx_reset : std_logic := '0';
signal rx_ts_reset : std_logic := '0';
signal meta_en_tx : std_logic := '0';
signal meta_en_rx : std_logic := '0';
signal rx_packet_control : packet_control_t := PACKET_CONTROL_DEFAULT;
signal tx_packet_control : packet_control_t;
signal rx_packet_ready : std_logic;
signal trigger_signal_sync_tb : std_logic;
signal adc_stream_val_at_rx_enable : signed(15 downto 0) := ( others => '0' );
function data_gen (count : natural) return std_logic_vector is
variable msw, lsw : std_logic_vector(15 downto 0);
begin
msw := std_logic_vector(to_signed(count, 16));
lsw := std_logic_vector(to_signed(-count, 16));
return (msw & lsw);
end function data_gen;
begin
-- ========================================================================
-- Brief summary of data flow
-- ========================================================================
--
-- Simulated samples flow from fx3_model's TX side to its RX side. The
-- validity of the data is checked there.
--
-- entity U_fx3_model FX3 model, TX process
-- signal fx3_gpif_i fx3_gpif.gpif_oe is '0'
-- process register_gpif
-- signal fx3_gpif.gpif_in Demuxed GPIF interface (FX3 -> FPGA)
-- entity U_fx3_gpif GPIF implementation, write side
-- signal tx_sample_fifo.w* TX fifo, write side
-- entity U_tx_sample_fifo
-- signal tx_sample_fifo.r* TX fifo, read side
-- process tx_mux
-- signal loopback_fifo.w* Loopback fifo, write side
-- entity U_rx_loopback_fifo
-- signal loopback_fifo.r* Loopback fifo, read side
-- process loopback_fifo_control
-- signal loopback_{i,q,valid}
-- process rx_mux
-- signal rx_mux_{i,q,valid}
-- entity U_fifo_writer
-- signal rx_sample_fifo.w* RX fifo, write side
-- entity U_rx_sample_fifo
-- signal rx_sample_fifo.r* RX fifo, read side
-- entity U_fx3_gpif GPIF implementation, read side
-- signal fx3_gpif.gpif_out Demuxed GPIF interface (FPGA -> FX3)
-- process register_gpif
-- signal fx3_gpif_i fx3_gpif.gpif_oe is '1'
-- entity U_fx3_model FX3 model, RX process
-- ========================================================================
-- Instantiations
-- ========================================================================
-- Unit under test
-- Clock domain: fx3_pclk_pll
U_fx3_gpif : entity nuand.fx3_gpif
port map (
pclk => fx3_pclk_pll,
reset => sys_rst,
usb_speed => fx3_control.usb_speed,
gpif_in => fx3_gpif.gpif_in,
gpif_out => fx3_gpif.gpif_out,
gpif_oe => fx3_gpif.gpif_oe,
ctl_in => fx3_gpif.ctl_in,
ctl_out => fx3_gpif.ctl_out,
ctl_oe => fx3_gpif.ctl_oe,
tx_enable => fx3_control.tx_enable,
rx_enable => fx3_control.rx_enable,
meta_enable => fx3_control.meta_enable,
packet_enable => fx3_control.packet,
tx_fifo_write => tx_sample_fifo.wreq,
tx_fifo_full => tx_sample_fifo.wfull,
tx_fifo_empty => tx_sample_fifo.wempty,
tx_fifo_usedw => tx_sample_fifo.wused,
tx_fifo_data => tx_sample_fifo.wdata,
tx_timestamp => tx_timestamp,
tx_meta_fifo_write => tx_meta_fifo.wreq,
tx_meta_fifo_full => tx_meta_fifo.wfull,
tx_meta_fifo_empty => tx_meta_fifo.wempty,
tx_meta_fifo_usedw => tx_meta_fifo.wused,
tx_meta_fifo_data => tx_meta_fifo.wdata,
rx_fifo_read => rx_sample_fifo.rreq,
rx_fifo_full => rx_sample_fifo.rfull,
rx_fifo_empty => rx_sample_fifo.rempty,
rx_fifo_usedw => rx_sample_fifo.rused,
rx_fifo_data => rx_sample_fifo.rdata,
rx_meta_fifo_read => rx_meta_fifo.rreq,
rx_meta_fifo_full => rx_meta_fifo.rfull,
rx_meta_fifo_empty => rx_meta_fifo.rempty,
rx_meta_fifo_usedr => rx_meta_fifo.rused,
rx_meta_fifo_data => rx_meta_fifo.rdata
);
-- Discrete control signals for fx3_gpif
fx3_control.usb_speed <= '0';
fx3_control.meta_enable <= '0';
fx3_control.packet <= '0';
U_pkt_gen : entity nuand.rx_packet_generator
port map(
rx_clock => rx_clock,
rx_reset => rx_reset,
rx_enable => fx3_control.rx_enable,
rx_packet_enable => fx3_control.packet,
rx_packet_ready => rx_packet_ready,
rx_packet_control => rx_packet_control
);
meta_en_tx <= fx3_control.meta_enable;
meta_en_rx <= fx3_control.meta_enable;
increment_tx_ts : process(tx_clock)
variable ping : boolean := true ;
begin
if( rising_edge(tx_clock) ) then
ping := not ping ;
if( ping = true ) then
tx_timestamp <= tx_timestamp + 1 ;
end if ;
end if ;
end process ;
increment_rx_ts : process(rx_clock)
variable ping : boolean := true ;
begin
if( rising_edge(rx_clock) ) then
ping := not ping ;
if( ping = true ) then
rx_timestamp <= rx_timestamp + 1 ;
end if ;
end if ;
end process ;
-- Model of FX3's GPIF interface
-- Clock domain: fx3_pclk (source)
U_fx3_model : entity nuand.fx3_model(micro_dma)
port map (
fx3_pclk => fx3_pclk,
fx3_gpif => fx3_gpif_i,
fx3_ctl => fx3_ctl_i,
fx3_uart_rxd => '0',
fx3_uart_txd => open,
fx3_uart_cts => open,
fx3_rx_en => '1',
fx3_rx_meta_en => meta_en_rx,
fx3_tx_en => '1',
fx3_tx_meta_en => meta_en_tx,
eight_bit_mode_en => EIGHT_BIT_MODE_EN,
done => done
);
-- Generate phase-shifted PLL clock
U_fx3_pll : entity rtl_work.fx3_pll
port map (
inclk0 => fx3_pclk,
areset => pll_reset,
c0 => fx3_pclk_pll,
locked => pll_locked
);
tx_clock <= not tx_clock after TX_HALF_PERIOD ;
rx_clock <= not rx_clock after RX_HALF_PERIOD ;
-- Reset handler
sys_rst <= '0' after 100 ns;
-- Generate system clock
sys_clk <= not sys_clk after SYSCLK_HALF_PERIOD when not done else '0';
tx_reset <= sys_rst;
tx_ts_reset <= sys_rst;
rx_reset <= sys_rst;
rx_ts_reset <= sys_rst;
meta_en_tx <= fx3_control.meta_enable;
meta_en_rx <= fx3_control.meta_enable;
-- TX Submodule
U_tx : entity work.tx
generic map (
NUM_STREAMS => dac_controls'length
)
port map (
tx_reset => tx_reset,
tx_clock => tx_clock,
tx_enable => fx3_control.tx_enable,
meta_en => meta_en_tx,
timestamp_reset => tx_ts_reset,
usb_speed => fx3_control.usb_speed,
tx_underflow_led => open,
tx_timestamp => tx_timestamp,
-- Triggering
trigger_arm => '0',
trigger_fire => '0',
trigger_master => '0',
trigger_line => open,
-- Packet FIFO
packet_en => fx3_control.packet,
packet_empty => open,
packet_control => tx_packet_control,
packet_ready => '1',
-- 8-bit mode
eight_bit_mode_en => EIGHT_BIT_MODE_EN,
-- Samples from host via FX3
sample_fifo_wclock => fx3_pclk_pll,
sample_fifo_wreq => tx_sample_fifo.wreq,
sample_fifo_wdata => tx_sample_fifo.wdata,
sample_fifo_wempty => tx_sample_fifo.wempty,
sample_fifo_wfull => tx_sample_fifo.wfull,
sample_fifo_wused => tx_sample_fifo.wused,
-- Metadata from host via FX3
meta_fifo_wclock => fx3_pclk_pll,
meta_fifo_wreq => tx_meta_fifo.wreq,
meta_fifo_wdata => tx_meta_fifo.wdata,
meta_fifo_wempty => tx_meta_fifo.wempty,
meta_fifo_wfull => tx_meta_fifo.wfull,
meta_fifo_wused => tx_meta_fifo.wused,
-- Digital Loopback Interface
loopback_enabled => '0',
loopback_fifo_wdata => loopback_fifo.wdata,
loopback_fifo_wreq => loopback_fifo.wreq,
loopback_fifo_wfull => loopback_fifo.wfull,
loopback_fifo_wused => loopback_fifo.wused,
-- RFFE Interface
dac_controls => dac_controls,
dac_streams => dac_streams
);
-- RX Submodule
U_rx : entity work.rx
generic map (
NUM_STREAMS => adc_controls'length
)
port map (
rx_reset => rx_reset,
rx_clock => rx_clock,
rx_enable => fx3_control.rx_enable,
meta_en => meta_en_rx,
timestamp_reset => rx_ts_reset,
usb_speed => fx3_control.usb_speed,
rx_mux_sel => to_unsigned(2, 3),
rx_overflow_led => open,
rx_timestamp => rx_timestamp,
-- Triggering
trigger_arm => '0',
trigger_fire => '0',
trigger_master => '0',
trigger_line => open,
trigger_signal_sync_tb => trigger_signal_sync_tb,
-- Packet FIFO
packet_en => fx3_control.packet,
packet_control => rx_packet_control,
packet_ready => rx_packet_ready,
-- 8-bit mode
eight_bit_mode_en => EIGHT_BIT_MODE_EN,
-- Samples to host via FX3
sample_fifo_rclock => fx3_pclk_pll,
sample_fifo_raclr => not fx3_control.rx_enable,
sample_fifo_rreq => rx_sample_fifo.rreq,
sample_fifo_rdata => rx_sample_fifo.rdata,
sample_fifo_rempty => rx_sample_fifo.rempty,
sample_fifo_rfull => rx_sample_fifo.rfull,
sample_fifo_rused => rx_sample_fifo.rused,
-- Mini expansion signals
mini_exp => "00",
-- Metadata to host via FX3
meta_fifo_rclock => fx3_pclk_pll,
meta_fifo_raclr => not fx3_control.rx_enable,
meta_fifo_rreq => rx_meta_fifo.rreq,
meta_fifo_rdata => rx_meta_fifo.rdata,
meta_fifo_rempty => rx_meta_fifo.rempty,
meta_fifo_rfull => rx_meta_fifo.rfull,
meta_fifo_rused => rx_meta_fifo.rused,
-- Digital Loopback Interface
loopback_fifo_wenabled => open,
loopback_fifo_wreset => tx_reset,
loopback_fifo_wclock => tx_clock,
loopback_fifo_wdata => loopback_fifo.wdata,
loopback_fifo_wreq => loopback_fifo.wreq,
loopback_fifo_wfull => loopback_fifo.wfull,
loopback_fifo_wused => loopback_fifo.wused,
-- RFFE Interface
adc_controls => adc_controls,
adc_streams => adc_streams
);
-- ========================================================================
-- Data converters
-- ========================================================================
gen_dac_controls : if( NUM_MIMO_STREAMS > 1 ) generate
-- The TX side of the AD9361 HDL is a FIFO pull interface
-- that expects a readahead FIFO. It toggles the data request
-- signal every other cycle. This behavior is mimicked here.
process( tx_clock, sys_rst )
begin
if( sys_rst = '1' ) then
dac_controls <= (
0 => (enable => ENABLE_CHANNEL_0, data_req => '1'),
1 => (enable => ENABLE_CHANNEL_1, data_req => '1')
);
elsif( rising_edge(tx_clock) ) then
for i in dac_controls'range loop
dac_controls(i) <= (
enable => dac_controls(i).enable,
data_req => not dac_controls(i).data_req );
end loop;
end if;
end process;
else generate
dac_controls <= (others => SAMPLE_CONTROL_ENABLE);
end generate;
gen_adc_controls : if( NUM_MIMO_STREAMS > 1 ) generate
process( rx_clock, sys_rst )
constant SIGMA_DELTA_BITS : signed (3 downto 0) := "0000";
constant COUNT_RESET : integer := 0;
variable count : integer range -2047 to 2047 := COUNT_RESET;
begin
if( sys_rst = '1' ) then
count := COUNT_RESET;
adc_controls <= (
0 => (enable => ENABLE_CHANNEL_0, data_req => '1'),
1 => (enable => ENABLE_CHANNEL_1, data_req => '1')
);
elsif( rising_edge(rx_clock) ) then
for i in adc_controls'range loop
adc_controls(i) <= (
enable => adc_controls(i).enable,
data_req => not adc_controls(i).data_req );
if( adc_controls(i).enable = '1') then
if( adc_streams(i).data_v = '1' ) then
if( EIGHT_BIT_MODE_EN = '1' ) then
adc_streams(i).data_i <= "0000" & to_signed(count, 8) & SIGMA_DELTA_BITS;
adc_streams(i).data_q <= "0000" & to_signed(-count, 8) & SIGMA_DELTA_BITS;
count := (count + 1) mod 128;
else
adc_streams(i).data_i <= to_signed(count, 16);
adc_streams(i).data_q <= to_signed(-count, 16);
count := (count + 1) mod 2048;
end if;
end if;
adc_streams(i).data_v <= not adc_streams(i).data_v;
end if;
end loop;
end if;
end process;
else generate
adc_controls <= (others => SAMPLE_CONTROL_ENABLE);
end generate;
-- ========================================================================
-- Processes
-- ========================================================================
-- FX3 GPIF bidirectional signal control
-- Adapted from same process in bladerf-hosted.vhd
register_gpif : process(sys_rst, fx3_pclk_pll)
begin
if( sys_rst = '1' ) then
fx3_gpif_i <= (others => 'Z');
fx3_gpif.gpif_in <= (others => 'Z');
elsif( rising_edge(fx3_pclk_pll) ) then
fx3_gpif.gpif_in <= fx3_gpif_i;
if( fx3_gpif.gpif_oe = '1' ) then
fx3_gpif_i <= fx3_gpif.gpif_out;
else
fx3_gpif_i <= (others =>'Z');
end if;
end if;
end process;
-- FX3 CTL bidirectional signals
-- Adapted from same generator in bladerf-hosted.vhd
generate_ctl : for i in fx3_ctl_i'range generate
fx3_ctl_i(i) <= fx3_gpif.ctl_out(i) when fx3_gpif.ctl_oe(i) = '1' else 'Z';
end generate;
fx3_gpif.ctl_in <= fx3_ctl_i;
-- Controller for loopback FIFO
-- Stripped-down version of same process from rx.vhd
loopback_fifo_control : process( sys_rst, loopback_fifo.rclock )
begin
if( sys_rst = '1' ) then
loopback_enabled <= '0';
loopback_fifo.rreq <= '0';
loopback_i <= (others => '0');
loopback_q <= (others => '0');
loopback_valid <= '0';
elsif( rising_edge(loopback_fifo.rclock) ) then
loopback_enabled <= '0';
loopback_fifo.rreq <= '0';
loopback_i <= loopback_i;
loopback_q <= loopback_q;
loopback_valid <= '0';
-- Is loopback enabled?
loopback_enabled <= fx3_control.rx_enable;
-- Do the loopback
loopback_i <= resize(signed(loopback_fifo.rdata(15 downto 0)), loopback_i'length);
loopback_q <= resize(signed(loopback_fifo.rdata(31 downto 16)), loopback_q'length);
loopback_valid <= loopback_fifo.rreq and not loopback_fifo.rempty;
-- Read from the FIFO if req'd
loopback_fifo.rreq <= loopback_enabled and (not loopback_fifo.rempty);
end if;
end process;
-- RX multiplexer
-- Stripped-down version of same process from rx.vhd
rx_mux : process(sys_rst, sys_clk)
begin
if( sys_rst = '1' ) then
rx_mux_i <= (others =>'0');
rx_mux_q <= (others =>'0');
rx_mux_valid <= '0';
elsif( rising_edge(sys_clk) ) then
rx_mux_i <= loopback_i;
rx_mux_q <= loopback_q;
rx_mux_valid <= loopback_valid;
end if;
end process;
-- TX multiplexer
-- Stripped-down version of mimo_channel_sel_mux from tx.vhd
--tx_mux : process( sys_clk )
--begin
-- if( rising_edge(sys_clk) ) then
-- tx_sample_fifo.rreq <= not tx_sample_fifo.rempty;
-- loopback_fifo.wdata <= tx_sample_fifo.rdata;
-- loopback_fifo.wreq <= tx_sample_fifo.rreq and not tx_sample_fifo.rempty;
-- end if;
--end process;
-- ========================================================================
-- Verification
-- ========================================================================
--
-- Check for metavalues
-- We should never see metavalues written to the FIFOs
--
check_fifo_write : process(fx3_pclk_pll) is
begin
if( rising_edge(fx3_pclk_pll) ) then
if( tx_sample_fifo.wreq = '1' and fx3_control.meta_enable = '0' ) then
for i in tx_sample_fifo.wdata'range loop
assert tx_sample_fifo.wdata(i) = '0' or tx_sample_fifo.wdata(i) = '1'
severity failure;
end loop;
end if;
end if;
end process;
check_fifo_read : process(fx3_pclk_pll) is
begin
if( rising_edge(fx3_pclk_pll) ) then
if( rx_sample_fifo.rreq = '1' ) then
for i in rx_sample_fifo.rdata'range loop
assert rx_sample_fifo.rdata(i) = '0' or rx_sample_fifo.rdata(i) = '1'
severity failure;
end loop;
end if;
end if;
end process check_fifo_read;
--
-- Check for fullness on FIFOs
--
assert(rx_sample_fifo.wfull = '0') report "rx_sample_fifo full (write)" severity warning;
assert(tx_sample_fifo.wfull = '0') report "tx_sample_fifo full (write)" severity warning;
assert(loopback_fifo.wfull = '0') report "loopback_fifo full (write)" severity warning;
--
-- Rx Sample Check
--
look_for_dropped_rx_samples: process(fx3_pclk_pll)
variable rx_val : unsigned (15 downto 0) := to_unsigned(1, 16);
variable sample1_expected : std_logic_vector (15 downto 0);
variable sample0_expected : std_logic_vector (15 downto 0);
variable sample1 : std_logic_vector (15 downto 0);
variable sample0 : std_logic_vector (15 downto 0);
variable fail_count : natural := 0;
variable both_channels_en : std_logic := ENABLE_CHANNEL_0 and ENABLE_CHANNEL_1;
variable delay : std_logic := '0';
begin
if (rising_edge(fx3_pclk_pll)
and fx3_gpif.gpif_oe = '1'
and fx3_control.rx_enable = '1')
then
sample1_expected := std_logic_vector(rx_val + 1) when not both_channels_en else std_logic_vector(rx_val);
sample0_expected := std_logic_vector(rx_val);
sample1 := fx3_gpif.gpif_out(31 downto 16);
sample0 := fx3_gpif.gpif_out(15 downto 0);
if (EIGHT_BIT_MODE_EN = '1') then
assert(sample1 = sample1_expected and sample0 = sample0_expected)
report lf&"sample0 " & to_hstring(sample0) &lf&
"sample0_expected " & to_hstring(sample0_expected) &lf&
"sample1 " & to_hstring(sample1) &lf&
"sample1_expected " & to_hstring(sample1_expected)
severity failure;
rx_val := rx_val + 1 when both_channels_en else rx_val + 2;
else
-- the count doesn't spill over 16 bits
assert(sample0 = std_logic_vector(rx_val))
report lf&
"sample " & to_hstring(sample0) &lf&
"sample_expected " & to_hstring(rx_val)
severity failure;
delay := not delay when both_channels_en else '0';
rx_val := rx_val + 1 when delay = '0' else rx_val;
end if;
end if;
if (fx3_control.rx_enable = '0') then
rx_val := to_unsigned(1, rx_val'length);
delay := '0';
end if;
end process look_for_dropped_rx_samples;
end architecture;

View file

@ -0,0 +1,661 @@
-- Copyright (c) 2022 Nuand LLC
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-- THE SOFTWARE.
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library rtl_work;
library altera_lnsim;
use altera_lnsim.altera_pll;
library nuand;
use nuand.util.all ;
use nuand.fifo_readwrite_p.all;
use nuand.common_dcfifo_p.all;
use nuand.bladerf_p.all;
use nuand.fx3_gpif_p.all;
entity rx_timestamp_tb is
generic (
-- For bladeRF2 (2x2 MIMO):
NUM_MIMO_STREAMS : natural := 2;
FIFO_READER_READ_THROTTLE : natural := 0;
ENABLE_CHANNEL_0 : std_logic := '1';
ENABLE_CHANNEL_1 : std_logic := '0';
EIGHT_BIT_MODE_EN : std_logic := '1'
);
end entity;
architecture arch of rx_timestamp_tb is
-- bladerf-hosted uses ad9361.clock (125 MHz) for rx_clock and tx_clock
constant SYSCLK_HALF_PERIOD : time := 1 sec * (1.0/125.0e6/2.0);
-- For reasons unknown, simulation of this system in ModelSim requires that
-- wrreq and data be asserted shortly before the rising clock edge. Sigh...
constant FIFO_WORKAROUND : time := 1 ps;
type fx3_control_t is record
usb_speed : std_logic;
tx_enable : std_logic;
rx_enable : std_logic;
meta_enable : std_logic;
packet : std_logic;
end record;
type fx3_gpif_t is record
gpif_in : std_logic_vector(31 downto 0);
gpif_out : std_logic_vector(31 downto 0);
gpif_oe : std_logic;
ctl_in : std_logic_vector(12 downto 0);
ctl_out : std_logic_vector(12 downto 0);
ctl_oe : std_logic_vector(12 downto 0);
end record;
signal sys_rst : std_logic := '1';
signal done : boolean := false;
signal fx3_pclk : std_logic := '1';
signal fx3_pclk_pll : std_logic := '1';
signal sys_clk : std_logic := '1';
signal pll_reset : std_logic := '0';
signal pll_locked : std_logic := '0';
signal fx3_control : fx3_control_t;
signal fx3_gpif : fx3_gpif_t;
signal fx3_gpif_i : std_logic_vector(31 downto 0);
signal fx3_ctl_i : std_logic_vector(12 downto 0);
-- Control mapping
alias dma0_rx_ack is fx3_ctl_i( 0);
alias dma1_rx_ack is fx3_ctl_i( 1);
alias dma2_tx_ack is fx3_ctl_i( 2);
alias dma3_tx_ack is fx3_ctl_i( 3);
alias dma_rx_enable is fx3_ctl_i( 4);
alias dma_tx_enable is fx3_ctl_i( 5);
alias dma_idle is fx3_ctl_i( 6);
alias system_reset is fx3_ctl_i( 7);
alias dma0_rx_reqx is fx3_ctl_i( 8);
alias dma1_rx_reqx is fx3_ctl_i(12); -- due to 9 being connected to dclk
alias dma2_tx_reqx is fx3_ctl_i(10);
alias dma3_tx_reqx is fx3_ctl_i(11);
signal loopback_i : signed(15 downto 0) := (others =>'0');
signal loopback_q : signed(15 downto 0) := (others =>'0');
signal loopback_valid : std_logic := '0';
signal loopback_enabled : std_logic := '0';
signal tx_clock : std_logic := '1' ;
signal rx_clock : std_logic := '1' ;
signal rx_sample_fifo : rx_fifo_t := RX_FIFO_T_DEFAULT;
signal tx_sample_fifo : tx_fifo_t := TX_FIFO_T_DEFAULT;
signal loopback_fifo : loopback_fifo_t := LOOPBACK_FIFO_T_DEFAULT;
signal rx_meta_fifo : meta_fifo_rx_t := META_FIFO_RX_T_DEFAULT;
signal tx_meta_fifo : meta_fifo_tx_t := META_FIFO_TX_T_DEFAULT;
signal rx_mux_i : signed(15 downto 0);
signal rx_mux_q : signed(15 downto 0);
signal rx_mux_valid : std_logic;
signal tx_timestamp : unsigned(63 downto 0) := ( others => '0' );
signal rx_timestamp : unsigned(63 downto 0) := ( others => '0' );
constant FX3_HALF_PERIOD : time := 1.0/(100.0e6)/2.0*1 sec ;
constant TX_HALF_PERIOD : time := 1.0/(9.0e6)/2.0*1 sec ;
constant RX_HALF_PERIOD : time := 1.0/(9.0e6)/2.0*1 sec ;
signal dac_controls : sample_controls_t(0 to NUM_MIMO_STREAMS-1) := (others => SAMPLE_CONTROL_DISABLE);
signal dac_streams : sample_streams_t(dac_controls'range) := (others => ZERO_SAMPLE);
signal adc_controls : sample_controls_t(0 to NUM_MIMO_STREAMS-1) := (others => SAMPLE_CONTROL_DISABLE);
signal adc_streams : sample_streams_t(adc_controls'range) := (others => ZERO_SAMPLE);
signal tx_reset : std_logic := '0';
signal tx_ts_reset : std_logic := '0';
signal rx_reset : std_logic := '0';
signal rx_ts_reset : std_logic := '0';
signal meta_en_tx : std_logic := '0';
signal meta_en_rx : std_logic := '0';
signal rx_packet_control : packet_control_t := PACKET_CONTROL_DEFAULT;
signal tx_packet_control : packet_control_t;
signal trigger_signal_sync_tb : std_logic;
signal adc_stream_val_at_rx_enable : signed(15 downto 0) := ( others => '0' );
function data_gen (count : natural) return std_logic_vector is
variable msw, lsw : std_logic_vector(15 downto 0);
begin
msw := std_logic_vector(to_signed(count, 16));
lsw := std_logic_vector(to_signed(-count, 16));
return (msw & lsw);
end function data_gen;
signal rx_packet_ready : std_logic;
begin
-- ========================================================================
-- Brief summary of data flow
-- ========================================================================
--
-- Simulated samples flow from fx3_model's TX side to its RX side. The
-- validity of the data is checked there.
--
-- entity U_fx3_model FX3 model, TX process
-- signal fx3_gpif_i fx3_gpif.gpif_oe is '0'
-- process register_gpif
-- signal fx3_gpif.gpif_in Demuxed GPIF interface (FX3 -> FPGA)
-- entity U_fx3_gpif GPIF implementation, write side
-- signal tx_sample_fifo.w* TX fifo, write side
-- entity U_tx_sample_fifo
-- signal tx_sample_fifo.r* TX fifo, read side
-- process tx_mux
-- signal loopback_fifo.w* Loopback fifo, write side
-- entity U_rx_loopback_fifo
-- signal loopback_fifo.r* Loopback fifo, read side
-- process loopback_fifo_control
-- signal loopback_{i,q,valid}
-- process rx_mux
-- signal rx_mux_{i,q,valid}
-- entity U_fifo_writer
-- signal rx_sample_fifo.w* RX fifo, write side
-- entity U_rx_sample_fifo
-- signal rx_sample_fifo.r* RX fifo, read side
-- entity U_fx3_gpif GPIF implementation, read side
-- signal fx3_gpif.gpif_out Demuxed GPIF interface (FPGA -> FX3)
-- process register_gpif
-- signal fx3_gpif_i fx3_gpif.gpif_oe is '1'
-- entity U_fx3_model FX3 model, RX process
-- ========================================================================
-- Instantiations
-- ========================================================================
-- Unit under test
-- Clock domain: fx3_pclk_pll
U_fx3_gpif : entity nuand.fx3_gpif
port map (
pclk => fx3_pclk_pll,
reset => sys_rst,
usb_speed => fx3_control.usb_speed,
gpif_in => fx3_gpif.gpif_in,
gpif_out => fx3_gpif.gpif_out,
gpif_oe => fx3_gpif.gpif_oe,
ctl_in => fx3_gpif.ctl_in,
ctl_out => fx3_gpif.ctl_out,
ctl_oe => fx3_gpif.ctl_oe,
tx_enable => fx3_control.tx_enable,
rx_enable => fx3_control.rx_enable,
meta_enable => fx3_control.meta_enable,
packet_enable => fx3_control.packet,
tx_fifo_write => tx_sample_fifo.wreq,
tx_fifo_full => tx_sample_fifo.wfull,
tx_fifo_empty => tx_sample_fifo.wempty,
tx_fifo_usedw => tx_sample_fifo.wused,
tx_fifo_data => tx_sample_fifo.wdata,
tx_timestamp => tx_timestamp,
tx_meta_fifo_write => tx_meta_fifo.wreq,
tx_meta_fifo_full => tx_meta_fifo.wfull,
tx_meta_fifo_empty => tx_meta_fifo.wempty,
tx_meta_fifo_usedw => tx_meta_fifo.wused,
tx_meta_fifo_data => tx_meta_fifo.wdata,
rx_fifo_read => rx_sample_fifo.rreq,
rx_fifo_full => rx_sample_fifo.rfull,
rx_fifo_empty => rx_sample_fifo.rempty,
rx_fifo_usedw => rx_sample_fifo.rused,
rx_fifo_data => rx_sample_fifo.rdata,
rx_meta_fifo_read => rx_meta_fifo.rreq,
rx_meta_fifo_full => rx_meta_fifo.rfull,
rx_meta_fifo_empty => rx_meta_fifo.rempty,
rx_meta_fifo_usedr => rx_meta_fifo.rused,
rx_meta_fifo_data => rx_meta_fifo.rdata
);
-- Discrete control signals for fx3_gpif
fx3_control.usb_speed <= '0';
fx3_control.meta_enable <= '1';
fx3_control.packet <= '0';
U_pkt_gen : entity nuand.rx_packet_generator
port map(
rx_clock => rx_clock,
rx_reset => rx_reset,
rx_enable => fx3_control.rx_enable,
rx_packet_enable => fx3_control.packet,
rx_packet_ready => rx_packet_ready,
rx_packet_control => rx_packet_control
);
meta_en_tx <= fx3_control.meta_enable;
meta_en_rx <= fx3_control.meta_enable;
increment_tx_ts : process(tx_clock)
variable ping : boolean := true ;
begin
if( rising_edge(tx_clock) ) then
ping := not ping ;
if( ping = true ) then
tx_timestamp <= tx_timestamp + 1 ;
end if ;
end if ;
end process ;
increment_rx_ts : process(rx_clock)
variable ping : boolean := true ;
begin
if( rising_edge(rx_clock) ) then
ping := not ping ;
if( ping = true ) then
rx_timestamp <= rx_timestamp + 1 ;
end if ;
end if ;
end process ;
-- Model of FX3's GPIF interface
-- Clock domain: fx3_pclk (source)
U_fx3_model : entity nuand.fx3_model(micro_dma)
port map (
fx3_pclk => fx3_pclk,
fx3_gpif => fx3_gpif_i,
fx3_ctl => fx3_ctl_i,
fx3_uart_rxd => '0',
fx3_uart_txd => open,
fx3_uart_cts => open,
fx3_rx_en => '1',
fx3_rx_meta_en => meta_en_rx,
fx3_tx_en => '1',
fx3_tx_meta_en => meta_en_tx,
eight_bit_mode_en => EIGHT_BIT_MODE_EN,
done => done
);
-- Generate phase-shifted PLL clock
U_fx3_pll : entity rtl_work.fx3_pll
port map (
inclk0 => fx3_pclk,
areset => pll_reset,
c0 => fx3_pclk_pll,
locked => pll_locked
);
tx_clock <= not tx_clock after TX_HALF_PERIOD ;
rx_clock <= not rx_clock after RX_HALF_PERIOD ;
-- Reset handler
sys_rst <= '0' after 100 ns;
-- Generate system clock
sys_clk <= not sys_clk after SYSCLK_HALF_PERIOD when not done else '0';
tx_reset <= sys_rst;
tx_ts_reset <= sys_rst;
rx_reset <= sys_rst;
rx_ts_reset <= sys_rst;
meta_en_tx <= fx3_control.meta_enable;
meta_en_rx <= fx3_control.meta_enable;
-- TX Submodule
U_tx : entity work.tx
generic map (
NUM_STREAMS => dac_controls'length
)
port map (
tx_reset => tx_reset,
tx_clock => tx_clock,
tx_enable => fx3_control.tx_enable,
meta_en => meta_en_tx,
timestamp_reset => tx_ts_reset,
usb_speed => fx3_control.usb_speed,
tx_underflow_led => open,
tx_timestamp => tx_timestamp,
-- Triggering
trigger_arm => '0',
trigger_fire => '0',
trigger_master => '0',
trigger_line => open,
-- Packet FIFO
packet_en => fx3_control.packet,
packet_empty => open,
packet_control => tx_packet_control,
packet_ready => '1',
-- 8-bit mode
eight_bit_mode_en => EIGHT_BIT_MODE_EN,
-- Samples from host via FX3
sample_fifo_wclock => fx3_pclk_pll,
sample_fifo_wreq => tx_sample_fifo.wreq,
sample_fifo_wdata => tx_sample_fifo.wdata,
sample_fifo_wempty => tx_sample_fifo.wempty,
sample_fifo_wfull => tx_sample_fifo.wfull,
sample_fifo_wused => tx_sample_fifo.wused,
-- Metadata from host via FX3
meta_fifo_wclock => fx3_pclk_pll,
meta_fifo_wreq => tx_meta_fifo.wreq,
meta_fifo_wdata => tx_meta_fifo.wdata,
meta_fifo_wempty => tx_meta_fifo.wempty,
meta_fifo_wfull => tx_meta_fifo.wfull,
meta_fifo_wused => tx_meta_fifo.wused,
-- Digital Loopback Interface
loopback_enabled => '0',
loopback_fifo_wdata => loopback_fifo.wdata,
loopback_fifo_wreq => loopback_fifo.wreq,
loopback_fifo_wfull => loopback_fifo.wfull,
loopback_fifo_wused => loopback_fifo.wused,
-- RFFE Interface
dac_controls => dac_controls,
dac_streams => dac_streams
);
-- RX Submodule
U_rx : entity work.rx
generic map (
NUM_STREAMS => adc_controls'length
)
port map (
rx_reset => rx_reset,
rx_clock => rx_clock,
rx_enable => fx3_control.rx_enable,
meta_en => meta_en_rx,
timestamp_reset => rx_ts_reset,
usb_speed => fx3_control.usb_speed,
rx_mux_sel => to_unsigned(0, 3),
rx_overflow_led => open,
rx_timestamp => rx_timestamp,
-- Triggering
trigger_arm => '0',
trigger_fire => '0',
trigger_master => '0',
trigger_line => open,
trigger_signal_sync_tb => trigger_signal_sync_tb,
-- Packet FIFO
packet_en => fx3_control.packet,
packet_control => rx_packet_control,
packet_ready => rx_packet_ready,
-- 8-bit mode
eight_bit_mode_en => EIGHT_BIT_MODE_EN,
-- Samples to host via FX3
sample_fifo_rclock => fx3_pclk_pll,
sample_fifo_raclr => not fx3_control.rx_enable,
sample_fifo_rreq => rx_sample_fifo.rreq,
sample_fifo_rdata => rx_sample_fifo.rdata,
sample_fifo_rempty => rx_sample_fifo.rempty,
sample_fifo_rfull => rx_sample_fifo.rfull,
sample_fifo_rused => rx_sample_fifo.rused,
-- Mini expansion signals
mini_exp => "00",
-- Metadata to host via FX3
meta_fifo_rclock => fx3_pclk_pll,
meta_fifo_raclr => not fx3_control.rx_enable,
meta_fifo_rreq => rx_meta_fifo.rreq,
meta_fifo_rdata => rx_meta_fifo.rdata,
meta_fifo_rempty => rx_meta_fifo.rempty,
meta_fifo_rfull => rx_meta_fifo.rfull,
meta_fifo_rused => rx_meta_fifo.rused,
-- Digital Loopback Interface
loopback_fifo_wenabled => open,
loopback_fifo_wreset => tx_reset,
loopback_fifo_wclock => tx_clock,
loopback_fifo_wdata => loopback_fifo.wdata,
loopback_fifo_wreq => loopback_fifo.wreq,
loopback_fifo_wfull => loopback_fifo.wfull,
loopback_fifo_wused => loopback_fifo.wused,
-- RFFE Interface
adc_controls => adc_controls,
adc_streams => adc_streams
);
-- ========================================================================
-- Data converters
-- ========================================================================
gen_dac_controls : if( NUM_MIMO_STREAMS > 1 ) generate
-- The TX side of the AD9361 HDL is a FIFO pull interface
-- that expects a readahead FIFO. It toggles the data request
-- signal every other cycle. This behavior is mimicked here.
process( tx_clock, sys_rst )
begin
if( sys_rst = '1' ) then
dac_controls <= (
0 => (enable => ENABLE_CHANNEL_0, data_req => '1'),
1 => (enable => ENABLE_CHANNEL_1, data_req => '1')
);
elsif( rising_edge(tx_clock) ) then
for i in dac_controls'range loop
dac_controls(i) <= (
enable => dac_controls(i).enable,
data_req => not dac_controls(i).data_req );
end loop;
end if;
end process;
else generate
dac_controls <= (others => SAMPLE_CONTROL_ENABLE);
end generate;
gen_adc_controls : if( NUM_MIMO_STREAMS > 1 ) generate
process( rx_clock, sys_rst )
constant SIGMA_DELTA_BITS : signed (3 downto 0) := "0000";
constant COUNT_RESET : integer := 0;
variable count : integer range -2047 to 2047 := COUNT_RESET;
begin
if( sys_rst = '1' ) then
count := COUNT_RESET;
adc_controls <= (
0 => (enable => ENABLE_CHANNEL_0, data_req => '1'),
1 => (enable => ENABLE_CHANNEL_1, data_req => '1')
);
elsif( rising_edge(rx_clock) ) then
for i in adc_controls'range loop
adc_controls(i) <= (
enable => adc_controls(i).enable,
data_req => not adc_controls(i).data_req );
if( adc_controls(i).enable = '1') then
if( adc_streams(i).data_v = '1' ) then
if( EIGHT_BIT_MODE_EN = '1' ) then
adc_streams(i).data_i <= "0000" & to_signed(count, 8) & SIGMA_DELTA_BITS;
adc_streams(i).data_q <= "0000" & to_signed(-count, 8) & SIGMA_DELTA_BITS;
count := (count + 1) mod 128;
else
adc_streams(i).data_i <= to_signed(count, 16);
adc_streams(i).data_q <= to_signed(-count, 16);
count := (count + 1) mod 2048;
end if;
end if;
adc_streams(i).data_v <= not adc_streams(i).data_v;
end if;
end loop;
end if;
end process;
else generate
adc_controls <= (others => SAMPLE_CONTROL_ENABLE);
end generate;
-- ========================================================================
-- Processes
-- ========================================================================
-- FX3 GPIF bidirectional signal control
-- Adapted from same process in bladerf-hosted.vhd
register_gpif : process(sys_rst, fx3_pclk_pll)
begin
if( sys_rst = '1' ) then
fx3_gpif_i <= (others => 'Z');
fx3_gpif.gpif_in <= (others => 'Z');
elsif( rising_edge(fx3_pclk_pll) ) then
fx3_gpif.gpif_in <= fx3_gpif_i;
if( fx3_gpif.gpif_oe = '1' ) then
fx3_gpif_i <= fx3_gpif.gpif_out;
else
fx3_gpif_i <= (others =>'Z');
end if;
end if;
end process;
-- FX3 CTL bidirectional signals
-- Adapted from same generator in bladerf-hosted.vhd
generate_ctl : for i in fx3_ctl_i'range generate
fx3_ctl_i(i) <= fx3_gpif.ctl_out(i) when fx3_gpif.ctl_oe(i) = '1' else 'Z';
end generate;
fx3_gpif.ctl_in <= fx3_ctl_i;
-- Controller for loopback FIFO
-- Stripped-down version of same process from rx.vhd
loopback_fifo_control : process( sys_rst, loopback_fifo.rclock )
begin
if( sys_rst = '1' ) then
loopback_enabled <= '0';
loopback_fifo.rreq <= '0';
loopback_i <= (others => '0');
loopback_q <= (others => '0');
loopback_valid <= '0';
elsif( rising_edge(loopback_fifo.rclock) ) then
loopback_enabled <= '0';
loopback_fifo.rreq <= '0';
loopback_i <= loopback_i;
loopback_q <= loopback_q;
loopback_valid <= '0';
-- Is loopback enabled?
loopback_enabled <= fx3_control.rx_enable;
-- Do the loopback
loopback_i <= resize(signed(loopback_fifo.rdata(15 downto 0)), loopback_i'length);
loopback_q <= resize(signed(loopback_fifo.rdata(31 downto 16)), loopback_q'length);
loopback_valid <= loopback_fifo.rreq and not loopback_fifo.rempty;
-- Read from the FIFO if req'd
loopback_fifo.rreq <= loopback_enabled and (not loopback_fifo.rempty);
end if;
end process;
-- RX multiplexer
-- Stripped-down version of same process from rx.vhd
rx_mux : process(sys_rst, sys_clk)
begin
if( sys_rst = '1' ) then
rx_mux_i <= (others =>'0');
rx_mux_q <= (others =>'0');
rx_mux_valid <= '0';
elsif( rising_edge(sys_clk) ) then
rx_mux_i <= loopback_i;
rx_mux_q <= loopback_q;
rx_mux_valid <= loopback_valid;
end if;
end process;
-- TX multiplexer
-- Stripped-down version of mimo_channel_sel_mux from tx.vhd
--tx_mux : process( sys_clk )
--begin
-- if( rising_edge(sys_clk) ) then
-- tx_sample_fifo.rreq <= not tx_sample_fifo.rempty;
-- loopback_fifo.wdata <= tx_sample_fifo.rdata;
-- loopback_fifo.wreq <= tx_sample_fifo.rreq and not tx_sample_fifo.rempty;
-- end if;
--end process;
-- ========================================================================
-- Verification
-- ========================================================================
meta_verify: process
type timestamp_arr is array (natural range <>) of unsigned(63 downto 0);
constant HEADER_LEN : integer := 4;
variable timestamp : timestamp_arr(1 downto 0);
variable delta : unsigned(63 downto 0) := (others => '0');
variable delta_expected : unsigned(63 downto 0);
variable iteration : natural := 1;
-- variable timestamp : unsigned(63 downto 0) := (others => '0');
begin
wait for 1 ns;
delta_expected := to_unsigned(GPIF_BUF_SIZE_SS-HEADER_LEN, 64) when not EIGHT_BIT_MODE_EN
else to_unsigned(2*(GPIF_BUF_SIZE_SS-HEADER_LEN), 64);
if (ENABLE_CHANNEL_0 and ENABLE_CHANNEL_1) then
delta_expected := delta_expected/2;
end if;
for j in 0 to 1 loop
wait until rising_edge(fx3_gpif.gpif_oe);
for i in 0 to HEADER_LEN-1 loop
wait until rising_edge(fx3_pclk_pll);
if (i = 1) then
timestamp(j)(31 downto 0) := unsigned(fx3_gpif.gpif_out);
end if;
if (i = 2) then
timestamp(j)(63 downto 32) := unsigned(fx3_gpif.gpif_out);
end if;
-- report "Header ["& integer'image(i) &"] "& to_hstring(fx3_gpif.gpif_out);
end loop;
report "Timestamp: " & integer'image(to_integer(timestamp(j)));
end loop;
delta := timestamp(1) - timestamp(0);
report "Timestamp Delta: " & integer'image(to_integer(delta));
iteration := iteration + 1;
if (iteration mod 3 /= 0) then
assert (delta = delta_expected)
report lf&"Unexpected Timestamp Delta"&lf&
"Expected " & integer'image(to_integer(delta_expected))
&" ("& integer'image(to_integer(timestamp(0)) + to_integer(delta_expected)) &")"&lf&
"Actual " & integer'image(to_integer(delta))
&" ("& integer'image(to_integer(timestamp(1))) &")"
severity failure;
else
report "rst timestamp ignored";
end if;
end process meta_verify;
end architecture;

View file

@ -26,6 +26,7 @@ library ieee;
library work; library work;
use work.util.all; use work.util.all;
use work.fx3_gpif_p.all;
architecture wlan_micro_packet_dma of fx3_model is architecture wlan_micro_packet_dma of fx3_model is
@ -108,7 +109,7 @@ begin
done <= rx_done and tx_done; done <= rx_done and tx_done;
rx_sample_stream : process rx_sample_stream : process
constant BLOCK_SIZE : natural := 512; constant BLOCK_SIZE : natural := GPIF_BUF_SIZE_SS;
variable count : natural := START_COUNT; variable count : natural := START_COUNT;
variable req_time : time; variable req_time : time;
begin begin
@ -161,7 +162,7 @@ begin
end process; end process;
tx_sample_stream : process tx_sample_stream : process
constant BLOCK_SIZE : natural := 512; constant BLOCK_SIZE : natural := GPIF_BUF_SIZE_SS;
variable count : natural := START_COUNT; variable count : natural := START_COUNT;
variable timestamp_cntr : natural := 100; variable timestamp_cntr : natural := 100;
variable header_len : natural := 0; variable header_len : natural := 0;

View file

@ -47,8 +47,9 @@ entity tx is
trigger_master : in std_logic; trigger_master : in std_logic;
trigger_line : inout std_logic; -- this is not good, should be in/out/oe trigger_line : inout std_logic; -- this is not good, should be in/out/oe
-- 8-bit mode -- Packing modes
eight_bit_mode_en : in std_logic := '0'; eight_bit_mode_en : in std_logic := '0';
highly_packed_mode_en : in std_logic := '0';
-- Packet from host via FX3 -- Packet from host via FX3
packet_en : in std_logic; packet_en : in std_logic;
@ -218,6 +219,7 @@ begin
timestamp => tx_timestamp, timestamp => tx_timestamp,
eight_bit_mode_en => eight_bit_mode_en, eight_bit_mode_en => eight_bit_mode_en,
highly_packed_mode_en => highly_packed_mode_en,
fifo_empty => sample_fifo.rempty, fifo_empty => sample_fifo.rempty,
fifo_usedw => sample_fifo.rused, fifo_usedw => sample_fifo.rused,

View file

@ -33,6 +33,7 @@ set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip syn
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/fifo_writer.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/fifo_writer.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/lms6002d/vhdl/lms6002d.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/lms6002d/vhdl/lms6002d.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/set_clear_ff.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/set_clear_ff.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif_p.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/bladerf-adsb.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/bladerf-adsb.vhd]]

View file

@ -33,6 +33,7 @@ set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip syn
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/fifo_writer.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/fifo_writer.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/lms6002d/vhdl/lms6002d.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/lms6002d/vhdl/lms6002d.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/set_clear_ff.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/set_clear_ff.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif_p.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/bladerf-atsc_tx.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/bladerf-atsc_tx.vhd]]
set_global_assignment -name QIP_FILE [file normalize nios_system/synthesis/nios_system.qip] set_global_assignment -name QIP_FILE [file normalize nios_system/synthesis/nios_system.qip]

View file

@ -35,6 +35,7 @@ set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip syn
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/lms6002d/vhdl/bladerf_agc.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/lms6002d/vhdl/bladerf_agc.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip trigger/trigger.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip trigger/trigger.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/set_clear_ff.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/set_clear_ff.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif_p.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $common_dir vhdl/fx3_gpif.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/rx_packet_generator.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $nuand_ip synthesis/rx_packet_generator.vhd]]
set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/bladerf-hosted.vhd]] set_global_assignment -name VHDL_FILE [file normalize [file join $here vhdl/bladerf-hosted.vhd]]

View file

@ -105,8 +105,8 @@ set_output_delay -clock [get_clocks altera_reserved_tck] 20 [get_ports altera_re
# Exceptions # Exceptions
# The dcfifo which goes from the C4 TX domain to the PCLK domain seems to have an issue with the clear signal. It isn't generally a issue so ignore it? # The dcfifo which goes from the C4 TX domain to the PCLK domain seems to have an issue with the clear signal. It isn't generally a issue so ignore it?
set_false_path -from {reset_synchronizer:U_tx_reset|sync} -to {tx_*fifo:U_tx_*_fifo|common_dcfifo:U_common_dcfifo|dcfifo*:auto_generated|dffpipe_3dc:wraclr|dffe12a[0]} set_false_path -from {reset_synchronizer:U_tx_reset|sync} -to {tx_*fifo:U_tx_*_fifo|common_dcfifo:U_common_dcfifo|dcfifo*:auto_generated|dffpipe_3dc:wraclr|dffe*a[0]}
set_false_path -from {reset_synchronizer:U_tx_reset|sync} -to {tx_*fifo:U_tx_*_fifo|common_dcfifo:U_common_dcfifo|dcfifo*:auto_generated|dffpipe_3dc:wraclr|dffe13a[0]} set_false_path -from {reset_synchronizer:U_tx_reset|sync} -to {tx_*fifo:U_tx_*_fifo|common_dcfifo:U_common_dcfifo|dcfifo*:auto_generated|dffpipe_3dc:wraclr|dffe*a[0]}
# False path between hold_time and compare_time due to the way the FSM is setup # False path between hold_time and compare_time due to the way the FSM is setup
set_false_path -from {*x_tamer|hold_time[*]} -to {*x_tamer|compare_time[*]} set_false_path -from {*x_tamer|hold_time[*]} -to {*x_tamer|compare_time[*]}

View file

@ -1,16 +1,17 @@
source ../../../ip/nuand/nuand.do source ../../../ip/nuand/nuand.do
compile_nuand ../../../ip/nuand compile_nuand ../../../ip/nuand bladerf
vcom -work nuand -2008 ../../../ip/altera/pll/pll.vhd vcom -work nuand -2008 ../../../ip/altera/pll/pll.vhd
vcom -work nuand -2008 ../../../ip/altera/fx3_pll/fx3_pll.vhd vcom -work nuand -2008 ../../../ip/altera/fx3_pll/fx3_pll.vhd
vcom -work nuand -2008 ../../../ip/altera/rx_fifo/rx_fifo.vhd
vcom -work nuand -2008 ../../../ip/altera/tx_fifo/tx_fifo.vhd
vcom -work nuand -2008 ../../../ip/altera/tx_meta_fifo/tx_meta_fifo.vhd
vcom -work nuand -2008 ../../../ip/altera/rx_meta_fifo/rx_meta_fifo.vhd
vcom -work nuand -2008 ../vhdl/tb/nios_system.vhd vcom -work nuand -2008 ../vhdl/tb/nios_system.vhd
vcom -work nuand -2008 ../vhdl/fx3_gpif.vhd vcom -work nuand -2008 ../../common/bladerf/vhdl/fx3_gpif_p.vhd
vcom -work nuand -2008 ../../common/bladerf/vhdl/fx3_gpif.vhd
vcom -work nuand -2008 ../../../ip/nuand/lms6_spi_controller/vhdl/lms6_spi_controller.vhd
vcom -work nuand -2008 ../../../ip/nuand/synthesis/lms6002d/vhdl/bladerf_agc_lms_drv.vhd
vcom -work nuand -2008 ../../../ip/nuand/synthesis/lms6002d/vhdl/bladerf_agc.vhd
vcom -work nuand -2008 ../vhdl/bladerf.vhd vcom -work nuand -2008 ../vhdl/bladerf.vhd
vcom -work nuand -2008 ../vhdl/bladerf_p.vhd vcom -work nuand -2008 ../vhdl/bladerf_p.vhd

View file

@ -7,7 +7,7 @@
#define FPGA_VERSION_ID 0x7777 #define FPGA_VERSION_ID 0x7777
#define FPGA_VERSION_MAJOR 0 #define FPGA_VERSION_MAJOR 0
#define FPGA_VERSION_MINOR 14 #define FPGA_VERSION_MINOR 16
#define FPGA_VERSION_PATCH 0 #define FPGA_VERSION_PATCH 0
#define FPGA_VERSION ((uint32_t)( FPGA_VERSION_MAJOR | \ #define FPGA_VERSION ((uint32_t)( FPGA_VERSION_MAJOR | \
(FPGA_VERSION_MINOR << 8) | \ (FPGA_VERSION_MINOR << 8) | \

View file

@ -769,6 +769,7 @@ begin
meta_en => meta_en_rx, meta_en => meta_en_rx,
packet_en => packet_en_rx, packet_en => packet_en_rx,
eight_bit_mode_en => '0', eight_bit_mode_en => '0',
highly_packed_mode_en => '0',
timestamp => rx_timestamp, timestamp => rx_timestamp,
mini_exp => mini_exp2 & mini_exp1, mini_exp => mini_exp2 & mini_exp1,
@ -919,6 +920,7 @@ begin
meta_en => meta_en_tx, meta_en => meta_en_tx,
packet_en => packet_en_tx, packet_en => packet_en_tx,
eight_bit_mode_en => '0', eight_bit_mode_en => '0',
highly_packed_mode_en => '0',
timestamp => tx_timestamp, timestamp => tx_timestamp,
fifo_empty => tx_sample_fifo.rempty, fifo_empty => tx_sample_fifo.rempty,

View file

@ -114,7 +114,7 @@ package bladerf_p is
constant TX_FIFO_WWIDTH : natural := 32; -- write side data width constant TX_FIFO_WWIDTH : natural := 32; -- write side data width
constant TX_FIFO_RWIDTH : natural := 32; -- read side data width constant TX_FIFO_RWIDTH : natural := 32; -- read side data width
constant TX_FIFO_LENGTH : natural := 4096; -- samples constant TX_FIFO_LENGTH : natural := 16384; -- samples
constant RX_FIFO_WWIDTH : natural := 32; -- write side data width constant RX_FIFO_WWIDTH : natural := 32; -- write side data width
constant RX_FIFO_RWIDTH : natural := 32; -- read side data width constant RX_FIFO_RWIDTH : natural := 32; -- read side data width

View file

@ -46,7 +46,16 @@ entity nios_system is
tx_trigger_ctl_in_port : in std_logic_vector(7 downto 0); tx_trigger_ctl_in_port : in std_logic_vector(7 downto 0);
tx_trigger_ctl_out_port : out std_logic_vector(7 downto 0); tx_trigger_ctl_out_port : out std_logic_vector(7 downto 0);
rx_trigger_ctl_in_port : in std_logic_vector(7 downto 0); rx_trigger_ctl_in_port : in std_logic_vector(7 downto 0);
rx_trigger_ctl_out_port : out std_logic_vector(7 downto 0) rx_trigger_ctl_out_port : out std_logic_vector(7 downto 0);
arbiter_request : in std_logic_vector(1 downto 0);
arbiter_granted : out std_logic_vector(1 downto 0);
arbiter_ack : in std_logic_vector(1 downto 0);
agc_dc_i_max_export : out std_logic_vector(15 downto 0);
agc_dc_q_max_export : out std_logic_vector(15 downto 0);
agc_dc_i_mid_export : out std_logic_vector(15 downto 0);
agc_dc_q_mid_export : out std_logic_vector(15 downto 0);
agc_dc_i_min_export : out std_logic_vector(15 downto 0);
agc_dc_q_min_export : out std_logic_vector(15 downto 0)
); );
end entity ; end entity ;
@ -83,5 +92,17 @@ begin
xb_gpio_out_port <= (others =>'0') ; xb_gpio_out_port <= (others =>'0') ;
xb_gpio_dir_export <= (others =>'0') ; xb_gpio_dir_export <= (others =>'0') ;
tx_trigger_ctl_out_port <= (others => '0');
rx_trigger_ctl_out_port <= (others => '0');
arbiter_granted <= (others => '0');
agc_dc_i_max_export <= (others => '0');
agc_dc_q_max_export <= (others => '0');
agc_dc_i_mid_export <= (others => '0');
agc_dc_q_mid_export <= (others => '0');
agc_dc_i_min_export <= (others => '0');
agc_dc_q_min_export <= (others => '0');
end architecture ; end architecture ;

View file

@ -88,6 +88,12 @@ It is possible to build, load, and debug the Nios software over JTAG using the I
(***Linux Users: Ensure you've installed udev rules for your JTAG debugger***) (***Linux Users: Ensure you've installed udev rules for your JTAG debugger***)
On Ubuntu 20.04 or similar, you will need these extra dependencies:
```bash
sudo apt install -y libncursesw5
```
Command-Line Debugging with GDB Command-Line Debugging with GDB
============================ ============================
@ -140,7 +146,7 @@ Command-Line Debugging with GDB
- `$QUARTUS_INSTALL_DIR/nios2eds/nios2_command_shell.sh` - `$QUARTUS_INSTALL_DIR/nios2eds/nios2_command_shell.sh`
- cd into `$BLADERF_DIR/hdl/quartus/work/<platform>-<size>-<rev>/bladeRF_nios` - cd into `$BLADERF_DIR/hdl/quartus/work/<platform>-<size>-<rev>/bladeRF_nios`
- Start the Nios gdb client: - Start the Nios gdb client:
- `nios2-elf-gdb -ex "target remote localhost:8888" bladeRF_nios.elf` - `make WORKDIR=work/<platform>-<size>-<rev> elf-gdb`
- The Nios processor will now be in a paused state. This lets us setup breakpoints and whatnot as needed for debug. When ready to begin the debug process, issue the `continue` command. This will unpause the Nios. - The Nios processor will now be in a paused state. This lets us setup breakpoints and whatnot as needed for debug. When ready to begin the debug process, issue the `continue` command. This will unpause the Nios.
- If a breakpoint is hit, gdb will pause the Nios again until you issue another `continue` command. This may cause a timeout and break the user application. Breakpoints can have [commands associated with them](https://ftp.gnu.org/old-gnu/Manuals/gdb/html_node/gdb_34.html), so when one is hit, gdb can immediately print a value and continue. The print operation is slow enough that if more than a few characters are printed, it will trigger a timeout in libbladeRF. Refer to the *Debugging Tips* section for how to increase the timeout. - If a breakpoint is hit, gdb will pause the Nios again until you issue another `continue` command. This may cause a timeout and break the user application. Breakpoints can have [commands associated with them](https://ftp.gnu.org/old-gnu/Manuals/gdb/html_node/gdb_34.html), so when one is hit, gdb can immediately print a value and continue. The print operation is slow enough that if more than a few characters are printed, it will trigger a timeout in libbladeRF. Refer to the *Debugging Tips* section for how to increase the timeout.
@ -176,6 +182,31 @@ To increase the Nios RAM size:
- Find the `get_qsys_ram` function, and change the return value to be the nearest power of 2 larger than the required memory size from the above. Sometimes simply doubling the existing return value is good enough. - Find the `get_qsys_ram` function, and change the return value to be the nearest power of 2 larger than the required memory size from the above. Sometimes simply doubling the existing return value is good enough.
- Rebuild the FPGA in its entirety. This is required because the FPGA needs to instantiate more block RAMs to fit the larger Nios, and it will need to re-fit the surrounding logic. - Rebuild the FPGA in its entirety. This is required because the FPGA needs to instantiate more block RAMs to fit the larger Nios, and it will need to re-fit the surrounding logic.
Install Eclipse
=====================
Before Eclipse can be used, it must be installed. This step is a new change as of recent Quartus versions, and is required for Quartus 20.1.
These steps will download eclipse, get a new jdk, and replace the jdk. Edit the first line if needed for your install path and version.
```bash
export QUARTUS_INSTALL_DIR=~/intelFPGA_lite/20.1/
sudo apt install -y openjdk-8-jdk
cd $QUARTUS_INSTALL_DIR/nios2eds/bin/
wget https://archive.eclipse.org/technology/epp/downloads/release/mars/2/eclipse-cpp-mars-2-linux-gtk-x86_64.tar.gz
tar -xf eclipse-cpp-mars-2-linux-gtk-x86_64.tar.gz
mv eclipse eclipse_nios2
tar -xf eclipse_nios2_plugins.tar.gz
mv jre64 jre64_old
ln -svf /lib/jvm/java-8-openjdk-amd64/jre/ jre64
```
This will install eclipse, however you must launch eclipse using our script, located at `hdl/quartus/launch_eclipse.sh`
These two pages are reference for this section:
* https://www.intel.com/content/www/us/en/support/programmable/articles/000086893.html
* https://community.intel.com/t5/Intel-Quartus-Prime-Software/Nios-Eclipse-crashes-free-invalid-pointer/m-p/1215921#M66524
Eclipse GUI Debugging Eclipse GUI Debugging
===================== =====================
@ -194,13 +225,17 @@ $ build_bladerf.sh -b <board> -s <size> -r <rev>
- Load the FPGA with the resulting image using the bladeRF-cli. The NIOS II will be loaded and reset in a following step. This is required to ensure the PCLK from the FX3 is provided to the NIOS II core. - Load the FPGA with the resulting image using the bladeRF-cli. The NIOS II will be loaded and reset in a following step. This is required to ensure the PCLK from the FX3 is provided to the NIOS II core.
- Launch the Eclipse version provided with Quartus II 15.0, contained located at: `$QUARTUS_INSTALL_DIR/nios2eds/bin/eclipse-nios2`. Create a workspace wherever you see fit. - Launch the Eclipse with our provided script. When prompted, create a workspace wherever you see fit.
```bash
cd $BLADERF_DIR
./hdl/quartus/launch_eclipse.sh hdl/quartus/work/<platform>-<size>-<rev>
```
- Import the bladeRF_nios_bsp project: - Import the bladeRF_nios_bsp project:
- From the project explorer, right click and select *Import...* - From the project explorer pane, right click and select *Import...*
- Select *General --> Existing projects into Workspace* - Select *General --> Existing projects into Workspace*
- Select *Root Directory* - Click *Browse...* next to *Root Directory*, and select `hdl/fpga/platforms/common/bladerf/software/bladeRF_nios_bsp`
- Select this directory. You should see a project labeled `bladeRF_nios_bsp` checked in the *Projects* pane. - You should see a project labeled `bladeRF_nios_bsp` checked in the *Projects* pane.
- Click Finish - Click Finish
- Import the bladeRF_nios projects: - Import the bladeRF_nios projects:
@ -231,22 +266,36 @@ $ build_bladerf.sh -b <board> -s <size> -r <rev>
- `<size>` is the FPGA size (e.g. 40, 115, A4, A9) - `<size>` is the FPGA size (e.g. 40, 115, A4, A9)
- `<rev>` is the project revision (typically 'hosted') - `<rev>` is the project revision (typically 'hosted')
- Click *OK* - Click *OK*
- The `bladeRF_nios` project should now build successfully.
- **Remember to update this variable if targeting a different platform later!** - **Remember to update this variable if targeting a different platform later!**
- Create a debug target: - You need to build the BSP once, then the project.
- Click *Debug Configurations...* - Right click "bladeRF_nios_bsp" and select "Nios II" -> "Generate BSP"
- Create a new *NIOS II Hardware v2 (beta)* target - Right click "bladeRF_nios" in the Project Explorer pane, and select "Build Project"
- For *Project*, select bladeRF_nios - The `bladeRF_nios` project should now build successfully.
- For *ELF:*, select bladeRF_nios.elf - Subsequent changes to the project only require a rebuild of the Project, not the BSP.
- Under *Connections* -> *Processor*, click *Browse...*. It should detect the NIOS II via the JTAG device and display a string describing its location in the scan chain.
- *Optional* Repeat the above for the *JTAG UART* field, if you wish to use have a console over JTAG. Be careful when using this, as it will significantly affect execution time. - Create a debug target (see alternative method below):
- Uncheck *Check Unique ID* and *Check timestamp*. - Right click "bladeRF_nios" in the Project Explorer pane, and select "Debug As" -> "Debug Configurations..."
- Right click "Nios II Hardware" and select "New"
- On the "Project" tab
- Click "Enable browse for filesystem ELF File
- Click "..." And browse to `hdl/quartus/work/<board>-<size>-<rev>/bladeRF_nios/bladeRF_nios.elf`
- On the "Target Connection" tab
- check "Ignore mismatched system ID" and "Ignore mismatched system timestamp"
- Find USB-Blaster in "Connections". (Click "Refresh Connections" if it does not show up)
- click apply
- "Debug" button should be clickable
- If you wish to download code to the device, reset, and run it... - If you wish to download code to the device, reset, and run it...
- Check *Download ELF*, *Reset Processor*, and *Start Processor* - Check *Download ELF*, *Reset Processor*, and *Start Processor*
- If you only wish to inspect the state of the NIOS after observing an issue on the host side... - If you only wish to inspect the state of the NIOS after observing an issue on the host side...
- Ensure all of the aforementioned items are unchecked - Ensure all of the aforementioned items are unchecked
- At this point, you may apply the settings and start a debug session. - Create a debug target V2 (Beta):
- Right click "bladeRF_nios" in the Project Explorer pane, and select "Debug As" -> "Debug Configurations..."
- Right click "Nios II Hardware v2 (beta)" and select "New"
- On the "Main" tab
- For *ELF:*, select `hdl/quartus/work/<board>-<size>-<rev>/bladeRF_nios/bladeRF_nios.elf`
- Under *Connections* -> *Processor*, click *Browse...*. It should detect the NIOS II via the JTAG device and display a string describing its location in the scan chain.
- *Optional* Repeat the above for the *JTAG UART* field, if you wish to use have a console over JTAG. Be careful when using this, as it will significantly affect execution time.
**Note:** You may have to repeat the step(s) where you browse for the device after unplugging and re-connecting the JTAG debugger. **Note:** You may have to repeat the step(s) where you browse for the device after unplugging and re-connecting the JTAG debugger.

View file

@ -897,6 +897,8 @@ endif # QSYS == 1
@$(ECHO) " Run targets:" @$(ECHO) " Run targets:"
@$(ECHO) " download-elf - Download and run your elf executable" @$(ECHO) " download-elf - Download and run your elf executable"
@$(ECHO) " program-flash - Program flash contents to the board" @$(ECHO) " program-flash - Program flash contents to the board"
@$(ECHO) " gdb-server - Start GDB server on port 8888"
@$(ECHO) " elf-gdb - Connect GDB to running server and load symbols"
# Handy rule to skip making libraries and just make application. # Handy rule to skip making libraries and just make application.
.PHONY : app .PHONY : app
@ -1004,7 +1006,7 @@ download-elf : $(ELF)
$(ECHO) Downloading $(ELF) not supported; \ $(ECHO) Downloading $(ELF) not supported; \
else \ else \
$(ECHO) Info: Downloading $(ELF); \ $(ECHO) Info: Downloading $(ELF); \
$(DOWNLOAD) --go --cpu_name=$(CPU_NAME) $(DOWNLOAD_CABLE_FLAG) $(SOPC_SYSID_FLAG) $(DOWNLOAD_JDI_FLAG) $(WRITE_GMON_OPTION) $(ELF); \ $(DOWNLOAD) --cpu_name=$(CPU_NAME) $(DOWNLOAD_CABLE_FLAG) $(SOPC_SYSID_FLAG) $(DOWNLOAD_JDI_FLAG) $(WRITE_GMON_OPTION) $(ELF); \
fi fi
# Delete the target of a rule if it has changed and its commands exit # Delete the target of a rule if it has changed and its commands exit
@ -1111,3 +1113,13 @@ $(OBJDUMP_NAME) : $(ELF)
.PHONY: print-elf-name .PHONY: print-elf-name
print-elf-name: print-elf-name:
@$(ECHO) $(ELF) @$(ECHO) $(ELF)
.PHONY : elf-gdb
elf-gdb : $(ELF)
@$(ECHO) Info: Starting GDB for $(ELF)
nios2-elf-gdb -ex "target remote localhost:8888" $(ELF)
.PHONY : gdb-server
gdb-server:
@$(ECHO) Info: Starting GDB server on port 8888
nios2-gdb-server --tcpport 8888 --tcppersist

View file

@ -27,6 +27,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <unistd.h>
#include "system.h" #include "system.h"
#include "altera_avalon_spi.h" #include "altera_avalon_spi.h"
@ -41,7 +42,23 @@ static inline uint32_t control_reg_read(void)
static inline void control_reg_write(uint32_t value) static inline void control_reg_write(uint32_t value)
{ {
const size_t CFG_GPIO_CLOCK_SELECT = 18; // Refer to bladerf2_common.h
const uint32_t CLK_SEL_MASK = (1 << CFG_GPIO_CLOCK_SELECT);
uint32_t current_clock_select, requested_clock_select;
bool delay_nios_response = false;
current_clock_select = control_reg_read() & CLK_SEL_MASK;
requested_clock_select = value & CLK_SEL_MASK;
delay_nios_response = current_clock_select != requested_clock_select;
IOWR_ALTERA_AVALON_PIO_DATA(CONTROL_BASE, value); IOWR_ALTERA_AVALON_PIO_DATA(CONTROL_BASE, value);
// Adding a delay to allow the Nios and FX3 Plls
// to stabilize before we send back the Nios response.
if (delay_nios_response) {
DBG("__resp_delay__");
usleep(5);
}
} }
static inline uint32_t rffe_csr_read(void) static inline uint32_t rffe_csr_read(void)

View file

@ -126,5 +126,13 @@ void pkt_8x32(struct pkt_buf *b)
success = perform_read(id, addr, &data); success = perform_read(id, addr, &data);
} }
if (!success && is_write) {
DBG("Failed to write 0x%08x to 0x%02x\n", data, addr);
}
if (!success && !is_write) {
DBG("Failed to read from 0x%02x\n", addr);
}
nios_pkt_8x32_resp_pack(b->resp, id, is_write, addr, data, success); nios_pkt_8x32_resp_pack(b->resp, id, is_write, addr, data, success);
} }

View file

@ -22,6 +22,9 @@ library ieee;
use ieee.std_logic_1164.all; use ieee.std_logic_1164.all;
use ieee.numeric_std.all; use ieee.numeric_std.all;
library nuand;
use nuand.fx3_gpif_p.all;
entity fx3_gpif is entity fx3_gpif is
port ( port (
-- FX3 control signals -- FX3 control signals
@ -117,10 +120,6 @@ architecture sample_shuffler of fx3_gpif is
constant META_DOWNCOUNT_RESET : natural := 4; constant META_DOWNCOUNT_RESET : natural := 4;
constant FINI_DOWNCOUNT_RESET : natural := 10; constant FINI_DOWNCOUNT_RESET : natural := 10;
-- GPIF buf sizes for USB high-speed and super-speed
constant GPIF_BUF_SIZE_HS : natural := 256;
constant GPIF_BUF_SIZE_SS : natural := 512;
type dma_handshake_t is record type dma_handshake_t is record
rx0 : std_logic; rx0 : std_logic;
rx1 : std_logic; rx1 : std_logic;
@ -180,8 +179,8 @@ architecture sample_shuffler of fx3_gpif is
signal current, future : fsm_t := FSM_RESET_VALUE; signal current, future : fsm_t := FSM_RESET_VALUE;
signal can_rx, should_rx : boolean; signal can_rx : boolean;
signal can_tx, should_tx : boolean; signal can_tx : boolean;
signal rx_fifo_enough : boolean; signal rx_fifo_enough : boolean;
signal tx_fifo_enough : boolean; signal tx_fifo_enough : boolean;
signal rx_fifo_critical : boolean; signal rx_fifo_critical : boolean;
@ -193,14 +192,10 @@ architecture sample_shuffler of fx3_gpif is
attribute preserve : boolean; attribute preserve : boolean;
attribute preserve of can_rx : signal is true; attribute preserve of can_rx : signal is true;
attribute preserve of can_tx : signal is true; attribute preserve of can_tx : signal is true;
attribute preserve of should_rx : signal is true;
attribute preserve of should_tx : signal is true;
attribute keep : boolean; attribute keep : boolean;
attribute keep of can_rx : signal is true; attribute keep of can_rx : signal is true;
attribute keep of can_tx : signal is true; attribute keep of can_tx : signal is true;
attribute keep of should_rx : signal is true;
attribute keep of should_tx : signal is true;
-- acknowledge(dma_channel) returns a dma_handshake_t with all bits 0 -- acknowledge(dma_channel) returns a dma_handshake_t with all bits 0
-- except the bit corresponding to dma_channel -- except the bit corresponding to dma_channel
@ -280,7 +275,7 @@ begin
-- Can we not fit one more block of data in RX buffer? -- Can we not fit one more block of data in RX buffer?
rx_fifo_critical <= (unsigned(rx_fifo_usedw) >= ((2**(rx_fifo_usedw'length-1) - gpif_buf_size))); rx_fifo_critical <= (unsigned(rx_fifo_usedw) >= ((2**(rx_fifo_usedw'length-1) - gpif_buf_size)));
-- Do we have room for one more block of data in the TX buffer? -- Do we have room for one more block of data in the TX buffer?
tx_fifo_enough <= (unsigned(tx_fifo_usedw) < ((2**(tx_fifo_usedw'length-1) - gpif_buf_size * 4))) and tx_fifo_enough <= (unsigned(tx_fifo_usedw) < ((2**(tx_fifo_usedw'length) - gpif_buf_size))) and
(unsigned(tx_meta_fifo_usedw) < ((2**(tx_meta_fifo_usedw'length-1) - 4))); (unsigned(tx_meta_fifo_usedw) < ((2**(tx_meta_fifo_usedw'length-1) - 4)));
end if; end if;
end process calculate_fifo_waterlines; end process calculate_fifo_waterlines;
@ -338,22 +333,28 @@ begin
end if; end if;
end process gpif_mux; end process gpif_mux;
-- Arbitrate RX and TX requests
-- In the event the FX3 simultaneously requests RX and TX, we generally
-- prioritize the TX first; this helps avoid discontinuities on the TX
-- signal. However, if RX is about to overflow, we'll choose that.
can_and_should : process(pclk, reset) can_and_should : process(pclk, reset)
variable rx_dma_req : boolean;
variable tx_dma_req : boolean;
variable rx_meta_ok : boolean;
begin begin
if (reset = '1') then if (reset = '1') then
can_rx <= false; can_rx <= false;
can_tx <= false; can_tx <= false;
should_rx <= false;
should_tx <= false;
elsif (rising_edge(pclk)) then elsif (rising_edge(pclk)) then
can_rx <= dma_rx_enable = '1' and rx_fifo_enough and (dma_req.rx0 = '1' or dma_req.rx1 = '1'); rx_dma_req := dma_req.rx0 = '1' or dma_req.rx1 = '1';
can_tx <= dma_tx_enable = '1' and tx_fifo_enough and (dma_req.tx2 = '1' or dma_req.tx3 = '1'); rx_meta_ok := meta_enable = '1' nand rx_meta_fifo_empty = '1';
should_rx <= can_rx and (not can_tx or rx_fifo_critical);
should_tx <= can_tx and not rx_fifo_critical; can_rx <= dma_rx_enable = '1' and
rx_fifo_enough and
rx_dma_req and
rx_meta_ok;
tx_dma_req := dma_req.tx2 = '1' or dma_req.tx3 = '1';
can_tx <= dma_tx_enable = '1' and
tx_fifo_enough and
tx_dma_req;
end if; end if;
end process; end process;
@ -409,21 +410,24 @@ begin
future.fini_downcount <= FINI_DOWNCOUNT_RESET; future.fini_downcount <= FINI_DOWNCOUNT_RESET;
future.finishing_rx <= '0'; future.finishing_rx <= '0';
-- Arbitrate RX and TX requests
-- In the event the FX3 simultaneously requests RX and TX, we generally
-- prioritize the TX first; this helps avoid discontinuities on the TX
-- signal. However, if RX is about to overflow, we'll choose that.
if (current.dma_idle = '1') then if (current.dma_idle = '1') then
if (should_rx and ( (rx_meta_fifo_empty = '0' and current.rx_meta_en = '1')
or (current.rx_meta_en = '0') ) ) then
-- There is an RX to perform (sending data to FX3).
future.ack_downcount <= ACK_DOWNCOUNT_READ;
future.dma_downcount <= gpif_buf_size-1; future.dma_downcount <= gpif_buf_size-1;
if (can_rx and rx_fifo_critical) then
future.ack_downcount <= ACK_DOWNCOUNT_READ;
future.rx_current_dma <= RX0; future.rx_current_dma <= RX0;
future.state <= SETUP_RD; future.state <= SETUP_RD;
elsif (can_tx) then
elsif (should_tx) then
-- There is a TX to perform (getting data from FX3).
future.ack_downcount <= ACK_DOWNCOUNT_WRITE; future.ack_downcount <= ACK_DOWNCOUNT_WRITE;
future.dma_downcount <= gpif_buf_size-1;
future.tx_current_dma <= TX3; future.tx_current_dma <= TX3;
future.state <= SETUP_WR; future.state <= SETUP_WR;
elsif (can_rx) then
future.ack_downcount <= ACK_DOWNCOUNT_READ;
future.rx_current_dma <= RX0;
future.state <= SETUP_RD;
end if; end if;
end if; end if;

View file

@ -0,0 +1,27 @@
-- Copyright (c) 2024 Nuand LLC
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-- THE SOFTWARE.
library ieee;
use ieee.std_logic_1164.all;
package fx3_gpif_p is
-- GPIF buf sizes for USB high-speed and super-speed
constant GPIF_BUF_SIZE_HS : natural := 1024;
constant GPIF_BUF_SIZE_SS : natural := 2048;
end package fx3_gpif_p;

View file

@ -3,6 +3,41 @@
# Build a bladeRF fpga image # Build a bladeRF fpga image
################################################################################ ################################################################################
# Ensure we're in the right directory and submodules are initialized
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
# Initialize and update submodules if needed
echo "Checking and initializing submodules..."
cd "$PROJECT_ROOT"
if [ -f .gitmodules ]; then
# Initialize submodules if not already initialized
git submodule init
# Update submodules to ensure they're checked out
git submodule update
echo "Submodules initialized and updated."
fi
cd "$SCRIPT_DIR"
cleanup() {
# Prevent recursive cleanup calls
trap '' INT TERM HUP
echo "Cleaning up and terminating builds..."
if [ -n "${build_pids[*]}" ]; then
for pid in "${build_pids[@]}"; do
pkill -P $pid 2>/dev/null || true
done
fi
exit 1
}
# Set up trap to catch Ctrl+C and other termination signals
trap cleanup INT TERM HUP
function print_boards() { function print_boards() {
echo "Supported boards:" echo "Supported boards:"
for i in ../fpga/platforms/*/build/platform.conf ; do for i in ../fpga/platforms/*/build/platform.conf ; do
@ -33,6 +68,7 @@ function usage()
echo " -r <rev> Quartus project revision" echo " -r <rev> Quartus project revision"
echo " -s <size> FPGA size" echo " -s <size> FPGA size"
echo " -a <stp> SignalTap STP file" echo " -a <stp> SignalTap STP file"
echo " -H Build all hosted configurations"
echo " -f Force SignalTap STP insertion by temporarily enabling" echo " -f Force SignalTap STP insertion by temporarily enabling"
echo " the TalkBack feature of Quartus (required for Web Edition)." echo " the TalkBack feature of Quartus (required for Web Edition)."
echo " The previous setting will be restored afterward." echo " The previous setting will be restored afterward."
@ -44,6 +80,7 @@ function usage()
echo " synth Synthesize the design" echo " synth Synthesize the design"
echo " full (default) Fit the design and create programming files" echo " full (default) Fit the design and create programming files"
echo " -S <seed> Fitter seed setting (default: 1)" echo " -S <seed> Fitter seed setting (default: 1)"
echo " -D Output directory name won't contain the date"
echo " -h Show this text" echo " -h Show this text"
echo "" echo ""
@ -125,8 +162,9 @@ fi
nios_rev="Tiny" nios_rev="Tiny"
flow="full" flow="full"
seed="1" seed="1"
omit_date=false
while getopts ":cb:r:s:a:fn:l:S:h" opt; do while getopts ":cb:r:s:a:fn:l:S:DhH" opt; do
case $opt in case $opt in
c) c)
clear_work_dir=1 clear_work_dir=1
@ -149,6 +187,10 @@ while getopts ":cb:r:s:a:fn:l:S:h" opt; do
stp=$(readlink -f $OPTARG) stp=$(readlink -f $OPTARG)
;; ;;
H)
build_hosted=1
;;
f) f)
echo "Forcing STP insertion" echo "Forcing STP insertion"
force="-force" force="-force"
@ -166,6 +208,10 @@ while getopts ":cb:r:s:a:fn:l:S:h" opt; do
seed=$OPTARG seed=$OPTARG
;; ;;
D)
omit_date=true
;;
h) h)
usage usage
exit 0 exit 0
@ -183,6 +229,39 @@ while getopts ":cb:r:s:a:fn:l:S:h" opt; do
esac esac
done done
if [ "$build_hosted" == "1" ]; then
mkdir -p build_logs
build_pids=()
echo "Starting parallel builds for all hosted configurations..."
for config in "bladeRF 40" "bladeRF 115" "bladeRF-micro A4" "bladeRF-micro A5" "bladeRF-micro A9"; do
read -r board size <<< "$config"
log_file="build_logs/$board-hosted-$size.log"
$0 -b "$board" -r hosted -s "$size" > "$log_file" 2>&1 &
build_pids+=($!)
echo " → $board $size (PID: ${build_pids[-1]})"
done
echo "Waiting for ${#build_pids[@]} builds to complete..."
# Monitor build processes
failed=0
for pid in "${build_pids[@]}"; do
if ! wait "$pid"; then
failed=1
fi
done
if [ "$failed" -ne 0 ]; then
echo "One or more builds failed. Check build_logs directory for details."
cleanup
exit 1
fi
echo "All hosted builds completed successfully!"
exit 0
fi
if [ "$board" == "" ]; then if [ "$board" == "" ]; then
echo -e "\nError: board (-b) is required\n" >&2 echo -e "\nError: board (-b) is required\n" >&2
print_boards print_boards
@ -446,7 +525,11 @@ if [[ ${flow} == "full" ]]; then
BUILD_TIME_DONE=$(date -d"$BUILD_TIME_DONE" '+%F_%H.%M.%S') BUILD_TIME_DONE=$(date -d"$BUILD_TIME_DONE" '+%F_%H.%M.%S')
BUILD_NAME="$rev"x"$size" BUILD_NAME="$rev"x"$size"
if [ "$omit_date" = false ]; then
BUILD_OUTPUT_DIR="$BUILD_NAME"-"$BUILD_TIME_DONE" BUILD_OUTPUT_DIR="$BUILD_NAME"-"$BUILD_TIME_DONE"
else
BUILD_OUTPUT_DIR="$BUILD_NAME"
fi
RBF=$BUILD_NAME.rbf RBF=$BUILD_NAME.rbf
mkdir -p "$BUILD_OUTPUT_DIR" mkdir -p "$BUILD_OUTPUT_DIR"
@ -462,6 +545,18 @@ if [[ ${flow} == "full" ]]; then
sha256sum $RBF > $RBF.sha256sum sha256sum $RBF > $RBF.sha256sum
MD5SUM=$(cat $RBF.md5sum | awk '{ print $1 }') MD5SUM=$(cat $RBF.md5sum | awk '{ print $1 }')
SHA256SUM=$(cat $RBF.sha256sum | awk '{ print $1 }') SHA256SUM=$(cat $RBF.sha256sum | awk '{ print $1 }')
GIT_HASH=$(git rev-parse --short HEAD)
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
GIT_DIRTY=$(git diff --quiet && echo "clean" || echo "dirty")
cat << EOF > git_info.txt
Git Information:
Commit Hash: $GIT_HASH
Branch: $GIT_BRANCH
Working Directory: $GIT_DIRTY
EOF
popd popd
echo "" echo ""
@ -473,6 +568,10 @@ if [[ ${flow} == "full" ]]; then
echo " MD5: $MD5SUM" echo " MD5: $MD5SUM"
echo " SHA256: $SHA256SUM" echo " SHA256: $SHA256SUM"
echo "" echo ""
echo " Git Information:"
echo " Commit: $GIT_HASH ($GIT_DIRTY)"
echo " Branch: $GIT_BRANCH"
echo ""
cat "$BUILD_OUTPUT_DIR/$BUILD_NAME.fit.summary" | sed -e 's/^\(.\)/ \1/g' cat "$BUILD_OUTPUT_DIR/$BUILD_NAME.fit.summary" | sed -e 's/^\(.\)/ \1/g'
echo "##########################################################################" echo "##########################################################################"
fi fi
@ -482,4 +581,4 @@ printf "%s %02d:%02d:%02d\n" "Total Build Time:" "$(($SECONDS / 3600))" "$((($SE
echo "" echo ""
# Delete empty SOPC directories in the user's home directory # Delete empty SOPC directories in the user's home directory
find ~ -maxdepth 1 -type d -empty -iname "sopc_altera_pll*" -delete #find ~ -maxdepth 1 -type d -empty -iname "sopc_altera_pll*" -delete

View file

@ -4,24 +4,32 @@ cat << EOF
To be able to run NiOS's Eclipse the following steps must be taken: To be able to run NiOS's Eclipse the following steps must be taken:
#1) ./build_bladerf.sh must finish successfully #1) ./build_bladerf.sh must finish successfully
#2) Ensure eclipse-nios2 is installed. Read Intel's guide at: #2) Ensure eclipse-nios2 is installed. Read Intel's guide at:
https://www.intel.com/content/altera-www/global/en_us/index/support/support-resources/knowledge-base/tools/2019/why-does-the-nios--ii-not-installed-after-full-installation-of-t.html https://www.intel.com/content/www/us/en/support/programmable/articles/000086893.html
#3) ./launch_eclipse.sh must be called from hdl/quartus and provided with a #3) Replace Quartus bundled JVM with OpenJDK 8:
Reference: https://community.intel.com/t5/Intel-Quartus-Prime-Software/Nios-Eclipse-crashes-free-invalid-pointer/m-p/1215921#M66524
sudo apt update
sudo apt install openjdk-8-jdk
cd <path to quartus>/intelFPGA/20.1/quartus/linux64
mv jre64 jre64_old
ln -s /lib/jvm/java-1.8.0-openjdk-amd64/jre jre64
#4) ./launch_eclipse.sh must be called from hdl/quartus and provided with a
path to the build directory, see ./launch_eclipse.sh for example path to the build directory, see ./launch_eclipse.sh for example
#4) Once Eclipse is launched, go to File -> Import -> General -> Existing Projects into Workspace. #5) Once Eclipse is launched, go to File -> Import -> General -> Existing Projects into Workspace.
#5) Click "Select root directory" and supply the path to the bladeRF git repository. #6) Click "Select root directory" and supply the path to the bladeRF git repository.
#6) Select and import 2 projects: the bladeRF_nios_bsp project and the corresponding bladeRF project for the target bladeRF: #7) Select and import 2 projects: the bladeRF_nios_bsp project and the corresponding bladeRF project for the target bladeRF:
a) bladeRF_nios_bsp should be in hdl/fpga/platforms/common/bladerf/software/bladeRF_nios_bsp/ a) bladeRF_nios_bsp should be in hdl/fpga/platforms/common/bladerf/software/bladeRF_nios_bsp/
b) bladeRF (select hdl/fpga/platforms/bladerf for bladeRF 1.0 targets, select hdl/fpga/platforms/bladerf-micro for bladeRF 2.0 targets) b) bladeRF (select hdl/fpga/platforms/bladerf for bladeRF 1.0 targets, select hdl/fpga/platforms/bladerf-micro for bladeRF 2.0 targets)
#7) Once imported and available on the Project Explorer pane, right click "bladeRF_nios_bsp" and select "Nios II" -> "Generate BSP" #8) Once imported and available on the Project Explorer pane, right click "bladeRF_nios_bsp" and select "Nios II" -> "Generate BSP"
#8) Right click "bladeRF" in the Project Explorer pane, and select "Build Project" #9) Right click "bladeRF" in the Project Explorer pane, and select "Build Project"
Optionally to debug, Optionally to debug,
#1) Right click "bladeRF" in the Project Explorer pane, and select "Debug As" -> "Debug Configurations..." #1) sudo apt install -y libncursesw5 # for Ubuntu 20.04
#2) Right click "Nios II Hardware" and select "New", select "New_configuation" #2) Right click "bladeRF" in the Project Explorer pane, and select "Debug As" -> "Debug Configurations..."
#3) Under the "Project" tab, fill in the path to the recently generated Nios II ELF file #3) Right click "Nios II Hardware" and select "New", select "New_configuation"
#4) Under the "Target connection" tab, check "Ignore mismatched system ID" and "Ignore mismatched system timestamp" #4) Under the "Project" tab, fill in the path to the recently generated Nios II ELF file
#5) Find USB-Blaster in "Connections", click "Refresh Connections" if it does not show up #5) Under the "Target connection" tab, check "Ignore mismatched system ID" and "Ignore mismatched system timestamp"
#6) "Debug" button should be clickable #6) Find USB-Blaster in "Connections", click "Refresh Connections" if it does not show up
#7) "Debug" button should be clickable
If on Linux, consider adding a udev rule to grant access to the USB-Blaster to the plugdev group by adding two lines to /etc/udev/rules.d/91-usb.rules: If on Linux, consider adding a udev rule to grant access to the USB-Blaster to the plugdev group by adding two lines to /etc/udev/rules.d/91-usb.rules:

View file

@ -1,9 +1,10 @@
cmake_minimum_required(VERSION 2.8.12) cmake_minimum_required(VERSION 3.10...3.27)
project(bladeRF C) project(bladeRF C)
################################################################################ ################################################################################
# Project configuration # Project configuration
################################################################################ ################################################################################
add_compile_definitions(NUAND_MODIFICATIONS=1)
# All build output lands in this directory: # All build output lands in this directory:
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/output) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/output)
@ -97,7 +98,7 @@ add_subdirectory(common/thirdparty/ad936x)
option(ENABLE_GDB_EXTENSIONS "Build with -ggdb3 instead of -g" OFF) option(ENABLE_GDB_EXTENSIONS "Build with -ggdb3 instead of -g" OFF)
if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR
${CMAKE_C_COMPILER_ID} STREQUAL "Clang") ${CMAKE_C_COMPILER_ID} MATCHES ".*Clang")
# Personal preference - as much debug info as possible with GDB # Personal preference - as much debug info as possible with GDB
if(${ENABLE_GDB_EXTENSIONS}) if(${ENABLE_GDB_EXTENSIONS})
@ -119,7 +120,7 @@ if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR
endif(${CMAKE_BUILD_TYPE} STREQUAL "Debug") endif(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
endif(${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR endif(${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR
${CMAKE_C_COMPILER_ID} STREQUAL "Clang") ${CMAKE_C_COMPILER_ID} MATCHES ".*Clang")
############################### ###############################
# MS Visual Studio # MS Visual Studio
@ -134,6 +135,9 @@ if(MSVC)
if(MSVC_VERSION LESS 1800) if(MSVC_VERSION LESS 1800)
set(MSVC_C99_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/common/include/windows/c99) set(MSVC_C99_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/common/include/windows/c99)
endif() endif()
# MSVC ships with its own timespec
add_definitions(-DHAVE_STRUCT_TIMESPEC)
endif(MSVC) endif(MSVC)
################################################################################ ################################################################################
@ -227,29 +231,6 @@ add_custom_target(uninstall
# Windows-only, Post build: Copy libraries to our build output directory # Windows-only, Post build: Copy libraries to our build output directory
################################################################################ ################################################################################
if(WIN32 AND NOT CMAKE_CROSSCOMPILING) if(WIN32 AND NOT CMAKE_CROSSCOMPILING)
find_package(LibPThreadsWin32)
if(LIBPTHREADSWIN32_FOUND)
set(WIN_RUNTIME_ITEMS ${WIN_RUNTIME_ITEMS}
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/licenses/pthreads-win32/COPYING.LIB.txt"
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/pthreadVC2.dll")
add_custom_command(
OUTPUT "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/licenses/pthreads-win32/COPYING.LIB.txt"
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${LIBPTHREADSWIN32_LIB_COPYING}"
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/licenses/pthreads-win32/COPYING.LIB.txt"
COMMENT "Copying pthreads-win32 license to output directory..."
)
add_custom_command(
OUTPUT "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/pthreadVC2.dll"
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${LIBPTHREADSWIN32_DLL}"
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/"
COMMENT "Copying pthreadVC2.dll to output directory..."
)
endif(LIBPTHREADSWIN32_FOUND)
if(LIBUSB_FOUND) if(LIBUSB_FOUND)
set(WIN_RUNTIME_ITEMS ${WIN_RUNTIME_ITEMS} set(WIN_RUNTIME_ITEMS ${WIN_RUNTIME_ITEMS}
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/licenses/libusb/COPYING" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/licenses/libusb/COPYING"

View file

@ -23,9 +23,6 @@ Windows users that wish to use a Cypress driver/library based libbladeRF backend
### CMake ### ### CMake ###
[CMake][CMake.org] is used to build the items in this directory. \>= v2.8.5 is required, but the latest available version is recommended. [CMake][CMake.org] is used to build the items in this directory. \>= v2.8.5 is required, but the latest available version is recommended.
### pthreads-win32 - Windows-only ###
Windows users will need to get [pthreads-win32], and may (with newer Windows versions) need to build it from scratch.
## Build ## ## Build ##
### Linux and OSX ### ### Linux and OSX ###
@ -63,7 +60,6 @@ This process was most recently validated on Windows 10 Enterprise with CMake 3.9
- If you run into any failures, check these items, then re-run Configure: - If you run into any failures, check these items, then re-run Configure:
- LIBUSB_PATH (and ENABLE_BACKEND_LIBUSB) - for using libusb - LIBUSB_PATH (and ENABLE_BACKEND_LIBUSB) - for using libusb
- FX3_SDK_PATH (and ENABLE_BACKEND_CYAPI) - for using the Cypress driver - FX3_SDK_PATH (and ENABLE_BACKEND_CYAPI) - for using the Cypress driver
- LIBPTHREADSWIN32_PATH
- Adjust options as desired and re-run the "Configure" command as needed. Values in red are new, and should be reviewed before running "Configure" again to get the red out. - Adjust options as desired and re-run the "Configure" command as needed. Values in red are new, and should be reviewed before running "Configure" again to get the red out.
- Click the CMake GUI's "Generate" button. - Click the CMake GUI's "Generate" button.
- In the ```build``` directory, a Visual Studio solution will now exist. You can click "Open Project" to get there. - In the ```build``` directory, a Visual Studio solution will now exist. You can click "Open Project" to get there.
@ -71,21 +67,6 @@ This process was most recently validated on Windows 10 Enterprise with CMake 3.9
- Upon building the solution, build artifacts will be present in: ```build\output\<build type>``` - Upon building the solution, build artifacts will be present in: ```build\output\<build type>```
- ```<build_type>``` may refer to Debug or Release, for example - ```<build_type>``` may refer to Debug or Release, for example
#### pthreads-win32 ####
If you are using a newer version of Windows / Visual Studio and are getting ```error C0211: 'timespec': 'struct' type redefinition``` when trying to build bladeRF, you will need to rebuild pthreads-win32. The below process seems to work with pthreads-w32 2.9.1.
- Get full source tree from [pthreads-win32] website, and unpack someplace convenient
- In Visual Studio, open `pthreads-w32-2-9-1-release\pthreads.2\pthread.dsw` (one-way upgrade is OK)
- Right-click the solution, select "Retarget solution", hit OK.
- Change "Solution Configurations" dropdown to "Release" ("Debug" doesn't work, but that's OK)
- Edit pthread.h to add `#define HAVE_STRUCT_TIMESPEC` and `#define PTW32_ARCHx64` near the top, just below the include guard
- Build the solution
- Back over in the bladeRF CMake:
- File -> Delete Cache
- Redo the "Configure" dance as before
- Point `LIBPTHREADSWIN32_PATH` to the `pthreads-w32-2-9-1-release\pthreads.2` directory you were just working in
## CMake Options and Flags ## ## CMake Options and Flags ##
Below is a list of useful and project-specific CMake options. Please see the [CMake documentation] for Below is a list of useful and project-specific CMake options. Please see the [CMake documentation] for
@ -120,4 +101,3 @@ more information.
[CMake documentation]: http://www.cmake.org/cmake/help/documentation.html (Cmake documentation) [CMake documentation]: http://www.cmake.org/cmake/help/documentation.html (Cmake documentation)
[Cypress FX3 SDK]: http://www.cypress.com/?rID=57990 (Cypress FX3 SDK) [Cypress FX3 SDK]: http://www.cypress.com/?rID=57990 (Cypress FX3 SDK)
[redhat144967]: https://bugzilla.redhat.com/show_bug.cgi?id=144967 (Red Hat Bugzilla - Bug 144967) [redhat144967]: https://bugzilla.redhat.com/show_bug.cgi?id=144967 (Red Hat Bugzilla - Bug 144967)
[pthreads-win32]: https://sourceware.org/pthreads-win32/ (POSIX Threads for Win32)

View file

@ -1,113 +0,0 @@
# This is file is based off of the FindLibUSB.cmake file written by Hendrik Sattler,
# from the OpenOBEX project (licensed GPLv2/LGPL). (If this is not correct,
# please contact us so we can attribute the author appropriately.)
#
# https://github.com/zuckschwerdt/openobex/blob/master/CMakeModules/FindLibUSB.cmake
# http://dev.zuckschwerdt.org/openobex/
#
# Find pthreads-win32
#
# This requires the LIBPTHREADSWIN32_PATH variable to be set to the path to the
# a pthreads-win32 release, such as the Pre-built.2 directory from the 2.9.1 release:
# ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip
#
# The following standard variables get defined:
# LIBPTHREADSWIN32_FOUND: true if LibUSB was found
# LIBPTHREADSWIN32_HEADER_FILE: the location of the C header file
# LIBPTHREADSWIN32_INCLUDE_DIRS: the directories that contain headers
# LIBPTHREADSWIN32_LIBRARIES: the library files
# LIBPTHREADSWIN32_LIB_COPYING: the license associated with the library
# LIBPTHREADSWIN32_DLL: the pthreadVC2.dll file
if(DEFINED __INCLUDED_BLADERF_FINDLIBPTHREADSWIN32_CMAKE)
return()
endif()
set(__INCLUDED_BLADERF_FINDLIBPTHREADSWIN32_CMAKE TRUE)
include ( CheckLibraryExists )
include ( CheckIncludeFile )
set(LIBPTHREADSWIN32_PATH
"C:/Program Files (x86)/pthreads-win32"
CACHE
PATH
"Path to win-pthreads files. (This is generally only needed for Windows users who downloaded binary distributions.)"
)
find_file ( LIBPTHREADSWIN32_HEADER_FILE
NAMES
pthread.h
PATHS
${LIBPTHREADSWIN32_PATH}
PATH_SUFFIXES
include include
)
mark_as_advanced ( LIBPTHREADSWIN32_HEADER_FILE )
get_filename_component ( LIBPTHREADSWIN32_INCLUDE_DIRS "${LIBPTHREADSWIN32_HEADER_FILE}" PATH )
if ( WIN32 )
if ( MSVC )
if ( CMAKE_CL_64 )
set ( LIBPTHREADSWIN32_LIBRARY_PATH_SUFFIX x64 )
else ( CMAKE_CL_64 )
set ( LIBPTHREADSWIN32_LIBRARY_PATH_SUFFIX x86 )
endif ( CMAKE_CL_64 )
elseif ( CMAKE_COMPILER_IS_GNUCC )
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set ( LIBPTHREADSWIN32_LIBRARY_PATH_SUFFIX x64 )
else ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set ( LIBPTHREADSWIN32_LIBRARY_PATH_SUFFIX x86 )
endif ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
endif ( MSVC )
find_library ( PTHREAD_LIBRARY
NAMES
pthreadVC2
PATHS
${LIBPTHREADSWIN32_PATH}
PATH_SUFFIXES
lib/${LIBPTHREADSWIN32_LIBRARY_PATH_SUFFIX}
)
mark_as_advanced ( PTHREAD_LIBRARY )
if ( PTHREAD_LIBRARY )
set ( LIBPTHREADSWIN32_LIBRARIES ${PTHREAD_LIBRARY} )
endif ( PTHREAD_LIBRARY )
find_file ( PTHREAD_DLL
NAMES
pthreadVC2.dll
PATHS
${LIBPTHREADSWIN32_PATH}
PATH_SUFFIXES
dll/${LIBPTHREADSWIN32_LIBRARY_PATH_SUFFIX}
.
)
mark_as_advanced ( PTHREAD_DLL )
if ( PTHREAD_DLL )
set ( LIBPTHREADSWIN32_DLL ${PTHREAD_DLL} )
endif ( PTHREAD_DLL )
else ( WIN32 )
message(FATAL_ERROR "This file only supports Windows")
endif ( WIN32 )
set ( LIBPTHREADSWIN32_LIB_COPYING
"${LIBPTHREADSWIN32_PATH}/COPYING.LIB" )
if ( NOT EXISTS ${LIBPTHREADSWIN32_LIB_COPYING} )
message(FATAL_ERROR "Unable to find pthread-win32 COPYING.LIB file")
endif ()
if ( LIBPTHREADSWIN32_INCLUDE_DIRS AND LIBPTHREADSWIN32_LIBRARIES AND LIBPTHREADSWIN32_DLL )
set ( LIBPTHREADSWIN32_FOUND true )
endif ( LIBPTHREADSWIN32_INCLUDE_DIRS AND LIBPTHREADSWIN32_LIBRARIES AND LIBPTHREADSWIN32_DLL )
if ( LIBPTHREADSWIN32_FOUND )
set ( CMAKE_REQUIRED_INCLUDES "${LIBPTHREADSWIN32_INCLUDE_DIRS}" )
check_include_file ( "{LIBPTHREADSWIN32_HEADER_FILE}" LIBPTHREADSWIN32_FOUND )
endif ( LIBPTHREADSWIN32_FOUND )
if ( NOT LIBPTHREADSWIN32_FOUND )
message ( FATAL_ERROR "pthreads-win32 not found. If you're using a binary distribution, try setting -DLIBPTHREADSWIN32_PATH=<path_to_win_pthread_files>." )
endif ( NOT LIBPTHREADSWIN32_FOUND )

View file

@ -80,6 +80,11 @@ if(PKGCONFIG_LIBUSB_FOUND AND NOT LIBUSB_FOUND)
mark_as_advanced(${ibase}_LIBRARY) mark_as_advanced(${ibase}_LIBRARY)
endforeach(i) endforeach(i)
# assume we're using vcpkg
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
set(LIBUSB_LIBRARY_PATH_SUFFIX bin)
endif()
else(PKGCONFIG_LIBUSB_FOUND) else(PKGCONFIG_LIBUSB_FOUND)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
# The libusbx binary distribution contains several libs. # The libusbx binary distribution contains several libs.

View file

@ -127,6 +127,14 @@ bladerf_channel str2channel(char const *str);
*/ */
const char *direction2str(bladerf_direction dir); const char *direction2str(bladerf_direction dir);
/**
* Convert a channel enumeration to a direction
*
* @param ch channel
* @return Direction of the channel
*/
bladerf_direction channel2direction(bladerf_channel ch);
/** /**
* Convert a trigger signal enumeration value to a string * Convert a trigger signal enumeration value to a string
* *

View file

@ -316,7 +316,9 @@
/******************************************************************************* /*******************************************************************************
* Miscellaneous utility macros * Miscellaneous utility macros
******************************************************************************/ ******************************************************************************/
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(n) (sizeof(n) / sizeof(n[0])) #define ARRAY_SIZE(n) (sizeof(n) / sizeof(n[0]))
#endif
/** /**
* GCC 7+ warns on implicit fallthroughs in switch statements * GCC 7+ warns on implicit fallthroughs in switch statements

View file

@ -39,7 +39,9 @@ extern "C" {
#endif // __MACH__ #endif // __MACH__
typedef int clockid_t; typedef int clockid_t;
#ifndef CLOCK_REALTIME
#define CLOCK_REALTIME 0 #define CLOCK_REALTIME 0
#endif
int clock_gettime(clockid_t clk_id, struct timespec *tp); int clock_gettime(clockid_t clk_id, struct timespec *tp);

View file

@ -32,11 +32,32 @@
/* Currently, only pthreads is supported. In the future, native windows threads /* Currently, only pthreads is supported. In the future, native windows threads
* may be used; one of the objectives of this file is to ease that transistion. * may be used; one of the objectives of this file is to ease that transistion.
*/ */
#include <pthread.h>
#include "rel_assert.h" #include "rel_assert.h"
#define MUTEX pthread_mutex_t #if (defined(_WIN32) || defined(USE_NATIVE_THREADS)) && \
!defined(DO_NOT_USE_PTHREADS)
// Do not use pthreads on Windows
#undef USE_PTHREADS
#else
// Use pthreads on non-Windows platforms
#undef USE_PTHREADS
#define USE_PTHREADS
#endif
#ifdef USE_PTHREADS
/* Use pthreads */
#include <pthread.h>
#include <errno.h>
#include <time.h>
#ifndef CLOCK_REALTIME
#define CLOCK_REALTIME 0
#endif
#define THREAD pthread_t
#define MUTEX pthread_mutex_t
#define COND pthread_cond_t
#ifdef ENABLE_LOCK_CHECKS #ifdef ENABLE_LOCK_CHECKS
# define MUTEX_INIT(m) do { \ # define MUTEX_INIT(m) do { \
int status; \ int status; \
@ -64,11 +85,103 @@
int status = pthread_mutex_destroy(m); \ int status = pthread_mutex_destroy(m); \
assert(status == 0 && "Mutex destroy failure");\ assert(status == 0 && "Mutex destroy failure");\
} while (0) } while (0)
#else #else /* ENABLE_LOCK_CHECKS */
# define MUTEX_INIT(m) pthread_mutex_init(m, NULL)
# define MUTEX_LOCK(m) pthread_mutex_lock(m) #define MUTEX_INIT(m) pthread_mutex_init(m, NULL)
# define MUTEX_UNLOCK(m) pthread_mutex_unlock(m) #define MUTEX_LOCK(m) pthread_mutex_lock(m)
# define MUTEX_DESTROY(m) pthread_mutex_destroy(m) #define MUTEX_UNLOCK(m) pthread_mutex_unlock(m)
#endif #define MUTEX_DESTROY(m) pthread_mutex_destroy(m)
#endif /* ENABLE_LOCK_CHECKS */
# define THREAD_CREATE(x,y,z) pthread_create(x, NULL, y, z)
# define THREAD_SUCCESS 0
# define THREAD_TIMEOUT ETIMEDOUT
# define THREAD_CANCEL(m) pthread_cancel(m)
# define THREAD_JOIN(t, s) pthread_join(t, s)
# define THREAD_EXIT(s) pthread_exit(s)
# define COND_INIT(m) pthread_cond_init(m, NULL)
# define COND_SIGNAL(m) pthread_cond_signal(m)
// POSIX implementation as a function
static inline int posix_cond_timedwait(pthread_cond_t *c,
pthread_mutex_t *m,
unsigned int t)
{
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
ts.tv_sec += t / 1000;
ts.tv_nsec += (t % 1000) * 1000000;
if (ts.tv_nsec >= 1000000000) {
ts.tv_sec++;
ts.tv_nsec -= 1000000000;
}
return pthread_cond_timedwait(c, m, &ts) == ETIMEDOUT ? -1 : 0;
}
#define COND_TIMED_WAIT(c, m, t) posix_cond_timedwait(c, m, t)
#define COND_WAIT(c, m) pthread_cond_wait(c, m)
#else /* USE_PTHREADS */
#include <windows.h>
#include <time.h>
/* Use C11 threads */
//#include <threads.h>
#define THREAD HANDLE // For thread handles
#define MUTEX CRITICAL_SECTION // For mutexes
#define COND CONDITION_VARIABLE // For condition variables
#ifdef ENABLE_LOCK_CHECKS
# define MUTEX_INIT(m) do { \
int status; \
status = mtx_init(m, mtx_plain | mtx_recursive); \
assert(status == thrd_success && "Mutex init failure"); \
} while (0)
# define MUTEX_LOCK(m) do { \
int status = mtx_lock(m); \
assert(status == thrd_success && "Mutex lock failure");\
} while (0)
# define MUTEX_UNLOCK(m) do { \
int status = mtx_unlock(m); \
assert(status == thrd_success && "Mutex unlock failure");\
} while (0)
# define MUTEX_DESTROY(m) do { \
mtx_destroy(m); \
} while (0)
#else /* ENABLE_LOCK_CHECKS */
#define MUTEX_INIT(m) InitializeCriticalSection(m)
#define MUTEX_LOCK(m) EnterCriticalSection(m)
#define MUTEX_UNLOCK(m) LeaveCriticalSection(m)
#define MUTEX_DESTROY(m) DeleteCriticalSection(m)
#endif /* ENABLE_LOCK_CHECKS */
# define THREAD_CREATE(handle, func, arg) \
((*(handle) = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)(func), \
(LPVOID)(arg), 0, NULL)) == NULL ? GetLastError() : 0)
# define THREAD_SUCCESS 0
# define THREAD_TIMEOUT WAIT_TIMEOUT
# define THREAD_CANCEL(m) TerminateThread(m, 0)
# define THREAD_JOIN(t, s) WaitForSingleObject(t, INFINITE)
# define THREAD_EXIT(s) ExitThread(s)
# define COND_INIT(m) (InitializeConditionVariable(m), 0)
# define COND_SIGNAL(m) WakeConditionVariable(m)
# define COND_TIMED_WAIT(c, m, t) \
(SleepConditionVariableCS(c, m, t) ? 0 : GetLastError())
# define COND_WAIT(c, m) (!SleepConditionVariableCS(c, m, INFINITE))
#endif /* USE_PTHREADS */
#endif #endif

View file

@ -25,7 +25,7 @@
#ifndef WIN_CLOCK_GETTIME_H_ #ifndef WIN_CLOCK_GETTIME_H_
#define WIN_CLOCK_GETTIME_H_ #define WIN_CLOCK_GETTIME_H_
#include <pthread.h> #include "thread.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -36,7 +36,9 @@ extern "C" {
#endif #endif
typedef int clockid_t; typedef int clockid_t;
#ifndef CLOCK_REALTIME
#define CLOCK_REALTIME 0 #define CLOCK_REALTIME 0
#endif
int clock_gettime(clockid_t clk_id, struct timespec *tp); int clock_gettime(clockid_t clk_id, struct timespec *tp);

View file

@ -0,0 +1,44 @@
/*
* This file is part of the bladeRF project:
* http://www.github.com/nuand/bladeRF
*
* Copyright (c) 2023 Nuand LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef WIN_GETTIMEOFDAY_H_
#define WIN_GETTIMEOFDAY_H_
#include "thread.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef WIN32
#error "This file is intended for use with WIN32 systems only."
#endif
int gettimeofday(struct timeval *tp, struct timezone *tzp);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif

View file

@ -25,7 +25,7 @@
#ifndef WIN_NANOSLEEP_H_ #ifndef WIN_NANOSLEEP_H_
#define WIN_NANOSLEEP_H_ #define WIN_NANOSLEEP_H_
#include <pthread.h> #include "thread.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View file

@ -48,9 +48,10 @@
#endif #endif
#include <Windows.h> #include <Windows.h>
#include <time.h>
#include <stdint.h> #include <stdint.h>
#include "host_config.h" #include "host_config.h"
#include "pthread.h" #include "thread.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

Some files were not shown because too many files have changed in this diff Show more