//------------------------------------------------------------------ // Example of Constant Evalutation Optimization added in Version 7.2 //------------------------------------------------------------------ main module OPTIMUM1 declare // --- multi-level structure C is structure Joe : integer endstructure B is structure This_C : C endstructure A is structure This_B : B endstructure // --- Multi-level structure with array inside a4_type is array[1..5] of integer a3_type is structure a3: integer a4: a4_type endstructure a2_type is structure a2: a3_type endstructure a1_type is structure a1: a2_type endstructure //--- constant multi-level structure with array inside a0 = a1_type(a1: a2_type(a2: a3_type(a3: 12345, a4: a4_type([1]:123,[2]:234,[3]:7,[4]:5)))) //--- constant array One_D_type is array[1..10] of integer Con_1_D = table One_D_type (1,1,2,3,4,5,6,7,8,9) //--- constant 2-dimensional array Two_D_1_type is array[0..9] of integer Two_D_type is array[0..9] of Two_D_1_type Two_D = table Two_D_type (table Two_D_1_type (00,01,02,03,04,05,06,07,08,09) ,table Two_D_1_type (10,11,12,13,14,15,16,17,18,19) ,table Two_D_1_type (20,21,22,23,24,25,26,27,28,29) ,table Two_D_1_type (30,31,32,33,34,35,36,37,38,39) ,table Two_D_1_type (40,41,42,43,44,45,46,47,48,49) ,table Two_D_1_type (50,51,52,53,54,55,56,57,58,59) ,table Two_D_1_type (60,61,62,63,64,65,66,67,68,69) ,table Two_D_1_type (70,71,72,73,74,75,76,77,78,79) ,table Two_D_1_type (80,81,82,83,84,85,86,87,88,89) ,table Two_D_1_type (90,91,92,93,94,95,96,97,98,99) ) //--- static places to assign things to This_A : static A // multi-lev structure I : static integer This_One_D : static One_D_type // 1 dim array enddeclare //-- assignment of fields of the structure that can be // evaluated as constants at compile time to various fields // of the structure This_A.This_B.This_C.Joe := a0.a1.a2.a4[5] This_A.This_B.This_C.Joe := a0.a1.a2.a4[Con_1_D[5]] This_A.This_B.This_C.Joe := a0.a1.a2.a4[Con_1_D[Con_1_D[5]]] This_A.This_B.This_C.Joe := a0.a1.a2.a4[Con_1_D[Con_1_D[Con_1_D[5]]]] This_A.This_B.This_C.Joe := a0.a1.a2.a4[Con_1_D[Con_1_D[Con_1_D[Con_1_D[5]]]]] //-- assignment of expresions of the fields of the one and // two-dimensional arrays which can be evalutated as // constants at compile time. I := Two_D[1,2] I := Two_D[4,5] I := Two_D[7,3] I := Two_D[Con_1_D[Con_1_D[Con_1_D[7]]],3] I := (Two_D[4,2]/Con_1_D[Con_1_D[8]]) * Two_D[1,Con_1_D[Con_1_D[2]]] //-- assignments of arrays with constant indexes This_One_D [Con_1_D[Con_1_D[1]]]:= Con_1_D[Con_1_D[Con_1_D[1]]] endmodule