forked from KutningJo/signal_processing_vorlage
Initial commit
This commit is contained in:
commit
0d1b73e3e0
255 files changed
+16057
No files matched your search
@@ -0,0 +1,65 @@
|
||||
#include "DataChannelSimulation.h"
|
||||
#include <iostream>
|
||||
|
||||
#define REG_CONFIG_OFFSET 0
|
||||
#define REG_EMPTY_OFFSET 1
|
||||
#define REG_FULL_OFFSET 2
|
||||
#define REG_LEVEL_OFFSET 3
|
||||
#define REG_SINK_OFFSET 4
|
||||
#define REG_SOURCE_OFFSET 5
|
||||
#define REG_CLEAR_OFFSET 6
|
||||
|
||||
DataChannelSimulation::DataChannelSimulation()
|
||||
: config ( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
DataChannelSimulation::~DataChannelSimulation() {
|
||||
}
|
||||
|
||||
uint32_t DataChannelSimulation::read( uint32_t offset ) {
|
||||
switch ( offset ) {
|
||||
case REG_CONFIG_OFFSET: return config;
|
||||
case REG_EMPTY_OFFSET: return isEmpty();
|
||||
case REG_FULL_OFFSET: return isFull();
|
||||
case REG_LEVEL_OFFSET: return fifo.size();
|
||||
case REG_SOURCE_OFFSET: return read();
|
||||
}
|
||||
return static_cast< uint32_t >( -1 );
|
||||
}
|
||||
|
||||
void DataChannelSimulation::write( uint32_t offset, uint32_t value ) {
|
||||
switch ( offset ) {
|
||||
case REG_CONFIG_OFFSET: config = value; break;
|
||||
case REG_SINK_OFFSET: write( value ); break;
|
||||
case REG_CLEAR_OFFSET: clear(); break;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t DataChannelSimulation::read() {
|
||||
uint32_t value = static_cast< uint32_t >( -1 );
|
||||
if ( fifo.size() ) {
|
||||
value = fifo.front();
|
||||
fifo.pop_front();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
void DataChannelSimulation::write( uint32_t value ) {
|
||||
if ( not isFull() ) {
|
||||
fifo.push_back( value );
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t DataChannelSimulation::isEmpty() const {
|
||||
return fifo.size() == 0;
|
||||
}
|
||||
|
||||
uint32_t DataChannelSimulation::isFull() const {
|
||||
return fifo.size() == MAX_SIZE;
|
||||
}
|
||||
|
||||
void DataChannelSimulation::clear() {
|
||||
fifo.clear();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <cinttypes>
|
||||
#include <deque>
|
||||
|
||||
class DataChannelSimulation {
|
||||
public:
|
||||
DataChannelSimulation();
|
||||
~DataChannelSimulation();
|
||||
|
||||
uint32_t read( uint32_t offset );
|
||||
void write( uint32_t offset, uint32_t value );
|
||||
|
||||
private:
|
||||
uint32_t read();
|
||||
void write( uint32_t value );
|
||||
|
||||
uint32_t isEmpty() const;
|
||||
uint32_t isFull() const;
|
||||
|
||||
void clear();
|
||||
|
||||
std::deque< uint32_t > fifo;
|
||||
uint32_t config;
|
||||
|
||||
static const uint32_t MAX_SIZE = 1024;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
#include "Hardware.h"
|
||||
|
||||
#include "../../software/signal_processing_bsp/system.h"
|
||||
|
||||
#include "../../software/signal_processing/system/task_sine.h"
|
||||
#include "../../software/signal_processing/system/task_rand.h"
|
||||
#include "../../software/signal_processing/system/task_add.h"
|
||||
#include "../../software/signal_processing/system/task_fft.h"
|
||||
#include "../../software/signal_processing/system/task_crc.h"
|
||||
|
||||
Hardware * Hardware::instance = nullptr;
|
||||
|
||||
Hardware * Hardware::getInstance() {
|
||||
if ( Hardware::instance == nullptr ) {
|
||||
Hardware::instance = new Hardware();
|
||||
}
|
||||
|
||||
return Hardware::instance;
|
||||
}
|
||||
|
||||
Hardware::~Hardware() {
|
||||
for ( uint32_t i = 0; i < 7; ++i ) {
|
||||
delete dataChannel[ i ];
|
||||
}
|
||||
}
|
||||
|
||||
void Hardware::write( uint32_t base, uint32_t offset, uint32_t value ) {
|
||||
switch ( base ) {
|
||||
case DATA_CHANNEL_0_BASE: dataChannel[ 0 ]->write( offset, value ); break;
|
||||
case DATA_CHANNEL_1_BASE: dataChannel[ 1 ]->write( offset, value ); break;
|
||||
case DATA_CHANNEL_2_BASE: dataChannel[ 2 ]->write( offset, value ); break;
|
||||
case DATA_CHANNEL_3_BASE: dataChannel[ 3 ]->write( offset, value ); break;
|
||||
case DATA_CHANNEL_4_BASE: dataChannel[ 4 ]->write( offset, value ); break;
|
||||
case DATA_CHANNEL_5_BASE: dataChannel[ 5 ]->write( offset, value ); break;
|
||||
case DATA_CHANNEL_6_BASE: dataChannel[ 6 ]->write( offset, value ); break;
|
||||
case HARDWARE_TASK_0_BASE: task[ 0 ]->write( offset, value ); break;
|
||||
case HARDWARE_TASK_1_BASE: task[ 1 ]->write( offset, value ); break;
|
||||
case HARDWARE_TASK_2_BASE: task[ 2 ]->write( offset, value ); break;
|
||||
case HARDWARE_TASK_3_BASE: task[ 3 ]->write( offset, value ); break;
|
||||
case HARDWARE_TASK_4_BASE: task[ 4 ]->write( offset, value ); break;
|
||||
case HARDWARE_TASK_5_BASE: task[ 5 ]->write( offset, value ); break;
|
||||
case HARDWARE_TASK_6_BASE: task[ 6 ]->write( offset, value ); break;
|
||||
};
|
||||
}
|
||||
|
||||
uint32_t Hardware::read( uint32_t base, uint32_t offset ) {
|
||||
switch ( base ) {
|
||||
case DATA_CHANNEL_0_BASE: return dataChannel[ 0 ]->read( offset );
|
||||
case DATA_CHANNEL_1_BASE: return dataChannel[ 1 ]->read( offset );
|
||||
case DATA_CHANNEL_2_BASE: return dataChannel[ 2 ]->read( offset );
|
||||
case DATA_CHANNEL_3_BASE: return dataChannel[ 3 ]->read( offset );
|
||||
case DATA_CHANNEL_4_BASE: return dataChannel[ 4 ]->read( offset );
|
||||
case DATA_CHANNEL_5_BASE: return dataChannel[ 5 ]->read( offset );
|
||||
case DATA_CHANNEL_6_BASE: return dataChannel[ 6 ]->read( offset );
|
||||
case HARDWARE_TASK_0_BASE: return task[ 0 ]->read( offset );
|
||||
case HARDWARE_TASK_1_BASE: return task[ 1 ]->read( offset );
|
||||
case HARDWARE_TASK_2_BASE: return task[ 2 ]->read( offset );
|
||||
case HARDWARE_TASK_3_BASE: return task[ 3 ]->read( offset );
|
||||
case HARDWARE_TASK_4_BASE: return task[ 4 ]->read( offset );
|
||||
case HARDWARE_TASK_5_BASE: return task[ 5 ]->read( offset );
|
||||
case HARDWARE_TASK_6_BASE: return task[ 6 ]->read( offset );
|
||||
default: return -1;
|
||||
};
|
||||
}
|
||||
|
||||
Hardware::Hardware() {
|
||||
task.push_back( new HardwareTaskSimulation( task_sine_run ) );
|
||||
task.push_back( new HardwareTaskSimulation( task_sine_run ) );
|
||||
task.push_back( new HardwareTaskSimulation( task_rand_run ) );
|
||||
task.push_back( new HardwareTaskSimulation( task_add_run ) );
|
||||
task.push_back( new HardwareTaskSimulation( task_add_run ) );
|
||||
task.push_back( new HardwareTaskSimulation( task_fft_run ) );
|
||||
task.push_back( new HardwareTaskSimulation( task_crc_run ) );
|
||||
|
||||
for ( uint32_t i = 0; i < 7; ++i ) {
|
||||
dataChannel.push_back( new DataChannelSimulation() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "DataChannelSimulation.h"
|
||||
#include "HardwareTaskSimulation.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include <vector>
|
||||
|
||||
class Hardware {
|
||||
public:
|
||||
static Hardware * getInstance();
|
||||
~Hardware();
|
||||
|
||||
void write( uint32_t base, uint32_t offset, uint32_t value );
|
||||
uint32_t read( uint32_t base, uint32_t offset );
|
||||
|
||||
private:
|
||||
Hardware();
|
||||
Hardware( const Hardware & ) = delete;
|
||||
|
||||
static Hardware * instance;
|
||||
|
||||
std::vector< DataChannelSimulation * > dataChannel;
|
||||
std::vector< HardwareTaskSimulation * > task;
|
||||
std::vector< task_function > function;
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
#include "HardwareTaskSimulation.h"
|
||||
|
||||
#include "../../software/signal_processing/system/hardware_task.h"
|
||||
#include <chrono>
|
||||
|
||||
#define REG_START_OFFSET 0
|
||||
#define REG_STATE_OFFSET 1
|
||||
#define REG_CYCLE_COUNT_OFFSET 2
|
||||
#define REG_CONFIG_0_OFFSET 3
|
||||
|
||||
#define FREQ 200e6
|
||||
|
||||
HardwareTaskSimulation::HardwareTaskSimulation( task_function function )
|
||||
: state( 0 ),
|
||||
cycleCount( 0 ),
|
||||
function( function ) {
|
||||
}
|
||||
|
||||
uint32_t HardwareTaskSimulation::read( uint32_t offset ) const {
|
||||
switch ( offset ) {
|
||||
case REG_STATE_OFFSET: return state;
|
||||
case REG_CYCLE_COUNT_OFFSET: return cycleCount;
|
||||
case REG_CONFIG_0_OFFSET: return config[ 0 ];
|
||||
}
|
||||
return static_cast< uint32_t >( -1 );
|
||||
}
|
||||
|
||||
void HardwareTaskSimulation::write( uint32_t offset, uint32_t value ) {
|
||||
switch ( offset ) {
|
||||
case REG_START_OFFSET: start(); break;
|
||||
case REG_CONFIG_0_OFFSET: config[ 0 ] = value; break;
|
||||
}
|
||||
}
|
||||
|
||||
void HardwareTaskSimulation::start() {
|
||||
using namespace std::chrono;
|
||||
auto start = high_resolution_clock::now();
|
||||
state = HARDWARE_TASK_RUNNING;
|
||||
function( config );
|
||||
state = HARDWARE_TASK_DONE;
|
||||
auto stop = high_resolution_clock::now();
|
||||
auto time = duration_cast< duration< double > >( stop - start );
|
||||
cycleCount = static_cast< uint32_t >( time.count() * FREQ );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../software/signal_processing/system/task_function.h"
|
||||
#include <cinttypes>
|
||||
|
||||
class HardwareTaskSimulation {
|
||||
public:
|
||||
HardwareTaskSimulation( task_function function );
|
||||
uint32_t read( uint32_t offset ) const;
|
||||
void write( uint32_t offset, uint32_t value );
|
||||
private:
|
||||
void start();
|
||||
|
||||
uint32_t state;
|
||||
uint32_t cycleCount;
|
||||
uint32_t config[4];
|
||||
task_function function;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "HardwareTimerSimulation.h"
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
#pragma once
|
||||
@@ -0,0 +1,107 @@
|
||||
#include "dataChannelTestUtility.h"
|
||||
|
||||
#include "../../software/signal_processing/system/data_channel.h"
|
||||
#include <fstream>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
void dataChannelRead( uint32_t base, float * data ) {
|
||||
for ( uint32_t i = 0; i < DATA_CHANNEL_DEPTH; ++i ) {
|
||||
data_channel_read( base, reinterpret_cast< uint32_t * >( & data[ i ] ) );
|
||||
}
|
||||
}
|
||||
|
||||
void dataChannelRead( uint32_t base, uint32_t * data ) {
|
||||
for ( uint32_t i = 0; i < DATA_CHANNEL_DEPTH; ++i ) {
|
||||
data_channel_read( base, & data[ i ] );
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t dataChannelRead( uint32_t base ) {
|
||||
uint32_t data;
|
||||
data_channel_read( base, & data );
|
||||
return data;
|
||||
}
|
||||
|
||||
void dataChannelCheck( const float * data, const float * expected ) {
|
||||
for ( uint32_t i = 0; i < DATA_CHANNEL_DEPTH; ++i ) {
|
||||
ASSERT_NEAR( data[ i ], expected[ i ], 1e-1 ) << " with i = " << i;
|
||||
}
|
||||
}
|
||||
|
||||
void dataChannelCheck( const uint32_t * data, const uint32_t * expected ) {
|
||||
for ( uint32_t i = 0; i < DATA_CHANNEL_DEPTH; ++i ) {
|
||||
ASSERT_EQ( data[ i ], expected[ i ] ) << " with i = " << i;
|
||||
}
|
||||
}
|
||||
|
||||
void dataChannelFill( uint32_t base, const float * data ) {
|
||||
for ( uint32_t i = 0; i < DATA_CHANNEL_DEPTH; ++i ) {
|
||||
data_channel_write( base, * reinterpret_cast< const uint32_t * >( & data[ i ] ) );
|
||||
}
|
||||
}
|
||||
|
||||
void dataChannelReadAndWriteToFile( const void * data, const char * filename ) {
|
||||
std::ofstream out;
|
||||
out.open( filename, std::ios::out );
|
||||
|
||||
auto float_data = reinterpret_cast< const float * >( data );
|
||||
auto u32_data = reinterpret_cast< const uint32_t * >( data );
|
||||
|
||||
out << "float_data = [" << std::setprecision(6) << std::fixed << std::scientific << float_data[ 0 ];
|
||||
for ( uint32_t i = 1; i < DATA_CHANNEL_DEPTH; ++i ) {
|
||||
out << "," << float_data[ i ];
|
||||
}
|
||||
out << "]" << std::endl;
|
||||
|
||||
out << "hex_data = [" << std::hex << "0x" << u32_data[ 0 ];
|
||||
for ( uint32_t i = 1; i < DATA_CHANNEL_DEPTH; ++i ) {
|
||||
out << ",0x" << u32_data[ i ];
|
||||
}
|
||||
out << "]" << std::endl;
|
||||
|
||||
out.close();
|
||||
}
|
||||
|
||||
void dataChannelReadAndWriteToFile( uint32_t data, const char * filename ) {
|
||||
std::ofstream out;
|
||||
out.open( filename, std::ios::out );
|
||||
|
||||
auto float_data = reinterpret_cast< const float * >( & data );
|
||||
auto u32_data = reinterpret_cast< const uint32_t * >( & data );
|
||||
|
||||
out << "float_data = [" << std::setprecision(6) << std::fixed << std::scientific << float_data[ 0 ];
|
||||
out << "]" << std::endl;
|
||||
|
||||
out << "hex_data = [" << std::hex << "0x" << u32_data[ 0 ];
|
||||
out << "]" << std::endl;
|
||||
|
||||
out.close();
|
||||
}
|
||||
|
||||
void dataChannelCheckAndWriteToFile( uint32_t base, const float * expected, const char * filename ) {
|
||||
float data[ DATA_CHANNEL_DEPTH ];
|
||||
memset( data, 0.0, sizeof( float ) * DATA_CHANNEL_DEPTH );
|
||||
dataChannelRead( base, data );
|
||||
dataChannelReadAndWriteToFile( data, filename );
|
||||
dataChannelCheck( data, expected );
|
||||
}
|
||||
|
||||
void dataChannelWriteToFile( uint32_t base, const char * filename ) {
|
||||
float data[ DATA_CHANNEL_DEPTH ];
|
||||
memset( data, 0.0, sizeof( float ) * DATA_CHANNEL_DEPTH );
|
||||
dataChannelRead( base, data );
|
||||
dataChannelReadAndWriteToFile( data, filename );
|
||||
}
|
||||
|
||||
void dataChannelCheckAndWriteToFile( uint32_t base, const uint32_t * expected, const char * filename ) {
|
||||
uint32_t data[ DATA_CHANNEL_DEPTH ];
|
||||
memset( data, 0, sizeof( uint32_t ) * DATA_CHANNEL_DEPTH );
|
||||
dataChannelRead( base, data );
|
||||
dataChannelReadAndWriteToFile( data, filename );
|
||||
dataChannelCheck( data, expected );
|
||||
}
|
||||
|
||||
void dataChannelCheck( uint32_t base, uint32_t expected, const char * filename ) {
|
||||
uint32_t data = dataChannelRead( base );
|
||||
ASSERT_EQ( data, expected );
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
void dataChannelFill( uint32_t base, const float * data );
|
||||
|
||||
void dataChannelWriteToFile( uint32_t base, const char * filename );
|
||||
|
||||
void dataChannelCheckAndWriteToFile( uint32_t base,
|
||||
const float * expected, const char * filename );
|
||||
|
||||
void dataChannelCheckAndWriteToFile( uint32_t base,
|
||||
const uint32_t * expected, const char * filename );
|
||||
|
||||
void dataChannelCheck( uint32_t base,
|
||||
uint32_t expected, const char * filename );
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
include ../tests.mk
|
||||
|
||||
artifacts += data.py __pycache__
|
||||
|
||||
plot: data.py
|
||||
@echo Plotting resulting signal vs. expected signal ...
|
||||
@../../scripts/plot.py ${expected_data} 2> /dev/null
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "io.h"
|
||||
|
||||
#include "Hardware.h"
|
||||
#include <cstdio>
|
||||
|
||||
void IOWR( uint32_t base, uint32_t REG_CONFIG_OFFSET, uint32_t value ) {
|
||||
auto hardware = Hardware::getInstance();
|
||||
hardware->write( base, REG_CONFIG_OFFSET, value );
|
||||
}
|
||||
|
||||
uint32_t IORD( uint32_t base, uint32_t REG_CONFIG_OFFSET ) {
|
||||
auto hardware = Hardware::getInstance();
|
||||
return hardware->read( base, REG_CONFIG_OFFSET );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void IOWR( uint32_t base, uint32_t REG_CONFIG_OFFSET, uint32_t value );
|
||||
uint32_t IORD( uint32_t base, uint32_t REG_CONFIG_OFFSET );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
#include "taskTests.h"
|
||||
#include "../../software/signal_processing/system/data_channel.h"
|
||||
#include "../../software/signal_processing/system/binding.h"
|
||||
#include "../../software/signal_processing/system/task_sine.h"
|
||||
#include "../../software/signal_processing/system/task_rand.h"
|
||||
#include "../../software/signal_processing/system/task_add.h"
|
||||
#include "../../software/signal_processing/system/task_fft.h"
|
||||
#include "../../software/signal_processing/system/task_crc.h"
|
||||
#include "../../software/signal_processing/system/sine_config.h"
|
||||
#include "../../software/signal_processing/system/rand_config.h"
|
||||
#include "../../software/signal_processing/system/add_config.h"
|
||||
#include "../../software/signal_processing/system/fft_config.h"
|
||||
#include "../../software/signal_processing/system/crc_config.h"
|
||||
#include "../../software/signal_processing_bsp/system.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
void configureAndRunSine() {
|
||||
DataChannelBinding binding = { BINDING_HW, BINDING_HW };
|
||||
data_channel_bind( DATA_CHANNEL_0_BASE, & binding );
|
||||
|
||||
task_sine_run( & SINE_CONFIG );
|
||||
}
|
||||
|
||||
void configureAndRunCosine() {
|
||||
DataChannelBinding binding = { BINDING_HW, BINDING_HW };
|
||||
data_channel_bind( DATA_CHANNEL_1_BASE, & binding );
|
||||
|
||||
task_sine_run( & COSINE_CONFIG );
|
||||
}
|
||||
|
||||
void configureAndRunRand() {
|
||||
DataChannelBinding binding = { BINDING_HW, BINDING_HW };
|
||||
data_channel_bind( DATA_CHANNEL_2_BASE, & binding );
|
||||
|
||||
task_rand_run( & RAND_CONFIG );
|
||||
}
|
||||
|
||||
void configureAndRunAddSineCosine() {
|
||||
DataChannelBinding binding = { BINDING_HW, BINDING_HW };
|
||||
data_channel_bind( DATA_CHANNEL_3_BASE, & binding );
|
||||
|
||||
task_add_run( & ADD_SINE_COSINE_CONFIG );
|
||||
}
|
||||
|
||||
void configureAndRunAddRand() {
|
||||
DataChannelBinding binding = { BINDING_HW, BINDING_HW };
|
||||
data_channel_bind( DATA_CHANNEL_4_BASE, & binding );
|
||||
|
||||
task_add_run( & ADD_RAND_CONFIG );
|
||||
}
|
||||
|
||||
void configureAndRunFft() {
|
||||
DataChannelBinding binding = { BINDING_HW, BINDING_HW };
|
||||
data_channel_bind( DATA_CHANNEL_5_BASE, & binding );
|
||||
|
||||
task_fft_run( & FFT_CONFIG );
|
||||
}
|
||||
|
||||
void configureAndRunCrc() {
|
||||
DataChannelBinding binding = { BINDING_HW, BINDING_HW };
|
||||
data_channel_bind( DATA_CHANNEL_6_BASE, & binding );
|
||||
|
||||
task_crc_run( & CRC_CONFIG );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
void configureAndRunSine();
|
||||
void configureAndRunCosine();
|
||||
void configureAndRunRand();
|
||||
void configureAndRunAddSineCosine();
|
||||
void configureAndRunAddRand();
|
||||
void configureAndRunFft();
|
||||
void configureAndRunCrc();
|
||||
@@ -0,0 +1,7 @@
|
||||
binary = test_task_add_rand
|
||||
expected_data = ../../data/add_rand.py
|
||||
|
||||
cc_sources = test_task_add_rand.cc \
|
||||
|
||||
include ../data_tests.mk
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include "../dataChannelTestUtility.h"
|
||||
#include "../taskTests.h"
|
||||
#include "../../../software/signal_processing_bsp/system.h"
|
||||
#include "../../data/rand.h"
|
||||
#include "../../data/sine_cosine.h"
|
||||
#include "../../data/add_rand.h"
|
||||
|
||||
int main( int argc, char ** argv ) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
TEST( test_task_add_rand, execute_only ) {
|
||||
dataChannelFill( DATA_CHANNEL_2_BASE, expected_rand );
|
||||
dataChannelFill( DATA_CHANNEL_3_BASE, expected_add_sine_cosine );
|
||||
configureAndRunAddRand();
|
||||
dataChannelWriteToFile( DATA_CHANNEL_4_BASE, "data.py" );
|
||||
}
|
||||
|
||||
TEST( test_task_add_rand, execute_and_check ) {
|
||||
dataChannelFill( DATA_CHANNEL_2_BASE, expected_rand );
|
||||
dataChannelFill( DATA_CHANNEL_3_BASE, expected_add_sine_cosine );
|
||||
configureAndRunAddRand();
|
||||
dataChannelCheckAndWriteToFile( DATA_CHANNEL_4_BASE, expected_add_rand, "data.py" );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
binary = test_task_add_sine_cosine
|
||||
expected_data=../../data/sine_cosine.py
|
||||
|
||||
cc_sources = test_task_add_sine_cosine.cc \
|
||||
|
||||
include ../data_tests.mk
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include "../dataChannelTestUtility.h"
|
||||
#include "../taskTests.h"
|
||||
#include "../../../software/signal_processing_bsp/system.h"
|
||||
#include "../../data/sine.h"
|
||||
#include "../../data/cosine.h"
|
||||
#include "../../data/sine_cosine.h"
|
||||
|
||||
int main( int argc, char ** argv ) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
TEST( test_task_add_sine_cosine, execute_only ) {
|
||||
dataChannelFill( DATA_CHANNEL_0_BASE, expected_sine );
|
||||
dataChannelFill( DATA_CHANNEL_1_BASE, expected_cosine );
|
||||
configureAndRunAddSineCosine();
|
||||
dataChannelWriteToFile( DATA_CHANNEL_3_BASE, "data.py" );
|
||||
}
|
||||
|
||||
TEST( test_task_add_sine_cosine, execute_and_check ) {
|
||||
dataChannelFill( DATA_CHANNEL_0_BASE, expected_sine );
|
||||
dataChannelFill( DATA_CHANNEL_1_BASE, expected_cosine );
|
||||
configureAndRunAddSineCosine();
|
||||
dataChannelCheckAndWriteToFile( DATA_CHANNEL_3_BASE, expected_add_sine_cosine, "data.py" );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
binary = test_task_cosine
|
||||
expected_data = ../../data/cosine.py
|
||||
|
||||
cc_sources = test_task_cosine.cc \
|
||||
|
||||
include ../data_tests.mk
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include "../dataChannelTestUtility.h"
|
||||
#include "../taskTests.h"
|
||||
#include "../../../software/signal_processing_bsp/system.h"
|
||||
#include "../../data/cosine.h"
|
||||
|
||||
int main( int argc, char ** argv ) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
TEST( test_task_cosine, execute_only ) {
|
||||
configureAndRunCosine();
|
||||
dataChannelWriteToFile( DATA_CHANNEL_1_BASE, "data.py" );
|
||||
}
|
||||
|
||||
TEST( test_task_cosine, execute_and_check ) {
|
||||
configureAndRunCosine();
|
||||
dataChannelCheckAndWriteToFile( DATA_CHANNEL_1_BASE, expected_cosine, "data.py" );
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
binary = test_task_crc
|
||||
|
||||
cc_sources = test_task_crc.cc \
|
||||
|
||||
include ../tests.mk
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include "../dataChannelTestUtility.h"
|
||||
#include "../taskTests.h"
|
||||
#include "../../../software/signal_processing_bsp/system.h"
|
||||
#include "../../data/fft.h"
|
||||
#include "../../data/crc.h"
|
||||
|
||||
int main( int argc, char ** argv ) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
TEST( test_task_crc, execute_and_check ) {
|
||||
dataChannelFill( DATA_CHANNEL_5_BASE, expected_fft );
|
||||
configureAndRunCrc();
|
||||
dataChannelCheck( DATA_CHANNEL_6_BASE, expected_crc, "data.py" );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
binary = test_task_fft
|
||||
expected_data = ../../data/fft.py
|
||||
|
||||
cc_sources = test_task_fft.cc \
|
||||
|
||||
include ../data_tests.mk
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
float expected [] = {6.965640e+02,2.435457e+03,3.809787e+03,5.342135e+03,5.033606e+03,1.878639e+04,2.992766e+03,4.251906e+03,2.327156e+03,6.943239e+03,3.233944e+03,5.899368e+03,1.212738e+03,2.634902e+03,2.338896e+03,3.062901e+03,4.583289e+03,5.207558e+03,3.945717e+03,1.610234e+03,2.913832e+03,3.207844e+03,1.765051e+03,2.745217e+03,1.826102e+03,1.814793e+03,3.131559e+03,4.545801e+03,6.835188e+03,3.423043e+03,1.033316e+03,3.960390e+02,1.635841e+04,1.769902e+03,5.383272e+02,3.671388e+03,3.044271e+03,4.295245e+03,2.932001e+03,2.699248e+03,2.816394e+03,1.677446e+03,1.645559e+03,3.061126e+03,3.998029e+03,4.814227e+03,3.953346e+03,3.981038e+03,3.813739e+03,3.002147e+03,1.689593e+03,2.421036e+03,2.612971e+03,1.693105e+03,3.422601e+03,2.952837e+03,2.287408e+03,1.314259e+03,2.700466e+03,3.986480e+02,2.248338e+03,2.890850e+03,2.046735e+03,2.819777e+03,2.529426e+03,4.147073e+03,3.575054e+03,6.092497e+02,3.410041e+03,6.042573e+02,3.740219e+03,3.373714e+03,2.975614e+03,5.166233e+03,3.462775e+03,5.806094e+03,2.013542e+03,1.050135e+03,2.077470e+03,3.493440e+03,3.564831e+03,1.558896e+03,4.422310e+03,1.399227e+03,2.472646e+03,1.845612e+03,1.601238e+03,9.195441e+02,1.920753e+03,1.299959e+03,2.926151e+03,2.507887e+03,3.292674e+03,3.486662e+03,1.911043e+03,2.904057e+03,1.166072e+03,4.306068e+03,2.270995e+03,1.361380e+03,1.991033e+03,6.817420e+02,2.372753e+03,2.269490e+03,5.084716e+02,2.020852e+03,4.253350e+02,3.230588e+03,2.716786e+03,4.015577e+03,9.436890e+02,2.444384e+03,1.035006e+03,3.845329e+03,3.811422e+02,5.433000e+02,2.613640e+03,1.572307e+03,1.009957e+03,8.700765e+02,1.073074e+03,2.224805e+03,2.065551e+03,3.031282e+03,6.783326e+02,3.477681e+03,2.428031e+03,4.071128e+03,2.475692e+03,2.009826e+03,5.320924e+03,1.325147e+03,2.228803e+03,1.431440e+03,1.351739e+03,2.303605e+03,1.178153e+03,2.184820e+03,1.295416e+03,3.918615e+03,3.068579e+03,3.915641e+03,2.574187e+03,1.164893e+03,1.575789e+03,2.090233e+03,2.493177e+03,2.230187e+03,1.278127e+03,1.600950e+03,1.111286e+03,3.048698e+03,5.667196e+03,2.425855e+03,7.738056e+02,2.292024e+03,3.328960e+03,2.685813e+03,3.043943e+03,6.309764e+02,5.348433e+03,3.362754e+02,2.974319e+03,2.712548e+03,3.626467e+03,7.289197e+02,2.687405e+03,5.621705e+03,1.481679e+03,1.880519e+03,2.209120e+03,4.280729e+03,1.386094e+03,2.093540e+03,1.851524e+03,2.194915e+03,2.754999e+03,2.230349e+03,2.557888e+03,2.600003e+03,2.592755e+03,1.533708e+03,2.682770e+03,1.614496e+03,3.203085e+03,1.294711e+03,3.653182e+03,2.684215e+03,1.086199e+03,1.725499e+03,2.146051e+03,1.815284e+03,1.032418e+03,4.143211e+03,1.752719e+03,4.086155e+03,1.263729e+03,8.088406e+02,3.010550e+03,1.622454e+03,2.161360e+03,6.799824e+02,1.977001e+03,1.849912e+03,1.698956e+03,1.082972e+03,4.031460e+03,9.294761e+02,2.519780e+03,3.410630e+03,1.117476e+03,1.940098e+03,2.104564e+03,9.994141e+02,3.557855e+03,8.594481e+02,1.527326e+03,3.352475e+03,9.170007e+02,1.315848e+03,2.829314e+03,1.900373e+03,2.455623e+03,2.238349e+03,3.581179e+03,2.424490e+03,1.297170e+03,8.914974e+02,3.032053e+03,1.262024e+03,1.804534e+03,2.224945e+03,1.720680e+03,2.767742e+03,1.430630e+03,2.856051e+03,4.741054e+03,2.059093e+03,2.006119e+03,1.282360e+03,8.749102e+02,1.496949e+03,7.659163e+02,3.145944e+03,4.130090e+02,3.028400e+03,1.097104e+03,4.902931e+02,2.016160e+03,7.994675e+02,3.109587e+03,2.086274e+03,1.478034e+03,1.176800e+03,2.823905e+03,1.358204e+03,2.730136e+03,1.443948e+03,2.269408e+03,1.578803e+03,9.810011e+02,2.065485e+03,2.016787e+03,4.391457e+03,3.670659e+03,2.053225e+03,4.017374e+03,1.299900e+03,1.375927e+03,3.103614e+03,4.254416e+03,3.073470e+03,8.345060e+02,2.272230e+03,2.292295e+03,1.727519e+03,1.217769e+03,2.216084e+03,2.510343e+03,3.155719e+03,3.618196e+03,6.128112e+02,7.465880e+02,1.602421e+03,3.411402e+03,5.008744e+03,3.226395e+03,3.383627e+03,2.118619e+03,4.156461e+03,3.402975e+03,2.575142e+02,4.157344e+03,1.153246e+03,2.347883e+03,3.383113e+03,5.658134e+03,1.864212e+03,3.256105e+03,1.488507e+03,1.138006e+03,2.900006e+03,1.845690e+03,1.433427e+03,9.777120e+02,4.967379e+03,3.211192e+03,1.775390e+03,4.024455e+03,2.125253e+03,4.777561e+03,5.186499e+03,2.258583e+03,4.525800e+03,1.103082e+03,1.682651e+03,2.929230e+03,9.934246e+02,3.218430e+03,3.926827e+03,3.276383e+03,3.499035e+03,8.953965e+02,1.571996e+03,2.316880e+03,3.871665e+03,3.262202e+03,4.793892e+03,1.266245e+03,3.408077e+03,4.248123e+03,1.607902e+03,2.698996e+03,2.642456e+03,2.132993e+03,2.396603e+03,2.027052e+03,1.202235e+03,3.479997e+03,1.626853e+03,1.923755e+03,5.853484e+03,2.149007e+03,3.273314e+03,1.259559e+03,3.054337e+03,3.410667e+03,4.735620e+03,2.864828e+03,3.591367e+03,1.879755e+03,4.253409e+03,2.377168e+03,1.320064e+03,5.746204e+03,2.817498e+03,3.357312e+03,1.286535e+03,3.967990e+03,1.595431e+03,1.955260e+03,2.363697e+03,2.642354e+03,4.261628e+03,1.931534e+03,1.799422e+03,1.300083e+03,2.161782e+03,1.493821e+03,1.555195e+03,1.836395e+03,2.834938e+03,1.109650e+03,3.518717e+03,1.412287e+03,2.652237e+03,3.806371e+03,3.944419e+03,5.889499e+03,1.378780e+03,4.879959e+03,2.167883e+03,3.423162e+03Line truncated
|
||||
@@ -0,0 +1,26 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include "../dataChannelTestUtility.h"
|
||||
#include "../taskTests.h"
|
||||
#include "../../../software/signal_processing_bsp/system.h"
|
||||
#include "../../data/add_rand.h"
|
||||
#include "../../data/fft.h"
|
||||
|
||||
int main( int argc, char ** argv ) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
TEST( test_task_fft, execute_only ) {
|
||||
dataChannelFill( DATA_CHANNEL_4_BASE, expected_add_rand );
|
||||
configureAndRunFft();
|
||||
dataChannelWriteToFile( DATA_CHANNEL_5_BASE, "data.py" );
|
||||
}
|
||||
|
||||
TEST( test_task_fft, execute_and_check ) {
|
||||
dataChannelFill( DATA_CHANNEL_4_BASE, expected_add_rand );
|
||||
configureAndRunFft();
|
||||
dataChannelCheckAndWriteToFile( DATA_CHANNEL_5_BASE, expected_fft, "data.py" );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
binary = test_task_rand
|
||||
expected_data = ../../data/rand.py
|
||||
|
||||
cc_sources = test_task_rand.cc \
|
||||
|
||||
include ../data_tests.mk
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include "../dataChannelTestUtility.h"
|
||||
#include "../taskTests.h"
|
||||
#include "../../../software/signal_processing_bsp/system.h"
|
||||
#include "../../data/rand.h"
|
||||
|
||||
int main( int argc, char ** argv ) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
TEST( test_task_rand, execute_only ) {
|
||||
configureAndRunRand();
|
||||
dataChannelWriteToFile( DATA_CHANNEL_2_BASE, "data.py" );
|
||||
}
|
||||
|
||||
TEST( test_task_rand, execute_and_check ) {
|
||||
configureAndRunRand();
|
||||
dataChannelCheckAndWriteToFile( DATA_CHANNEL_2_BASE, expected_rand, "data.py" );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
binary = test_task_sine
|
||||
expected_data = ../../data/sine.py
|
||||
|
||||
cc_sources = test_task_sine.cc \
|
||||
|
||||
include ../data_tests.mk
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include "../dataChannelTestUtility.h"
|
||||
#include "../taskTests.h"
|
||||
#include "../../../software/signal_processing_bsp/system.h"
|
||||
#include "../../data/sine.h"
|
||||
|
||||
int main( int argc, char ** argv ) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
TEST( test_task_sine, execute_only ) {
|
||||
configureAndRunSine();
|
||||
dataChannelWriteToFile( DATA_CHANNEL_0_BASE, "data.py" );
|
||||
}
|
||||
|
||||
TEST( test_task_sine, execute_and_check ) {
|
||||
configureAndRunSine();
|
||||
dataChannelCheckAndWriteToFile( DATA_CHANNEL_0_BASE, expected_sine, "data.py" );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
cc_sources += \
|
||||
../io.cc \
|
||||
../Hardware.cc \
|
||||
../HardwareTaskSimulation.cc \
|
||||
../DataChannelSimulation.cc \
|
||||
../HardwareTimerSimulation.cc \
|
||||
../dataChannelTestUtility.cc \
|
||||
../taskTests.cc \
|
||||
|
||||
c_sources += \
|
||||
../../../software/signal_processing/system/data_channel.c \
|
||||
../../../software/signal_processing/system/hardware_task.c \
|
||||
../../../software/signal_processing/system/Complex.c \
|
||||
../../../software/signal_processing/system/task_sine.c \
|
||||
../../../software/signal_processing/system/task_rand.c \
|
||||
../../../software/signal_processing/system/task_add.c \
|
||||
../../../software/signal_processing/system/task_fft.c \
|
||||
../../../software/signal_processing/system/task_crc.c \
|
||||
../../../software/signal_processing/sine.c \
|
||||
../../../software/signal_processing/rand.c \
|
||||
../../../software/signal_processing/add.c \
|
||||
../../../software/signal_processing/fft.c \
|
||||
../../../software/signal_processing/crc.c \
|
||||
|
||||
includes += \
|
||||
-I .. \
|
||||
-I ../../../software/signal_processing_bsp \
|
||||
-I ../../../software/signal_processing_bsp/drivers/inc \
|
||||
-I ../../../software/signal_processing_bsp/HAL/inc \
|
||||
|
||||
c_objects = $(patsubst %.c,%.o, ${c_sources})
|
||||
cc_objects = $(patsubst %.cc,%.oo, $(cc_sources))
|
||||
|
||||
objects = ${c_objects} ${cc_objects}
|
||||
|
||||
.PHONY: all
|
||||
all: ${binary}
|
||||
@./$< --gtest_filter=*_and_check
|
||||
|
||||
data.py: ${binary}
|
||||
@./$< --gtest_filter=*_only
|
||||
|
||||
${binary}: bsp ${objects}
|
||||
@${CXX} ${objects} -lgtest -lpthread -o $@
|
||||
|
||||
%.oo:%.cc
|
||||
${CXX} --std=c++14 ${includes} -c $< -o $@
|
||||
|
||||
%.o:%.c
|
||||
${CC} --std=gnu99 ${includes} -c $< -o $@
|
||||
|
||||
PHONY: bsp
|
||||
bsp:
|
||||
@${MAKE} -C ../../.. $@
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@${RM} -rf ${objects} ${binary} ${artifacts}
|
||||
|
||||
Reference in new issue
Block a user