1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-16 00:00:02 +01:00
VILLASnode/fpga/lib/ips/rtds2gpu/gpu2rtds.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

142 lines
4.4 KiB
C++
Raw Permalink Normal View History

/* GPU2RTDS IP core
*
* Author: Daniel Krebs <github@daniel-krebs.net>
* SPDX-FileCopyrightText: 2017 Daniel Krebs <github@daniel-krebs.net>
* SPDX-License-Identifier: Apache-2.0
*/
2018-05-30 17:24:51 +02:00
#include <cstring>
#include <unistd.h>
2018-05-30 17:24:51 +02:00
#include <villas/fpga/ips/gpu2rtds.hpp>
2018-08-21 14:25:20 +02:00
#include <villas/log.hpp>
2018-05-30 17:24:51 +02:00
#include <villas/memory_manager.hpp>
using namespace villas::fpga::ip;
2018-05-30 17:24:51 +02:00
bool Gpu2Rtds::init() {
Hls::init();
2018-05-30 17:24:51 +02:00
auto &registers = addressTranslations.at(registerMemory);
2018-05-30 17:24:51 +02:00
registerStatus = reinterpret_cast<StatusRegister *>(
registers.getLocalAddr(registerStatusOffset));
registerStatusCtrl = reinterpret_cast<StatusControlRegister *>(
registers.getLocalAddr(registerStatusCtrlOffset));
registerFrameSize = reinterpret_cast<uint32_t *>(
registers.getLocalAddr(registerFrameSizeOffset));
registerFrames =
reinterpret_cast<uint32_t *>(registers.getLocalAddr(registerFrameOffset));
2018-05-30 17:24:51 +02:00
maxFrameSize = getMaxFrameSize();
logger->info("Max. frame size supported: {}", maxFrameSize);
2018-05-30 17:24:51 +02:00
return true;
2018-05-30 17:24:51 +02:00
}
bool Gpu2Rtds::startOnce(size_t frameSize) {
*registerFrameSize = frameSize;
2018-05-30 17:24:51 +02:00
start();
2018-05-30 17:24:51 +02:00
return true;
2018-05-30 17:24:51 +02:00
}
void Gpu2Rtds::dump(spdlog::level::level_enum logLevel) {
const auto frame_size = *registerFrameSize;
auto status = *registerStatus;
logger->log(logLevel, "Gpu2Rtds registers:");
logger->log(logLevel, " Frame size (words): {:#x}", frame_size);
logger->log(logLevel, " Status: {:#x}", status.value);
logger->log(logLevel, " Running: {}",
(status.is_running ? "yes" : "no"));
logger->log(logLevel, " Frame too short: {}",
(status.frame_too_short ? "yes" : "no"));
logger->log(logLevel, " Frame too long: {}",
(status.frame_too_long ? "yes" : "no"));
logger->log(logLevel, " Frame size invalid: {}",
(status.invalid_frame_size ? "yes" : "no"));
logger->log(logLevel, " Last count: {}", (int)status.last_count);
logger->log(logLevel, " Last seq. number: {}", (int)status.last_seq_nr);
logger->log(logLevel, " Max. frame size: {}",
(int)status.max_frame_size);
2018-05-30 17:24:51 +02:00
}
2020-06-14 22:03:50 +02:00
//bool Gpu2Rtds::startOnce(const MemoryBlock &mem, size_t frameSize, size_t dataOffset, size_t doorbellOffset)
2018-05-30 17:24:51 +02:00
//{
2020-06-14 22:03:50 +02:00
// auto &mm = MemoryManager::get();
2018-05-30 17:24:51 +02:00
2020-06-11 18:38:46 +02:00
// if (frameSize > maxFrameSize) {
2018-05-30 17:24:51 +02:00
// logger->error("Requested frame size of {} exceeds max. frame size of {}",
// frameSize, maxFrameSize);
// return false;
// }
// auto translationFromIp = mm.getTranslation(
// getMasterAddrSpaceByInterface(axiInterface),
// mem.getAddrSpaceId());
2022-08-30 12:01:47 -04:00
// // Set address of memory block in HLS IP
2018-05-30 17:24:51 +02:00
// XGpu2Rtds_Set_baseaddr(&xInstance, translationFromIp.getLocalAddr(0));
// XGpu2Rtds_Set_doorbell_offset(&xInstance, doorbellOffset);
// XGpu2Rtds_Set_data_offset(&xInstance, dataOffset);
// XGpu2Rtds_Set_frame_size(&xInstance, frameSize);
2022-08-30 12:01:47 -04:00
// // Prepare memory with all zeroes
2018-05-30 17:24:51 +02:00
// auto translationFromProcess = mm.getTranslationFromProcess(mem.getAddrSpaceId());
// auto memory = reinterpret_cast<void*>(translationFromProcess.getLocalAddr(0));
// memset(memory, 0, mem.getSize());
2022-08-30 12:01:47 -04:00
// // Start IP
2018-05-30 17:24:51 +02:00
// return start();
//}
//bool
//Gpu2Rtds::updateStatus()
//{
2020-06-11 18:38:46 +02:00
// if (not XGpu2Rtds_Get_status_vld(&xInstance))
2018-05-30 17:24:51 +02:00
// return false;
// status.value = XGpu2Rtds_Get_status(&xInstance);
// return true;
//}
size_t Gpu2Rtds::getMaxFrameSize() {
*registerFrameSize = 0;
2018-05-30 17:24:51 +02:00
start();
while (not isFinished())
;
2018-05-30 17:24:51 +02:00
while (not registerStatusCtrl->status_ap_vld)
;
2018-05-30 17:24:51 +02:00
axilite_reg_status_t status = *registerStatus;
2018-05-30 17:24:51 +02:00
// logger->debug("(*registerStatus).max_frame_size: {}", (*registerStatus).max_frame_size);
// logger->debug("status.max_frame_size: {}", status.max_frame_size);
2018-05-30 17:24:51 +02:00
// assert(status.max_frame_size == (*registerStatus).max_frame_size);
2018-05-30 17:24:51 +02:00
return status.max_frame_size;
2018-05-30 17:24:51 +02:00
}
//void
//Gpu2Rtds::dumpDoorbell(uint32_t doorbellRegister) const
//{
2020-06-14 22:03:50 +02:00
// auto &doorbell = reinterpret_cast<reg_doorbell_t&>(doorbellRegister);
2018-05-30 17:24:51 +02:00
// logger->info("Doorbell register: {:#08x}", doorbell.value);
// logger->info(" Valid: {}", (doorbell.is_valid ? "yes" : "no"));
// logger->info(" Count: {}", doorbell.count);
2022-03-04 03:33:47 -05:00
// logger->info(" Seq. number: {}", (int) doorbell.seq_nr);
2018-05-30 17:24:51 +02:00
//}
static char n[] = "gpu2rtds";
static char d[] = "HLS Gpu2Rtds IP";
static char v[] = "acs.eonerc.rwth-aachen.de:hls:gpu2rtds:";
static NodePlugin<Gpu2Rtds, n, d, v> p;