mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
fpga: switch to float accessor for writes
Signed-off-by: Niklas Eiling <niklas.eiling@eonerc.rwth-aachen.de>
This commit is contained in:
parent
7991d31393
commit
675c489126
1 changed files with 5 additions and 19 deletions
|
@ -209,20 +209,13 @@ int FpgaNode::fastWrite(Sample *smps[], unsigned cnt) {
|
|||
|
||||
assert(cnt == 1 && smps != nullptr && smps[0] != nullptr);
|
||||
|
||||
auto mem = MemoryAccessor<uint32_t>(*blockTx);
|
||||
float scaled;
|
||||
auto mem = MemoryAccessor<float>(*blockTx);
|
||||
|
||||
for (unsigned i = 0; i < smp->length; i++) {
|
||||
if (smp->signals->getByIndex(i)->type == SignalType::FLOAT) {
|
||||
scaled = smp->data[i].f;
|
||||
if (scaled > 10.) {
|
||||
scaled = 10.;
|
||||
} else if (scaled < -10.) {
|
||||
scaled = -10.;
|
||||
}
|
||||
mem[i] = (scaled + 10.) * ((float)0xFFFF / 20.);
|
||||
mem[i] = smp->data[i].f;
|
||||
} else {
|
||||
mem[i] = smp->data[i].i;
|
||||
mem[i] = static_cast<float>(smp->data[i].i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -312,17 +305,10 @@ int FpgaNode::slowWrite(Sample *smps[], unsigned cnt) {
|
|||
|
||||
assert(cnt == 1 && smps != nullptr && smps[0] != nullptr);
|
||||
|
||||
auto mem = MemoryAccessor<uint32_t>(*blockTx);
|
||||
float scaled;
|
||||
auto mem = MemoryAccessor<float>(*blockTx);
|
||||
|
||||
for (unsigned i = 0; i < smps[0]->length; i++) {
|
||||
scaled = smps[0]->data[i].f;
|
||||
if (scaled > 10.) {
|
||||
scaled = 10.;
|
||||
} else if (scaled < -10.) {
|
||||
scaled = -10.;
|
||||
}
|
||||
mem[i] = (scaled + 10.) * ((float)0xFFFF / 20.);
|
||||
mem[i] = smps[0]->data[i].f;
|
||||
}
|
||||
|
||||
bool state = dma->write(*blockTx, smp->length * sizeof(float));
|
||||
|
|
Loading…
Add table
Reference in a new issue