@@ -275,27 +275,29 @@ sub storeGroups
275
275
# # for accessing targets and busses
276
276
# # Structure:
277
277
# #
278
- # #{TARGETS} # location of all targets
279
- # #{NSTANCE_PATH} # keeps track of hierarchy
280
- # # path while iterating
281
- # #{TARGETS} -> target_name # specific target
282
- # #{TARGETS} -> target_name -> {TARGET} # pointer to target data
283
- # # from XML data struture
284
- # #{TARGETS} -> target_name -> {TYPE}# special attribute
285
- # #{TARGETS} -> target_name -> {PARENT} # parent target name
286
- # #{TARGETS} -> target_name -> {CHILDREN} # array of children targets
287
- # #{TARGETS} -> target_name -> {CONNECTION} -> {DEST} # array of connection
288
- # # destination targets
289
- # #{TARGETS} -> target_name -> {CONNECTION} -> {BUS} # array of busses
290
- # #{TARGETS} -> target_name -> {CHILDREN} # array of children targets
291
- # #{TARGETS} -> target_name -> {ATTRIBUTES} # attributes
292
- # # {ENUMERATION} -> enumeration_type -> enum # value of enumeration
293
- # # {BUSSES} -> bus_type[] # array of busses by
294
- # # bus_type (I2C, FSI, etc)
295
- # # {BUSSES} -> bus_type[] -> {BUS} # pointer to bus target
296
- # # from xml structure
297
- # # {BUSSES} -> bus_type[] -> {SOURCE_TARGET} # source target name
298
- # # {BUSSES} -> bus_type[] -> {DEST_TARGET} # dest target name
278
+ # #{TARGETS} # location of all targets
279
+ # #{NSTANCE_PATH} # keeps track of hierarchy
280
+ # # path while iterating
281
+ # #{TARGETS} -> target_name # specific target
282
+ # #{TARGETS} -> target_name -> {TARGET} # pointer to target data
283
+ # # from XML data struture
284
+ # #{TARGETS} -> target_name -> {TYPE} # special attribute
285
+ # #{TARGETS} -> target_name -> {PARENT} # parent target name
286
+ # #{TARGETS} -> target_name -> {CHILDREN} # array of children targets
287
+ # #{TARGETS} -> target_name -> {CONNECTION} -> {DEST} # array of connection
288
+ # # destination targets
289
+ # #{TARGETS} -> target_name -> {CONNECTION} -> {SOURCE} # array of connection
290
+ # # source targets
291
+ # #{TARGETS} -> target_name -> {CONNECTION} -> {BUS} # array of busses
292
+ # #{TARGETS} -> target_name -> {CHILDREN} # array of children targets
293
+ # #{TARGETS} -> target_name -> {ATTRIBUTES} # attributes
294
+ # # {ENUMERATION} -> enumeration_type -> enum # value of enumeration
295
+ # # {BUSSES} -> bus_type[] # array of busses by
296
+ # # bus_type (I2C, FSI, etc)
297
+ # # {BUSSES} -> bus_type[] -> {BUS} # pointer to bus target
298
+ # # from xml structure
299
+ # # {BUSSES} -> bus_type[] -> {SOURCE_TARGET} # source target name
300
+ # # {BUSSES} -> bus_type[] -> {DEST_TARGET} # dest target name
299
301
300
302
sub buildHierarchy
301
303
{
@@ -414,6 +416,13 @@ sub buildHierarchy
414
416
},
415
417
$dest_target
416
418
);
419
+ push (
420
+ @{
421
+ $self -> {data }-> {TARGETS }-> {$dest_target }-> {CONNECTION }
422
+ -> {SOURCE }
423
+ },
424
+ $source_target
425
+ );
417
426
push (
418
427
@{
419
428
$self -> {data }-> {TARGETS }-> {$source_target }-> {CONNECTION }
@@ -840,7 +849,8 @@ sub getTargetParent
840
849
return $target_ptr -> {PARENT };
841
850
}
842
851
843
- # # returns the number of connections associated with target
852
+ # # returns the number of connections associated with target where the target is
853
+ # # the source
844
854
sub getNumConnections
845
855
{
846
856
my $self = shift ;
@@ -853,6 +863,20 @@ sub getNumConnections
853
863
return scalar (@{ $target_ptr -> {CONNECTION }-> {DEST } });
854
864
}
855
865
866
+ # # returns the number of connections associated with target where the target is
867
+ # # the destination
868
+ sub getNumDestConnections
869
+ {
870
+ my $self = shift ;
871
+ my $target = shift ;
872
+ my $target_ptr = $self -> getTarget($target );
873
+ if (!defined ($target_ptr -> {CONNECTION }-> {SOURCE }))
874
+ {
875
+ return 0;
876
+ }
877
+ return scalar (@{ $target_ptr -> {CONNECTION }-> {SOURCE } });
878
+ }
879
+
856
880
# # returns destination target name of first connection
857
881
# # useful for point to point busses with only 1 endpoint
858
882
sub getFirstConnectionDestination
@@ -880,6 +904,15 @@ sub getConnectionDestination
880
904
my $target_ptr = $self -> getTarget($target );
881
905
return $target_ptr -> {CONNECTION }-> {DEST }-> [$i ];
882
906
}
907
+ # # returns target name of $i source connection
908
+ sub getConnectionSource
909
+ {
910
+ my $self = shift ;
911
+ my $target = shift ;
912
+ my $i = shift ;
913
+ my $target_ptr = $self -> getTarget($target );
914
+ return $target_ptr -> {CONNECTION }-> {SOURCE }-> [$i ];
915
+ }
883
916
884
917
sub getConnectionBus
885
918
{
@@ -921,13 +954,42 @@ sub findFirstEndpoint
921
954
}
922
955
return " " ;
923
956
}
957
+
958
+ # Find connections _from_ $target (and it's children)
924
959
sub findConnections
925
960
{
926
961
my $self = shift ;
927
962
my $target = shift ;
928
963
my $bus_type = shift ;
929
964
my $end_type = shift ;
930
965
966
+ return $self -> findConnectionsByDirection($target , $bus_type ,
967
+ $end_type , 0);
968
+ }
969
+
970
+ # Find connections _to_ $target (and it's children)
971
+ sub findDestConnections
972
+ {
973
+ my $self = shift ;
974
+ my $target = shift ;
975
+ my $bus_type = shift ;
976
+ my $source_type = shift ;
977
+
978
+ return $self -> findConnectionsByDirection($target , $bus_type ,
979
+ $source_type , 1);
980
+
981
+ }
982
+
983
+ # Find connections from/to $target (and it's children)
984
+ # $to_this_target indicates the direction to find.
985
+ sub findConnectionsByDirection
986
+ {
987
+ my $self = shift ;
988
+ my $target = shift ;
989
+ my $bus_type = shift ;
990
+ my $other_end_type = shift ;
991
+ my $to_this_target = shift ;
992
+
931
993
my %connections ;
932
994
my $num =0;
933
995
my $target_children = $self -> getTargetChildren($target );
@@ -946,13 +1008,31 @@ sub findConnections
946
1008
947
1009
if ($child_bus_type eq $bus_type )
948
1010
{
949
- for (my $i = 0; $i < $self -> getNumConnections($child ); $i ++)
1011
+ my $numOfConnections = 0;
1012
+ if ($to_this_target )
950
1013
{
951
- my $dest_target = $self -> getConnectionDestination($child , $i );
952
- my $dest_parent = $self -> getTargetParent($dest_target );
953
- my $type = $self -> getMrwType($dest_parent );
954
- my $dest_type = $self -> getType($dest_parent );
955
- my $dest_class = $self -> getAttribute($dest_parent ," CLASS" );
1014
+ $numOfConnections = $self -> getNumDestConnections($child );
1015
+ }
1016
+ else
1017
+ {
1018
+ $numOfConnections = $self -> getNumConnections($child );
1019
+ }
1020
+ for (my $i = 0; $i < $numOfConnections ; $i ++)
1021
+ {
1022
+ my $other_end_target = undef ;
1023
+ if ($to_this_target )
1024
+ {
1025
+ $other_end_target = $self -> getConnectionSource($child , $i );
1026
+ }
1027
+ else
1028
+ {
1029
+ $other_end_target = $self -> getConnectionDestination($child ,
1030
+ $i );
1031
+ }
1032
+ my $other_end_parent = $self -> getTargetParent($other_end_target );
1033
+ my $type = $self -> getMrwType($other_end_parent );
1034
+ my $dest_type = $self -> getType($other_end_parent );
1035
+ my $dest_class = $self -> getAttribute($other_end_parent ," CLASS" );
956
1036
if ($type eq " NA" )
957
1037
{
958
1038
$type = $dest_type ;
@@ -961,34 +1041,45 @@ sub findConnections
961
1041
$type = $dest_class ;
962
1042
}
963
1043
964
- if ($end_type ne " " ) {
965
- # Look for an end_type match on any ancestor, as
1044
+ if ($other_end_type ne " " ) {
1045
+ # Look for an other_end_type match on any ancestor, as
966
1046
# connections may have a destination unit with a hierarchy
967
1047
# like unit->pingroup->muxgroup->chip where the chip has
968
1048
# the interesting type.
969
- while ($type ne $end_type ) {
1049
+ while ($type ne $other_end_type ) {
970
1050
971
- $dest_parent = $self -> getTargetParent($dest_parent );
972
- if ($dest_parent eq " " ) {
1051
+ $other_end_parent = $self -> getTargetParent($other_end_parent );
1052
+ if ($other_end_parent eq " " ) {
973
1053
last ;
974
1054
}
975
1055
976
- $type = $self -> getMrwType($dest_parent );
1056
+ $type = $self -> getMrwType($other_end_parent );
977
1057
if ($type eq " NA" ) {
978
- $type = $self -> getType($dest_parent );
1058
+ $type = $self -> getType($other_end_parent );
979
1059
}
980
1060
if ($type eq " NA" ) {
981
- $type = $self -> getAttribute($dest_parent , " CLASS" );
1061
+ $type = $self -> getAttribute($other_end_parent , " CLASS" );
982
1062
}
983
1063
}
984
1064
}
985
1065
986
- if ($type eq $end_type || $end_type eq " " )
1066
+ if ($type eq $other_end_type || $other_end_type eq " " )
987
1067
{
988
- $connections {CONN }[$num ]{SOURCE }=$child ;
989
- $connections {CONN }[$num ]{SOURCE_PARENT }=$target ;
990
- $connections {CONN }[$num ]{DEST }=$dest_target ;
991
- $connections {CONN }[$num ]{DEST_PARENT }=$dest_parent ;
1068
+ if ($to_this_target )
1069
+ {
1070
+ $connections {CONN }[$num ]{SOURCE }=$other_end_target ;
1071
+ $connections {CONN }[$num ]{SOURCE_PARENT }=
1072
+ $other_end_parent ;
1073
+ $connections {CONN }[$num ]{DEST }=$child ;
1074
+ $connections {CONN }[$num ]{DEST_PARENT }=$target ;
1075
+ }
1076
+ else
1077
+ {
1078
+ $connections {CONN }[$num ]{SOURCE }=$child ;
1079
+ $connections {CONN }[$num ]{SOURCE_PARENT }=$target ;
1080
+ $connections {CONN }[$num ]{DEST }=$other_end_target ;
1081
+ $connections {CONN }[$num ]{DEST_PARENT }=$other_end_parent ;
1082
+ }
992
1083
$connections {CONN }[$num ]{BUS_NUM }=$i ;
993
1084
$num ++;
994
1085
}
@@ -999,7 +1090,6 @@ sub findConnections
999
1090
return \%connections ;
1000
1091
}
1001
1092
1002
-
1003
1093
# # returns BUS_TYPE attribute of target
1004
1094
sub getBusType
1005
1095
{
@@ -1289,7 +1379,7 @@ sub getAllTargetChildren
1289
1379
push @children , @more ;
1290
1380
}
1291
1381
}
1292
-
1382
+
1293
1383
return @children ;
1294
1384
}
1295
1385
0 commit comments