Skip to content

Commit

Permalink
TimingSource: basic implementation of snoop logic
Browse files Browse the repository at this point in the history
Adds timing block with unit-test and dokumentation.

run `build/blocklib/timing/test/qa_timingSource timing-hardware`
to run the actual hardware tests, which are disabled by default because
they cannot work on the CI.

Other changes:
timing.hpp: use custom signal group to allow multiple threads

Special thanks to @RalphSteinhagen and @slebedev for their feedback and
for catching a few issues early on in the review.

Signed-off-by: Alexander Krimm <alex@wirew0rm.de>
  • Loading branch information
wirew0rm committed Dec 11, 2024
1 parent 0fced61 commit 4d7a4b9
Show file tree
Hide file tree
Showing 10 changed files with 922 additions and 146 deletions.
2 changes: 1 addition & 1 deletion blocklib/picoscope/test/qa_Picoscope.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void testStreamingBasics() {

expect(ge(sink._nSamplesProduced, 80000UZ));
expect(le(sink._nSamplesProduced, 170000UZ));
expect(eq(tagMonitor._tags.size(), 1UZ));
expect(ge(tagMonitor._tags.size(), 1UZ));
if (tagMonitor._tags.size() == 1UZ) {
const auto& tag = tagMonitor._tags[0];
expect(eq(tag.index, int64_t{0}));
Expand Down
43 changes: 25 additions & 18 deletions blocklib/timing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
if (NOT EMSCRIPTEN AND NOT CLANG)
add_library(timing INTERFACE)
target_include_directories(timing INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include/)
if(NOT EMSCRIPTEN AND NOT CLANG)
add_library(timing INTERFACE include/timing.hpp include/TimingSource.hpp)
target_include_directories(timing
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include/)
target_link_libraries(timing INTERFACE PkgConfig::saftlib
PkgConfig::etherbone)

if (GR_DIGITIZERS_TOPLEVEL_PROJECT)
cmrc_add_resource_library(
ui_assets
NAMESPACE
ui_assets
WHENCE
${imgui_SOURCE_DIR}/misc/fonts
${imgui_SOURCE_DIR}/misc/fonts/Roboto-Medium.ttf)
if(GR_DIGITIZERS_TOPLEVEL_PROJECT)
cmrc_add_resource_library(
ui_assets NAMESPACE ui_assets WHENCE ${imgui_SOURCE_DIR}/misc/fonts
${imgui_SOURCE_DIR}/misc/fonts/Roboto-Medium.ttf)

add_executable(test-timing src/test-timing.cpp)
target_link_libraries(test-timing PRIVATE gr-digitizers-options timing PkgConfig::saftlib PkgConfig::etherbone imgui implot gnuradio-algorithm gnuradio-core ui_assets)
endif ()
endif ()
add_executable(test-timing src/test-timing.cpp)
target_link_libraries(
test-timing
PRIVATE gr-digitizers-options
timing
imgui
implot
gnuradio-algorithm
gnuradio-core
ui_assets)
endif()
endif()

if (ENABLE_GR_DIGITIZERS_TESTING)
add_subdirectory(test)
endif ()
if(ENABLE_GR_DIGITIZERS_TESTING)
add_subdirectory(test)
endif()
80 changes: 40 additions & 40 deletions blocklib/timing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This directory contains the timing realated gnuradio blocks along with some testing utilites and setup instructions.

# Dependencies

For actually using the blocks and utilities built by this you will also need actual timing receiver hardware, the
[wishbone kernel module](https://ohwr.org/project/fpga-config-space/tree/realtime_fixes/pcie-wb) has to be loaded and the saftlibd daemon has to be running and configured properly.

Expand All @@ -19,7 +20,7 @@ sudo make install
git clone --branch v3.0.3 --depth=1 https://github.com/GSI-CS-CO/saftlib.git
cd saftlib
./autogen.sh
./configure
./configure
make -j
sudo make install
```
Expand All @@ -29,45 +30,44 @@ sudo make install
- build etherbone and saftlib as described above
- build gr-digitizers with `-DENABLE_TIMING=True`
- load the required kernel modules if the card is connected via PCIe: `modprobe pcie_wb`
- verify they are loaded correctly: `lsmod | grep wb`, `dmesg | tail`
- verify they are loaded correctly: `lsmod | grep wb`, `dmesg | tail`
- start saftd demon and attach timing card: `saftd tr0:dev/wbm0` (where `dev/wbm0` is the device path of the wishbone device without leading slash)
- if there is no physical timing signal plugged into the card, the card has to be switched to master mode:
- `eb-console /dev/wbm0` and enter `mode master` and hit return. The console should print a message that the timing mode is changed.
- eb-console is included in [bel_projects](https://github.com/GSI-CS-CO/bel_projects).
If you only need the single tool and have installed etherbone on your system by other means you can build only eb-console:
```bash
$ git clone https://github.com/GSI-CS-CO/bel_projects
$ cd bel_projects/tools
$ make EB=/usr/include eb-console # or point the EB variable to whatever prefix you installed etherbone to
$ ./eb-console dev/wbm0 # or dev/ttyUSB0
```
- `eb-console /dev/wbm0` and enter `mode master` and hit return. The console should print a message that the timing mode is changed.
- eb-console is included in [bel_projects](https://github.com/GSI-CS-CO/bel_projects).
If you only need the single tool and have installed etherbone on your system by other means you can build only eb-console:
```bash
$ git clone https://github.com/GSI-CS-CO/bel_projects
$ cd bel_projects/tools
$ make EB=/usr/include eb-console # or point the EB variable to whatever prefix you installed etherbone to
$ ./eb-console dev/wbm0 # or dev/ttyUSB0
```
- verify that everything works with saft-ctl:
- ``` bash
$ saft-ctl tr0 -ijkst
saftlib source version : saftlib 3.0.3 (6aab401-dirty): Aug 29 2023 09:50:19
saftlib build info : built by unknown on Jan 1 1980 00:00:00 with localhost running
devices attached on this host : 1
device: /de/gsi/saftlib/tr0, name: tr0, path: dev/wbm0, gatewareVersion : 6.1.2
--gateware version info:
---- Mon Aug 09 08:48:31 CEST 2021
---- fallout-v6.1.2
---- Arria V (5agxma3d4f27i3)
---- CentOS Linux release 7.9.2009 (Core), kernel 3.10.0-1160.36.2.el7.x86_64
---- pexaria5 +db[12] +wrex1
---- Timing Group Jenkins <csco-tg@gsi.de>
---- tsl021.acc.gsi.de
---- pci_control
---- Version 18.1.0 Build 625 09/12/2018 SJ Standard Edition
---- fallout-3847
6.1.2
current temperature (Celsius): 48
WR locked, time: 0x001181787bda0268
receiver free conditions: 255, max (capacity of HW): 0(256), early threshold: 4294967296 ns, latency: 4096 ns
sinks instantiated on this host: 1
/de/gsi/saftlib/tr0/software/_77 (minOffset: -1000000000 ns, maxOffset: 1000000000 ns)
-- actions: 0, delayed: 0, conflict: 0, late: 0, early: 0, overflow: 0 (max signalRate: 10Hz)
-- conditions: 0
```
- snoop on all events: `saft-ctl tr0 snoop 0x0 0x0 0x0` and on another terminal inject an event: `saft-ctl tr0 inject 0x1154000140000000 0x15 1000000` to verify it arrives.
- finally launch `build/blocklib/timing/test-timing` to show the UI

- ```bash
$ saft-ctl tr0 -ijkst
saftlib source version : saftlib 3.0.3 (6aab401-dirty): Aug 29 2023 09:50:19
saftlib build info : built by unknown on Jan 1 1980 00:00:00 with localhost running
devices attached on this host : 1
device: /de/gsi/saftlib/tr0, name: tr0, path: dev/wbm0, gatewareVersion : 6.1.2
--gateware version info:
---- Mon Aug 09 08:48:31 CEST 2021
---- fallout-v6.1.2
---- Arria V (5agxma3d4f27i3)
---- CentOS Linux release 7.9.2009 (Core), kernel 3.10.0-1160.36.2.el7.x86_64
---- pexaria5 +db[12] +wrex1
---- Timing Group Jenkins <csco-tg@gsi.de>
---- tsl021.acc.gsi.de
---- pci_control
---- Version 18.1.0 Build 625 09/12/2018 SJ Standard Edition
---- fallout-3847
6.1.2
current temperature (Celsius): 48
WR locked, time: 0x001181787bda0268
receiver free conditions: 255, max (capacity of HW): 0(256), early threshold: 4294967296 ns, latency: 4096 ns
sinks instantiated on this host: 1
/de/gsi/saftlib/tr0/software/_77 (minOffset: -1000000000 ns, maxOffset: 1000000000 ns)
-- actions: 0, delayed: 0, conflict: 0, late: 0, early: 0, overflow: 0 (max signalRate: 10Hz)
-- conditions: 0
```
- snoop on all events: `saft-ctl tr0 snoop 0x0 0x0 0x0` and on another terminal inject an event: `saft-ctl tr0 inject 0x1154000140000000 0x15 1000000` to verify it arrives.
- finally launch `build/blocklib/timing/test-timing` to show the UI of the debug utility
Loading

0 comments on commit 4d7a4b9

Please sign in to comment.