OpenCores
URL https://opencores.org/ocsvn/socgen/socgen/trunk

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [padring/] [create_padring.safe] - Rev 135

Compare with Previous | Blame | View Log

eval 'exec `which perl` -S $0 ${1+"$@"}'
   if 0;

#/**********************************************************************/
#/*                                                                    */
#/*             -------                                                */
#/*            /   SOC  \                                              */
#/*           /    GEN   \                                             */
#/*          /    TOOL    \                                            */
#/*          ==============                                            */
#/*          |            |                                            */
#/*          |____________|                                            */
#/*                                                                    */
#/*                                                                    */
#/*                                                                    */
#/*  Author(s):                                                        */
#/*      - John Eaton, jt_eaton@opencores.org                          */
#/*                                                                    */
#/**********************************************************************/
#/*                                                                    */
#/*    Copyright (C) <2010-2016>  <Ouabache Design Works>              */
#/*                                                                    */
#/*  This source file may be used and distributed without              */
#/*  restriction provided that this copyright statement is not         */
#/*  removed from the file and that any derivative work contains       */
#/*  the original copyright notice and the associated disclaimer.      */
#/*                                                                    */
#/*  This source file is free software; you can redistribute it        */
#/*  and/or modify it under the terms of the GNU Lesser General        */
#/*  Public License as published by the Free Software Foundation;      */
#/*  either version 2.1 of the License, or (at your option) any        */
#/*  later version.                                                    */
#/*                                                                    */
#/*  This source is distributed in the hope that it will be            */
#/*  useful, but WITHOUT ANY WARRANTY; without even the implied        */
#/*  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR           */
#/*  PURPOSE.  See the GNU Lesser General Public License for more      */
#/*  details.                                                          */
#/*                                                                    */
#/*  You should have received a copy of the GNU Lesser General         */
#/*  Public License along with this source; if not, download it        */
#/*  from http://www.opencores.org/lgpl.shtml                          */
#/*                                                                    */
#/**********************************************************************/




############################################################################
# General PERL config
############################################################################
use Getopt::Long;
use English;
use File::Basename;
use Cwd;
use XML::LibXML;
use lib './tools';
use sys::lib;
use yp::lib;

$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.

############################################################################
### Process the options
############################################################################
Getopt::Long::config("require_order", "prefix=-");
GetOptions("h","help",
           "vendor=s" => \$vendor,
           "library=s" => \$library,
           "component=s" => \$component,
           "version=s" => \$version,
           "rtl=s" => \$rtl,
           "xml=s" => \$xml
) || die "(use '$program_name -h' for help)";



##############################################################################
## Help option
##############################################################################
if ( $opt_h  or $opt_help) 
  { print "\n create_padring -vendor vendor_name  -library library_name  -component component_name path_to_pads_csv_from_cfgfile   ";
    print "\nEX: create_padring -vendor foo  -library bar  -component chip  ./pads/padring.csv   ";
    exit 1;
  }


##############################################################################
## 
##############################################################################

$home = cwd();


my    $pads_csv     = $ARGV[0];

chomp($pads_csv);




unless(defined $rtl)       {$rtl = "rtl";}
unless(defined $xml)       {$xml = "xml";}

unless(defined $pads_csv)  {print "pads_csv file missing \n";exit}

unless(defined $vendor)    { print "vendor missing \n";exit}
unless(defined $library)   { print "library missing \n";exit}
unless(defined $component) { print "component missing \n";exit}
unless(defined $version)   { $version = "padring";}

my $parser = XML::LibXML->new();


my $component_repo           = yp::lib::find_component_repo($vendor,$library,$component);
my $lib_comp_sep             = yp::lib::find_lib_comp_sep($vendor,$library,$component);

$pads_csv ="${home}${component_repo}/${vendor}/${library}${lib_comp_sep}${component}/${pads_csv}";

unless(-e $pads_csv)
{
print "file not exist:  $pads_csv  \n";
exit;

}
print " Processing  $vendor $library $component  $rtl  $xml \n ---->>  ${pads_csv} \n";

my $xml_file = "${home}${component_repo}/${vendor}/${library}${lib_comp_sep}${component}/${rtl}";
mkdir $xml_file,0755   unless( -e $xml_file );

my $xml_file = "${xml_file}/${xml}";
mkdir $xml_file,0755   unless( -e $xml_file );


my $outfile = "${xml_file}/${component}_padring.xml";

my $cmd = "cp ${home}/tools/padring/boilerplate ${outfile}\n";

if(system($cmd)){}

open DEST_FILE,">>$outfile" or die "unable to open $outfile";

print DEST_FILE  "<ipxact:vendor>${vendor}</ipxact:vendor> \n";
print DEST_FILE  "<ipxact:library>${library}</ipxact:library> \n";
print DEST_FILE  "<ipxact:component>${component}</ipxact:component> \n";
print DEST_FILE  "<ipxact:version>${version}</ipxact:version> \n";


my @scaler_list;
my @vector_list;

$SRCFILE ="$pads_csv";
open(SRCFILE) or die("Could not open src file.  $SRCFILE ");
foreach $line (<SRCFILE>) 
    {
    chomp($line);
    $_ = $line;
    if(/(\S+),(\S+),(\S+),(\S+)/)
      {
      $pin_name    = $1;
      $pin_dir     = $2;
      $pin_reset   = $3;
      $pin_ucf     = $4;

      $_ = $pin_name;

      if(/(\w+)[\[](\d+)[\]]/)
        {
        $pin_name    = $1;
        $pin_bit     = $2;
        $pin_type    = "vector";
        push (@vector_list,  "${pin_name}::${pin_bit}::${pin_dir}::${pin_reset}::${pin_ucf}");
        }
       else
        {
        push (@scaler_list,  "${pin_name}::${pin_dir}::${pin_reset}::${pin_ucf}");
        }
      }

    } 






