Commit graph

133 commits

Author SHA1 Message Date
Martin Braun
29a2dbfcf9 python: Add pyproject.toml with black line length
This file is added for both UHD and MPM.
2024-04-08 21:44:38 -05:00
Wade Fife
d0cdf87b07 rfnoc: image builder: Add option to specify build output directory 2024-03-15 20:08:15 -05:00
Wade Fife
1981e2c548 rfnoc: image builder: Add make jobs option 2024-03-15 20:07:28 -05:00
Wade Fife
5b85c5d0ff rfnoc: image builder: Add option to build IP only 2024-03-15 20:07:28 -05:00
Wade Fife
0ec8e95576 rfnoc: image builder: Add project save option to image builder 2024-03-15 20:05:39 -05:00
Martin Anderseck
ad6607a8fe python: Add DramReceiver class
This class is a utility to more easily using an available replay block
as a receiver
2024-02-27 11:29:00 -06:00
Martin Braun
09f3453f39 fpga: Update tooling to use image builder instead of make
This modifies repeat_fpga_build.py such that it can take a YAML file as
input, not just a make target. It will then use the image builder to
prepare the build and generate a valid make command, which in turn is
used to build FPGA images repeatedly.
2024-02-25 16:54:12 -06:00
Martin Braun
16bab2eec4 python: Explicitly list .mako files as part of Python package 2024-02-25 16:54:12 -06:00
Martin Braun
56c1a7c63b cmake: Add ENABLE_PYMOD_UTILS option, fix venv
This options allows to install Python utils, including a subset of the
Python API 'uhd' module, without having to compile UHD. The main reason
to do this is to allow installing the RFNoC image builder without the
rest of UHD. To achieve this, run cmake as such:

    cmake /path/to/uhd -DENABLE_LIBUHD=OFF -DENABLE_PYMOD_UTILS=ON

You might also want to disable building the manual in this case.

The refactoring required to enable this also fixes an issues when
installing UHD from source into a venv.  This updates the CMake to use
pip3 to install the module, fixing some warnings and install issues.
2024-02-19 21:12:01 -06:00
Martin Braun
2233b8d05e cmake: Update UHDPython.cmake
- Use find_package(pybind11) to find a system-wide Pybind11. This will
  take preference over the vendored version of Pybind11, unless
  requested otherwise.
- Fix a typo.
2024-02-14 21:53:16 -06:00
Martin Braun
736d20ea95 python: Add version API calls
New API calls in UHD Python API:
- get_version_string()
- get_abi_string()
- get_component()
2024-01-30 13:37:07 -06:00
zolveuran
f3815f3384 python: Fix setting start_time having no effect
In the Python MultiUSRP class, has_time_spec and stream_now were not
being properly set, basically making send_waveform() unable to use
timed streams.
2024-01-25 09:57:47 -06:00
Martin Braun
754813b0d6 rfnoc: image builder: Add clock index support to image builder
- Image core files can now provide timebase_clock and ctrl_clock fields
  to blocks, which will populate the backend interface accordingly.
- Clocks ports now have a direction associated (in, out).
2023-10-17 10:24:15 -05:00
Grant Meyerhoff
31bfb70dc8 usrpctl: add reset command 2023-08-04 19:42:57 -05:00
SaarthakMohanNI
41c0ab4d95 host/python: Update last_gain at end of run_rx_cal loop 2023-07-18 17:03:16 -05:00
Martin Braun
51c1a74eee examples: Amend tx_waveforms.py to use DramTransmitter
When calling tx_waveforms.py with the --dram option, it will internally
use DramTransmitter and first upload the signal before transmitting it
from DRAM.
2023-07-07 12:35:55 -07:00
Martin Braun
73fd6f8c0d python: Add 'const' to get_continuous_tone(); improve sanity-checks
- 'const' is now a valid waveform
- Fixes an issue with generating ramps and handling floating-point
  inputs
