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']);
23 # per-core definitions
26 foreach my $chips ($input->{'chips'}->[0]->{'chip'}) {
27 foreach my $chip (@$chips) {
28 $chip->{'id'} =~ /\((\d+),(\d+)\)/;
29 my @origin = ($1, $2);
31 foreach my $row (1..$chip->{'rows'}) {
32 foreach my $col (1..$chip->{'cols'}) {
33 my $newrow = $origin[0] + $row - 1;
34 my $newcol = $origin[1] + $col - 1;
35 my $memsize = $chip->{'core_memory_size'};
36 $memsize = "0x8000" unless($memsize);
40 'name' => "core_${newrow}_${newcol}",
43 { 'name' => 'version',
50 'name' => "mem_${newrow}_${newcol}",
54 'value' => $memsize },
60 'name' => "regs_${newrow}_${newcol}",
70 foreach my $banks ($input->{'external_memory'}->[0]->{'bank'}) {
72 foreach my $bank (@$banks) {
73 # DOL doesn't need to know the epiphany-internal address
74 next if($bank->{'name'} eq 'EPIPHANY_DRAM');
76 if($bank->{'name'} eq 'EXTERNAL_DRAM') {
78 'name' => "emem_${counter}",
82 say "Warning: Unknown Extmem $bank->{'name'}!";
87 # TODO: add hw_channels data
93 'xmlns' => "http://www.tik.ee.ethz.ch/~shapes/schema/ARCHITECTURE",
94 'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
95 'xsi:schemaLocation' => 'http://www.tik.ee.ethz.ch/~shapes/schema/ARCHITECTURE http://www.tik.ee.ethz.ch/~shapes/schema/architecture.xsd',
96 'name' => 'Adapteva Parallella Architecture',
98 'processor' => \@processors,
99 'memory' => \@memories,
100 'hw_channel' => \@hw_channels,
103 my $outxml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".
104 XMLout($output, KeyAttr => [], KeepRoot => 1);
107 if($outfile eq '-') {
111 open (FH, ">$outfile");