diff --git a/include/villas/nodes/fpga.hpp b/include/villas/nodes/fpga.hpp index 022bb8874..98a0fc9f3 100644 --- a/include/villas/nodes/fpga.hpp +++ b/include/villas/nodes/fpga.hpp @@ -62,9 +62,11 @@ protected: std::shared_ptr card; std::shared_ptr dma; std::shared_ptr blockRx; - std::shared_ptr> accessorRx; + std::shared_ptr> accessorRxInt; + std::shared_ptr> accessorRxFloat; std::shared_ptr blockTx; - std::shared_ptr> accessorTx; + std::shared_ptr> accessorTxInt; + std::shared_ptr> accessorTxFloat; // Non-public methods virtual int fastRead(Sample *smps[], unsigned cnt); diff --git a/lib/nodes/fpga.cpp b/lib/nodes/fpga.cpp index 2ac59cd9a..3e12653c2 100644 --- a/lib/nodes/fpga.cpp +++ b/lib/nodes/fpga.cpp @@ -37,8 +37,9 @@ static std::shared_ptr vfioContainer; FpgaNode::FpgaNode(const uuid_t &id, const std::string &name) : Node(id, name), cardName(""), connectStrings(), lowLatencyMode(false), - timestep(10e-3), card(nullptr), dma(), blockRx(), accessorRx(nullptr), - blockTx(), accessorTx(nullptr) {} + timestep(10e-3), card(nullptr), dma(), blockRx(), accessorRxInt(nullptr), + accessorRxFloat(nullptr), blockTx(), accessorTxInt(nullptr), + accessorTxFloat(nullptr) {} FpgaNode::~FpgaNode() {} @@ -92,8 +93,10 @@ int FpgaNode::prepare() { blockRx = alloc.allocateBlock(0x200 * sizeof(float)); blockTx = alloc.allocateBlock(0x200 * sizeof(float)); - accessorRx = std::make_shared>(*blockRx); - accessorTx = std::make_shared>(*blockTx); + accessorRxInt = std::make_shared>(*blockRx); + accessorTxInt = std::make_shared>(*blockTx); + accessorRxFloat = std::make_shared>(*blockRx); + accessorTxFloat = std::make_shared>(*blockTx); dma->makeAccesibleFromVA(blockRx); dma->makeAccesibleFromVA(blockTx); @@ -223,10 +226,10 @@ int FpgaNode::fastWrite(Sample *smps[], unsigned cnt) { for (unsigned i = 0; i < smp->length; i++) { if (smp->signals->getByIndex(i)->type == SignalType::FLOAT) { - float f = static_cast(smp->data[i].f); - (*accessorTx)[i] = *reinterpret_cast(&f); + (*accessorTxFloat)[i] = static_cast(smp->data[i].f); + ; } else { - (*accessorTx)[i] = static_cast(smp->data[i].i); + (*accessorTxInt)[i] = static_cast(smp->data[i].i); } } @@ -277,10 +280,9 @@ int FpgaNode::fastRead(Sample *smps[], unsigned cnt) { break; } if (in.signals->getByIndex(i)->type == SignalType::INTEGER) { - smp->data[i].i = static_cast((*accessorRx)[i]); + smp->data[i].i = static_cast((*accessorRxInt)[i]); } else { - smp->data[i].f = - static_cast(*reinterpret_cast(&(*accessorRx)[i])); + smp->data[i].f = static_cast((*accessorRxFloat)[i]); } smp->length++; }