9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
67
68
|
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
67
68
69
70
71
72
73
74
|
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
|
################################
## create component structure ##
################################
## loop over each bond in ibg.m file
for [bond, bond_name] = bonds
## get the bond number
bond_name
i = str2num(split(bond_name, "bond")(2,:));
i = str2num(strtok(bond_name, "bond"))
## populate "head" and "tail" structures
## then copy the contents to an overall structure
## track (signed) vector bond number within each component
head.index = +i;
tail.index = -i;
head.index = +i
tail.index = -i
## extract type of component at each end
head_type = deblank(split(bond.head.component, ":")(1,:));
tail_type = deblank(split(bond.tail.component, ":")(1,:));
head_type = deblank(char(strsplit(bond.head.component, ":"))(1,:))
tail_type = deblank(char(strsplit(bond.tail.component, ":"))(1,:))
## extract name of component at each end
head_name = deblank(split(bond.head.component, ":")(2,:));
tail_name = deblank(split(bond.tail.component, ":")(2,:));
head_name = deblank(char(strsplit(bond.head.component, ":"))(2,:))
tail_name = deblank(char(strsplit(bond.tail.component, ":"))(2,:))
## extract port label data
head.label = bond.head.ports;
tail.label = bond.tail.ports;
head.label = bond.head.ports
tail.label = bond.tail.ports
disp("--checking head and tail for components or ports --")
## determine whether internal port or subsystem
## and fix names of ports
if (strcmp(head_type, "SS") & (index(head_name, "[") == 1))
head_comp_or_port = "port";
head_comp_or_port = "port"
head_name = mtt_strip_name(head_name);
else
head_comp_or_port = "comp";
head_comp_or_port = "comp"
endif
if (strcmp(tail_type, "SS") & (index(tail_name, "[") == 1))
tail_comp_or_port = "port";
tail_comp_or_port = "port"
tail_name = mtt_strip_name(tail_name);
else
tail_comp_or_port = "comp";
tail_comp_or_port = "comp"
endif
## copy data to object structure (objects)
eval(sprintf("objects.%s.%s.type = '%s';",
head_comp_or_port, head_name, head_type));
eval(sprintf("objects.%s.%s.type = '%s';",
tail_comp_or_port, tail_name, tail_type));
eval(sprintf("objects.%s.%s.bond%i = head;",
head_comp_or_port, head_name, i));
eval(sprintf("objects.%s.%s.bond%i = tail;",
tail_comp_or_port, tail_name, i));
cmd = sprintf("objects.%s.%s.type = '%s';",
head_comp_or_port, head_name, head_type)
eval(cmd)
cmd = sprintf("objects.%s.%s.type = '%s';",
tail_comp_or_port, tail_name, tail_type)
eval(cmd)
cmd = sprintf("objects.%s.%s.bond%i = head;",
head_comp_or_port, head_name, i)
eval(cmd)
cmd = sprintf("objects.%s.%s.bond%i = tail;",
tail_comp_or_port, tail_name, i)
eval(cmd)
endfor
disp("--finished extracting data from ibg.m --")
objects
## object structure:
##
|
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
|
-
+
-
-
+
+
-
-
+
+
|
#########################################
## assign a unique number to each bond ##
#########################################
unique_bond_number = 0;
for [bond, bond_name] = bonds
i = str2num(split(bond_name, "bond")(2,:));
i = str2num(strtok(bond_name, "bond"));
## extract type of component at each end
head.type = deblank(split(bond.head.component, ":")(1,:));
tail.type = deblank(split(bond.tail.component, ":")(1,:));
head.type = deblank(char(strsplit(bond.head.component, ":"))(1,:));
tail.type = deblank(char(strsplit(bond.tail.component, ":"))(1,:));
## extract name of component at each end
head_name = deblank(split(bond.head.component, ":")(2,:));
tail_name = deblank(split(bond.tail.component, ":")(2,:));
head_name = deblank(char(strsplit(bond.head.component, ":"))(2,:));
tail_name = deblank(char(strsplit(bond.tail.component, ":"))(2,:));
## determine whether internal port or subsystem
## and fix names of ports
if (strcmp(head.type, "SS") & (index(head_name, "[") == 1))
head_comp_or_port = "port";
head_name = mtt_strip_name(head_name);
else
|