Skip to content

Commit

Permalink
demo par decimator -> XCCM
Browse files Browse the repository at this point in the history
  • Loading branch information
ed-xmos committed Sep 20, 2024
1 parent 72370e5 commit b101652
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 196 deletions.
83 changes: 30 additions & 53 deletions examples/demo_par_decimator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,59 +1,36 @@
cmake_minimum_required(VERSION 3.21)
include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake)
project(demo_par_decimator)
set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..)

set(APP_NAME demo_par_decimator)

set( TARGET_XN XCORE-AI-EXPLORER.xn )

#**********************
# configuration
#**********************

set( MCLK_FREQ 24576000 )
set( PDM_FREQ 3072000 )
set( SAMPLES_PER_FRAME 16 )

#**********************
# includes
#**********************

set( APP_INCLUDES "src" )
list( APPEND APP_INCLUDES ${DEMO_COMMON_INCLUDES} )

#**********************
# sources
#**********************

file( GLOB_RECURSE APP_SOURCES "src/*.c" "src/*.xc" "src/*.cpp" "src/*.S" )

list( APPEND APP_SOURCES ${DEMO_COMMON_SOURCES} )

#**********************
# create targets
#**********************
include(${CMAKE_CURRENT_LIST_DIR}/../deps.cmake)
set(APP_HW_TARGET XCORE-AI-EXPLORER)

foreach( N_MICS 8 16 )
set(CONFIG ${N_MICS}_MIC)
set(APP_COMPILER_FLAGS_${CONFIG} -Os
-g
-report
-mcmodel=large
-DMIC_ARRAY_CONFIG_MIC_COUNT=${N_MICS}
-DMIC_ARRAY_CONFIG_MCLK_FREQ=24576000
-DMIC_ARRAY_CONFIG_PDM_FREQ=3072000
-DMIC_ARRAY_CONFIG_SAMPLES_PER_FRAME=16
-DMIC_ARRAY_CONFIG_USE_DDR=1
-DMIC_ARRAY_CONFIG_PORT_MCLK=XS1_PORT_1D
-DMIC_ARRAY_CONFIG_PORT_PDM_CLK=XS1_PORT_1A
-DMIC_ARRAY_CONFIG_PORT_PDM_DATA=XS1_PORT_4D
-DPORT_I2C_SCL=XS1_PORT_1N
-DPORT_I2C_SDA=XS1_PORT_1O
-DAPP_NAME="PAR_DECIMATOR_${CONFIG}")
endforeach()

set( TARGET_NAME "${APP_NAME}_${N_MICS}mic" )

make_demo_app_target( ${TARGET_NAME} "${APP_SOURCES}" "${APP_INCLUDES}" "" )

target_compile_definitions( ${TARGET_NAME}
PRIVATE MIC_ARRAY_CONFIG_MCLK_FREQ=${MCLK_FREQ} )
target_compile_definitions( ${TARGET_NAME}
PRIVATE MIC_ARRAY_CONFIG_PDM_FREQ=${PDM_FREQ} )
target_compile_definitions( ${TARGET_NAME}
PRIVATE MIC_ARRAY_CONFIG_MIC_COUNT=${N_MICS} )
target_compile_definitions( ${TARGET_NAME}
PRIVATE MIC_ARRAY_CONFIG_USE_DDR=1 )
target_compile_definitions( ${TARGET_NAME}
PRIVATE MIC_ARRAY_CONFIG_PORT_MCLK=PORT_MCLK_IN_OUT )
target_compile_definitions( ${TARGET_NAME}
PRIVATE MIC_ARRAY_CONFIG_PORT_PDM_CLK=PORT_PDM_CLK )
target_compile_definitions( ${TARGET_NAME}
PRIVATE MIC_ARRAY_CONFIG_PORT_PDM_DATA=PORT_PDM_DATA )
target_compile_definitions( ${TARGET_NAME}
PRIVATE MIC_ARRAY_CONFIG_SAMPLES_PER_FRAME=${SAMPLES_PER_FRAME} )

add_dependencies( demos ${TARGET_NAME} )
# Manually set sources as we take from the common directory too
file(GLOB_RECURSE APP_C_SRCS RELATIVE ${CMAKE_CURRENT_LIST_DIR} "src/*.c" "../common/src/*.c")
file(GLOB_RECURSE APP_XC_SRCS RELATIVE ${CMAKE_CURRENT_LIST_DIR} "src/*.xc" "../common/src/*.xc")
file(GLOB_RECURSE APP_CXX_SRCS RELATIVE ${CMAKE_CURRENT_LIST_DIR} "src/*.cpp")
file(GLOB_RECURSE APP_ASM_SRCS RELATIVE ${CMAKE_CURRENT_LIST_DIR} "../common/src/*.S")

endforeach()
set(APP_INCLUDES src ../common/src ../common/util)

XMOS_REGISTER_APP()
124 changes: 0 additions & 124 deletions examples/demo_par_decimator/XCORE-AI-EXPLORER.xn

This file was deleted.

23 changes: 11 additions & 12 deletions examples/demo_par_decimator/src/app_config.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2023 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.

#pragma once

#define AUDIO_BUFFER_SAMPLES ((unsigned)(MIC_ARRAY_CONFIG_SAMPLES_PER_FRAME * 1.2))
Expand Down Expand Up @@ -30,7 +29,7 @@
// LEDs, and USB.

// X0D00, J14 - Pin 2
#define PORT_PDM_CLK XS1_PORT_1A
#define APP_PORT_PDM_CLK XS1_PORT_1A

