From abc3cd72f7efe4d2e81941a9f047474524ea5800 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Mon, 8 Apr 2019 11:15:56 +0200 Subject: from Tacle Bench --- test/monniaux/tacle-bench-lift/lift.c | 145 ++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 test/monniaux/tacle-bench-lift/lift.c (limited to 'test/monniaux/tacle-bench-lift/lift.c') diff --git a/test/monniaux/tacle-bench-lift/lift.c b/test/monniaux/tacle-bench-lift/lift.c new file mode 100644 index 00000000..5a810244 --- /dev/null +++ b/test/monniaux/tacle-bench-lift/lift.c @@ -0,0 +1,145 @@ +/* DM */ +#include "../clock.h" +#include + +/* + + This program is part of the TACLeBench benchmark suite. + Version V 2.0 + + Name: lift + + Author: Martin Schoeberl, Benedikt Huber + + Function: Lift Controler + + Source: C-Port from http://www.jopdesign.com/doc/jembench.pdf + + Original name: run_lift.c + + Changes: no major functional changes + + License: GPL version 3 or later + +*/ + + +/* + Include section +*/ + +#include "liftlibio.h" +#include "liftlibcontrol.h" + + +/* + Forward declaration of functions +*/ + +void lift_controller(); +void lift_init(); +void lift_main(); +int lift_return(); + + +/* + Declaration of global variables +*/ + +int lift_checksum;/* Checksum */ + + +/* + Initialization- and return-value-related functions +*/ + +void lift_init() +{ + unsigned int i; + unsigned char *p; + volatile char bitmask = 0; + + /* + Apply volatile XOR-bitmask to entire input array. + */ + p = ( unsigned char * ) &lift_ctrl_io_in[ 0 ]; + _Pragma( "loopbound min 40 max 40" ) + for ( i = 0; i < sizeof( lift_ctrl_io_in ); ++i, ++p ) + *p ^= bitmask; + + p = ( unsigned char * ) &lift_ctrl_io_out[ 0 ]; + _Pragma( "loopbound min 16 max 16" ) + for ( i = 0; i < sizeof( lift_ctrl_io_out ); ++i, ++p ) + *p ^= bitmask; + + p = ( unsigned char * ) &lift_ctrl_io_analog[ 0 ]; + _Pragma( "loopbound min 16 max 16" ) + for ( i = 0; i < sizeof( lift_ctrl_io_analog ); ++i, ++p ) + *p ^= bitmask; + + p = ( unsigned char * ) &lift_ctrl_io_led[ 0 ]; + _Pragma( "loopbound min 64 max 64" ) + for ( i = 0; i < sizeof( lift_ctrl_io_led ); ++i, ++p ) + *p ^= bitmask; + + lift_checksum = 0; + lift_ctrl_init(); +} + + +int lift_return() +{ + return ( lift_checksum - 4005888 != 0 ); +} + + +/* + Algorithm core functions +*/ + +void lift_controller() +{ + lift_ctrl_get_vals(); + lift_ctrl_loop(); + lift_ctrl_set_vals(); +} + + +/* + Main functions +*/ + +void _Pragma( "entrypoint" ) lift_main() +{ + int i = 0; + _Pragma( "loopbound min 1001 max 1001" ) + while ( 1 ) { + /* zero input stimulus */ + lift_simio_in = 0; + lift_simio_adc1 = 0; + lift_simio_adc2 = 0; + lift_simio_adc3 = 0; + /* run lift_controller */ + lift_controller(); + if ( i++ >= 1000 ) + break; + } +} + + +int main( void ) +{ + clock_prepare(); + clock_start(); + + lift_init(); + lift_main(); + + clock_stop(); + + int ret = lift_return(); + + printf("check: %s\n", ret ? "FAIL" : "passed"); + + print_total_clock(); +} -- cgit