Skip to content

Commit

Permalink
Merge pull request #152 from fair-acc/timingBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
wirew0rm authored Dec 11, 2024
2 parents 749394c + 4d7a4b9 commit 3bcb5e8
Show file tree
Hide file tree
Showing 13 changed files with 963 additions and 171 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ set(ENABLE_TESTING OFF)
FetchContent_Declare(
gnuradio4
GIT_REPOSITORY https://github.com/fair-acc/gnuradio4.git
GIT_TAG 5e7ecc561dfb35a6a8fd357f50d12efd09303c4f # main as of 2024-10-18
GIT_TAG db0a2bcc4a14759c992ca89661f687b87d93e923 # main as of 2024-12-09
)

FetchContent_Declare(
Expand Down Expand Up @@ -63,7 +63,7 @@ else()
FetchContent_Declare(
imgui
GIT_REPOSITORY https://github.com/ocornut/imgui.git
GIT_TAG v1.90.1)
GIT_TAG v1.91.5)

# Enables 32 bit vertex indices for ImGui
add_compile_definitions("ImDrawIdx=unsigned int")
Expand Down
25 changes: 14 additions & 11 deletions blocklib/digitizers/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
function(add_ut_test TEST_NAME)
add_executable(${TEST_NAME} ${TEST_NAME}.cc)
if ((CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")) # needed for clang15 (false positives, fixed in clang16)
target_compile_options(${TEST_NAME} PRIVATE -Wall)
target_link_options(${TEST_NAME} PRIVATE -Wall)
else ()
target_compile_options(${TEST_NAME} PRIVATE -fsanitize=address -Wall)
target_link_options(${TEST_NAME} PRIVATE -fsanitize=address -Wall)
endif ()
target_include_directories(${TEST_NAME} PRIVATE ${CMAKE_BINARY_DIR}/include ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(${TEST_NAME} PRIVATE gnuradio-core gr-digitizers refl-cpp fmt ut)
add_test(NAME ${TEST_NAME} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME})
add_executable(${TEST_NAME} ${TEST_NAME}.cc)
if((CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")) # needed for clang15 (false
# positives, fixed in clang16)
target_compile_options(${TEST_NAME} PRIVATE -Wall)
target_link_options(${TEST_NAME} PRIVATE -Wall)
else()
target_compile_options(${TEST_NAME} PRIVATE -fsanitize=address -Wall)
target_link_options(${TEST_NAME} PRIVATE -fsanitize=address -Wall)
endif()
target_include_directories(${TEST_NAME} PRIVATE ${CMAKE_BINARY_DIR}/include
${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(${TEST_NAME} PRIVATE gnuradio-core gr-digitizers fmt ut)
add_test(NAME ${TEST_NAME} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR}
${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME})
endfunction()

add_ut_test(qa_BlockScalingOffset)
37 changes: 25 additions & 12 deletions blocklib/picoscope/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
# TODO do not hardcode
add_library(ps4000a SHARED IMPORTED GLOBAL)
set_property(TARGET ps4000a PROPERTY
IMPORTED_LOCATION ${PICOSCOPE_PREFIX}/lib/libps4000a.so)
set_property(TARGET ps4000a PROPERTY IMPORTED_LOCATION
${PICOSCOPE_PREFIX}/lib/libps4000a.so)
target_link_libraries(ps4000a INTERFACE PkgConfig::zlib PkgConfig::libusb)
target_include_directories(ps4000a INTERFACE ${PICOSCOPE_PREFIX}/include/libps4000a ${PICOSCOPE_PREFIX}/include/libps5000a) # Hack: PicoCallback.h is missing in libps4000a/
target_include_directories(
ps4000a INTERFACE ${PICOSCOPE_PREFIX}/include/libps4000a
${PICOSCOPE_PREFIX}/include/libps5000a) # Hack:
# PicoCallback.h is
# missing in
# libps4000a/

add_library(ps5000a SHARED IMPORTED GLOBAL)
set_property(TARGET ps5000a PROPERTY
IMPORTED_LOCATION ${PICOSCOPE_PREFIX}/lib/libps5000a.so)
set_property(TARGET ps5000a PROPERTY IMPORTED_LOCATION
${PICOSCOPE_PREFIX}/lib/libps5000a.so)
target_link_libraries(ps5000a INTERFACE PkgConfig::zlib PkgConfig::libusb)
target_include_directories(ps5000a INTERFACE ${PICOSCOPE_PREFIX}/include/libps5000a)
target_include_directories(ps5000a
INTERFACE ${PICOSCOPE_PREFIX}/include/libps5000a)

add_library(fair-picoscope INTERFACE)
target_include_directories(fair-picoscope INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:include/>)
target_include_directories(
fair-picoscope INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include/>)

target_link_libraries(fair-picoscope INTERFACE ps4000a ps5000a gr-digitizers-options gnuradio-core refl-cpp fmt)
set_target_properties(gr-digitizers PROPERTIES PUBLIC_HEADER "Picoscope.hpp;Picoscope4000a.hpp;StatusMessages.hpp")
target_link_libraries(
fair-picoscope INTERFACE ps4000a ps5000a gr-digitizers-options gnuradio-core
fmt)
set_target_properties(
gr-digitizers
PROPERTIES PUBLIC_HEADER
"Picoscope.hpp;Picoscope4000a.hpp;StatusMessages.hpp")

if (ENABLE_GR_DIGITIZERS_TESTING)
add_subdirectory(test)
endif ()
if(ENABLE_GR_DIGITIZERS_TESTING)
add_subdirectory(test)
endif()
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 3bcb5e8

Please sign in to comment.