2023-09-04 12:21:37 +02:00
|
|
|
/* Communicate with VILLASfpga Xilinx FPGA boards.
|
2020-06-13 15:49:31 +02:00
|
|
|
*
|
2022-03-15 09:18:01 -04:00
|
|
|
* Author: Steffen Vogel <post@steffenvogel.de>
|
2023-12-12 14:15:55 +01:00
|
|
|
* Author: Niklas Eiling <niklas.eiling@eonerc.rwth-aachen.de>
|
2022-03-15 09:28:57 -04:00
|
|
|
* SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
2023-12-12 14:15:55 +01:00
|
|
|
* SPDX-FileCopyrightText: 2023 Niklas Eiling <niklas.eiling@eonerc.rwth-aachen.de>
|
2022-07-04 18:20:03 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2020-06-13 15:49:31 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-05-10 00:12:30 +02:00
|
|
|
#include <villas/format.hpp>
|
2023-09-07 11:46:39 +02:00
|
|
|
#include <villas/node.hpp>
|
|
|
|
#include <villas/node/config.hpp>
|
2021-08-10 10:12:48 -04:00
|
|
|
#include <villas/timing.hpp>
|
2020-06-13 15:49:31 +02:00
|
|
|
|
2020-06-15 22:21:56 +02:00
|
|
|
#include <villas/fpga/card.hpp>
|
|
|
|
#include <villas/fpga/ips/dma.hpp>
|
2023-09-07 11:46:39 +02:00
|
|
|
#include <villas/fpga/node.hpp>
|
|
|
|
#include <villas/fpga/pcie_card.hpp>
|
2020-06-15 22:21:56 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
namespace villas {
|
|
|
|
namespace node {
|
|
|
|
|
2021-02-24 15:33:47 +01:00
|
|
|
class FpgaNode : public Node {
|
|
|
|
|
2023-12-12 14:15:55 +01:00
|
|
|
enum InterfaceType { PCIE, PLATFORM };
|
2020-06-13 15:49:31 +02:00
|
|
|
|
2023-12-12 14:15:55 +01:00
|
|
|
protected:
|
|
|
|
// Settings
|
2023-09-07 11:46:39 +02:00
|
|
|
std::string cardName;
|
2023-12-12 14:15:55 +01:00
|
|
|
std::list<std::string> connectStrings;
|
2020-06-13 15:49:31 +02:00
|
|
|
|
2023-12-12 14:15:55 +01:00
|
|
|
// State
|
|
|
|
std::shared_ptr<fpga::Card> card;
|
|
|
|
std::shared_ptr<villas::fpga::ip::Dma> dma;
|
|
|
|
std::shared_ptr<villas::MemoryBlock> blockRx[2];
|
|
|
|
std::shared_ptr<villas::MemoryBlock> blockTx;
|
2022-11-03 07:51:23 -04:00
|
|
|
|
2023-12-12 14:15:55 +01:00
|
|
|
// Non-public methods
|
|
|
|
virtual int _read(Sample *smps[], unsigned cnt) override;
|
|
|
|
|
|
|
|
virtual int _write(Sample *smps[], unsigned cnt) override;
|
2022-11-03 07:51:23 -04:00
|
|
|
|
2021-02-24 15:33:47 +01:00
|
|
|
public:
|
2023-09-07 11:46:39 +02:00
|
|
|
FpgaNode(const uuid_t &id = {}, const std::string &name = "");
|
2022-12-07 18:51:25 +01:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
virtual ~FpgaNode();
|
2020-06-13 15:49:31 +02:00
|
|
|
|
2023-12-12 14:15:55 +01:00
|
|
|
virtual int prepare() override;
|
|
|
|
|
|
|
|
virtual int parse(json_t *json) override;
|
2020-06-13 15:49:31 +02:00
|
|
|
|
2023-12-12 14:15:55 +01:00
|
|
|
virtual int check() override;
|
2020-06-13 15:49:31 +02:00
|
|
|
|
2023-12-12 14:15:55 +01:00
|
|
|
virtual int start() override;
|
2020-06-13 15:49:31 +02:00
|
|
|
|
2023-12-12 14:15:55 +01:00
|
|
|
virtual std::vector<int> getPollFDs() override;
|
2020-06-13 15:49:31 +02:00
|
|
|
|
2023-12-12 14:15:55 +01:00
|
|
|
virtual const std::string &getDetails() override;
|
2022-11-03 07:51:23 -04:00
|
|
|
};
|
2020-06-13 15:49:31 +02:00
|
|
|
|
2022-11-03 07:51:23 -04:00
|
|
|
class FpgaNodeFactory : public NodeFactory {
|
|
|
|
|
|
|
|
public:
|
2023-09-07 11:46:39 +02:00
|
|
|
using NodeFactory::NodeFactory;
|
|
|
|
|
2023-12-12 14:15:55 +01:00
|
|
|
virtual Node *make(const uuid_t &id = {},
|
|
|
|
const std::string &nme = "") override {
|
2023-09-07 11:46:39 +02:00
|
|
|
auto *n = new FpgaNode(id, nme);
|
|
|
|
|
|
|
|
init(n);
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2023-12-12 14:15:55 +01:00
|
|
|
virtual int getFlags() const override {
|
2023-09-07 11:46:39 +02:00
|
|
|
return (int)NodeFactory::Flags::SUPPORTS_READ |
|
|
|
|
(int)NodeFactory::Flags::SUPPORTS_WRITE |
|
|
|
|
(int)NodeFactory::Flags::SUPPORTS_POLL;
|
|
|
|
}
|
|
|
|
|
2023-12-12 14:15:55 +01:00
|
|
|
virtual std::string getName() const override { return "fpga"; }
|
2023-09-07 11:46:39 +02:00
|
|
|
|
2023-12-12 14:15:55 +01:00
|
|
|
virtual std::string getDescription() const override { return "VILLASfpga"; }
|
2023-09-07 11:46:39 +02:00
|
|
|
|
2023-12-12 14:15:55 +01:00
|
|
|
virtual int start(SuperNode *sn) override;
|
2021-02-24 15:33:47 +01:00
|
|
|
};
|
2020-06-13 15:49:31 +02:00
|
|
|
|
2023-08-28 09:34:02 +02:00
|
|
|
} // namespace node
|
|
|
|
} // namespace villas
|