2023-09-08 11:35:18 +02:00
|
|
|
/* Driver for wrapper around Aurora (acs.eonerc.rwth-aachen.de:user:aurora)
|
2020-06-02 00:54:31 +02:00
|
|
|
*
|
2023-01-07 17:20:15 +01:00
|
|
|
* Author: Hatim Kanchwala <hatim@hatimak.me>
|
2023-09-08 11:35:18 +02:00
|
|
|
* SPDX-FileCopyrightText: 2020 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
2023-01-07 17:20:15 +01:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2023-09-08 11:35:18 +02:00
|
|
|
*/
|
2020-06-02 00:54:31 +02:00
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
2020-06-11 14:20:33 +02:00
|
|
|
#include <villas/utils.hpp>
|
2020-06-02 00:54:31 +02:00
|
|
|
|
|
|
|
#include <villas/fpga/ips/aurora.hpp>
|
|
|
|
|
2022-08-30 12:01:47 -04:00
|
|
|
// Register offsets
|
2024-02-29 19:34:27 +01:00
|
|
|
#define AURORA_AXIS_SR_OFFSET 0x00 // Status Register (read-only)
|
|
|
|
#define AURORA_AXIS_CR_OFFSET 0x04 // Control Register (read/write)
|
|
|
|
#define AURORA_AXIS_CNTR_IN_HIGH_OFFSET \
|
|
|
|
0x0C // Higher 32-bits of incoming frame counter
|
|
|
|
#define AURORA_AXIS_CNTR_IN_LOW_OFFSET \
|
|
|
|
0x08 // Lower 32-bits of incoming frame counter
|
|
|
|
#define AURORA_AXIS_CNTR_OUT_HIGH_OFFSET \
|
|
|
|
0x18 // Higher 32-bits of outgoing frame counter
|
|
|
|
#define AURORA_AXIS_CNTR_OUT_LOW_OFFSET \
|
|
|
|
0x1C // Lower 32-bits of outgoing frame counter
|
2022-08-30 12:01:47 -04:00
|
|
|
|
|
|
|
// Status register bits
|
2024-02-29 19:34:27 +01:00
|
|
|
#define AURORA_AXIS_SR_CHAN_UP \
|
|
|
|
(1 \
|
|
|
|
<< 0) // 1-bit, asserted when channel initialisation is complete and is ready for data transfer
|
|
|
|
#define AURORA_AXIS_SR_LANE_UP \
|
|
|
|
(1 << 1) // 1-bit, asserted for each lane upon successful lane initialisation
|
|
|
|
#define AURORA_AXIS_SR_HARD_ERR (1 << 2) // 1-bit hard rror status
|
|
|
|
#define AURORA_AXIS_SR_SOFT_ERR (1 << 3) // 1-bit soft error status
|
|
|
|
#define AURORA_AXIS_SR_FRAME_ERR (1 << 4) // 1-bit frame error status
|
2022-08-30 12:01:47 -04:00
|
|
|
|
|
|
|
// Control register bits
|
|
|
|
// 1-bit, assert to put Aurora IP in loopback mode.
|
2024-02-29 19:34:27 +01:00
|
|
|
#define AURORA_AXIS_CR_LOOPBACK (1 << 0)
|
2022-08-30 12:01:47 -04:00
|
|
|
|
|
|
|
// 1-bit, assert to reset counters, incoming and outgoing frame counters.
|
2024-02-29 19:34:27 +01:00
|
|
|
#define AURORA_AXIS_CR_RST_CTRS (1 << 1)
|
2022-08-30 12:01:47 -04:00
|
|
|
|
|
|
|
// 1-bit, assert to turn off any sequence number handling by Aurora IP
|
|
|
|
// Sequence number must be handled in software then.
|
2024-02-29 19:34:27 +01:00
|
|
|
#define AURORA_AXIS_CR_SEQ_MODE (1 << 2)
|
2022-08-30 12:01:47 -04:00
|
|
|
|
2023-09-08 11:35:18 +02:00
|
|
|
/* 1-bit, assert to strip the received frame of the trailing sequence
|
2022-08-30 12:01:47 -04:00
|
|
|
* number. Sequence number mode must be set to handled by Aurora IP,
|
2020-06-08 00:55:33 +02:00
|
|
|
* otherwise this bit is ignored. */
|
2024-02-29 19:34:27 +01:00
|
|
|
#define AURORA_AXIS_CR_SEQ_STRIP (1 << 3)
|
2020-06-11 13:01:27 +02:00
|
|
|
|
2023-09-08 11:35:18 +02:00
|
|
|
/* 1-bit, assert to use the same sequence number in the outgoing
|
2022-08-30 12:01:47 -04:00
|
|
|
* NovaCor-bound frames as the sequence number received from the
|
|
|
|
* incoming frames from NovaCor. Sequence number mode must be set to
|
2020-06-08 00:55:33 +02:00
|
|
|
* handled by Aurora IP, otherwise this bit is ignored.*/
|
2024-02-29 19:34:27 +01:00
|
|
|
#define AURORA_AXIS_CR_SEQ_ECHO (1 << 4)
|
2020-06-08 00:55:33 +02:00
|
|
|
|
2020-06-14 22:11:15 +02:00
|
|
|
using namespace villas::fpga::ip;
|
2020-06-02 00:54:31 +02:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
void Aurora::dump() {
|
|
|
|
// Check Aurora AXI4 registers
|
|
|
|
const uint32_t sr =
|
|
|
|
readMemory<uint32_t>(registerMemory, AURORA_AXIS_SR_OFFSET);
|
|
|
|
|
|
|
|
logger->info("Aurora-NovaCor AXI-Stream interface details:");
|
|
|
|
logger->info("Aurora status: {:#x}", sr);
|
|
|
|
logger->info(" Channel up: {}",
|
|
|
|
sr & AURORA_AXIS_SR_CHAN_UP ? CLR_GRN("yes") : CLR_RED("no"));
|
|
|
|
logger->info(" Lane up: {}",
|
|
|
|
sr & AURORA_AXIS_SR_LANE_UP ? CLR_GRN("yes") : CLR_RED("no"));
|
|
|
|
logger->info(" Hard error: {}",
|
|
|
|
sr & AURORA_AXIS_SR_HARD_ERR ? CLR_RED("yes") : CLR_GRN("no"));
|
|
|
|
logger->info(" Soft error: {}",
|
|
|
|
sr & AURORA_AXIS_SR_SOFT_ERR ? CLR_RED("yes") : CLR_GRN("no"));
|
|
|
|
logger->info(" Frame error: {}",
|
|
|
|
sr & AURORA_AXIS_SR_FRAME_ERR ? CLR_RED("yes") : CLR_GRN("no"));
|
|
|
|
|
|
|
|
const uint64_t inCntLow =
|
|
|
|
readMemory<uint32_t>(registerMemory, AURORA_AXIS_CNTR_IN_LOW_OFFSET);
|
|
|
|
const uint64_t inCntHigh =
|
|
|
|
readMemory<uint32_t>(registerMemory, AURORA_AXIS_CNTR_IN_HIGH_OFFSET);
|
|
|
|
const uint64_t inCnt = (inCntHigh << 32) | inCntLow;
|
|
|
|
|
|
|
|
const uint64_t outCntLow =
|
|
|
|
readMemory<uint32_t>(registerMemory, AURORA_AXIS_CNTR_OUT_LOW_OFFSET);
|
|
|
|
const uint64_t outCntHigh =
|
|
|
|
readMemory<uint32_t>(registerMemory, AURORA_AXIS_CNTR_OUT_HIGH_OFFSET);
|
|
|
|
const uint64_t outCnt = (outCntHigh << 32) | outCntLow;
|
|
|
|
|
|
|
|
logger->info("Aurora frames received: {}", inCnt);
|
|
|
|
logger->info("Aurora frames sent: {}", outCnt);
|
2020-06-02 00:54:31 +02:00
|
|
|
}
|
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
void Aurora::setLoopback(bool state) {
|
|
|
|
auto cr = readMemory<uint32_t>(registerMemory, AURORA_AXIS_CR_OFFSET);
|
2020-06-11 13:08:42 +02:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
if (state)
|
|
|
|
cr |= AURORA_AXIS_CR_LOOPBACK;
|
|
|
|
else
|
|
|
|
cr &= ~AURORA_AXIS_CR_LOOPBACK;
|
2020-06-11 13:08:42 +02:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
writeMemory<uint32_t>(registerMemory, AURORA_AXIS_CR_OFFSET, cr);
|
2020-06-11 13:08:42 +02:00
|
|
|
}
|
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
void Aurora::resetFrameCounters() {
|
|
|
|
auto cr = readMemory<uint32_t>(registerMemory, AURORA_AXIS_CR_OFFSET);
|
2020-06-11 13:08:42 +02:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
cr |= AURORA_AXIS_CR_RST_CTRS;
|
2020-06-11 13:08:42 +02:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
writeMemory<uint32_t>(registerMemory, AURORA_AXIS_CR_OFFSET, cr);
|
2020-06-11 13:08:42 +02:00
|
|
|
}
|
2022-12-02 18:46:00 +01:00
|
|
|
|
|
|
|
static char n[] = "aurora";
|
2024-02-29 19:34:27 +01:00
|
|
|
static char d[] = "Aurora 8B/10B and additional support modules, like an "
|
|
|
|
"AXI4-Lite register interface.";
|
2022-12-02 18:46:00 +01:00
|
|
|
static char v[] = "acs.eonerc.rwth-aachen.de:user:aurora_axis:";
|
|
|
|
static NodePlugin<Aurora, n, d, v> f;
|