5 use XML::Simple qw(:strict);
11 if(!$infile || !$outfile) {
12 say "Usage: bsp2arch.pl <infile> <outfile>";
13 say "\tinfile: Epiphany Platform Description";
14 say "\toutfile: DOL Architecture Specification";
15 say "\tUse \'-\' for standard input/output.";
19 # parse input xml file
20 my $input = XMLin($infile, ForceArray => '1', KeyAttr => ['chips']);
27 # per-core definitions
28 foreach my $chips ($input->{'chips'}->[0]->{'chip'}) {
29 foreach my $chip (@$chips) {
30 $chip->{'id'} =~ /\((\d+),(\d+)\)/;
31 my @origin = ($1, $2);
32 my $version = $chip->{'version'};
34 foreach my $row (1..$chip->{'rows'}) {
35 foreach my $col (1..$chip->{'cols'}) {
36 my $newrow = $origin[0] + $row - 1;
37 my $newcol = $origin[1] + $col - 1;
38 my $memsize = $chip->{'core_memory_size'};
39 $memsize = "0x8000" unless($memsize);
43 'name' => "core_${newrow}_${newcol}",
46 { 'name' => 'version',
47 'value' => $version },
53 'name' => "mem_${newrow}_${newcol}",
57 'value' => $memsize },
63 'name' => "regs_${newrow}_${newcol}",
86 foreach my $banks ($input->{'external_memory'}->[0]->{'bank'}) {
88 foreach my $bank (@$banks) {
89 # DOL doesn't need to know the epiphany-internal address
90 next if($bank->{'name'} eq 'EPIPHANY_DRAM');
92 if($bank->{'name'} eq 'EXTERNAL_DRAM') {
94 'name' => "emem_${counter}",
98 'value' => $bank->{'size'} },
100 'value' => $bank->{'start'} }
104 say "Warning: Unknown Extmem $bank->{'name'}!";
109 # TODO: add hw_channels data
111 # generate XML output
114 'xmlns' => "http://www.tik.ee.ethz.ch/~shapes/schema/ARCHITECTURE",
115 'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
116 'xsi:schemaLocation' => 'http://www.tik.ee.ethz.ch/~shapes/schema/ARCHITECTURE http://www.tik.ee.ethz.ch/~shapes/schema/architecture.xsd',
117 'name' => 'Adapteva Parallella Architecture',
119 'processor' => \@processors,
120 'memory' => \@memories,
121 'hw_channel' => \@hw_channels,
124 my $outxml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".
125 XMLout($output, KeyAttr => [], KeepRoot => 1);
128 if($outfile eq '-') {
132 open (FH, ">$outfile");