#if MIC_ARRAY_CONFIG_MIC_COUNT == 8
// Either of the following ports may be used with VocalSorcery adapter card.
Expand All @@ -39,23 +38,23 @@
//#define PORT_PDM_DATA XS1_PORT_4C

// X0D16..X0D19, J14 - Pin 6,7,10,11
#define PORT_PDM_DATA XS1_PORT_4D
#define APP_PORT_PDM_DATA XS1_PORT_4D

#elif MIC_ARRAY_CONFIG_MIC_COUNT == 16
// X0D14..X0D21 | J14 - Pin 3,5,12,14 and Pin 6,7,10,11
#define PORT_PDM_DATA XS1_PORT_8B
#define APP_PORT_PDM_DATA XS1_PORT_8B

#endif // MIC_ARRAY_CONFIG_MIC_COUNT

#if PORT_PDM_DATA == XS1_PORT_4C
// X1D09
#define PORT_CODEC_RST_N XS1_PORT_4A
#define APP_PORT_CODEC_RST_N XS1_PORT_4A
#endif

// NOTE: This conditional only works if the other 4 data lines are not connected.
//#if USE_BUTTONS && (PORT_PDM_DATA == XS1_PORT_4D || PORT_PDM_DATA == XS1_PORT_8B)
// X0D12, J12 - Pin2
#define ALTERNATE_BUTTON XS1_PORT_1E
#define APP_ALTERNATE_BUTTON XS1_PORT_1E
//#endif

#else // MIC_ARRAY_TILE == 0
Expand All @@ -68,7 +67,7 @@
// there are only 14 usable MICs of the 16 for this configuration.

// X1D36, J10 - Pin 2
#define PORT_PDM_CLK XS1_PORT_1M
#define APP_PORT_PDM_CLK XS1_PORT_1M

#if MIC_ARRAY_CONFIG_MIC_COUNT == 8
// Either of the following ports may be used with VocalSorcery adapter card.
Expand All @@ -77,23 +76,23 @@
//#define PORT_PDM_DATA XS1_PORT_4A

// X1D04..X1D07 | J10 - Pin 6,7,10,11
#define PORT_PDM_DATA XS1_PORT_4B
#define APP_PORT_PDM_DATA XS1_PORT_4B

#if PORT_PDM_DATA == XS1_PORT_4B
#define PORT_CODEC_RST_N XS1_PORT_4A
#define APP_PORT_CODEC_RST_N XS1_PORT_4A
#else
// X1D38 | J10 - Pin 15
// Used with 3k3 resistor to drive CODEC_RST_N high
#define PORT_CODEC_RST_N XS1_PORT_1O
#define APP_PORT_CODEC_RST_N XS1_PORT_1O
#endif

#elif MIC_ARRAY_CONFIG_MIC_COUNT == 16
// X1D02..X1D09 | J10 - Pin 3,5,12 and Pin 6,7,10,11
#define PORT_PDM_DATA XS1_PORT_8B
#define APP_PORT_PDM_DATA XS1_PORT_8B

// X1D38 | J10 - Pin 15
// Used with 3k3 resistor to drive CODEC_RST_N high
#define PORT_CODEC_RST_N XS1_PORT_1O
#define APP_PORT_CODEC_RST_N XS1_PORT_1O

#endif // MIC_ARRAY_CONFIG_MIC_COUNT

Expand Down
4 changes: 2 additions & 2 deletions examples/demo_par_decimator/src/app_i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void app_i2s_task(void *app_context)
{
i2s_context.app_data = app_context;

port_t p_i2s_dout[] = { I2S_DATA_IN };
port_t p_i2s_dout[] = { PORT_I2S_DAC_DATA };
// port_t p_i2s_din[] = { I2S_DATA_IN };
port_t p_i2s_din[0];

Expand All @@ -174,6 +174,6 @@ void app_i2s_task(void *app_context)
p_i2s_din, 0,
PORT_I2S_BCLK,
PORT_I2S_LRCLK,
PORT_MCLK_IN_OUT,
PORT_MCLK_IN,
I2S_CLKBLK);
}
5 changes: 0 additions & 5 deletions examples/demo_par_decimator/src/main.xc
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ int main() {
par {

on tile[0]: {
xscope_config_io(XSCOPE_IO_BASIC);

#if (MIC_ARRAY_TILE == 0 || USE_BUTTONS)
app_context_t app_context;
app_context.c_intertile = (chanend_t)c_tile_sync;
Expand Down Expand Up @@ -110,9 +108,6 @@ int main() {
}

on tile[1]: {
// Force it to use xscope, never mind any config.xscope files
xscope_config_io(XSCOPE_IO_BASIC);

// Pull DAC CODEC out of reset
aic3204_codec_reset();

Expand Down
4 changes: 4 additions & 0 deletions examples/demo_vanilla/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ foreach( N_MICS 1 2 )
-DMIC_ARRAY_CONFIG_MCLK_FREQ=24576000
-DMIC_ARRAY_CONFIG_PDM_FREQ=3072000
-DMIC_ARRAY_CONFIG_SAMPLES_PER_FRAME=16
-DMIC_ARRAY_CONFIG_USE_DDR=1
-DMIC_ARRAY_CONFIG_PORT_MCLK=PORT_MCLK_IN_OUT
-DMIC_ARRAY_CONFIG_PORT_PDM_CLK=PORT_PDM_CLK
-DMIC_ARRAY_CONFIG_PORT_PDM_DATA=PORT_PDM_DAT
-DAPP_NAME="VANILLA_${CONFIG}")
endforeach()

Expand Down

0 comments on commit b101652

Please sign in to comment.