2023-07-07 12:35:55 -07:00
Martin Braun
c42cd3617c python: multi_usrp: Remove spurious print 2023-07-07 12:35:55 -07:00
Martin Braun
8c108418c9 python: Add DramTransmitter class
This class is a utility to more easily using an available replay block as
a transmitter.
2023-07-07 12:35:55 -07:00
Martin Braun
fc58ee343f python: Wrap direction_t 2023-06-29 09:39:47 -05:00
Martin Braun
2c057a37e9 python: signal: Add more waveforms to get_continuous_tone()
Still defaults to sine, can now also do square and ramp.
2023-06-28 10:45:39 -05:00
Wade Fife
e3794ba5ed python: Add X440 to image builder 2023-06-26 10:45:10 -05:00
Martin Braun
c385d20eee cmake: Fix auto-detection of Python install directory
This fixes an issue where on Ubuntu 22.04 (with Python 3.10), the
installation of the Python module would go to $PREFIX/local/lib even if
the rest goes to $PREFIX/lib. We achieve this by avoiding a) using
sysconfig.get_path() to get *both* the prefix and the library path, and
then also avoiding the `posix_local` install scheme.

Note: This same logic fails to work for MPM, so we don't touch that, but
simply force MPM to use the same path as UHD has. This means MPM is
unaffected when built by itself, but follows the UHD path when built as
part of UHD.

Hat-tip to Johannes Demel for pointing out this solution path.
2023-04-03 13:09:59 -07:00
Wade Fife
85f71cda7b rfnoc: Support multiple CHDR widths in RFNoC image builder
This adds support for different CHDR widths in the RFNoC image builder
and allows you to specify which crossbar paths to enable in the CHDR
crossbar.

In the HDL, a different CHDR width can be specified for each transport
adapter using Verilog parameters. In the RFNoC image YAML, the width of
each stream endpoint can be specified using the chdr_width parameter,
and the width for all blocks can be specified using the
block_chdr_width parameter.

With this change, the existing top-level "chdr_width" setting is now
effectively the default when not otherwise specified.

The crossbar_routes parameter can be provided using an NxN array where
N is the number of transport adapters + stream endpoints for the image
being built. For example, on X310 the following could be used:

crossbar_routes:
  #  eth0  pcie  ep1   ep3   ep5
  #     eth1  ep0   ep2   ep4
  - [ 1, 0, 0, 1, 1, 1, 1, 1, 1 ] # eth0 (10/1 GbE/Aurora)
  - [ 0, 1, 0, 1, 1, 1, 1, 1, 1 ] # eth1 (10 GbE/Aurora)
  - [ 0, 0, 1, 1, 1, 1, 1, 1, 1 ] # pcie
  - [ 1, 1, 1, 0, 0, 0, 0, 1, 1 ] # ep0 (radio0.0)
  - [ 1, 1, 1, 0, 0, 0, 0, 1, 1 ] # ep1 (radio0.1)
  - [ 1, 1, 1, 0, 0, 0, 0, 1, 1 ] # ep2 (radio1.0)
  - [ 1, 1, 1, 0, 0, 0, 0, 1, 1 ] # ep3 (radio1.1)
  - [ 1, 1, 1, 1, 1, 1, 1, 0, 0 ] # ep4 (replay0.0)
  - [ 1, 1, 1, 1, 1, 1, 1, 0, 0 ] # ep5 (replay0.1)

This would disable loopback paths between transport adapters, between
radio ports, and between replay ports.

Note that these features should be used with care. Removing some
crossbar routes may prevent the USRP from functioning correctly.
Specifying improper CHDR widths may lead to streaming issues.
2023-02-24 08:07:17 -06:00
Wade Fife
79eb470a93 rfnoc: Add options for RFNoC image core headers
This adds options to rfnoc_image_builder to make optional the fields of
the header in the generated RFNoC image core files. This includes the
copyright, license, date/time of generation, and source hash.
2023-02-22 21:55:02 -06:00
Wade Fife
d556d92f8f rfnoc: Set DEVICE_FAMILY on stream endpoints 2023-02-13 10:50:45 -06:00
David Raeman
51d4411ec1 e3xx: add support for power calibration api
This commit adds support for the UHD power calibration API on the E3xx
family of radios. It also updates the documentation to reflect this
support, and it adds support to the uhd_power_cal.py utility by adding a
"calibrator" subclass for E3xx radios.
2023-01-17 11:30:53 -08:00
Martin Braun
f14ce015b9 uhd: python: Bind {separate,combine}_device_addr{s}
This adds two functions from C++ land into Python:

- uhd.types.separate_device_addr()
- uhd.types.combine_device_addrs()

