rtds2gpu.hpp 2 KB
Newer Older
Daniel Krebs's avatar
Daniel Krebs committed
1
2
3
4
#pragma once

#include <villas/memory.hpp>
#include <villas/fpga/ip_node.hpp>
5
#include <villas/fpga/ips/hls.hpp>
Daniel Krebs's avatar
Daniel Krebs committed
6
7

#include "rtds2gpu/xrtds2gpu.h"
Daniel Krebs's avatar
Daniel Krebs committed
8
#include "rtds2gpu/register_types.hpp"
Daniel Krebs's avatar
Daniel Krebs committed
9
10
11
12
13

namespace villas {
namespace fpga {
namespace ip {

Daniel Krebs's avatar
Daniel Krebs committed
14
15
16
17
18
19
20
21
22
23
24
25
26
union ControlRegister {
	uint32_t value;
	struct  { uint32_t
		ap_start				: 1,
		ap_done					: 1,
		ap_idle					: 1,
		ap_ready				: 1,
		_res1					: 3,
		auto_restart			: 1,
		_res2					: 24;
	};
};

Daniel Krebs's avatar
Daniel Krebs committed
27

28
class Rtds2Gpu : public IpNode, public Hls
Daniel Krebs's avatar
Daniel Krebs committed
29
30
31
32
33
34
{
public:
	friend class Rtds2GpuFactory;

	bool init();

35
36
37
38
	void dump()
	{ dumpLog(); }

	bool dumpLog(spdlog::level::level_enum logLevel = spdlog::level::info);
Daniel Krebs's avatar
Daniel Krebs committed
39

Daniel Krebs's avatar
Daniel Krebs committed
40
41
42
43
44
45
	bool startOnce(const MemoryBlock& mem, size_t frameSize, size_t dataOffset, size_t doorbellOffset);

	size_t getMaxFrameSize();

	void dumpDoorbell(uint32_t doorbellRegister) const;

46
47
48
	bool doorbellIsValid(const uint32_t& doorbellRegister) const
	{ return reinterpret_cast<const reg_doorbell_t&>(doorbellRegister).is_valid; }

49
50
51
52
	const axilite_reg_status_t&
	getStatusRegister()
	{ updateStatus(); return status; }

53
54
55
56
57
	void doorbellReset(uint32_t& doorbellRegister) const
	{ doorbellRegister = 0; }

	static constexpr const char* registerMemory = "Reg";

Daniel Krebs's avatar
Daniel Krebs committed
58
	std::list<MemoryBlockName> getMemoryBlocks() const
59
	{ return { registerMemory }; }
Daniel Krebs's avatar
Daniel Krebs committed
60
61


62
63
64
65
	const StreamVertex&
	getDefaultSlavePort() const
	{ return getSlavePort(rtdsInputStreamPort); }

Daniel Krebs's avatar
Daniel Krebs committed
66
67
private:
	bool updateStatus();
Daniel Krebs's avatar
Daniel Krebs committed
68
69
70

private:
	static constexpr const char* axiInterface = "m_axi_axi_mm";
71
	static constexpr const char* rtdsInputStreamPort = "rtds_input";
Daniel Krebs's avatar
Daniel Krebs committed
72
73

	XRtds2gpu xInstance;
Daniel Krebs's avatar
Daniel Krebs committed
74
75
76
77
78

	axilite_reg_status_t status;
	size_t maxFrameSize;

	bool started;
Daniel Krebs's avatar
Daniel Krebs committed
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
};


class Rtds2GpuFactory : public IpNodeFactory {
public:
	Rtds2GpuFactory();

	IpCore* create()
	{ return new Rtds2Gpu; }

	std::string
	getName() const
	{ return "Rtds2Gpu"; }

	std::string
	getDescription() const
	{ return "HLS RTDS2GPU IP"; }

	Vlnv getCompatibleVlnv() const
98
	{ return {"acs.eonerc.rwth-aachen.de:hls:rtds2gpu:"}; }
Daniel Krebs's avatar
Daniel Krebs committed
99
100
101
102
103
};

} // namespace ip
} // namespace fpga
} // namespace villas