feat: add live statistics with per-trial snapshots and von Neumann option (FPGA v5)

This commit is contained in:
randogoth 2026-10-25 14:27:45 +02:00
parent 67bd7eec58
commit 5305d66102
8 changed files with 427 additions and 17 deletions

View file

@ -7,6 +7,7 @@
// w <register> <value> write a register, prints "OK"
// cap start a capture with the current settings and send it as
// "DATA <n>\n" followed by n raw bytes
// stats print the latest statistics trial snapshot as hex
#include <SPI.h>
#include <VidorBoot.h>
@ -23,6 +24,7 @@ enum : uint8_t {
REG_CONTROL = 0x0B,
REG_STATUS = 0x0C,
REG_DATA = 0x10,
REG_STATS = 0x40,
};
const uint8_t READ = 0x80;
@ -30,6 +32,7 @@ const uint8_t CONTROL_START_CAPTURE = 0x01;
const uint8_t STATUS_CAPTURE_DONE = 0x02;
const size_t CAPTURE_BYTES = 32768;
const size_t CHUNK_BYTES = 512;
const size_t SNAPSHOT_BYTES = 72;
VidorUtils fpga;
@ -89,6 +92,17 @@ void capture() {
}
}
void printSnapshot() {
beginTransaction(READ | REG_STATS);
for (size_t i = 0; i < SNAPSHOT_BYTES; i++) {
uint8_t value = strixSpi.transfer(0);
if (value < 0x10) Serial.print('0');
Serial.print(value, HEX);
}
endTransaction();
Serial.println();
}
// Parses "<a>" or "<a> <b>" after the command word; returns the number of values found.
int parseArgs(const String &args, long &a, long &b) {
int space = args.indexOf(' ');
@ -116,6 +130,8 @@ void handleCommand(String line) {
Serial.println("OK");
} else if (command == "cap") {
capture();
} else if (command == "stats") {
printSnapshot();
} else if (line.length() > 0) {
Serial.println("ERR unknown or malformed command");
}