//----------------------------------------------------------------- // Example of structure constructors //----------------------------------------------------------------- // main module STCONST use TEXTIO declare // v---- edit this for interesting test (4 to 32 is legal) Integer_item is 4 bit integer initially 7 B1_list is [Field_B2, Field_B3, Field_B4] B4_list is [Field_B5, Field_B6] // v---- use packed for very demanding test X_struct is packed structure B1 : Integer_Item initially 1 Tag_B1 : B1_list initially Field_B3 select Tag_B1 from case Field_B2: B2: Integer_Item initially 2 extra_1: 4 bit integer case Field_B3: B3: Integer_Item initially 3 extra_3: 32 bit integer case Field_B4: B4: Integer_Item initially 4 Tag_B4: B4_list select B4_list from case Field_B5: B5: Integer_Item initially 5 case Field_B6: B6: Integer_Item initially 6 endselect endselect endstructure X is X_struct X_init is X_struct initially X_struct (Tag_B1:Field_B4, Tag_B4:Field_B5, B5:-4) Dyn_X : X Static_X : X Dyn_X_init : X_init Static_X_init : static X_init Dyn_X_const_init : X initially X_init () Static_X_const_init : X initially X_init () enddeclare procedure Print_it param S : in ref packed array [1..?N] of char B1,B2,B3,B4,B5,B6 : integer endparam declare blank_char is char initially $<SP> My_S : packed array [1..24] of blank_char enddeclare for I := 1 to N do My_S [I] := S [I] endfor out_string (TTY, MY_S) out_integer (TTY, B1) out_string (TTY, "<HT>") out_integer (TTY, B2) out_string (TTY, "<HT>") out_integer (TTY, B3) out_string (TTY, "<HT>") out_integer (TTY, B4) out_string (TTY, "<HT>") out_integer (TTY, B5) out_string (TTY, "<HT>") out_integer (TTY, B6) out_record (TTY) endprocedure Print_it ("Dyn_X:" ,Dyn_X.B1 ,Dyn_X.B2 ,Dyn_X.B3 ,Dyn_X.B4 ,Dyn_X.B5 ,Dyn_X.B6) Print_it ("Static_X:" ,Static_X.B1 ,Static_X.B2 ,Static_X.B3 ,Static_X.B4 ,Static_X.B5 ,Static_X.B6) Print_it ("Dyn_X_init:" ,Dyn_X_init.B1 ,Dyn_X_init.B2 ,Dyn_X_init.B3 ,Dyn_X_init.B4 ,Dyn_X_init.B5 ,Dyn_X_init.B6) Print_it ("Static_X_init:" ,Static_X_init.B1 ,Static_X_init.B2 ,Static_X_init.B3 ,Static_X_init.B4 ,Static_X_init.B5 ,Static_X_init.B6) Print_it ("Dyn_X_const_init:" ,Dyn_X_const_init.B1 ,Dyn_X_const_init.B2 ,Dyn_X_const_init.B3 ,Dyn_X_const_init.B4 ,Dyn_X_const_init.B5 ,Dyn_X_const_init.B6) Print_it ("Static_X_const_init:" ,Static_X_const_init.B1 ,Static_X_const_init.B2 ,Static_X_const_init.B3 ,Static_X_const_init.B4 ,Static_X_const_init.B5 ,Static_X_const_init.B6) endmodule