Signed-off-by: Martin Braun <martin.braun@ettus.com>
2022-10-28 10:15:20 -05:00
Martin Braun
e62a92793d fixup! mpm: Add CompatNumber utility class
The original commit did not add the compat_num.py file to the
CMakeLists.txt file. This would only be a problem when re-running
CMake with a different branch.
2022-07-20 17:08:33 -05:00
mattprost
f6101fb07d python: cmake: Detect python virtual environments
This allows a UHD build to link to python modules installed in a virtual
environment such a venv or pyenv.

Signed-off-by: mattprost <matt.prost@ni.com>
2022-06-23 05:57:12 -07:00
Wade Fife
ff8212ca84 python: Check rfnoc_version in rfnoc_image_builder 2022-05-11 12:29:35 -07:00
Wade Fife
c1f1f32d0b rfnoc: Update image builder to check for deprecated blocks
Adds checks for deprecated blocks (e.g., radio_1x64.yml instead of
radio.yml) as well as deprecated IO signature types (e.g., ctrl_port
instead of ctrlport).

Deprecated block descriptions are no longer parsed. Old IO signature
types are automatically converted to the new type. Warnings are
printed in both cases.
2022-04-12 13:31:19 -07:00
mattprost
b8acf58798 n310: Add Filter API to n310
Add the Filter API to n3xx specifically for the AD937x device.  The TX
filter is limited to 32 taps, and the RX filter is limited to 48 taps.

This feature requires MPM version 4.2 or later on the device.

Co-authored-by: bpadalino <bpadalino@gmail.com>
Signed-off-by: mattprost <matt.prost@ni.com>
2022-04-07 13:28:02 -07:00
mattprost
0cf8a60a4e types: filters: Add python support for digital filters
Signed-off-by: mattprost <matt.prost@ni.com>
2022-04-07 13:28:02 -07:00
Wade Fife
246b725195 rfnoc: Update image builder to check for deprecated port names 2022-03-31 13:51:23 -07:00
Lars Amsel
99ad89609b tools: Add general purpose tool for USRP configuration
Over the years the UHD code base got a whole bunch of tools to
control and configure devices. This is an attempt to unify these
tools into one.

Co-authored-by: Alexander Weber <alexander.weber@ni.com>
2022-03-23 16:27:04 -05:00
Martin Braun
850ff3b2bf python: Add __init__ to uhd.utils
Without this, the following code fails:

>>> import uhd
>>> U = uhd.usrp.MultiUSRP("type=x4xx")
>>> M = U.get_mpm_client()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    M = U.get_mpm_client()
  File ".../uhd/usrp/multi_usrp.py", line 37, in <lambda>
    setattr(self,
        'get_mpm_client', lambda: _get_mpm_client(token, mb_args))
  File ".../uhd/usrp/multi_usrp.py", line 19, in _get_mpm_client
    from uhd.utils import mpmtools
ModuleNotFoundError: No module named 'uhd.utils'
2022-03-14 15:50:57 -05:00
Martin Braun
bcdb8a1b8f python: rfnoc: Add connect_through_blocks() and get_block_chain()
These RFNoC C++ API calls were previously not exported into Python.
2022-02-24 13:39:56 -06:00
André Apitzsch
0db4d4124f python: Read number of ports from grc file in image builder 2022-02-24 13:33:22 -06:00
André Apitzsch
8b19791f37 python: Fix RuntimeError: dictionary changed size during iteration
Iterate over copy and delete from original dictionary.
2022-02-24 13:33:22 -06:00
Steven Koo
396ed0c8af fixup! cmake: Replace distutils.sysconfig with sysconfig
The original commit incorrectly fails the build
uhd in the meta-ettus context. This uses prefix
instead to get the base path.

Signed-off-by: Steven Koo <steven.koo@ni.com>
2022-01-20 08:31:50 -06:00
Aaron Rossetto
87bc7c1bde cmake: Replace distutils.sysconfig with sysconfig
This commit replaces uses of distutils.sysconfig's get_python_lib()
function with sysconfig's near-equivalent get_path() function to get the
directory for site-specific, platform-specific files. Unfortunately,
get_path() does not have a way to easily modify or strip the prefix
applied to the path like get_python_lib() does, so the code must
manually modify the path to get the same effect:

