tags:

views:

64

answers:

2

I'm looking for a way to convert signals connections to a simple scheme or graph.

Let's say I have 2 components with 2 line/signals around them:

component A:
 input - S1
 output - S2

component B: 
 input - S2
 output - S1

This will be the input data file, and the output will be a scheme that shows it as 2 blocks with connecting lines around them or a illustration graph.

I'm wondering if an implementation of that exists in Perl's world.

+6  A: 

It sounds like you want something like the graphviz graph generator.

It's written in C, but there is a Perl interface: GraphViz.

Example:

use GraphViz;
use File::Slurp qw(write_file);

my $g = GraphViz->new;
$g->add_node('componentA');
$g->add_node('componentB');
$g->add_edge('componentB' => 'componentA', label => 'S1');
$g->add_edge('componentA' => 'componentB', label => 'S2');

write_file('out.png', $g->as_png);

You could load your input data and keep track of component connections via a hash on the signal number, then call add_edge for each one.

Output:

graphviz output

(labels are optional).

rjh
I think this might be good to try, but still after over look at the GraphViz, I'm wondering how can I make a massive data connections without losing its readability. The final purpose is to map a CPU architecture.
YoDar
+1  A: 

Cf. Graph::Easy and GraphViz.

tsee