eval 'exec `which perl` -S $0 ${1+"$@"}'
|
eval 'exec `which perl` -S $0 ${1+"$@"}'
|
if 0;
|
if 0;
|
|
|
#/**********************************************************************/
|
#/**********************************************************************/
|
#/* */
|
#/* */
|
#/* ------- */
|
#/* ------- */
|
#/* / SOC \ */
|
#/* / SOC \ */
|
#/* / GEN \ */
|
#/* / GEN \ */
|
#/* / TOOL \ */
|
#/* / TOOL \ */
|
#/* ============== */
|
#/* ============== */
|
#/* | | */
|
#/* | | */
|
#/* |____________| */
|
#/* |____________| */
|
#/* */
|
#/* */
|
#/* Traverse a socgen project and link it */
|
|
#/* */
|
#/* */
|
#/* */
|
#/* */
|
#/* Author(s): */
|
#/* Author(s): */
|
#/* - John Eaton, jt_eaton@opencores.org */
|
#/* - John Eaton, jt_eaton@opencores.org */
|
#/* */
|
#/* */
|
#/**********************************************************************/
|
#/**********************************************************************/
|
#/* */
|
#/* */
|
#/* Copyright (C) <2010> */
|
#/* Copyright (C) <2010-2011> */
|
#/* */
|
#/* */
|
#/* This source file may be used and distributed without */
|
#/* This source file may be used and distributed without */
|
#/* restriction provided that this copyright statement is not */
|
#/* restriction provided that this copyright statement is not */
|
#/* removed from the file and that any derivative work contains */
|
#/* removed from the file and that any derivative work contains */
|
#/* the original copyright notice and the associated disclaimer. */
|
#/* the original copyright notice and the associated disclaimer. */
|
#/* */
|
#/* */
|
#/* This source file is free software; you can redistribute it */
|
#/* This source file is free software; you can redistribute it */
|
#/* and/or modify it under the terms of the GNU Lesser General */
|
#/* and/or modify it under the terms of the GNU Lesser General */
|
#/* Public License as published by the Free Software Foundation; */
|
#/* Public License as published by the Free Software Foundation; */
|
#/* either version 2.1 of the License, or (at your option) any */
|
#/* either version 2.1 of the License, or (at your option) any */
|
#/* later version. */
|
#/* later version. */
|
#/* */
|
#/* */
|
#/* This source is distributed in the hope that it will be */
|
#/* This source is distributed in the hope that it will be */
|
#/* useful, but WITHOUT ANY WARRANTY; without even the implied */
|
#/* useful, but WITHOUT ANY WARRANTY; without even the implied */
|
#/* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR */
|
#/* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR */
|
#/* PURPOSE. See the GNU Lesser General Public License for more */
|
#/* PURPOSE. See the GNU Lesser General Public License for more */
|
#/* details. */
|
#/* details. */
|
#/* */
|
#/* */
|
#/* You should have received a copy of the GNU Lesser General */
|
#/* You should have received a copy of the GNU Lesser General */
|
#/* Public License along with this source; if not, download it */
|
#/* Public License along with this source; if not, download it */
|
#/* from http://www.opencores.org/lgpl.shtml */
|
#/* from http://www.opencores.org/lgpl.shtml */
|
#/* */
|
#/* */
|
#/**********************************************************************/
|
#/**********************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
use Cwd;
|
use Cwd;
|
use XML::LibXML;
|
use XML::LibXML;
|
|
|
|
|
|
|
|
|
#/*********************************************************************************************/
|
#/*********************************************************************************************/
|
#/ We never generate files into a RCS database. */
|
#/ We never generate files into a RCS database. */
|
#/ */
|
#/ */
|
#/ A special work area is created that is the image of the database using symbolic links */
|
#/ A special work area is created that is the image of the database using symbolic links */
|
#/ */
|
#/ */
|
#/*********************************************************************************************/
|
#/*********************************************************************************************/
|
|
|
my $root = "projects";
|
my $root = "projects/opencores.org";
|
$home = cwd();
|
$home = cwd();
|
my $prefix = "/work/";
|
my $prefix = "/work/";
|
$lib_comp_sep = "/ip/";
|
$lib_comp_sep = "/ip/";
|
$comp_xml_sep = "/rtl/xml/";
|
$comp_xml_sep = "/rtl/xml/";
|
$tb_xml_sep = "/sim/xml/";
|
$tb_xml_sep = "/sim/xml/";
|
|
|
|
|
print "Building a work area for ${home}/${root} in ${home}${prefix} \n" ;
|
print "Building a work area for ${home}/${root} in ${home}${prefix} \n" ;
|
|
|
&link_sub( $root,$root, "work" );
|
&link_sub( $root,$root, "work" );
|
|
|
|
|
#/*********************************************************************************************/
|
#/*********************************************************************************************/
|
#/ */
|
#/ */
|
#/ Each project is given access to the system tools by giving each of them a link to the */
|
#/ Each project is given access to the system tools by giving each of them a link to the */
|
#/ Master Makefiles in tools/bin */
|
#/ Master Makefiles in tools/bin */
|
#/ */
|
#/ */
|
#/ Every component in a project is given access to the system testbench/models and CDE */
|
#/ Every component in a project is given access to the system testbench/models and CDE */
|
#/ library files via symbolic links */
|
#/ library files via symbolic links */
|
#/ */
|
#/ */
|
#/*********************************************************************************************/
|
#/*********************************************************************************************/
|
|
|
|
|
@projects = qx(ls ${home}${prefix} );
|
@projects = qx(ls ${home}${prefix} );
|
|
|
|
|
foreach my $project (@projects)
|
foreach my $project (@projects)
|
{
|
{
|
chomp($project);
|
chomp($project);
|
symlink( "${home}/tools/bin/Makefile.root", "${home}/work/${project}/bin/Makefile.root");
|
symlink( "${home}/tools/bin/Makefile.root", "${home}/work/${project}/bin/Makefile.root");
|
symlink( "${home}/tools/bin/Makefile", "${home}/work/${project}/bin/Makefile");
|
symlink( "${home}/tools/bin/Makefile", "${home}/work/${project}/bin/Makefile");
|
|
|
$cmd ="chmod 755 ${home}/projects/${project}/bin/* \n";
|
$cmd ="chmod 755 ${home}/projects/opencores.org/${project}/bin/* \n";
|
if (system($cmd)) {}
|
if (system($cmd)) {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
my $path = "${home}${prefix}${project}/children";
|
my $path = "${home}${prefix}${project}/children";
|
mkdir $path,0755 unless( -e $path );
|
mkdir $path,0755 unless( -e $path );
|
|
|
my $path = "${home}${prefix}${project}/children/Busdefs";
|
my $path = "${home}${prefix}${project}/children/Busdefs";
|
mkdir $path,0755 unless( -e $path );
|
mkdir $path,0755 unless( -e $path );
|
|
|
|
&link_dir( "${home}/projects/opencores.org/Busdefs", "${home}${prefix}${project}/children/Busdefs" );
|
|
|
&link_dir( "${home}/projects/Busdefs", "${home}${prefix}${project}/children/Busdefs" );
|
|
|
|
|
|
my @components = qx(ls ${home}/work/${project}/ip );
|
my @components = qx(ls ${home}/work/${project}/ip );
|
foreach my $component (@components)
|
foreach my $component (@components)
|
{
|
{
|
chomp($component);
|
chomp($component);
|
|
|
|
|
$cmd ="./tools/sys/build_geda $project $component /n";
|
$cmd ="./tools/sys/build_geda $project $component /n";
|
if (system($cmd)) {}
|
if (system($cmd)) {}
|
|
|
my $parser = XML::LibXML->new();
|
my $parser = XML::LibXML->new();
|
my $doc = $parser->parse_file("${home}${prefix}${project}${lib_comp_sep}${component}/soc/design.soc");
|
my $doc = $parser->parse_file("${home}${prefix}${project}${lib_comp_sep}${component}/ip-xact/design.xml");
|
|
|
{
|
|
|
|
#/*********************************************************************************************/
|
#/*********************************************************************************************/
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/*********************************************************************************************/
|
#/*********************************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach my $i_name ($doc->findnodes("//components/component/name"))
|
foreach my $i_name ($doc->findnodes("//components/component/name"))
|
{
|
{
|
my($comp_name) = $i_name ->findnodes('./text()')->to_literal ;
|
my($comp_name) = $i_name ->findnodes('./text()')->to_literal ;
|
my($comp_version) = $i_name ->findnodes('../version/text()')->to_literal ;
|
my($comp_version) = $i_name ->findnodes('../version/text()')->to_literal ;
|
my($variant) = $i_name ->findnodes('../variant/text()')->to_literal ;
|
|
$cmd ="./tools/sys/soc_link_child -project $project -lib_comp_sep $lib_comp_sep -component $component -comp_xml_sep $comp_xml_sep -variant $variant $comp_xml_sep /n";
|
my $comp_variant = "";
|
|
if($comp_version) {$comp_variant = "${comp_name}_${comp_version}"}
|
|
else {$comp_variant = "${comp_name}"}
|
|
|
|
$cmd ="./tools/sys/soc_link_child -vendor opencores.org -project $project -lib_comp_sep $lib_comp_sep -component $component -comp_xml_sep $comp_xml_sep -variant $comp_variant $comp_xml_sep /n";
|
if (system($cmd)) {}
|
if (system($cmd)) {}
|
}
|
}
|
|
|
|
|
foreach my $i_name ($doc->findnodes("//testbenchs/testbench/name"))
|
foreach my $i_name ($doc->findnodes("//testbenchs/testbench/name"))
|
{
|
{
|
my($tb_name) = $i_name ->findnodes('./text()')->to_literal ;
|
my($tb_name) = $i_name ->findnodes('./text()')->to_literal ;
|
my($tb_version) = $i_name ->findnodes('../version/text()')->to_literal ;
|
my($tb_version) = $i_name ->findnodes('../version/text()')->to_literal ;
|
my($tb_variant) = $i_name ->findnodes('../variant/text()')->to_literal ;
|
|
$cmd ="./tools/sys/soc_link_child -project $project -lib_comp_sep $lib_comp_sep -component $component -comp_xml_sep $comp_xml_sep -variant $tb_variant $tb_xml_sep /n";
|
my $tb_variant = "";
|
|
if($tb_version) {$tb_variant = "${tb_name}_${tb_version}"}
|
|
else {$tb_variant = "${tb_name}"}
|
|
|
|
$cmd ="./tools/sys/soc_link_child -vendor opencores.org -project $project -lib_comp_sep $lib_comp_sep -component $component -comp_xml_sep $comp_xml_sep -variant $tb_variant $tb_xml_sep /n";
|
if (system($cmd)) {}
|
if (system($cmd)) {}
|
}
|
}
|
|
|
|
|
#/*********************************************************************************************/
|
#/*********************************************************************************************/
|
#/ link chip files for synthesys */
|
#/ link chip files for synthesys */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/*********************************************************************************************/
|
#/*********************************************************************************************/
|
|
|
print "Linking targets for $project $component \n";
|
print "Linking targets for $project $component \n";
|
foreach my $i_name ($doc->findnodes("//chips/chip/name"))
|
foreach my $i_name ($doc->findnodes("//chips/chip/name"))
|
{
|
{
|
my($chip) = $i_name ->findnodes('./text()')->to_literal ;
|
my($chip) = $i_name ->findnodes('./text()')->to_literal ;
|
my($chip_target) = $i_name ->findnodes('../target/text()')->to_literal ;
|
my($chip_target) = $i_name ->findnodes('../target/text()')->to_literal ;
|
my($configuration) = $i_name ->findnodes('../configuration/text()')->to_literal ;
|
my($configuration) = $i_name ->findnodes('../configuration/text()')->to_literal ;
|
my($variant) = $i_name ->findnodes('../variant/text()')->to_literal ;
|
my($variant) = $i_name ->findnodes('../variant/text()')->to_literal ;
|
|
|
$outfile ="${home}${prefix}${project}${lib_comp_sep}${component}/syn/ise/${chip}/Makefile";
|
$outfile ="${home}${prefix}${project}${lib_comp_sep}${component}/syn/ise/${chip}/Makefile";
|
open MAKSYNFILE,">$outfile" or die "unable to open $outfile";
|
open MAKSYNFILE,">$outfile" or die "unable to open $outfile";
|
|
|
print MAKSYNFILE "include ../../../../../bin/Makefile.root\n";
|
print MAKSYNFILE "include ../../../../../bin/Makefile.root\n";
|
print MAKSYNFILE "include ./target/Makefile.brd\n";
|
print MAKSYNFILE "include ./target/Makefile.brd\n";
|
print MAKSYNFILE "board=${chip_target}\n";
|
print MAKSYNFILE "board=${chip_target}\n";
|
print MAKSYNFILE "Design=${chip_target}_${configuration}\n";
|
print MAKSYNFILE "Design=${chip_target}_${configuration}\n";
|
my $path = "${home}${prefix}${project}${lib_comp_sep}${component}/syn/ise/${chip}/target";
|
my $path = "${home}${prefix}${project}${lib_comp_sep}${component}/syn/ise/${chip}/target";
|
mkdir $path,0755 unless( -e $path );
|
mkdir $path,0755 unless( -e $path );
|
|
|
&link_dir( "${home}/projects/targets/ip/${chip_target}", "${home}${prefix}${project}${lib_comp_sep}${component}/syn/ise/${chip}/target" );
|
&link_dir( "${home}/projects/opencores.org/targets/ip/${chip_target}", "${home}${prefix}${project}${lib_comp_sep}${component}/syn/ise/${chip}/target" );
|
&link_dir( "${home}/projects/cde/ip", "${home}${prefix}${project}${lib_comp_sep}${component}/syn/ise/${chip}/target/lib/ip" );
|
&link_dir( "${home}/projects/opencores.org/cde/ip", "${home}${prefix}${project}${lib_comp_sep}${component}/syn/ise/${chip}/target/lib/ip" );
|
&link_dir( "${home}/tools/Jtag_programmers/debug", "${home}${prefix}${project}${lib_comp_sep}${component}/syn/ise/${chip}/debug" );
|
&link_dir( "${home}/tools/Jtag_programmers/debug", "${home}${prefix}${project}${lib_comp_sep}${component}/syn/ise/${chip}/debug" );
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
|
|
|
|
|
|
|
#/*********************************************************************************************/
|
#/*********************************************************************************************/
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/*********************************************************************************************/
|
#/*********************************************************************************************/
|
|
|
|
|
# recursively map directory information
|
# recursively map directory information
|
|
|
sub link_sub {
|
sub link_sub {
|
my $root = shift;
|
my $root = shift;
|
my $path = shift;
|
my $path = shift;
|
my $dest = shift;
|
my $dest = shift;
|
return unless( -e $path );
|
return unless( -e $path );
|
|
|
|
|
my $dest_path = $path;
|
my $dest_path = $path;
|
$dest_path =~ s/$root/$dest/;
|
$dest_path =~ s/$root/$dest/;
|
|
|
|
|
if( -d $path ) {
|
if( -d $path ) {
|
|
|
mkdir $dest_path,0755;
|
mkdir $dest_path,0755;
|
|
|
my @contents = ( );
|
my @contents = ( );
|
opendir( DIR, $path );
|
opendir( DIR, $path );
|
while( my $item = readdir( DIR )) {
|
while( my $item = readdir( DIR )) {
|
next if( $item eq '.' or $item eq '..' or $item eq '.svn' );
|
next if( $item eq '.' or $item eq '..' or $item eq '.svn' );
|
push( @contents, $item );
|
push( @contents, $item );
|
}
|
}
|
closedir( DIR );
|
closedir( DIR );
|
|
|
# recurse on items in the directory
|
# recurse on items in the directory
|
foreach my $item ( @contents ) { &link_sub($root, "$path/$item", $dest );}
|
foreach my $item ( @contents ) { &link_sub($root, "$path/$item", $dest );}
|
|
|
|
|
} else {
|
} else {
|
|
|
symlink( "${home}/${path}", $dest_path);
|
symlink( "${home}/${path}", $dest_path);
|
}
|
}
|
}
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#/*********************************************************************************************/
|
#/*********************************************************************************************/
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/*********************************************************************************************/
|
#/*********************************************************************************************/
|
|
|
# recursively map directory information
|
# recursively map directory information
|
|
|
sub link_dir {
|
sub link_dir {
|
my $src = shift;
|
my $src = shift;
|
my $dest = shift;
|
my $dest = shift;
|
return unless( -e $src );
|
return unless( -e $src );
|
|
|
if( -d $src )
|
if( -d $src )
|
{
|
{
|
|
|
mkdir $dest,0755;
|
mkdir $dest,0755;
|
my @contents = ( );
|
my @contents = ( );
|
opendir( DIR, $src );
|
opendir( DIR, $src );
|
while( my $item = readdir( DIR ))
|
while( my $item = readdir( DIR ))
|
{
|
{
|
next if( $item eq '.' or $item eq '..' or $item eq '.svn' );
|
next if( $item eq '.' or $item eq '..' or $item eq '.svn' );
|
push( @contents, $item );
|
push( @contents, $item );
|
}
|
}
|
closedir( DIR );
|
closedir( DIR );
|
|
|
# recurse on items in the directory
|
# recurse on items in the directory
|
foreach my $item ( @contents ) { &link_dir("$src/$item", "$dest/$item" );}
|
foreach my $item ( @contents ) { &link_dir("$src/$item", "$dest/$item" );}
|
|
|
|
|
}
|
}
|
else {symlink( "${src}", "${dest}") unless( -e "${dest}" ); }
|
else {symlink( "${src}", "${dest}") unless( -e "${dest}" ); }
|
}
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|