From: Sebastian Date: Mon, 2 Sep 2013 18:45:35 +0000 (+0200) Subject: bsp2arch.pl: initial commit (processor, memory) X-Git-Url: http://sraa.de/git/?a=commitdiff_plain;h=43d950acc04e4ebaff00908b61b622d3d6e9b376;hp=c3ceb046994c4533987c131a787c17b330177169;p=jump.git bsp2arch.pl: initial commit (processor, memory) The utility bsp2arch.pl reads the XML hardware description file from the Epiphany SDK and generates a DOL architecture specification. example: $ ./bsp2arch.pl zed_E16G3_512mb.xml epiphany.xml The SDK uses a flat hardware description file (HDF), which was supposed to be a temporary solution (SDK 4.x documentation), but seems to be final (SDK 5.x documentation). The current version does not define any , or tags and does not need any flattening. --- diff --git a/hdf2arch/bsp2arch.pl b/hdf2arch/bsp2arch.pl new file mode 100755 index 0000000..6e80ed0 --- /dev/null +++ b/hdf2arch/bsp2arch.pl @@ -0,0 +1,115 @@ +#!/usr/bin/perl -w +use strict; +use v5.010; + +use XML::Simple qw(:strict); +use Data::Dumper; + +# argument evaluation +my $infile = shift; +my $outfile = shift; +if(!$infile || !$outfile) { + say "Usage: bsp2arch.pl "; + say "\tinfile: Epiphany Platform Description"; + say "\toutfile: DOL Architecture Specification"; + say "\tUse \'-\' for standard input/output."; + exit 1; +} + +# parse input xml file +my $input = XMLin($infile, ForceArray => '1', KeyAttr => ['chips']); + + +# per-core definitions +my @processors; +my @memories; +foreach my $chips ($input->{'chips'}->[0]->{'chip'}) { + foreach my $chip (@$chips) { + $chip->{'id'} =~ /\((\d+),(\d+)\)/; + my @origin = ($1, $2); + + foreach my $row (1..$chip->{'rows'}) { + foreach my $col (1..$chip->{'cols'}) { + my $newrow = $origin[0] + $row - 1; + my $newcol = $origin[1] + $col - 1; + my $memsize = $chip->{'core_memory_size'}; + $memsize = "0x8000" unless($memsize); + + # eCore + push @processors, { + 'name' => "core_${newrow}_${newcol}", + 'type' => 'RISC', + 'configuration' => [ + { 'name' => 'version', + 'value' => '3' }, + ], + }; + + # eCore local memory + push @memories, { + 'name' => "mem_${newrow}_${newcol}", + 'type' => 'RAM', + 'configuration' => [ + { 'name' => 'size', + 'value' => $memsize }, + ], + }; + + # eCore register file + push @memories, { + 'name' => "regs_${newrow}_${newcol}", + 'type' => 'REG', + } + } + } + + } +} + +# external memory +foreach my $banks ($input->{'external_memory'}->[0]->{'bank'}) { + my $counter = 0; + foreach my $bank (@$banks) { + # DOL doesn't need to know the epiphany-internal address + next if($bank->{'name'} eq 'EPIPHANY_DRAM'); + + if($bank->{'name'} eq 'EXTERNAL_DRAM') { + push @memories, { + 'name' => "emem_${counter}", + 'type' => 'DXM', + }; + next; + say "Warning: Unknown Extmem $bank->{'name'}!"; + } + } +} + +# TODO: add hw_channels data +my @hw_channels; + +# generate XML output +my $output = { + 'architecture' => { + 'xmlns' => "http://www.tik.ee.ethz.ch/~shapes/schema/ARCHITECTURE", + 'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance", + 'xsi:schemaLocation' => 'http://www.tik.ee.ethz.ch/~shapes/schema/ARCHITECTURE http://www.tik.ee.ethz.ch/~shapes/schema/architecture.xsd', + 'name' => 'Adapteva Parallella Architecture', + + 'processor' => \@processors, + 'memory' => \@memories, + 'hw_channel' => \@hw_channels, + }, +}; +my $outxml = "\n". + XMLout($output, KeyAttr => [], KeepRoot => 1); + +# save XML output +if($outfile eq '-') { + print $outxml; + exit 0; +} else { + open (FH, ">$outfile"); + print FH $outxml; + close (FH); +} +