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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [simulation/] [build_lint_filelists] - Rev 124

Go to most recent revision | 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-2011>  <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",
           "work_site=s" => \$work_site,
           "vendor=s" => \$vendor,
           "project=s" => \$project,
           "component=s" => \$component,
           "version=s" => \$version
) || die "(use '$program_name -h' for help)";



##############################################################################
## Help option
##############################################################################
if ( $opt_h  or $opt_help) 
  { print "\n build_lint_filelists -work_site /work  -vendor vendor_name  -project project_name  -component component_name   ";
    print "\n";
    exit 1;
  }


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



$home = cwd();

my $variant = "";
if($version) {$variant = "${component}_${version}"}
else         {$variant = "${component}"}

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

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



#/*********************************************************************************************/
#/                                                                                            */
#/  Create filelists for simulation  and  linting                                             */
#/                                                                                            */
#/                                                                                            */
#/*********************************************************************************************/

@filelist_sim = (  );
@filelist_ver = (  );

my @filelist_hier = (  );


push(@filelist_hier,"::${vendor}::${project}::${component}::${version}::");
my  @filelist =       parse_component_file("$vendor","$project","$component","$version");
@filelist     =       sys::lib::trim_sort(@filelist);



foreach $line (@filelist) 
   {
   $_ = $line;
   if(/::(\S+)::(\S+)::(\S+)::(\S+)::/) 
     { 
     $new_proj      = $2;
     $new_comp      = $3;
     $new_vendor    = $1;
     $new_version   = $4;                
     }



   #############################################################################
   ## Read destination from source xml file
   ## 
   #############################################################################



   my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$new_vendor,$new_proj,$new_comp,$new_version));




   if($new_version){$new_variant   = "${new_comp}_${new_version}"}
   else             {$new_variant   = $new_comp}




   if($new_proj eq $project )
        {

           foreach  my   $i_name ($spirit_component_file->findnodes("//spirit:fileSets/spirit:fileSet/spirit:file/spirit:name"))
              {    
              my($file_name)      = $i_name ->findnodes('./text()')->to_literal ;
              my($file_type)      = $i_name ->findnodes('../spirit:userFileType/text()')->to_literal ;
              my($logical_name)   = $i_name ->findnodes('../spirit:logicalName/text()')->to_literal ;
              my($view_file)      = $i_name ->findnodes('../../spirit:name/text()')->to_literal ;
              my $component_path  = yp::lib::find_ipxact_component_path("spirit:component",$new_vendor,$new_proj,$new_comp,$new_version);

              if( ($file_type eq "libraryDir") &&  ($view_file eq "fs-lint")  &&  ($logical_name eq "dest_dir")                    )
                 { 
                 push(@filelist_sim,"../../../../${new_comp}${component_path}/${file_name}${new_variant}.v\n");
                 push(@filelist_ver,"    ../../../../${new_comp}${component_path}/${file_name}${new_variant}.v\n");
                 };

              } 
        }
   else
        {

           foreach  my   $i_name ($spirit_component_file->findnodes("//spirit:fileSets/spirit:fileSet/spirit:file/spirit:name"))
              {    
              my($file_name)      = $i_name ->findnodes('./text()')->to_literal ;
              my($file_type)      = $i_name ->findnodes('../spirit:userFileType/text()')->to_literal ;
              my($logical_name)   = $i_name ->findnodes('../spirit:logicalName/text()')->to_literal ;
              my($view_file)      = $i_name ->findnodes('../../spirit:name/text()')->to_literal ;
              my $library_path    = yp::lib::find_ipxact_library_path("spirit:component",$new_vendor,$new_proj,$new_comp,$new_version);



              if(($file_type eq "libraryDir")&& (($view_file eq "fs-lint") ) &&  ($logical_name eq "dest_dir")  )
                 { 
                 push(@filelist_sim,"../../../../../children/${new_vendor}__${new_proj}${library_path}/${file_name}${new_variant}.v\n");
                 push(@filelist_ver,"   ../../../../../children/${new_vendor}__${new_proj}${library_path}/${file_name}${new_variant}.v\n");
                 };
              } 
           
        }
  
   }






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

