#!/usr/bin/perl # DSM stands for Design Structure Matrix, or maybe possibly Dependency Structure Method # # DSM.pl: Generate the vector output format (CSV) for a design file. # .. needs component_list.csv # # To be used in tandem with the modified graphsynth project. # # To be used by a script/wrapper, not really interesting or meant for direct human use. # # Use the modified graphsynth project to take a gxml file and spit out the dot file, which is then used here. # # Foolish mortal responsible for this file: # Bryan Bishop 2009-01-26 (kanzure@gmail.com) ################################################################# # DEPRECATED COMMENTS BELOW -- BUYER BEWARE -- *** WARNING *** -- ################################################################# # Generate graphsynth XML rule sets from /home/bryan/lab/2008-10-20/functionstructures/ # and /home/bryan/lab/CFGs_2/ # 2008-11-06 -- modified the arc name generator. $name was used instead of $arcname. So now that it's fixed, the arcs should all have proper names or something. use Graph::Easy; use Graph::Easy::Parser; # #$ARGV = the number of command line arguments $functionstructure = Graph::Easy::Parser->new(); $CFG = Graph::Easy::Parser->new(); # used to be ../2008-10-20/functionstructures/ open(COMPE, "component_terms.csv"); #my @component_terms = ; #close(COMP); # http://www.tek-tips.com/viewthread.cfm?qid=1521186&page=1 # http://www.tek-tips.com/userinfo.cfm?member=rharsh # 2009-01-26: This is because the .csv file comes from a Windows machine and has the \r\n line endings. # Without this, things are doomed and getID() will not work. Also, the world will explode. while (my $input = ) { $input =~ s/[\x0A\x0D]+/\n/g; my @temp = split("\n", $input); push (@component_terms, @temp); } close(COMP); $fs_graph = $functionstructure->from_file($ARGV[0]); @nodes = $fs_graph->nodes(); @arcs = $fs_graph->edges(); foreach $arc (@arcs) { $arcname = $arc->name(); $from = $arc->from(); $to = $arc->to(); $from = $from->name(); $from =~ s/ /_/g; $to = $to->name(); $to =~ s/ /_/g; #print "from: $from (", giveID($from), ")\nto: $to (", giveID($to), ")\n"; $bigarray[giveID($from)][giveID($to)] += 1; } # Output the file. # Note that because of the failure of getID(), $bigarray[0][0] is going to be some big number, representing the total number of bad component names used in the design. for ($i = 0; $i < $#component_terms; $i++) { for ($j = 0; $j < $#component_terms; $j++) { print $bigarray[$i][$j], ","; } print "\n"; } # Give an ID number from the list of 136 component terms. In alphabetical order. # giveID() should produce very annoying error messages any time a component is not found in the list. sub giveID() { my $name = shift; $id = 0; $foundit = 0; #$name = "$name\n"; #print "giveID naming $name\n"; $final_ID = 0; #my( $id )= grep { $component_terms[$_] eq $name } 0..$#component_terms; foreach my $possibleThing (@component_terms) { $id++; #print "giveID has found a ---------> $possibleThing for $name\n"; if($possibleThing eq $name) { $final_ID = $id; } } return $final_ID; }