print DEST_FILE  "\n <ipxact:busInterfaces> \n";

foreach $list (@scaler_list)
  {


  ( ${pin_name},${pin_dir},${pin_reset},${pin_ucf}) = split( /::/ , $list);

  $pin_name   =  uc $pin_name;
  if   ($pin_dir eq  "in")     {$pin_port ="in" ;}
  elsif($pin_dir eq "out")     {$pin_port ="out";} 
  elsif($pin_dir eq "inout")   {$pin_port ="io";}
  elsif($pin_dir eq "tsout")   {$pin_port ="out";}
  elsif($pin_dir eq "odout")   {$pin_port ="out";}
  elsif($pin_dir eq "odinout") {$pin_port ="io";}
  else                         {$pin_port ="XX";}
  print DEST_FILE  " <ipxact:busInterface>                                                                                  \n";
  print DEST_FILE  " <ipxact:name>${pin_name}</ipxact:name>                                                                       \n";
  print DEST_FILE  " <ipxact:busType vendor=\"opencores.org\" library=\"Busdefs\" name=\"pad\" version=\"def\"/>            \n";     
  print DEST_FILE  " <ipxact:abstractionTypes><ipxact:abstractionType>                                                      \n";
  print DEST_FILE  "  <ipxact:abstractionRef  vendor=\"opencores.org\" library=\"Busdefs\" name=\"pad\" version=\"ring\"/>  \n";  
  print DEST_FILE  "    <ipxact:portMaps>                                                                                   \n";
  print DEST_FILE  "          <ipxact:portMap>                                                                              \n";
  print DEST_FILE  "      <ipxact:logicalPort><ipxact:name>PAD_${pin_port}</ipxact:name></ipxact:logicalPort>                       \n";
  print DEST_FILE  "          <ipxact:physicalPort><ipxact:name>${pin_name}</ipxact:name></ipxact:physicalPort>                   \n";         
  print DEST_FILE  "          </ipxact:portMap>                                                                             \n";
  print DEST_FILE  "    </ipxact:portMaps>                                                                                  \n";
  print DEST_FILE  "  </ipxact:abstractionType>     </ipxact:abstractionTypes>                                              \n";
  print DEST_FILE  "  <ipxact:master/>                                                                                      \n";
  print DEST_FILE  "  </ipxact:busInterface>                                                                                \n\n";

  }  





foreach $list (@vector_list)   {  print DEST_FILE  "++>  $list      \n";}      

print DEST_FILE  "\n </ipxact:busInterfaces> \n ";



















print DEST_FILE  "\n <ipxact:model> \n";




print DEST_FILE  "  <ipxact:instantiations> \n";
print DEST_FILE  "   <ipxact:designInstantiation> \n";
print DEST_FILE  "     <ipxact:name>Padring</ipxact:name> \n";
print DEST_FILE  "    <ipxact:designRef vendor=\"${vendor}\" library=\"${library}\" name=\"${component}\" version=\"${version}.design\"/> \n";
print DEST_FILE  "   </ipxact:designInstantiation> \n";
print DEST_FILE  "  </ipxact:instantiations> \n";
print DEST_FILE  " \n";
print DEST_FILE  "  <ipxact:views> \n";
print DEST_FILE  "    <ipxact:view> \n";
print DEST_FILE  "      <ipxact:name>Padring</ipxact:name> \n";
print DEST_FILE  "      <ipxact:designInstantiationRef>Padring</ipxact:designInstantiationRef> \n";
print DEST_FILE  "    </ipxact:view>   \n";  
print DEST_FILE  "  </ipxact:views> \n";







print DEST_FILE  "\n <ipxact:ports> \n";

foreach $list (@scaler_list)
  {


  ( ${pin_name},${pin_dir},${pin_reset},${pin_ucf}) = split( /::/ , $list);

  $pin_name   =  uc $pin_name;
  if   ($pin_dir eq  "in")     {$pin_port ="in" ;}
  elsif($pin_dir eq "out")     {$pin_port ="out";} 
  elsif($pin_dir eq "inout")   {$pin_port ="inout";}
  elsif($pin_dir eq "tsout")   {$pin_port ="out";}
  elsif($pin_dir eq "odout")   {$pin_port ="out";}
  elsif($pin_dir eq "odinout") {$pin_port ="inout";}
  else                         {$pin_port ="XX";}
  print DEST_FILE  " <ipxact:port>  <ipxact:name>${pin_name}</ipxact:name>                                                 \n";
  print DEST_FILE  " <ipxact:wire><ipxact:wireTypeDefs><ipxact:wireTypeDef><ipxact:typeName>wire</ipxact:typeName></ipxact:wireTypeDef></ipxact:wireTypeDefs>         \n";     
  print DEST_FILE  "  <ipxact:direction>${pin_port}</ipxact:direction></ipxact:wire>                                                     \n";
  print DEST_FILE  "  </ipxact:port>                                                                                \n\n";

  }  



foreach $list (@vector_list)   {  print DEST_FILE  "++>  $list      \n";}      


print DEST_FILE  "\n </ipxact:ports> \n ";

print DEST_FILE  "\n </ipxact:model> \n ";














print DEST_FILE  "\n </ipxact:component> \n ";

1



Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.