print "Building rtl_check  filelists for  $work_site  $vendor $project   $component $version $variant \n" ;

my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$vendor,$project,$component,$version));
my $sogen_file               = $parser->parse_file(yp::lib::find_socgen("socgen:componentConfiguration",$vendor,$project,$component));





#/*********************************************************************************************/
#/                                                                                            */
#/                                                                                            */
#/  Read each variants parameters and defaults into an array and their order into an array    */
#/  order must be preservered so that parameters can use the values of other parameters       */
#/                                                                                            */
#/*********************************************************************************************/

my %default_parameters = ();
my @parameter_order    = ();


foreach  my   $i_name ($sogen_file->findnodes("//socgen:configurations/socgen:configuration[socgen:name/text() = '$variant']/socgen:parameters/socgen:parameter"))
      {
      my($parameter_name)     = $i_name ->findnodes('socgen:name/text()')->to_literal ;
      my($parameter_default)  = $i_name ->findnodes('socgen:value/text()')->to_literal ;
      $default_parameters{$parameter_name}  = $parameter_default;
      push  @parameter_order ,$parameter_name ;  
 #     print "XXXXY $parameter_name     $parameter_default       \n"; 
      }









foreach my $comp ($spirit_component_file->findnodes('//spirit:component')) 
   {
   my($vendor)   = $comp->findnodes('./spirit:vendor/text()')->to_literal ;
   my($library)  = $comp->findnodes('./spirit:library/text()')->to_literal ;
   my($name)     = $comp->findnodes('./spirit:name/text()')->to_literal ;
   my($version)  = $comp->findnodes('./spirit:version/text()')->to_literal ;
   my $variant = "";
   if($version) {$variant = "${name}_${version}"}
   else         {$variant = "${name}"}
   print "rtl/gen directories  for    $project - $component         VLNV        $vendor - $library -  $name -  $variant \n"; 
   }



 







   push(@filelist_sim,"    ./TestBench\n");             

   print "CREATING componentRef filelists for   $project   $component  $name $variant \n"; 




        @filelist_ver =       sys::lib::trim_sort(@filelist_ver);
        @filelist_sim =       sys::lib::trim_sort(@filelist_sim);

        







   #/*********************************************************************************************/
   #/                                                                                            */
   #/                                                                                            */
   #/                                                                                            */
   #/                                                                                            */
   #/                                                                                            */
   #/                                                                                            */
   #/*********************************************************************************************/



   @wire_inst = (  );
        
   foreach  my   $i_name ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:ports/spirit:port/name"))
      {
      my($port_name)  = $i_name ->findnodes('./text()')->to_literal ;
      my($left)       = $i_name ->findnodes('../spirit:wire/spirit:vector/spirit:left/text()')->to_literal ;
      my($right)      = $i_name ->findnodes('../spirit:wire/spirit:vector/spirit:right/text()')->to_literal ;
      if($left)  {      push(@wire_inst,"wire    [${left}:${right}]      ${port_name};\n");}
      else       {      push(@wire_inst,"wire                  ${port_name};\n");}
      }

   push(@wire_inst,"\n\n\n  $variant \n ");

   my $first = 1;

   foreach  my  $parameter_name  (@parameter_order)
      {
      if($first)
        {
         push(@wire_inst,"       #(.${parameter_name}(${parameter_name})");
         $first=0;
        }
      else
        {
        push(@wire_inst,",\n        .${parameter_name}(${parameter_name})");
        }
      }

   if($first == 0){push(@wire_inst,")\n");}
   push(@wire_inst," test \n (   \n");

   $first = 1;
   foreach  my   $i_name ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:ports/spirit:port/name"))
      {
      my($port_name)  = $i_name ->findnodes('./text()')->to_literal ;
      if($first)
        {
        push(@wire_inst,"        .${port_name}      (${port_name})");
        $first=0;
        }
      else
        {
        push(@wire_inst,",\n        .${port_name}   (${port_name})");
        }
      }

   push(@wire_inst,"\n  );\n\n\n\n");






   #/*********************************************************************************************/
   #/                                                                                            */
   #/ Make simulation file set                                                                   */
   #/                                                                                            */
   #/                                                                                            */
   #/                                                                                            */
   #/                                                                                            */
   #/*********************************************************************************************/

   print "CREATING sim files for   $project  $component   $chip   $name  $variant \n"; 




   my $sogen_file     = $parser->parse_file(yp::lib::find_socgen("socgen:componentConfiguration",$vendor,$project,$component));

    foreach  my   $i_name ($sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:rtl_check/socgen:lint[socgen:variant/text() = '$variant']"))
      {
      my($simulation)      = $i_name ->findnodes('socgen:name/text()')->to_literal ;
      my($configuration)   = $i_name ->findnodes('socgen:configuration/text()')->to_literal ;

      print " lint  files for   $project  $component   $variant  $simulation $configuration          \n"; 



      foreach  my   $i_name ($sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:library_path"))
         {
         my($library_path)     = $i_name ->findnodes('./text()')->to_literal ;

         my $path  = "${home}${work_site}/${vendor}__${project}${library_path}/rtl_check";

         mkdir $path,0755 unless (-e $path) ;

         $path  = "${home}${work_site}/${vendor}__${project}${library_path}/rtl_check/${simulation}";
         mkdir $path,0755   unless (-e $path);

         my $outfile ="${home}${work_site}/${vendor}__${project}${library_path}/rtl_check/${simulation}/Makefile";
         open  MAKSIMFILE,">$outfile" or die "unable to open $outfile";



         }


      print MAKSIMFILE  "include ../../../../../bin/Makefile.root\n";
      print MAKSIMFILE  "comp=${variant}\n";
      print MAKSIMFILE  "test=${simulation}\n";

      foreach  my   $i_name ($sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:library_path"))
        {
        my($library_path)     = $i_name ->findnodes('./text()')->to_literal ;
        my $outfile ="${home}${work_site}/${vendor}__${project}${library_path}/rtl_check/${simulation}/filelist.ver";
        open SIMFILE,">$outfile" or die "unable to open $outfile";
        }  

      foreach  my   $i_line (@filelist_sim){ print SIMFILE  "$i_line";}



      my %local_parameters =  %default_parameters;
      my @local_order      =  @parameter_order;

      foreach  my   $i_name ($sogen_file->findnodes("//socgen:configurations/socgen:configuration[socgen:name/text() = '$configuration']/./socgen:parameters/socgen:parameter/socgen:name"))
         {
         my($par_name)   = $i_name ->findnodes('./text()')->to_literal ;
         my($par_value)  = $i_name ->findnodes('../socgen:value/text()')->to_literal ;
         if($local_parameters{$par_name} eq '' )  { push @local_order , $par_name; }
         $local_parameters{$par_name} = $par_value; 
         }

    
      foreach  my   $i_name ($sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:rtl_check/socgen:lint[socgen:name/text() = '$simulation']/./socgen:parameters/socgen:parameter/socgen:name"))
         {
         my($par_name)   = $i_name ->findnodes('./text()')->to_literal ;
         my($par_value)  = $i_name ->findnodes('../socgen:value/text()')->to_literal ;
         if  ( $local_parameters{$par_name} eq '' )  { push @local_order , $par_name; }
         $local_parameters{$par_name} = $par_value;    
         }

       foreach  my   $i_name ($sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:library_path"))
         {
         my($library_path)     = $i_name ->findnodes('./text()')->to_literal ;
         my $outfile ="${home}${work_site}/${vendor}__${project}${library_path}/rtl_check/${simulation}/TestBench";
         open SIM_PARM_FILE,">$outfile" or die "unable to open $outfile";
         }
      print SIM_PARM_FILE  "//  Testbench  for  $project    $component    $variant   $configuration    $simulation\n";
      print SIM_PARM_FILE  "                                \n";
      print SIM_PARM_FILE  "                                \n";
      print SIM_PARM_FILE  "module TB();                                \n";
      print SIM_PARM_FILE  "                                \n";
      print SIM_PARM_FILE  "     $variant   \n";

      my $first =1;

      foreach  my  $parameter_name  (@local_order)
         {
         my($parameter_default)  =    $local_parameters{$parameter_name}; 
         if($first)
           {         
           print SIM_PARM_FILE  "   #(  .${parameter_name}(${parameter_default})";
           $first = 0;
           }
         else
           {         
           print SIM_PARM_FILE  ",\n       .${parameter_name}(${parameter_default})";
           }
         }

         if($first)       { print SIM_PARM_FILE  "  ";}
         else             { print SIM_PARM_FILE  ") ";}

      print SIM_PARM_FILE  "  test \n (); \n\n\n\n endmodule \n  ";



      }

 





#/*********************************************************************************************/
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/*********************************************************************************************/




sub parse_component_file
   {
   my @params     = @_;
   my $version    = pop(@params);
   my $component  = pop(@params);
   my $library    = pop(@params);
   my $vendor     = pop(@params);
   my $spirit_component_file         = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$vendor,$library,$component,$version )); 




foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:hierarchyRef")) 
   {
            my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
            my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
            my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
            my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
            my $hier_ref_type      = yp::lib::find_file_type($new_vendor,$new_library,$new_name,$new_version) ;

     if($hier_ref_type eq "spirit:component")
     {
     my  @filelist_sub = parse_component_file($new_vendor,$new_library,$new_name,$new_version);
        foreach $line (@filelist_sub) { push(@filelist_hier,"$line"); }
     }


     elsif($hier_ref_type eq "spirit:designConfiguration")
     {

        my $spirit_designCfg_file    
         = $parser->parse_file(yp::lib::find_ipxact("spirit:designConfiguration",$new_vendor,$new_library,$new_name,$new_version )); 

        foreach my $design_ref_view ($spirit_designCfg_file->findnodes('//spirit:designConfiguration')) 
           {
           $new_vendor         = $design_ref_view->findnodes('./spirit:designRef/@spirit:vendor')->to_literal ;
           $new_library        = $design_ref_view->findnodes('./spirit:designRef/@spirit:library')->to_literal ;
           $new_name           = $design_ref_view->findnodes('./spirit:designRef/@spirit:name')->to_literal ;
           $new_version        = $design_ref_view->findnodes('./spirit:designRef/@spirit:version')->to_literal ;
           $hier_ref_type                ="spirit:design";
           }
     }

     if($hier_ref_type eq "spirit:design")
     {
     my  @filelist_sub = parse_design_file($new_vendor,$new_library,$new_name,$new_version);
     foreach $line (@filelist_sub) { push(@filelist_hier,"$line"); }
     }
  }

   @filelist_hier     =       sys::lib::trim_sort(@filelist_hier);
   return(@filelist_hier);

}

#/*********************************************************************************************/
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/*********************************************************************************************/

sub parse_design_file 
   {
   my @params     = @_;
   my $version    = pop(@params);
   my $component  = pop(@params);
   my $library    = pop(@params);
   my $vendor     = pop(@params);

   $home = cwd();

   my $spirit_design_file = $parser->parse_file(yp::lib::find_ipxact("spirit:design",$vendor,$library,$component,$version )); 
   #/*********************************************************************************************/
   #/                                                                                            */
   #/  Create filelists for simulation ,  linting and synthesis                     */
   #/                                                                                            */
   #/                                                                                            */
   #/*********************************************************************************************/

   if($spirit_design_file)
    {
   foreach  my   $i_name ($spirit_design_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:componentRef/\@spirit:vendor"))
        {
        my($vendor_name)         = $i_name  ->to_literal ;
        my($library_name)        = $i_name  ->findnodes('../@spirit:library')->to_literal ;
        my($component_name)      = $i_name  ->findnodes('../@spirit:name')->to_literal ;
        my($version_name)        = $i_name  ->findnodes('../@spirit:version')->to_literal ;

        push(@filelist_hier,"::${vendor_name}::${library_name}::${component_name}::${version_name}::");
        my  @filelist_sub = parse_component_file($vendor_name,$library_name,$component_name,$version_name);
           foreach $line (@filelist_sub) { push(@filelist_hier,"$line"); }
        }       
    }
   @filelist_hier     =       sys::lib::trim_sort(@filelist_hier);
   return(@filelist_hier);
   }



Go to most recent revision | 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.