2023-09-08 11:35:18 +02:00
|
|
|
/* RTDS AXI-Stream RTT unit test.
|
2017-11-21 21:31:08 +01:00
|
|
|
*
|
2023-01-07 17:20:15 +01:00
|
|
|
* Author: Steffen Vogel <post@steffenvogel.de>
|
2023-01-07 17:32:48 +01:00
|
|
|
* SPDX-FileCopyrightText: 2017 Steffen Vogel <post@steffenvogel.de>
|
2023-01-07 17:20:15 +01:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2023-09-08 11:35:18 +02:00
|
|
|
*/
|
2017-11-21 21:31:08 +01:00
|
|
|
|
|
|
|
#include <criterion/criterion.h>
|
|
|
|
|
2020-06-11 23:55:05 +02:00
|
|
|
#include <villas/fpga/card.hpp>
|
|
|
|
#include <villas/fpga/vlnv.hpp>
|
2017-11-21 21:31:08 +01:00
|
|
|
|
2020-06-11 23:55:05 +02:00
|
|
|
#include <villas/fpga/ips/dma.hpp>
|
|
|
|
#include <villas/fpga/ips/rtds.hpp>
|
2024-02-29 19:34:27 +01:00
|
|
|
#include <villas/fpga/ips/switch.hpp>
|
2017-11-21 21:31:08 +01:00
|
|
|
|
|
|
|
extern struct fpga_card *card;
|
|
|
|
|
2020-09-21 09:35:41 +02:00
|
|
|
// cppcheck-suppress unknownMacro
|
2024-02-29 19:34:27 +01:00
|
|
|
Test(fpga, rtds_rtt, .description = "RTDS: tight rtt") {
|
|
|
|
int ret;
|
|
|
|
struct fpga_ip *ip, *rtds;
|
|
|
|
struct dma_mem buf;
|
|
|
|
size_t recvlen;
|
2020-06-11 23:55:05 +02:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
std::list<villas::fpga::ip::Rtds *> rtdsIps;
|
|
|
|
std::list<villas::fpga::ip::Dma *> dmaIps;
|
2020-06-11 23:55:05 +02:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
// Get IP cores
|
|
|
|
for (auto &ip : state.cards.front()->ips) {
|
|
|
|
if (*ip ==
|
|
|
|
villas::fpga::Vlnv("acs.eonerc.rwth-aachen.de:user:rtds_axis:")) {
|
|
|
|
auto rtds = reinterpret_cast<villas::fpga::ip::Rtds *>(ip.get());
|
|
|
|
rtdsIps.push_back(rtds);
|
|
|
|
}
|
2020-06-11 23:55:05 +02:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
if (*ip == villas::fpga::Vlnv("xilinx.com:ip:axi_dma:")) {
|
|
|
|
auto dma = reinterpret_cast<villas::fpga::ip::Dma *>(ip.get());
|
|
|
|
dmaIps.push_back(dma);
|
|
|
|
}
|
|
|
|
}
|
2020-06-11 23:55:05 +02:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
for (auto rtds : rtdsIps) {
|
|
|
|
for (auto dma : dmaIps) {
|
2017-11-21 21:31:08 +01:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
rtds->connect
|
|
|
|
}
|
|
|
|
}
|
2017-11-21 21:31:08 +01:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
ret = switch_connect(card->sw, rtds, ip);
|
|
|
|
cr_assert_eq(ret, 0, "Failed to configure switch");
|
2017-11-21 21:31:08 +01:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
ret = switch_connect(card->sw, ip, rtds);
|
|
|
|
cr_assert_eq(ret, 0, "Failed to configure switch");
|
2017-11-21 21:31:08 +01:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
ret = dma_alloc(ip, &buf, 0x100, 0);
|
|
|
|
cr_assert_eq(ret, 0, "Failed to allocate DMA memory");
|
2017-11-21 21:31:08 +01:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
while (1) {
|
2017-11-21 21:31:08 +01:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
ret = dma_read(ip, buf.base_phys, buf.len);
|
|
|
|
cr_assert_eq(ret, 0, "Failed to start DMA read: %d", ret);
|
2017-11-21 21:31:08 +01:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
ret = dma_read_complete(ip, NULL, &recvlen);
|
|
|
|
cr_assert_eq(ret, 0, "Failed to complete DMA read: %d", ret);
|
2017-11-21 21:31:08 +01:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
ret = dma_write(ip, buf.base_phys, recvlen);
|
|
|
|
cr_assert_eq(ret, 0, "Failed to start DMA write: %d", ret);
|
2017-11-21 21:31:08 +01:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
ret = dma_write_complete(ip, NULL, NULL);
|
|
|
|
cr_assert_eq(ret, 0, "Failed to complete DMA write: %d", ret);
|
|
|
|
}
|
2017-11-21 21:31:08 +01:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
ret = switch_disconnect(card->sw, rtds, ip);
|
|
|
|
cr_assert_eq(ret, 0, "Failed to configure switch");
|
2017-11-21 21:31:08 +01:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
ret = switch_disconnect(card->sw, ip, rtds);
|
|
|
|
cr_assert_eq(ret, 0, "Failed to configure switch");
|
2017-11-21 21:31:08 +01:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
ret = dma_free(ip, &buf);
|
|
|
|
cr_assert_eq(ret, 0, "Failed to release DMA memory");
|
2017-11-21 21:31:08 +01:00
|
|
|
}
|