From eb8f4b3b5a207fd854ba074f1f947d2dba63222e Mon Sep 17 00:00:00 2001 From: Allan Skellett Date: Wed, 25 Feb 2026 10:05:33 +0000 Subject: [PATCH 1/2] Remove xc from TwoStageDecimator test remove HW timer, rename --- tests/signal/TwoStageDecimator/CMakeLists.txt | 2 +- .../src/{run.cpp => app.cpp} | 77 +++++++++++++++++- tests/signal/TwoStageDecimator/src/main.xc | 81 ------------------- 3 files changed, 74 insertions(+), 86 deletions(-) rename tests/signal/TwoStageDecimator/src/{run.cpp => app.cpp} (65%) delete mode 100644 tests/signal/TwoStageDecimator/src/main.xc diff --git a/tests/signal/TwoStageDecimator/CMakeLists.txt b/tests/signal/TwoStageDecimator/CMakeLists.txt index ed0346a5..183f4ab3 100644 --- a/tests/signal/TwoStageDecimator/CMakeLists.txt +++ b/tests/signal/TwoStageDecimator/CMakeLists.txt @@ -4,7 +4,7 @@ project(tests-signal-decimator) set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../..) -include(${CMAKE_CURRENT_LIST_DIR}/../../../examples/deps.cmake) +set(APP_DEPENDENT_MODULES "lib_mic_array") set(APP_HW_TARGET XK-EVK-XU316) diff --git a/tests/signal/TwoStageDecimator/src/run.cpp b/tests/signal/TwoStageDecimator/src/app.cpp similarity index 65% rename from tests/signal/TwoStageDecimator/src/run.cpp rename to tests/signal/TwoStageDecimator/src/app.cpp index 74223a17..2b2690d5 100644 --- a/tests/signal/TwoStageDecimator/src/run.cpp +++ b/tests/signal/TwoStageDecimator/src/app.cpp @@ -1,16 +1,21 @@ // Copyright 2020-2026 XMOS LIMITED. // This Software is subject to the terms of the XMOS Public Licence: Version 1. -#include -#include #include #include +#include +#include +#include +#include +#include +#include #include +#include #include extern "C" { -#include "xscope.h" +#include } #include "mic_array.h" @@ -25,12 +30,20 @@ extern "C" { # error S2_DEC_FACT must be defined. #endif +#define BUFF_SIZE 256 + +typedef chanend_t streaming_chanend_t; + // Will be loaded from file static uint32_t test_stage1_coef[128]; static int32_t test_stage2_coef[S2_TAPS]; static right_shift_t test_stage2_shr; +DECLARE_JOB(run, (chanend_t)); +DECLARE_JOB(host_words_to_app, (chanend_t, streaming_chanend_t)); + +// ------------------------------- HELPER FUNCTIONS ------------------------------- void load_stage1(chanend_t c_from_host) { @@ -101,7 +114,6 @@ void process_signal(chanend_t c_from_host) printf("Finished processing PDM signal.\n"); } -extern "C" void run(chanend_t c_from_host) { // Tell the host script what parameters are currently being used @@ -116,3 +128,60 @@ void run(chanend_t c_from_host) process_signal(c_from_host); } + + +void host_words_to_app(chanend_t c_from_host, streaming_chanend_t c_to_app) +{ + xscope_connect_data_from_host(c_from_host); + + // +3 is for any partial word at the end of the read + char buff[BUFF_SIZE+3]; + int buff_lvl = 0; + + SELECT_RES( + CASE_THEN(c_from_host, c_from_host_handler) + ){ + c_from_host_handler:{ + int dd; + xscope_data_from_host(c_from_host, &buff[0], &dd); + dd--; // last byte is always 0 (for some reason) + buff_lvl += dd; + + // Send all (complete) words to app + int* next_word = ((int*)(void*) &buff[0]); + while(buff_lvl >= sizeof(int)){ + s_chan_out_word(c_to_app, next_word[0]); + next_word++; + buff_lvl -= sizeof(int); + } + + // if there's 1-3 bytes left move it to the front. + if(buff_lvl) { + memmove(&buff[0], &next_word[0], buff_lvl); + } + + continue; + }} +} + + +int main() +{ + streaming_channel_t c_to_app = s_chan_alloc(); + + // xscope init note: only one channel end is needed + // the second one and the xscope service will be + // automatically started and routed by the tools + chanend_t xscope_chan = chanend_alloc(); + xscope_mode_lossless(); + + PAR_JOBS( + PJOB(host_words_to_app, (xscope_chan, c_to_app.end_a)), + PJOB(run, (c_to_app.end_b)) + ); + + s_chan_free(c_to_app); + + printf("Done.\n"); + return 0; +} diff --git a/tests/signal/TwoStageDecimator/src/main.xc b/tests/signal/TwoStageDecimator/src/main.xc deleted file mode 100644 index 5b2a020a..00000000 --- a/tests/signal/TwoStageDecimator/src/main.xc +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2020-2026 XMOS LIMITED. -// This Software is subject to the terms of the XMOS Public Licence: Version 1. - -#include -#include -#include - -#include -#include - -void run(streaming chanend); - -unsafe { - - -// We can't be guaranteed to read less than this, and we cannot read more than -// this -#define BUFF_SIZE 256 - -void host_words_to_app( - chanend c_from_host, - streaming chanend c_to_app) -{ - xscope_connect_data_from_host(c_from_host); - - // +3 is for any partial word at the end of the read - char buff[BUFF_SIZE+3]; - int buff_lvl = 0; - - while(1){ - int dd; - select { - case xscope_data_from_host(c_from_host, &buff[0], dd): - { - dd--; // last byte is always 0 (for some reason) - buff_lvl += dd; - // printf("& Received %d bytes.\n", dd); - - // Send all (complete) words to app - int* next_word = ((int*) (void*) &buff[0]); - while(buff_lvl >= sizeof(int)){ - c_to_app <: next_word[0]; - next_word++; - buff_lvl -= sizeof(int); - } - - // if there's 1-3 bytes left move it to the front. - if(buff_lvl) memmove(&buff[0], &next_word[0], buff_lvl); - - break; - } - } - - // repeat forever - } -} - - -int main() -{ - chan c_from_host; - streaming chan c_to_app; - - par { - xscope_host_data(c_from_host); - - on tile[0]: { - host_words_to_app(c_from_host, c_to_app); - } - - on tile[0]: { - xscope_mode_lossless(); - run(c_to_app); - printf("Done.\n"); - exit(0); - } - } - return 0; -} - -} \ No newline at end of file From ec271819ead20b77f372b5bebd59f7dab1944b67 Mon Sep 17 00:00:00 2001 From: Allan Skellett Date: Thu, 26 Feb 2026 12:31:08 +0000 Subject: [PATCH 2/2] Bump JSL --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 13b738c2..f015d1bc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,6 @@ // This file relates to internal XMOS infrastructure and should be ignored by external users -@Library('xmos_jenkins_shared_library@v0.45.0') _ +@Library('xmos_jenkins_shared_library@v0.46.0') _ getApproval() pipeline {