AnnexF/diffeq_st.txt
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 06 May 2016 11:38:35 +0300
changeset 1007 afb3974f8fb3
parent 0 fb772792efd1
permissions -rwxr-xr-x
fix warning about overflow if matiec is running on 64-bit platform,
but the generated C code will cross-compiled for 32-bit platform

For example:
./build/config.c:29:39: error: large integer implicitly truncated to unsigned type [-Werror=overflow]
unsigned long greatest_tick_count__ = 18446744073709551611UL; /*tick*/
^
compilation terminated due to -Wfatal-errors.
cc1: all warnings being treated as errors
 FUNCTION_BLOCK DIFFEQ
   VAR_INPUT
     RUN : BOOL ;             (* 1 = run, 0 = reset *)
     XIN : REAL ;
     A : ARRAY[1..] OF REAL ; (* Input coefficients *)
     M : INT ;                (* Length of input history  *)
     B : ARRAY[0..] OF REAL ; (* Output coefficients *)
     N : INT ;                (* Length of output history *)        
   END_VAR
   VAR_OUTPUT XOUT : REAL := 0.0 ; END_VAR
   VAR  (* NOTE : Manufacturer may specify other array sizes *)   
     XI : ARRAY [0..128] OF REAL ; (* Input history  *)
     XO : ARRAY [0..128] OF REAL ; (* Output history *)
     I : INT ;
   END_VAR
   XO[0] := XOUT ; XI[0] := XIN ;
   XOUT := B[0] * XIN ;
   IF RUN THEN
      FOR I := M TO 1 BY -1 DO
          XOUT := XOUT + A[I] * XO[I] ; XO[I] := XO[I-1];
      END_FOR;
      FOR I := N TO 1 BY -1 DO
          XOUT := XOUT + B[I] * XI[I] ; XI[I] := XI[I-1];
      END_FOR;
   ELSE
      FOR I := 1 TO M DO XO[I] := 0.0; END_FOR;
      FOR I := 1 TO N DO XI[I] := 0.0; END_FOR;
   END_IF ;
 END_FUNCTION_BLOCK