init
This commit is contained in:
36
lib_audio_dsp/examples/app_td_block_fir/CMakeLists.txt
Normal file
36
lib_audio_dsp/examples/app_td_block_fir/CMakeLists.txt
Normal file
@@ -0,0 +1,36 @@
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake)
|
||||
project(app_td_block_fir)
|
||||
|
||||
set(APP_HW_TARGET XK-EVK-XU316)
|
||||
set(APP_DEPENDENT_MODULES
|
||||
"lib_audio_dsp"
|
||||
"lib_logging(3.2.0)"
|
||||
"lib_locks(2.2.0)"
|
||||
)
|
||||
set(APP_PCA_ENABLE OFF)
|
||||
set(EXAMPLE_BUILD_FLAGS ${EXTRA_BUILD_FLAGS} -fcomment-asm
|
||||
-Wall
|
||||
-O3
|
||||
-report
|
||||
-lquadflash
|
||||
-mcmodel=large
|
||||
-g
|
||||
-fxscope)
|
||||
|
||||
set(APP_COMPILER_FLAGS ${EXAMPLE_BUILD_FLAGS})
|
||||
|
||||
file(GLOB C_SRC CONFIGURE_DEPENDS RELATIVE ${CMAKE_CURRENT_LIST_DIR} src/*.c)
|
||||
|
||||
set(APP_C_SRCS
|
||||
"${C_SRC};${DSP_MAIN}")
|
||||
|
||||
|
||||
set(APP_INCLUDES
|
||||
src
|
||||
src/core
|
||||
src/extensions
|
||||
${CMAKE_CURRENT_LIST_DIR}/build/dsp_pipeline)
|
||||
set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..)
|
||||
|
||||
XMOS_REGISTER_APP()
|
||||
7
lib_audio_dsp/examples/app_td_block_fir/readme.md
Normal file
7
lib_audio_dsp/examples/app_td_block_fir/readme.md
Normal file
@@ -0,0 +1,7 @@
|
||||
app_td_block_fir
|
||||
---
|
||||
|
||||
This demos 16 concurrent FIRs running on a single tile with a frame size of 8 and of length 4008.
|
||||
Currently, it runs at 46kHz.
|
||||
The application demonstrates how two channels per thread can be run in parallel over a single tile
|
||||
in order to get 16 channels running concurrently.
|
||||
17
lib_audio_dsp/examples/app_td_block_fir/src/gen.sh
Normal file
17
lib_audio_dsp/examples/app_td_block_fir/src/gen.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
python make_test_filters.py
|
||||
python ../../../python/audio_dsp/dsp/td_block_fir.py test_0.npy
|
||||
python ../../../python/audio_dsp/dsp/td_block_fir.py test_1.npy
|
||||
python ../../../python/audio_dsp/dsp/td_block_fir.py test_2.npy
|
||||
python ../../../python/audio_dsp/dsp/td_block_fir.py test_3.npy
|
||||
python ../../../python/audio_dsp/dsp/td_block_fir.py test_4.npy
|
||||
python ../../../python/audio_dsp/dsp/td_block_fir.py test_5.npy
|
||||
python ../../../python/audio_dsp/dsp/td_block_fir.py test_6.npy
|
||||
python ../../../python/audio_dsp/dsp/td_block_fir.py test_7.npy
|
||||
python ../../../python/audio_dsp/dsp/td_block_fir.py test_8.npy
|
||||
python ../../../python/audio_dsp/dsp/td_block_fir.py test_9.npy
|
||||
python ../../../python/audio_dsp/dsp/td_block_fir.py test_10.npy
|
||||
python ../../../python/audio_dsp/dsp/td_block_fir.py test_11.npy
|
||||
python ../../../python/audio_dsp/dsp/td_block_fir.py test_12.npy
|
||||
python ../../../python/audio_dsp/dsp/td_block_fir.py test_13.npy
|
||||
python ../../../python/audio_dsp/dsp/td_block_fir.py test_14.npy
|
||||
python ../../../python/audio_dsp/dsp/td_block_fir.py test_15.npy
|
||||
130
lib_audio_dsp/examples/app_td_block_fir/src/main.c
Normal file
130
lib_audio_dsp/examples/app_td_block_fir/src/main.c
Normal file
@@ -0,0 +1,130 @@
|
||||
// Copyright 2024-2025 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <xcore/hwtimer.h>
|
||||
#include <xcore/parallel.h>
|
||||
#include <xcore/channel.h>
|
||||
#include "dsp/td_block_fir.h"
|
||||
|
||||
#include "test_0.h"
|
||||
#include "test_1.h"
|
||||
#include "test_2.h"
|
||||
#include "test_3.h"
|
||||
#include "test_4.h"
|
||||
#include "test_5.h"
|
||||
#include "test_6.h"
|
||||
#include "test_7.h"
|
||||
#include "test_8.h"
|
||||
#include "test_9.h"
|
||||
#include "test_10.h"
|
||||
#include "test_11.h"
|
||||
#include "test_12.h"
|
||||
#include "test_13.h"
|
||||
#include "test_14.h"
|
||||
#include "test_15.h"
|
||||
|
||||
#define WORKER_THREAD_COUNT 8
|
||||
|
||||
DECLARE_JOB(worker, (chanend_t, int32_t*, uint32_t, td_block_fir_filter_t*, int32_t*, uint32_t, td_block_fir_filter_t*));
|
||||
void worker(chanend_t c,
|
||||
int32_t * data0,
|
||||
uint32_t data0_elements,
|
||||
td_block_fir_filter_t * f0,
|
||||
int32_t * data1,
|
||||
uint32_t data1_elements,
|
||||
td_block_fir_filter_t * f1)
|
||||
{
|
||||
td_block_fir_data_t d0, d1;
|
||||
td_block_fir_data_init(&d0, data0, data0_elements);
|
||||
td_block_fir_data_init(&d1, data1, data1_elements);
|
||||
memset(data0, 0, data0_elements *sizeof(int32_t));
|
||||
memset(data1, 0, data1_elements*sizeof(int32_t));
|
||||
|
||||
while(1){
|
||||
int32_t audio_channel_0[TD_BLOCK_FIR_LENGTH];
|
||||
int32_t audio_channel_1[TD_BLOCK_FIR_LENGTH];
|
||||
|
||||
chan_in_buf_word(c, audio_channel_0, TD_BLOCK_FIR_LENGTH);
|
||||
chan_in_buf_word(c, audio_channel_1, TD_BLOCK_FIR_LENGTH);
|
||||
|
||||
td_block_fir_add_data(audio_channel_0, &d0);
|
||||
td_block_fir_compute(audio_channel_0, &d0, f0);
|
||||
|
||||
td_block_fir_add_data(audio_channel_1, &d1);
|
||||
td_block_fir_compute(audio_channel_1, &d1, f1);
|
||||
|
||||
chan_out_buf_word(c, audio_channel_0, TD_BLOCK_FIR_LENGTH);
|
||||
chan_out_buf_word(c, audio_channel_1, TD_BLOCK_FIR_LENGTH);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void worker_tile(chanend_t c[WORKER_THREAD_COUNT]){
|
||||
int32_t mem_0[test_0_DATA_BUFFER_ELEMENTS];
|
||||
int32_t mem_1[test_1_DATA_BUFFER_ELEMENTS];
|
||||
int32_t mem_2[test_2_DATA_BUFFER_ELEMENTS];
|
||||
int32_t mem_3[test_3_DATA_BUFFER_ELEMENTS];
|
||||
int32_t mem_4[test_4_DATA_BUFFER_ELEMENTS];
|
||||
int32_t mem_5[test_5_DATA_BUFFER_ELEMENTS];
|
||||
int32_t mem_6[test_6_DATA_BUFFER_ELEMENTS];
|
||||
int32_t mem_7[test_7_DATA_BUFFER_ELEMENTS];
|
||||
int32_t mem_8[test_8_DATA_BUFFER_ELEMENTS];
|
||||
int32_t mem_9[test_9_DATA_BUFFER_ELEMENTS];
|
||||
int32_t mem_10[test_10_DATA_BUFFER_ELEMENTS];
|
||||
int32_t mem_11[test_11_DATA_BUFFER_ELEMENTS];
|
||||
int32_t mem_12[test_12_DATA_BUFFER_ELEMENTS];
|
||||
int32_t mem_13[test_13_DATA_BUFFER_ELEMENTS];
|
||||
int32_t mem_14[test_14_DATA_BUFFER_ELEMENTS];
|
||||
int32_t mem_15[test_15_DATA_BUFFER_ELEMENTS];
|
||||
|
||||
PAR_JOBS (
|
||||
PJOB(worker, (c[0], mem_0, test_0_DATA_BUFFER_ELEMENTS, &td_block_fir_filter_test_0,
|
||||
mem_1, test_1_DATA_BUFFER_ELEMENTS, &td_block_fir_filter_test_1)),
|
||||
PJOB(worker, (c[1], mem_2, test_2_DATA_BUFFER_ELEMENTS, &td_block_fir_filter_test_2,
|
||||
mem_3, test_3_DATA_BUFFER_ELEMENTS, &td_block_fir_filter_test_3)),
|
||||
PJOB(worker, (c[2], mem_4, test_4_DATA_BUFFER_ELEMENTS, &td_block_fir_filter_test_4,
|
||||
mem_5, test_5_DATA_BUFFER_ELEMENTS, &td_block_fir_filter_test_5)),
|
||||
PJOB(worker, (c[3], mem_6, test_6_DATA_BUFFER_ELEMENTS, &td_block_fir_filter_test_6,
|
||||
mem_7, test_7_DATA_BUFFER_ELEMENTS, &td_block_fir_filter_test_7)),
|
||||
PJOB(worker, (c[4], mem_8, test_8_DATA_BUFFER_ELEMENTS, &td_block_fir_filter_test_8,
|
||||
mem_9, test_9_DATA_BUFFER_ELEMENTS, &td_block_fir_filter_test_9)),
|
||||
PJOB(worker, (c[5], mem_10, test_10_DATA_BUFFER_ELEMENTS, &td_block_fir_filter_test_10,
|
||||
mem_11, test_11_DATA_BUFFER_ELEMENTS, &td_block_fir_filter_test_11)),
|
||||
PJOB(worker, (c[6], mem_12, test_12_DATA_BUFFER_ELEMENTS, &td_block_fir_filter_test_12,
|
||||
mem_13, test_13_DATA_BUFFER_ELEMENTS, &td_block_fir_filter_test_13)),
|
||||
PJOB(worker, (c[7], mem_14, test_14_DATA_BUFFER_ELEMENTS, &td_block_fir_filter_test_14,
|
||||
mem_15, test_15_DATA_BUFFER_ELEMENTS, &td_block_fir_filter_test_15))
|
||||
);
|
||||
}
|
||||
|
||||
void audio_gen(chanend_t c[WORKER_THREAD_COUNT]){
|
||||
|
||||
hwtimer_t SysTimer = hwtimer_alloc();
|
||||
uint32_t from, to;
|
||||
|
||||
const uint32_t loops = 128;
|
||||
from = hwtimer_get_time(SysTimer);
|
||||
|
||||
int32_t buffer0[TD_BLOCK_FIR_LENGTH];
|
||||
int32_t buffer1[TD_BLOCK_FIR_LENGTH];
|
||||
for(int i=0;i<loops;i++){
|
||||
//send the unfiltered samples
|
||||
for(int worker_idx=0;worker_idx < WORKER_THREAD_COUNT;worker_idx++){
|
||||
chan_out_buf_word(c[worker_idx], buffer0, TD_BLOCK_FIR_LENGTH);
|
||||
chan_out_buf_word(c[worker_idx], buffer1, TD_BLOCK_FIR_LENGTH);
|
||||
}
|
||||
|
||||
//recieve the filtered samples
|
||||
for(int worker_idx=0;worker_idx < WORKER_THREAD_COUNT;worker_idx++){
|
||||
chan_in_buf_word(c[worker_idx], buffer0, TD_BLOCK_FIR_LENGTH);
|
||||
chan_in_buf_word(c[worker_idx], buffer1, TD_BLOCK_FIR_LENGTH);
|
||||
}
|
||||
}
|
||||
to = hwtimer_get_time(SysTimer);
|
||||
uint32_t elapsed = to - from;
|
||||
printf("elapsed: %lu\n", elapsed/loops);
|
||||
exit(1);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
# Copyright 2024-2025 XMOS LIMITED.
|
||||
# This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
import numpy as np
|
||||
from scipy import signal
|
||||
|
||||
def bandpass_filters(length, count):
|
||||
for i in range(count):
|
||||
t = signal.firwin(length, (i + 1) / (count + 2))
|
||||
name = 'test_' + str(i)
|
||||
np.save(name, t)
|
||||
|
||||
if __name__ == '__main__':
|
||||
bandpass_filters(4008, 16)
|
||||
15
lib_audio_dsp/examples/app_td_block_fir/src/toplevel.xc
Normal file
15
lib_audio_dsp/examples/app_td_block_fir/src/toplevel.xc
Normal file
@@ -0,0 +1,15 @@
|
||||
// Copyright 2024-2025 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
#include <platform.h>
|
||||
|
||||
void audio_gen(chanend c[8]);
|
||||
void worker_tile(chanend c[8]);
|
||||
|
||||
int main(){
|
||||
chan c[8];
|
||||
par {
|
||||
on tile[0] : audio_gen(c);
|
||||
on tile[1] : worker_tile(c);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user