diff options
author | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2020-03-03 08:17:40 +0100 |
---|---|---|
committer | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2020-03-03 08:17:40 +0100 |
commit | 1ab7b51c30e1b10ac45b0bd64cefdc01da0f7f68 (patch) | |
tree | 210ffc156c83f04fb0c61a40b4f9037d7ba8a7e1 /test/monniaux/tacle-bench-lift/liftlibio.c | |
parent | 222c9047d61961db9c6b19fed5ca49829223fd33 (diff) | |
parent | 12be46d59a2483a10d77fa8ee67f7e0ca1bd702f (diff) | |
download | compcert-kvx-1ab7b51c30e1b10ac45b0bd64cefdc01da0f7f68.tar.gz compcert-kvx-1ab7b51c30e1b10ac45b0bd64cefdc01da0f7f68.zip |
Merge branch 'mppa-cse2' of gricad-gitlab.univ-grenoble-alpes.fr:sixcy/CompCert into mppa-work
Diffstat (limited to 'test/monniaux/tacle-bench-lift/liftlibio.c')
-rw-r--r-- | test/monniaux/tacle-bench-lift/liftlibio.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/test/monniaux/tacle-bench-lift/liftlibio.c b/test/monniaux/tacle-bench-lift/liftlibio.c new file mode 100644 index 00000000..f61df2d0 --- /dev/null +++ b/test/monniaux/tacle-bench-lift/liftlibio.c @@ -0,0 +1,65 @@ +#include "liftlibio.h" + +/* Global variables */ +int lift_ctrl_io_in[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +int lift_ctrl_io_out[4] = {0, 0, 0, 0}; +int lift_ctrl_io_analog[4] = {0, 0, 0, 0}; +int lift_ctrl_io_led[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +int lift_ctrl_dly1; +int lift_ctrl_dly2; + +/* Simulated hardware */ +volatile int lift_simio_in; +volatile int lift_simio_out; +volatile int lift_simio_led; +volatile int lift_simio_adc1; +volatile int lift_simio_adc2; +volatile int lift_simio_adc3; + +void lift_io_init() +{ + lift_ctrl_dly1 = 0; + lift_ctrl_dly2 = 0; +} + + +void lift_ctrl_set_vals() +{ + int val = 0, i; + _Pragma( "loopbound min 4 max 4" ) + for ( i = 4 - 1; i >= 0; --i ) { + val <<= 1; + val |= lift_ctrl_io_out[i] ? 1 : 0; + } + lift_simio_out = val; + _Pragma( "loopbound min 16 max 16" ) + for ( i = 14 - 1; i >= 0; --i ) { + val <<= 1; + val |= lift_ctrl_io_led[i] ? 1 : 0; + } + lift_simio_led = val; + lift_checksum += val; +} + + +void lift_ctrl_get_vals() +{ + int i; + unsigned short int in0 = lift_simio_in; + unsigned short int in1 = lift_ctrl_dly1; + unsigned short int in2 = lift_ctrl_dly2; + lift_ctrl_dly2 = lift_ctrl_dly1; + lift_ctrl_dly1 = in0; + /* majority voting for input values + delays input value change by one period */ + _Pragma( "loopbound min 10 max 10" ) + for ( i = 0; i < 10; ++i ) { + lift_ctrl_io_in[i] = ( ( in0 & 1 ) + ( in1 & 1 ) + ( in2 & 1 ) ) > 1; + in0 >>= 1; + in1 >>= 1; + in2 >>= 1; + } + lift_ctrl_io_analog[0] = lift_simio_adc1; + lift_ctrl_io_analog[1] = lift_simio_adc2; + lift_ctrl_io_analog[2] = lift_simio_adc3; +} |