Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a matcher for OS IP devices and IPs on a FPGA #839

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions common/include/villas/kernel/devices/device_ip_matcher.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* Matcher for IP devices in an OS devicetree and ips on a fpga board.
* Matching based on address prefix in device name and ip memory address
*
* Author: Pascal Bauer <[email protected]>
*
* SPDX-FileCopyrightText: 2023-2024 Pascal Bauer <[email protected]>
* SPDX-License-Identifier: Apache-2.0
*/

#pragma once

#include <villas/fpga/core.hpp>
#include <villas/kernel/devices/ip_device.hpp>

class DeviceIpMatcher {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why create a class? A function would be enough right?

private:
std::vector<villas::kernel::devices::IpDevice> devices;
std::list<std::shared_ptr<villas::fpga::ip::Core>> ips;

public:
DeviceIpMatcher(std::vector<villas::kernel::devices::IpDevice> devices,
std::list<std::shared_ptr<villas::fpga::ip::Core>> ips)
: devices(devices), ips(ips) {}

std::vector<std::pair<std::shared_ptr<villas::fpga::ip::Core>,
villas::kernel::devices::IpDevice>>
match() const {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look correctly formatted. Please check your clang-format configuration

std::vector<std::pair<std::shared_ptr<villas::fpga::ip::Core>,
villas::kernel::devices::IpDevice>>
pairs;
for (auto device : devices) {
for (auto ip : ips) {
if (ip->getBaseaddr() == device.addr()) {
pairs.push_back(std::make_pair(ip, device));
}
}
}
return pairs;
}
};