31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
fprintf(fid,"\n# Subsystems and Ports\n");
i_port=0;
for i=1:N
eval(["[comp_type, name, cr, arg, repetitions] = ", system_name, "_cmp(i);"]);
ch=name(1); # First char of name
if (ch>="0")&&(ch<="9") # Its a numeral
name=["mtt",name]; # prefix by mtt
endif;
if index(name,"[")==0 # Not a port
fprintf(fid,"\n# Component %s\n", name);
fprintf(fid,Sformat,system_name,name,"type",comp_type);
fprintf(fid,Sformat,system_name,name,"cr",cr);
fprintf(fid,Sformat,system_name,name,"arg",arg);
fprintf(fid,Iformat,system_name,name,"repetitions",repetitions);
c = nozeros(connections(i,:));# Connections to this component
m = length(c); # Number of connections
fprintf(fid,Cformat,system_name,name);
for j=1:m
fprintf(fid,"%i ", c(j));
endfor;
fprintf(fid,"];\n");
else
name=name(2:length(name)-1); # Strip []
fprintf(fid,"\n# Port %s\n", name);
fprintf(fid,PIformat,system_name,name,"index",++i_port);
fprintf(fid,PSformat,system_name,name,"type",comp_type);
fprintf(fid,PSformat,system_name,name,"cr",cr);
fprintf(fid,PSformat,system_name,name,"arg",arg);
fprintf(fid,PIformat,system_name,name,"repetitions",repetitions);
|
<
<
<
<
<
>
>
>
>
>
|
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
fprintf(fid,"\n# Subsystems and Ports\n");
i_port=0;
for i=1:N
eval(["[comp_type, name, cr, arg, repetitions] = ", system_name, "_cmp(i);"]);
if index(name,"[")==0 # Not a port
fprintf(fid,"\n# Component %s\n", name);
fprintf(fid,Sformat,system_name,name,"type",comp_type);
fprintf(fid,Sformat,system_name,name,"cr",cr);
fprintf(fid,Sformat,system_name,name,"arg",arg);
fprintf(fid,Iformat,system_name,name,"repetitions",repetitions);
c = nozeros(connections(i,:));# Connections to this component
m = length(c); # Number of connections
fprintf(fid,Cformat,system_name,name);
for j=1:m
fprintf(fid,"%i ", c(j));
endfor;
fprintf(fid,"];\n");
else
name=name(2:length(name)-1); # Strip []
ch=name(1); # First char of name
if (ch>="0")&&(ch<="9") # Its a numeral
name=["mttp",name]; # prefix by mttp
endif;
fprintf(fid,"\n# Port %s\n", name);
fprintf(fid,PIformat,system_name,name,"index",++i_port);
fprintf(fid,PSformat,system_name,name,"type",comp_type);
fprintf(fid,PSformat,system_name,name,"cr",cr);
fprintf(fid,PSformat,system_name,name,"arg",arg);
fprintf(fid,PIformat,system_name,name,"repetitions",repetitions);
|