- First, the platlib path is retrieved from the get_path() call.
- Next, the default base that is used to form the pathlib path is
queried via the get_config_var('base') call.
- Next, the portion of the platlib path that matches the default base is
stripped, and any leading path separator remaining is stripped. This
fundamentally replicates the behavior of get_python_lib() with an empty
prefix (i.e., the prefix positional parameter is specified as '').
- If a different prefix is desired, then the os.path.join() function is
used to combine the new prefix with the stripped pathlib path, ensuring
that the platform-specific path separator is used in crafting the path.
2022-01-14 14:36:39 -06:00
Aaron Rossetto
6d746fd296 cmake: Replace distutils with CMake for version checks
This commit replaces the use of distutils.version.LooseVersion() with
CMake's version comparison operator, which implements relational version
string checking in the same manner (i.e., comparing numeric components
of a version string numerically).
2022-01-14 14:36:39 -06:00
Lars Amsel
9ad4bedd86 fixup! uhd: Allow pass raw IQ data array to tone generator 2022-01-13 14:32:31 -06:00
Lars Amsel
d33deb3cae uhd: Allow pass raw IQ data array to tone generator
Instead of calculating a tone from its parameter it is also useful
to pass an precalculated signal to be played. This change modifies
the __init__ to take an iq_data as parameter for the internal buffer
and moves the generation of the tone from rate, frequency and amplitude
into a class method. The streamer parameter was deleted (never used).
2022-01-10 13:31:44 -06:00
Lars Amsel
f59f3c2490 tools: Add check for SEP with ctrl enabled to rfnoc_image_builder
When creating RFNoC images at least one SEP needs to have ctrl enabled
otherwise one will end up with a non-functional image.

This commit adds a method to the image builder to do plausibility checks
on the configuration. The only check done for now is to verify that there
is at least one SEP with ctrl enabled.
2021-12-16 09:26:46 -06:00
Martin Braun
4e1068671f python: multi_usrp: Fix issues in send_waveform()
- Like with RX, this now allows passing in stream time and existing
  streamer
- There was no EOB being sent at the end (now there is)
- Fixed some linter issues
2021-10-06 11:57:25 -07:00
Martin Braun
9650342c12 python: multi_usrp: Fix issues with recv_num_samps()
- This function didn't set the time properly for multi-chan rx
- There was no way to set a start time manually
- It relied on garbage collection and correct destruction of streamers
  when being called multiple times. Addressed this by adding an option
  to pass in an existing streamer object.
- Linter wasn't too happy with this function.
2021-10-06 11:57:25 -07:00
Martin Braun
09d94529e5 cmake: Replace CMAKE_{SOURCE,BINARY}_DIR with UHD_*_DIR
See the CMake 3.8 documentation on these two variables:
https://cmake.org/cmake/help/v3.8/variable/PROJECT-NAME_SOURCE_DIR.html
https://cmake.org/cmake/help/v3.8/variable/CMAKE_SOURCE_DIR.html

Under normal circumstances, these two are identical. For sub-projects
(i.e., when building UHD as part of something else that is also a CMake
project), only the former is useful. There is no discernible downside of
using UHD_SOURCE_DIR over CMAKE_SOURCE_DIR.

This was changed using sed:

$ sed -i "s/CMAKE_SOURCE_DIR/UHD_SOURCE_DIR/g" \
    `ag -l CMAKE_SOURCE_DIR **/{CMakeLists.txt,*.cmake}`
$ sed -i "s/CMAKE_BINARY_DIR/UHD_BINARY_DIR/g" \
    `ag -l CMAKE_BINARY_DIR **/{CMakeLists.txt,*.cmake}`

At the same time, we also replace the CMake variable UHD_HOST_ROOT (used
in MPM) with UHD_SOURCE_DIR. There's no reason to have two variables
with the same meaning and different names, but more importantly, this
means that UHD_SOURCE_DIR is defined even in those cases where MPM calls
into CMake files from UHD without any additional patches.

Shoutout to GitHub user marcobergamin for bringing this up.
2021-09-10 15:08:10 -05:00
Wade Fife
3d7d5668fb rfnoc: Add vivado-path to rfnoc_image_builder
Adds a --vivado-path option to rfnoc_image_builder that, if present,
gets passed to setupenv.sh for the target device. This can be used to
specify the location of Vivado if it is not installed in one of the
default search locations.
2021-09-10 15:07:05 -05:00