Initial commit

This commit is contained in:
Johannes Kutning
2023-10-31 07:47:27 +01:00
commit 0d1b73e3e0
255 changed files with 16057 additions and 0 deletions
+65
View File
@@ -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();
}
+28
View File
@@ -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;
};
+79
View File
@@ -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() );
}
}
+26
View File
@@ -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;
};
+45
View File
@@ -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 );
}
+19
View File
@@ -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"
+1
View File
@@ -0,0 +1 @@
#pragma once
+107
View File
@@ -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 );
}
+17
View File
@@ -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 );
+7
View File
@@ -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
+15
View File
@@ -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 );
}
+14
View File
@@ -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
+66
View File
@@ -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 );
}
+9
View File
@@ -0,0 +1,9 @@
#pragma once
void configureAndRunSine();
void configureAndRunCosine();
void configureAndRunRand();
void configureAndRunAddSineCosine();
void configureAndRunAddRand();
void configureAndRunFft();
void configureAndRunCrc();
+7
View File
@@ -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" );
}
+7
View File
@@ -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" );
}
+6
View File
@@ -0,0 +1,6 @@
binary = test_task_crc
cc_sources = test_task_crc.cc \
include ../tests.mk
+20
View File
@@ -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" );
}
+7
View File
@@ -0,0 +1,7 @@
binary = test_task_fft
expected_data = ../../data/fft.py
cc_sources = test_task_fft.cc \
include ../data_tests.mk
File diff suppressed because one or more lines are too long
+26
View File
@@ -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" );
}
+7
View File
@@ -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" );
}
+7
View File
@@ -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" );
}
+59
View File
@@ -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}