mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
add device ip matcher
This commit is contained in:
parent
f335d40b98
commit
4e5f23ea66
1 changed files with 39 additions and 0 deletions
39
common/include/villas/kernel/devices/device_ip_matcher.hpp
Normal file
39
common/include/villas/kernel/devices/device_ip_matcher.hpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* Devicematcher
|
||||
*
|
||||
* Author: Pascal Bauer <pascal.bauer@rwth-aachen.de>
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2023-2024 Pascal Bauer <pascal.bauer@rwth-aachen.de>
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <villas/fpga/core.hpp>
|
||||
#include <villas/kernel/devices/ip_device.hpp>
|
||||
|
||||
class DeviceIpMatcher {
|
||||
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 {
|
||||
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;
|
||||
}
|
||||
};
|
Loading…
Add table
Reference in a new issue