Export Filterkoeffizienten

This commit is contained in:
Patrick Hangl
2026-03-19 16:29:46 +01:00
parent f6fa0ed021
commit 91e62d48e8
76 changed files with 14848 additions and 2074659 deletions

View File

@@ -1,3 +1,5 @@
#include <stdio.h>
#include <stdint.h>
#include "include/signal_path.h"
#define BLOCK_LEN 1
@@ -15,7 +17,6 @@ int chess_storage(DMA % (sizeof(long long))) coefficient_line[MAX_FIR_COEFFS];
BufferPtrDMB chess_storage(DMB) pointer_sample_line;
BufferPtr pointer_coefficient_line;
#ifdef PLATFORM_GENERIC
// lpdsp32 functionallity moddeling functions
accum_t fract_mult(int a, int b){
@@ -253,7 +254,7 @@ int inline apply_fir_filter(BufferPtrDMB chess_storage(DMB) *pointer_sample_line
return rnd_saturate(acc_fir);
}
void static inline update_filter_coefficients(BufferPtrDMB chess_storage(DMB) *pointer_sample_line, BufferPtr *pointer_coefficient_line, int output){
void static inline update_filter_coefficients(FILE *fp, BufferPtrDMB chess_storage(DMB) *pointer_sample_line, BufferPtr *pointer_coefficient_line, int output){
int chess_storage(DMA) *p_w0 = pointer_coefficient_line->ptr_start; //Pointer auf Filterkoeffizienten-Array
int chess_storage(DMB) *p_x0 = pointer_sample_line->ptr_current; //Current-Pointer 1 auf Sample-Line Array
@@ -279,6 +280,7 @@ void static inline update_filter_coefficients(BufferPtrDMB chess_storage(DMB) *p
// Filterkoeffizienten mit Korrekturterm*Acc-Sensor-Sample updaten - 1 Cycle
acc_w0 += fract_mult(correction, *p_x0);
acc_w1 += fract_mult(correction, *p_x1);
fprintf(fp, "%d, %d, ", rnd_saturate(acc_w0), rnd_saturate(acc_w1));
//Beide Pointer in der Sample-Line um 2 dekrementieren
p_x0 = cyclic_add(p_x0, -2, p_xstart, sample_line_len);
p_x1 = cyclic_add(p_x1, -2, p_xstart, sample_line_len);
@@ -286,6 +288,7 @@ void static inline update_filter_coefficients(BufferPtrDMB chess_storage(DMB) *p
*((long long *)p_w0) = llcompose(rnd_saturate(acc_w0), rnd_saturate(acc_w1));//LOAD/STORE-Hazard - +1 NOP benötigt - 1 Cycle
p_w0+=2; //Koeffizienten-Pointer um 2 inkrementieren
}
fprintf(fp, "\n");
}
void initialize_signal(
@@ -329,6 +332,7 @@ void initialize_signal(
// C-Sensor (d) = Corrupted Signal (Desired Signal + Corruption Noise Signal)
// Acc-Sensor (x) = Reference Noise Signal
void calculate_output(
FILE *fp,
SingleSignalPath *c_sensor_signal_t,
SingleSignalPath *acc_sensor_signal_t,
int16_t volatile chess_storage(DMB) *c_sensor_input, //Pointer auf Input-Port im Shared Memory
@@ -371,7 +375,7 @@ void calculate_output(
// Output-Signal berechnen -> C-Sensor Sample - Akkumulator Output des adaptiven Filters
output_32[0] = c_sensor_pre[0] - filter_accumulator[0];
// Filterkoeffizienten adaptieren
update_filter_coefficients(&pointer_sample_line, &pointer_coefficient_line, output_32[0]);
update_filter_coefficients(fp, &pointer_sample_line, &pointer_coefficient_line, output_32[0]);
// Bitshift zurück auf 16-Bit und in Ausgangsarray schreiben
for (uint32_t i=0; i<BLOCK_LEN; i++) chess_flatten_loop
{