Initial commit
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
test = test_data_channel
|
||||
bsp_root_dir = ../../../software/signal_processing_bsp
|
||||
scripts = ../../scripts
|
||||
|
||||
c_sources += \
|
||||
../../../software/signal_processing/system/data_channel.c \
|
||||
test_data_channel.c \
|
||||
main.c \
|
||||
|
||||
include ../device_test.mk
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
#include <stdio.h>
|
||||
#include <system.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "test_data_channel.h"
|
||||
|
||||
int main() {
|
||||
test_data_channels();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,232 @@
|
||||
#include "test_data_channel.h"
|
||||
|
||||
#include "../device_test.h"
|
||||
#include "../../software/signal_processing/system/data_channel.h"
|
||||
|
||||
#include <system.h>
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
int assert_data_channel_binding_eq( uint32_t base, uint32_t expected ) {
|
||||
uint32_t binding = data_channel_get_binding( base );
|
||||
if ( binding != expected ) {
|
||||
printf( TEST_FAIL " assert_data_channel_binding_eq %" PRIu32 " != %" PRIu32 "\n", expected, binding );
|
||||
}
|
||||
|
||||
return binding;
|
||||
}
|
||||
|
||||
int assert_data_channel_empty( uint32_t base ) {
|
||||
uint32_t empty = data_channel_is_empty( base );
|
||||
if ( ! empty ) {
|
||||
printf( TEST_FAIL " assert_data_channel_empty\n" );
|
||||
}
|
||||
|
||||
return empty;
|
||||
}
|
||||
|
||||
int assert_not_empty( uint32_t base ) {
|
||||
uint32_t empty = data_channel_is_empty( base );
|
||||
if ( empty ) {
|
||||
printf( TEST_FAIL " assert_not_empty\n" );
|
||||
}
|
||||
|
||||
return ! empty;
|
||||
}
|
||||
|
||||
int assert_data_channel_full( uint32_t base ) {
|
||||
uint32_t full = data_channel_is_full( base );
|
||||
if ( ! full ) {
|
||||
printf( TEST_FAIL " assert_data_channel_full\n" );
|
||||
}
|
||||
|
||||
return full;
|
||||
}
|
||||
|
||||
int assert_not_full( uint32_t base ) {
|
||||
uint32_t full = data_channel_is_full( base );
|
||||
if ( full ) {
|
||||
printf( TEST_FAIL " assert_not_full\n" );
|
||||
}
|
||||
|
||||
return ! full;
|
||||
}
|
||||
|
||||
int assert_data_channel_level_eq( uint32_t base, uint32_t expected ) {
|
||||
uint32_t level = data_channel_level( base );
|
||||
if ( level != expected ) {
|
||||
printf( TEST_FAIL " assert_data_channel_level_eq %" PRIu32 " != %" PRIu32 "\n", expected, level );
|
||||
}
|
||||
return level == expected;
|
||||
}
|
||||
|
||||
int assert_data_channel_read_eq( uint32_t base, uint32_t expected ) {
|
||||
uint32_t readdata;
|
||||
int ret = data_channel_read( base, & readdata );
|
||||
|
||||
if ( ret ) {
|
||||
printf( TEST_FAIL " %s data_channel empty\n", __func__ );
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( readdata != expected ) {
|
||||
printf( TEST_FAIL " %s %" PRIu32 " != %" PRIu32 "\n", __func__, expected, readdata );
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int test_data_channel_reset_values( uint32_t channel ) {
|
||||
printf( " %s %" PRIu32 " ...", __func__, channel );
|
||||
uint32_t base = data_channel_base_from_number( channel );
|
||||
data_channel_clear( base );
|
||||
|
||||
if ( ! assert_data_channel_empty( base ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( ! assert_not_full( base ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( ! assert_data_channel_level_eq( base, 0 ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf( TEST_OK "\n" );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_data_channel_sw_single_write_read( uint32_t channel ) {
|
||||
printf( " %s %" PRIu32 " ...", __func__, channel );
|
||||
|
||||
uint32_t base = data_channel_base_from_number( channel );
|
||||
DataChannelBinding binding = { BINDING_SW, BINDING_SW };
|
||||
data_channel_bind( base, & binding );
|
||||
|
||||
uint32_t value = 0xa5a5f00f;
|
||||
data_channel_write( base, value );
|
||||
|
||||
if ( ! assert_data_channel_level_eq( base, 1 ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( ! assert_data_channel_read_eq( base, value ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf( TEST_OK "\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_data_channel_sw_fill_read( uint32_t channel ) {
|
||||
printf( " %s ...", __func__ );
|
||||
uint32_t base = data_channel_base_from_number( channel );
|
||||
DataChannelBinding binding = { BINDING_SW, BINDING_SW };
|
||||
data_channel_bind( base, & binding );
|
||||
data_channel_clear( base );
|
||||
|
||||
if ( ! assert_data_channel_empty( base ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf( " write ..." );
|
||||
for ( uint32_t i = 0; i < DATA_CHANNEL_DEPTH; ++i ) {
|
||||
if ( ! assert_data_channel_level_eq( base, i ) ) {
|
||||
return 1;
|
||||
}
|
||||
data_channel_write( base, i );
|
||||
}
|
||||
|
||||
if ( ! assert_data_channel_full( base ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( ! assert_data_channel_level_eq( base, 0 ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf( " read ..." );
|
||||
for ( uint32_t i = 0; i < DATA_CHANNEL_DEPTH; ++i ) {
|
||||
assert_data_channel_read_eq( base, i );
|
||||
if ( ! assert_data_channel_level_eq( base, DATA_CHANNEL_DEPTH - i - 1 ) ) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! assert_data_channel_empty( base ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( ! assert_data_channel_level_eq( base, 0 ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf( TEST_OK "\n" );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_data_channel_sw_fill_clear( uint32_t channel ) {
|
||||
printf( " %s ...", __func__ );
|
||||
uint32_t base = data_channel_base_from_number( channel );
|
||||
DataChannelBinding binding = { BINDING_SW, BINDING_SW };
|
||||
data_channel_bind( base, & binding );
|
||||
|
||||
if ( ! assert_data_channel_empty( base ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
for ( uint32_t i = 0; i < DATA_CHANNEL_DEPTH; ++i ) {
|
||||
if ( ! assert_data_channel_level_eq( base, i ) ) {
|
||||
return 1;
|
||||
}
|
||||
data_channel_write( base, i );
|
||||
}
|
||||
|
||||
if ( ! assert_data_channel_full( base ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( ! assert_data_channel_level_eq( base, 0 ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
data_channel_clear( base );
|
||||
|
||||
if ( ! assert_data_channel_empty( base ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( ! assert_data_channel_level_eq( base, 0 ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf( TEST_OK "\n" );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_data_channel( uint32_t channel ) {
|
||||
int ret = 0;
|
||||
ret |= test_data_channel_reset_values( channel );
|
||||
ret |= test_data_channel_sw_single_write_read( channel );
|
||||
ret |= test_data_channel_sw_fill_read( channel );
|
||||
ret |= test_data_channel_sw_fill_clear( channel );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int test_data_channels( void ) {
|
||||
printf( "%s\n", __func__ );
|
||||
int ret = 0;
|
||||
for ( uint32_t i = 0; i < DATA_CHANNEL_COUNT; ++i ) {
|
||||
ret |= test_data_channel( i );
|
||||
}
|
||||
printf( TEST_DONE );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
int test_data_channels( void );
|
||||
int assert_data_channel_binding_eq( uint32_t base, uint32_t expected );
|
||||
int assert_data_channel_empty( uint32_t base );
|
||||
int assert_data_channel_full( uint32_t base );
|
||||
int assert_data_channel_level_eq( uint32_t base, uint32_t expected );
|
||||
int assert_data_channel_read_eq( uint32_t base, uint32_t expected );
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
extract_python_data = ${scripts}/extract_python_data.sh
|
||||
plot_data = data.py
|
||||
artifacts += ${plot_data}
|
||||
artifacts += __pycache__
|
||||
|
||||
include ../device_test.mk
|
||||
|
||||
plot: _plot
|
||||
@${scripts}/plot.py $(expected_data)
|
||||
@@ -0,0 +1,53 @@
|
||||
#include "device_test.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
int device_test( test_function test, uint32_t binding, void * task, void * input_a, void * input_b, void * expected, float epsilon ) {
|
||||
int ret = test( binding, task, input_a, input_b, expected, epsilon );
|
||||
|
||||
printf( TEST_DONE );
|
||||
return ret;
|
||||
}
|
||||
|
||||
int assert_float_near( float expected, float value, float abs_err ) {
|
||||
float abs_diff = fabs( expected - value );
|
||||
int pass = abs_diff <= abs_err;
|
||||
if ( ! pass ) {
|
||||
printf( TEST_FAIL " assert_float_near |%e - %e| = %e < %e\n", expected, value, abs_diff, abs_err );
|
||||
}
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
int assert_eq( uint32_t expected, uint32_t value ) {
|
||||
int pass = expected == value;
|
||||
if ( ! pass ) {
|
||||
printf( TEST_FAIL " assert_eq %" PRIx32" = %" PRIx32, expected, value );
|
||||
}
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
void print_float_data_for_python( const float_word * data, uint32_t len ) {
|
||||
printf( "py_float_data=[%e", data[ 0 ].value );
|
||||
for ( uint32_t i = 1; i < len; ++i ) {
|
||||
printf( ",%e", data[ i ].value );
|
||||
}
|
||||
printf( "]\n" );
|
||||
}
|
||||
|
||||
void print_hex_data_for_python( const float_word * data, uint32_t len ) {
|
||||
printf( "py_hex_data=[0x%"PRIx32, data[ 0 ].word );
|
||||
for ( uint32_t i = 1; i < len; ++i ) {
|
||||
printf( ",0x%"PRIx32, data[ i ].word );
|
||||
}
|
||||
printf( "]\n" );
|
||||
}
|
||||
|
||||
void print_results_for_python( uint32_t cycle_count, const float_word * data, uint32_t len ) {
|
||||
printf( "py_cycle_count=%"PRIu32"\n", cycle_count );
|
||||
print_float_data_for_python( data, len );
|
||||
print_hex_data_for_python( data, len );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "test_function.h"
|
||||
#include "../../software/signal_processing/system/float_word.h"
|
||||
|
||||
#define TEST_OK " [ OK ]"
|
||||
#define TEST_FAIL " [ FAIL ]"
|
||||
#define TEST_DONE "test done\n"
|
||||
|
||||
int device_test( test_function test, uint32_t binding, void * task, void * input_a, void * input_b, void * expected, float epsilon );
|
||||
|
||||
int assert_float_near( float expected, float value, float abs_err );
|
||||
|
||||
int assert_eq( uint32_t expected, uint32_t value );
|
||||
|
||||
void print_float_data_for_python( const float_word * data, uint32_t len );
|
||||
|
||||
void print_hex_data_for_python( const float_word * data, uint32_t len );
|
||||
|
||||
void print_results_for_python( uint32_t cycle_count, const float_word * data, uint32_t len );
|
||||
@@ -0,0 +1,92 @@
|
||||
|
||||
elf = $(test).elf
|
||||
map = $(test).map
|
||||
|
||||
ALT_LIBRARY_ROOT_DIR := $(bsp_root_dir)
|
||||
ABS_BSP_ROOT_DIR := $(shell realpath $(bsp_root_dir))
|
||||
BSP_INCLUDE_FILE := $(bsp_root_dir)/public.mk
|
||||
include $(BSP_INCLUDE_FILE)
|
||||
|
||||
libbsp = $(bsp_root_dir)/${BSP_LIB}
|
||||
|
||||
cross_compile := nios2-elf-
|
||||
ECHO = echo
|
||||
LD := $(cross_compile)g++
|
||||
CC := $(cross_compile)gcc
|
||||
CXX := $(cross_compile)g++
|
||||
|
||||
ldflags += -T$(BSP_LINKER_SCRIPT)
|
||||
ldflags += -msys-crt0=$(BSP_CRT0)
|
||||
ldflags += -msys-lib=$(BSP_SYS_LIB)
|
||||
ldflags += $(addprefix -L,$(ALT_LIBRARY_DIRS))
|
||||
ldflags += -O2
|
||||
ldflags += -Wall
|
||||
ldflags += $(ALT_CFLAGS)
|
||||
|
||||
cflags += -O2
|
||||
cflags += -Wall
|
||||
cflags += $(ALT_CFLAGS)
|
||||
|
||||
include_dirs += $(addprefix -I, $(ALT_INCLUDE_DIRS))
|
||||
|
||||
c_objects = $(patsubst %.c,%.o, ${c_sources})
|
||||
cc_objects = $(patsubst %.cc,%.oo, $(cc_sources))
|
||||
|
||||
objects = ${c_objects} ${cc_objects}
|
||||
|
||||
execute_on_device_and_read_output = ${scripts}/execute_on_device_and_read_output.sh
|
||||
check_test_results = ${scripts}/check_test_results.sh
|
||||
execute_and_highlight = ${scripts}/execute_and_highlight.sh
|
||||
device_output=device.out
|
||||
|
||||
artifacts += ${device_output}
|
||||
|
||||
.PHONY: all
|
||||
all: test remove_device_output
|
||||
|
||||
.PHONY: remove_device_output
|
||||
remove_device_output:
|
||||
@${RM} -rf ${device_output}
|
||||
|
||||
ifdef plot_data
|
||||
.PHONY: _plot
|
||||
_plot: ${plot_data} remove_device_output
|
||||
|
||||
${plot_data}: ${device_output}
|
||||
@cat $< | ${extract_python_data} > $@
|
||||
endif
|
||||
|
||||
.PHONY: test
|
||||
test: ${device_output}
|
||||
@$(ECHO) Checking test results
|
||||
@${check_test_results} $<
|
||||
|
||||
${device_output}: ${elf} ${execute_on_device_and_read_output}
|
||||
@$(ECHO) Executing $<
|
||||
@${execute_and_highlight} ${execute_on_device_and_read_output} ${elf} ${device_output}
|
||||
|
||||
${elf}: ${objects} ${linker_script} ${libbsp}
|
||||
@$(ECHO) Linking $@
|
||||
@${LD} ${ldflags} ${objects} -o $@
|
||||
|
||||
%.oo:%.cc
|
||||
@$(ECHO) Compiling $<
|
||||
@${CXX} --std=c++14 ${include_dirs} -c $< -o $@
|
||||
|
||||
%.o:%.c
|
||||
@$(ECHO) Compiling $<
|
||||
@${CC} $(cflags) ${include_dirs} -c $< -o $@
|
||||
|
||||
${libbsp}:
|
||||
@$(ECHO) Building $(bsp_root_dir)
|
||||
@$(MAKE) --no-print-directory -C $(bsp_root_dir)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@$(ECHO) Cleaning test
|
||||
@${RM} -rf ${objects} ${elf} ${artifacts}
|
||||
|
||||
.PHONY: download
|
||||
download: $(elf)
|
||||
@nios2-download -r -g $(elf)
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
test = test_task_add_sine_cosine
|
||||
bsp_root_dir = ../../../software/signal_processing_bsp
|
||||
expected_data = ../../data/sine.py
|
||||
scripts = ../../scripts
|
||||
|
||||
c_sources += \
|
||||
../../../software/signal_processing/system/task.c \
|
||||
../../../software/signal_processing/system/hardware_task.c \
|
||||
../../../software/signal_processing/system/data_channel.c \
|
||||
../../../software/signal_processing/system/hardware_timestamp.c \
|
||||
../../../software/signal_processing/system/task_add.c \
|
||||
../../../software/signal_processing/system/binding.c \
|
||||
../../../software/signal_processing/add.c \
|
||||
../data_channel/test_data_channel.c \
|
||||
../device_test.c \
|
||||
../test_task.c \
|
||||
main.c \
|
||||
|
||||
include ../device_data_test.mk
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#include <stdio.h>
|
||||
#include <system.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "../device_test.h"
|
||||
#include "../test_task.h"
|
||||
#include "../../../software/signal_processing/system/binding.h"
|
||||
#include "../../../software/signal_processing/system/task_add.h"
|
||||
#include "../../data/rand.h"
|
||||
#include "../../data/sine_cosine.h"
|
||||
#include "../../data/add_rand.h"
|
||||
|
||||
int main() {
|
||||
device_test( test_task, BINDING_HW, & ADD_RAND_CONFIG, expected_rand, expected_add_sine_cosine, expected_add_rand, 5e-2 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
test = test_task_add_sine_cosine
|
||||
bsp_root_dir = ../../../software/signal_processing_bsp
|
||||
expected_data = ../../data/sine.py
|
||||
scripts = ../../scripts
|
||||
|
||||
c_sources += \
|
||||
../../../software/signal_processing/system/task.c \
|
||||
../../../software/signal_processing/system/hardware_task.c \
|
||||
../../../software/signal_processing/system/data_channel.c \
|
||||
../../../software/signal_processing/system/hardware_timestamp.c \
|
||||
../../../software/signal_processing/system/task_add.c \
|
||||
../../../software/signal_processing/system/binding.c \
|
||||
../../../software/signal_processing/add.c \
|
||||
../data_channel/test_data_channel.c \
|
||||
../device_test.c \
|
||||
../test_task.c \
|
||||
main.c \
|
||||
|
||||
include ../device_data_test.mk
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#include <stdio.h>
|
||||
#include <system.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "../device_test.h"
|
||||
#include "../test_task.h"
|
||||
#include "../../../software/signal_processing/system/binding.h"
|
||||
#include "../../../software/signal_processing/system/task_add.h"
|
||||
#include "../../data/rand.h"
|
||||
#include "../../data/sine_cosine.h"
|
||||
#include "../../data/add_rand.h"
|
||||
|
||||
int main() {
|
||||
device_test( test_task, BINDING_SW, & ADD_RAND_CONFIG, expected_rand, expected_add_sine_cosine, expected_add_rand, 5e-2 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
test = test_task_add_sine_cosine
|
||||
bsp_root_dir = ../../../software/signal_processing_bsp
|
||||
expected_data = ../../data/sine.py
|
||||
scripts = ../../scripts
|
||||
|
||||
c_sources += \
|
||||
../../../software/signal_processing/system/task.c \
|
||||
../../../software/signal_processing/system/hardware_task.c \
|
||||
../../../software/signal_processing/system/data_channel.c \
|
||||
../../../software/signal_processing/system/hardware_timestamp.c \
|
||||
../../../software/signal_processing/system/task_add.c \
|
||||
../../../software/signal_processing/system/binding.c \
|
||||
../../../software/signal_processing/add.c \
|
||||
../data_channel/test_data_channel.c \
|
||||
../device_test.c \
|
||||
../test_task.c \
|
||||
main.c \
|
||||
|
||||
include ../device_data_test.mk
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#include <stdio.h>
|
||||
#include <system.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "../device_test.h"
|
||||
#include "../test_task.h"
|
||||
#include "../../../software/signal_processing/system/binding.h"
|
||||
#include "../../../software/signal_processing/system/task_add.h"
|
||||
#include "../../data/sine.h"
|
||||
#include "../../data/cosine.h"
|
||||
#include "../../data/sine_cosine.h"
|
||||
|
||||
int main() {
|
||||
device_test( test_task, BINDING_HW, & ADD_SINE_COSINE_CONFIG, expected_sine, expected_cosine, expected_add_sine_cosine, 5e-2 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
test = test_task_add_sine_cosine
|
||||
bsp_root_dir = ../../../software/signal_processing_bsp
|
||||
expected_data = ../../data/sine.py
|
||||
scripts = ../../scripts
|
||||
|
||||
c_sources += \
|
||||
../../../software/signal_processing/system/task.c \
|
||||
../../../software/signal_processing/system/hardware_task.c \
|
||||
../../../software/signal_processing/system/data_channel.c \
|
||||
../../../software/signal_processing/system/hardware_timestamp.c \
|
||||
../../../software/signal_processing/system/task_add.c \
|
||||
../../../software/signal_processing/system/binding.c \
|
||||
../../../software/signal_processing/add.c \
|
||||
../data_channel/test_data_channel.c \
|
||||
../device_test.c \
|
||||
../test_task.c \
|
||||
main.c \
|
||||
|
||||
include ../device_data_test.mk
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#include <stdio.h>
|
||||
#include <system.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "../device_test.h"
|
||||
#include "../test_task.h"
|
||||
#include "../../../software/signal_processing/system/binding.h"
|
||||
#include "../../../software/signal_processing/system/task_add.h"
|
||||
#include "../../data/sine.h"
|
||||
#include "../../data/cosine.h"
|
||||
#include "../../data/sine_cosine.h"
|
||||
|
||||
int main() {
|
||||
device_test( test_task, BINDING_SW, & ADD_SINE_COSINE_CONFIG, expected_sine, expected_cosine, expected_add_sine_cosine, 5e-2 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
test = test_task_cosine
|
||||
bsp_root_dir = ../../../software/signal_processing_bsp
|
||||
expected_data = ../../data/cosine.py
|
||||
scripts = ../../scripts
|
||||
|
||||
c_sources += \
|
||||
../../../software/signal_processing/system/task.c \
|
||||
../../../software/signal_processing/system/hardware_task.c \
|
||||
../../../software/signal_processing/system/data_channel.c \
|
||||
../../../software/signal_processing/system/hardware_timestamp.c \
|
||||
../../../software/signal_processing/system/task_sine.c \
|
||||
../../../software/signal_processing/system/binding.c \
|
||||
../../../software/signal_processing/sine.c \
|
||||
../data_channel/test_data_channel.c \
|
||||
../device_test.c \
|
||||
../test_task.c \
|
||||
main.c \
|
||||
|
||||
include ../device_data_test.mk
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
#include <system.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "../device_test.h"
|
||||
#include "../test_task.h"
|
||||
#include "../../../software/signal_processing/system/binding.h"
|
||||
#include "../../software/signal_processing/system/task_sine.h"
|
||||
#include "../../data/cosine.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
device_test( test_task, BINDING_HW, & COSINE_CONFIG, NULL, NULL, expected_cosine, 5e-2 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
test = test_task_cosine
|
||||
bsp_root_dir = ../../../software/signal_processing_bsp
|
||||
expected_data = ../../data/cosine.py
|
||||
scripts = ../../scripts
|
||||
|
||||
c_sources += \
|
||||
../../../software/signal_processing/system/task.c \
|
||||
../../../software/signal_processing/system/hardware_task.c \
|
||||
../../../software/signal_processing/system/data_channel.c \
|
||||
../../../software/signal_processing/system/hardware_timestamp.c \
|
||||
../../../software/signal_processing/system/task_sine.c \
|
||||
../../../software/signal_processing/system/binding.c \
|
||||
../../../software/signal_processing/sine.c \
|
||||
../data_channel/test_data_channel.c \
|
||||
../device_test.c \
|
||||
../test_task.c \
|
||||
main.c \
|
||||
|
||||
include ../device_data_test.mk
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
#include <system.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "../device_test.h"
|
||||
#include "../test_task.h"
|
||||
#include "../../../software/signal_processing/system/binding.h"
|
||||
#include "../../software/signal_processing/system/task_sine.h"
|
||||
#include "../../data/cosine.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
device_test( test_task, BINDING_SW, & COSINE_CONFIG, NULL, NULL, expected_cosine, 5e-2 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
test = test_task_crc
|
||||
bsp_root_dir = ../../../software/signal_processing_bsp
|
||||
expected_data = ../../data/crc.py
|
||||
scripts = ../../scripts
|
||||
|
||||
c_sources += \
|
||||
../../../software/signal_processing/system/task.c \
|
||||
../../../software/signal_processing/system/hardware_task.c \
|
||||
../../../software/signal_processing/system/data_channel.c \
|
||||
../../../software/signal_processing/system/hardware_timestamp.c \
|
||||
../../../software/signal_processing/system/task_crc.c \
|
||||
../../../software/signal_processing/system/binding.c \
|
||||
../../../software/signal_processing/crc.c \
|
||||
../data_channel/test_data_channel.c \
|
||||
../device_test.c \
|
||||
../test_crc.c \
|
||||
main.c \
|
||||
|
||||
include ../device_data_test.mk
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
#include <system.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "../device_test.h"
|
||||
#include "../test_crc.h"
|
||||
#include "../../../software/signal_processing/system/binding.h"
|
||||
#include "../../../software/signal_processing/system/task_crc.h"
|
||||
#include "../../data/fft.h"
|
||||
#include "../../data/crc.h"
|
||||
|
||||
int main() {
|
||||
device_test( test_task, BINDING_HW, & CRC_CONFIG, expected_fft, NULL, & expected_crc, 0.0 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
test = test_task_crc
|
||||
bsp_root_dir = ../../../software/signal_processing_bsp
|
||||
expected_data = ../../data/crc.py
|
||||
scripts = ../../scripts
|
||||
|
||||
c_sources += \
|
||||
../../../software/signal_processing/system/task.c \
|
||||
../../../software/signal_processing/system/hardware_task.c \
|
||||
../../../software/signal_processing/system/data_channel.c \
|
||||
../../../software/signal_processing/system/hardware_timestamp.c \
|
||||
../../../software/signal_processing/system/task_crc.c \
|
||||
../../../software/signal_processing/system/binding.c \
|
||||
../../../software/signal_processing/crc.c \
|
||||
../data_channel/test_data_channel.c \
|
||||
../device_test.c \
|
||||
../test_crc.c \
|
||||
main.c \
|
||||
|
||||
include ../device_data_test.mk
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
#include <system.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "../device_test.h"
|
||||
#include "../test_crc.h"
|
||||
#include "../../../software/signal_processing/system/binding.h"
|
||||
#include "../../../software/signal_processing/system/task_crc.h"
|
||||
#include "../../data/fft.h"
|
||||
#include "../../data/crc.h"
|
||||
|
||||
int main() {
|
||||
device_test( test_task, BINDING_SW, & CRC_CONFIG, expected_fft, NULL, & expected_crc, 0.0 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
test = test_task_fft
|
||||
bsp_root_dir = ../../../software/signal_processing_bsp
|
||||
expected_data = ../../data/fft.py
|
||||
scripts = ../../scripts
|
||||
|
||||
c_sources += \
|
||||
../../../software/signal_processing/system/task.c \
|
||||
../../../software/signal_processing/system/hardware_task.c \
|
||||
../../../software/signal_processing/system/data_channel.c \
|
||||
../../../software/signal_processing/system/hardware_timestamp.c \
|
||||
../../../software/signal_processing/system/task_fft.c \
|
||||
../../../software/signal_processing/system/binding.c \
|
||||
../../../software/signal_processing/fft.c \
|
||||
../data_channel/test_data_channel.c \
|
||||
../device_test.c \
|
||||
../test_task.c \
|
||||
main.c \
|
||||
|
||||
include ../device_data_test.mk
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
#include <system.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "../device_test.h"
|
||||
#include "../test_task.h"
|
||||
#include "../../../software/signal_processing/system/binding.h"
|
||||
#include "../../../software/signal_processing/system/task_fft.h"
|
||||
#include "../../data/add_rand.h"
|
||||
#include "../../data/fft.h"
|
||||
|
||||
int main() {
|
||||
device_test( test_task, BINDING_HW, & FFT_CONFIG, expected_add_rand, NULL, expected_fft, 2e-1 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
test = test_task_fft
|
||||
bsp_root_dir = ../../../software/signal_processing_bsp
|
||||
expected_data = ../../data/fft.py
|
||||
scripts = ../../scripts
|
||||
|
||||
c_sources += \
|
||||
../../../software/signal_processing/system/task.c \
|
||||
../../../software/signal_processing/system/hardware_task.c \
|
||||
../../../software/signal_processing/system/data_channel.c \
|
||||
../../../software/signal_processing/system/hardware_timestamp.c \
|
||||
../../../software/signal_processing/system/task_fft.c \
|
||||
../../../software/signal_processing/system/binding.c \
|
||||
../../../software/signal_processing/fft.c \
|
||||
../data_channel/test_data_channel.c \
|
||||
../device_test.c \
|
||||
../test_task.c \
|
||||
main.c \
|
||||
|
||||
include ../device_data_test.mk
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
#include <system.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "../device_test.h"
|
||||
#include "../test_task.h"
|
||||
#include "../../../software/signal_processing/system/binding.h"
|
||||
#include "../../../software/signal_processing/system/task_fft.h"
|
||||
#include "../../data/add_rand.h"
|
||||
#include "../../data/fft.h"
|
||||
|
||||
int main() {
|
||||
device_test( test_task, BINDING_SW, & FFT_CONFIG, expected_add_rand, NULL, expected_fft, 2e-1 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
test = test_task_rand
|
||||
bsp_root_dir = ../../../software/signal_processing_bsp
|
||||
expected_data = ../../data/rand.py
|
||||
scripts = ../../scripts
|
||||
|
||||
c_sources += \
|
||||
../../../software/signal_processing/system/task.c \
|
||||
../../../software/signal_processing/system/hardware_task.c \
|
||||
../../../software/signal_processing/system/data_channel.c \
|
||||
../../../software/signal_processing/system/hardware_timestamp.c \
|
||||
../../../software/signal_processing/system/task_rand.c \
|
||||
../../../software/signal_processing/system/binding.c \
|
||||
../../../software/signal_processing/rand.c \
|
||||
../data_channel/test_data_channel.c \
|
||||
../device_test.c \
|
||||
../test_task.c \
|
||||
main.c \
|
||||
|
||||
include ../device_data_test.mk
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
#include <system.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "../device_test.h"
|
||||
#include "../test_task.h"
|
||||
#include "../../../software/signal_processing/system/binding.h"
|
||||
#include "../../../software/signal_processing/system/task_rand.h"
|
||||
#include "../../data/rand.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
device_test( test_task, BINDING_HW, & RAND_CONFIG, NULL, NULL, expected_rand, 5e-2 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
test = test_task_rand
|
||||
bsp_root_dir = ../../../software/signal_processing_bsp
|
||||
expected_data = ../../data/rand.py
|
||||
scripts = ../../scripts
|
||||
|
||||
c_sources += \
|
||||
../../../software/signal_processing/system/task.c \
|
||||
../../../software/signal_processing/system/hardware_task.c \
|
||||
../../../software/signal_processing/system/data_channel.c \
|
||||
../../../software/signal_processing/system/hardware_timestamp.c \
|
||||
../../../software/signal_processing/system/task_rand.c \
|
||||
../../../software/signal_processing/system/binding.c \
|
||||
../../../software/signal_processing/rand.c \
|
||||
../data_channel/test_data_channel.c \
|
||||
../device_test.c \
|
||||
../test_task.c \
|
||||
main.c \
|
||||
|
||||
include ../device_data_test.mk
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
#include <system.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "../device_test.h"
|
||||
#include "../test_task.h"
|
||||
#include "../../../software/signal_processing/system/binding.h"
|
||||
#include "../../../software/signal_processing/system/task_rand.h"
|
||||
#include "../../data/rand.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
device_test( test_task, BINDING_SW, & RAND_CONFIG, NULL, NULL, expected_rand, 5e-2 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
test = test_task_sine
|
||||
bsp_root_dir = ../../../software/signal_processing_bsp
|
||||
expected_data = ../../data/sine.py
|
||||
scripts = ../../scripts
|
||||
|
||||
c_sources += \
|
||||
../../../software/signal_processing/system/task.c \
|
||||
../../../software/signal_processing/system/hardware_task.c \
|
||||
../../../software/signal_processing/system/data_channel.c \
|
||||
../../../software/signal_processing/system/hardware_timestamp.c \
|
||||
../../../software/signal_processing/system/task_sine.c \
|
||||
../../../software/signal_processing/system/binding.c \
|
||||
../../../software/signal_processing/sine.c \
|
||||
../data_channel/test_data_channel.c \
|
||||
../device_test.c \
|
||||
../test_task.c \
|
||||
main.c \
|
||||
|
||||
include ../device_data_test.mk
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
#include <system.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "../device_test.h"
|
||||
#include "../test_task.h"
|
||||
#include "../../../software/signal_processing/system/binding.h"
|
||||
#include "../../../software/signal_processing/system/task_sine.h"
|
||||
#include "../../data/sine.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
device_test( test_task, BINDING_HW, & SINE_CONFIG, NULL, NULL, expected_sine, 5e-2 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
test = test_task_sine
|
||||
bsp_root_dir = ../../../software/signal_processing_bsp
|
||||
expected_data = ../../data/sine.py
|
||||
scripts = ../../scripts
|
||||
|
||||
c_sources += \
|
||||
../../../software/signal_processing/system/task.c \
|
||||
../../../software/signal_processing/system/hardware_task.c \
|
||||
../../../software/signal_processing/system/data_channel.c \
|
||||
../../../software/signal_processing/system/hardware_timestamp.c \
|
||||
../../../software/signal_processing/system/task_sine.c \
|
||||
../../../software/signal_processing/system/binding.c \
|
||||
../../../software/signal_processing/sine.c \
|
||||
../data_channel/test_data_channel.c \
|
||||
../device_test.c \
|
||||
../test_task.c \
|
||||
main.c \
|
||||
|
||||
include ../device_data_test.mk
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#include <stdio.h>
|
||||
#include <system.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "../device_test.h"
|
||||
#include "../test_task.h"
|
||||
#include "../../../software/signal_processing/system/binding.h"
|
||||
#include "../../../software/signal_processing/system/task_sine.h"
|
||||
#include "../../data/sine.h"
|
||||
|
||||
int main() {
|
||||
device_test( test_task, BINDING_SW, & SINE_CONFIG, NULL, NULL, expected_sine, 5e-2 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
#include "test_crc.h"
|
||||
|
||||
#include "../../software/signal_processing/system/task.h"
|
||||
#include "../../software/signal_processing/system/task_sine.h"
|
||||
#include "../../software/signal_processing/system/binding.h"
|
||||
#include "../../software/signal_processing/system/data_channel.h"
|
||||
#include "../../software/signal_processing/system/float_word.h"
|
||||
#include "data_channel/test_data_channel.h"
|
||||
#include "device_test.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <system.h>
|
||||
|
||||
void write_input_data( uint32_t base, uint32_t binding, void * data ) {
|
||||
if ( data == NULL ) return;
|
||||
|
||||
DataChannelBinding data_channel_binding = { .sink = BINDING_SW, .source = binding };
|
||||
data_channel_clear( base );
|
||||
data_channel_bind( base, & data_channel_binding );
|
||||
data_channel_write_all( base, data, DATA_CHANNEL_DEPTH );
|
||||
}
|
||||
|
||||
int test_task( uint32_t binding, void * task, void * input_a, void * input_b, void * expected, float epsilon ) {
|
||||
task_base_config * base = ( task_base_config * ) task;
|
||||
printf( " %s %s %s ...", __func__, base->name, binding_to_string( binding ) );
|
||||
|
||||
uint32_t output_channel_base = base->sink;
|
||||
|
||||
write_input_data( base->sources[ 0 ], binding, input_a );
|
||||
write_input_data( base->sources[ 1 ], binding, input_b );
|
||||
|
||||
task_bind( task, binding );
|
||||
DataChannelBinding channel_binding = { .sink = binding, .source = BINDING_SW };
|
||||
|
||||
data_channel_clear( output_channel_base );
|
||||
data_channel_bind( output_channel_base, & channel_binding );
|
||||
|
||||
if ( ! assert_data_channel_empty( output_channel_base ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
task_run( task );
|
||||
|
||||
uint32_t cycle_count = task_get_cycle_count( task );
|
||||
|
||||
if ( ! assert_data_channel_level_eq( output_channel_base, 1 ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32_t output = 0;
|
||||
|
||||
data_channel_read( output_channel_base, & output );
|
||||
|
||||
uint32_t * expected_crc = ( uint32_t * ) expected;
|
||||
if ( ! assert_eq( expected_crc[ 0 ], output ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf( TEST_OK "\n" );
|
||||
printf( " cycles: %" PRIu32 "\n", cycle_count );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
int test_task( uint32_t binding, void * task, void *, void *, void * expected, float epsilon );
|
||||
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
typedef int ( * test_function )( uint32_t, void * config, void * input_a,
|
||||
void * input_b, void * expected, float epsilon );
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
#include "test_task.h"
|
||||
|
||||
#include "../../software/signal_processing/system/task.h"
|
||||
#include "../../software/signal_processing/system/task_sine.h"
|
||||
#include "../../software/signal_processing/system/binding.h"
|
||||
#include "../../software/signal_processing/system/data_channel.h"
|
||||
#include "../../software/signal_processing/system/float_word.h"
|
||||
#include "data_channel/test_data_channel.h"
|
||||
#include "device_test.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <system.h>
|
||||
|
||||
void write_input_data( uint32_t base, uint32_t binding, void * data ) {
|
||||
if ( data == NULL ) return;
|
||||
|
||||
DataChannelBinding data_channel_binding = { .sink = BINDING_SW, .source = binding };
|
||||
data_channel_clear( base );
|
||||
data_channel_bind( base, & data_channel_binding );
|
||||
data_channel_write_all( base, data, DATA_CHANNEL_DEPTH );
|
||||
}
|
||||
|
||||
int test_task( uint32_t binding, void * task, void * input_a, void * input_b, void * expected, float epsilon ) {
|
||||
printf( " %s %s ...", __func__, binding_to_string( binding ) );
|
||||
|
||||
task_base_config * base = ( task_base_config * ) task;
|
||||
uint32_t output_channel_base = base->sink;
|
||||
|
||||
write_input_data( base->sources[ 0 ], binding, input_a );
|
||||
write_input_data( base->sources[ 1 ], binding, input_b );
|
||||
|
||||
task_bind( task, binding );
|
||||
DataChannelBinding channel_binding = { .sink = binding, .source = BINDING_SW };
|
||||
|
||||
data_channel_clear( output_channel_base );
|
||||
data_channel_bind( output_channel_base, & channel_binding );
|
||||
|
||||
if ( ! assert_data_channel_empty( output_channel_base ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
task_run( task );
|
||||
|
||||
uint32_t cycle_count = task_get_cycle_count( task );
|
||||
|
||||
if ( ! assert_data_channel_full( output_channel_base ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( ! assert_data_channel_level_eq( output_channel_base, 0 ) ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
float_word output[ DATA_CHANNEL_DEPTH ];
|
||||
|
||||
for ( uint32_t i = 0; i < DATA_CHANNEL_DEPTH; ++i ) {
|
||||
data_channel_read( output_channel_base, & output[ i ].word );
|
||||
}
|
||||
|
||||
print_results_for_python( cycle_count, output, DATA_CHANNEL_DEPTH );
|
||||
|
||||
float * expected_sine = ( float * ) expected;
|
||||
for ( uint32_t i = 0; i < DATA_CHANNEL_DEPTH; ++i ) {
|
||||
if ( ! assert_float_near( expected_sine[ i ], output[ i ].value, epsilon ) ) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
printf( TEST_OK "\n" );
|
||||
printf( " cycles: %" PRIu32 "\n", cycle_count );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
int test_task( uint32_t binding, void * task, void *, void *, void * expected, float epsilon );
|
||||
Reference in New Issue
Block a user