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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [verilog/] [gen_elab_verilogLib] - Rev 135

Compare with Previous | Blame | View Log

eval 'exec `which perl` -S $0 ${1+"$@"}'
   if 0;
#/****************************************************************************/
#/*                                                                          */
#/*   SOCGEN Design for Reuse toolset                                        */
#/*                                                                          */
#/*   Version 1.0.0                                                          */
#/*                                                                          */
#/*   Author(s):                                                             */
#/*      - John Eaton, z3qmtr45@gmail.com                                    */
#/*                                                                          */
#/****************************************************************************/
#/*                                                                          */
#/*                                                                          */
#/*             Copyright 2016 John T Eaton                                  */ 
#/*                                                                          */
#/* Licensed under the Apache License, Version 2.0 (the "License");          */
#/* you may not use this file except in compliance with the License.         */
#/* You may obtain a copy of the License at                                  */
#/*                                                                          */
#/*    http://www.apache.org/licenses/LICENSE-2.0                            */
#/*                                                                          */
#/* Unless required by applicable law or agreed to in writing, software      */
#/* distributed under the License is distributed on an "AS IS" BASIS,        */
#/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
#/* See the License for the specific language governing permissions and      */
#/* limitations under the License.                                           */
#/*                                                                          */
#/*                                                                          */
#/****************************************************************************/



############################################################################
# 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",
           "envidentifier=s" => \$envidentifier,
           "prefix=s" => \$prefix,
           "vendor=s" => \$vendor,
           "library=s" => \$library,
           "component=s" => \$component,
           "version=s" => \$version,
           "configuration=s" => \$configuration,
           "dest_dir=s" => \$dest_dir,
           "view=s" => \$view
) || die "(use '$program_name -h' for help)";


##############################################################################
## Help option
##############################################################################
if ( $opt_h  or ($opt_help) ) 
   { 
   print "\n gen_elab_verilogLib -envidentifier *simulation* -prefix /work  -vendor vendor_name -library  library_name  -component component_name -version version_name -dest_dir dest_dir";
   print "\n";
   exit 1;
   }


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

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

my $socgen_file               = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));
my $ip_name_base_macro       = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:ip_name_base_macro/text()")->to_literal;




$home = cwd();
my @search_paths = ();
my $variant;










my @configs  = yp::lib::get_component_configs($vendor,$library,$component,$version);


   print "\n ---GEN_elab_verilogLib -envidentifier  $envidentifier -prefix $prefix  -vendor $vendor -library  $library  -component $component -version $version -dest_dir $dest_dir -configuration  $configuration  \n";

foreach my $config (@configs)

{




print "+++GEN_verilogLib  Configuration  $config  \n";

}







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

my $lib_comp_sep    = yp::lib::find_lib_comp_sep($vendor,$library,$component);
my $comp_xml_sep    = yp::lib::find_comp_xml_sep($vendor,$library,$component,$version);
my $module_name     = yp::lib::get_module_name($vendor,$library,$component,$version);   








my $parser = XML::LibXML->new();
my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact_component($vendor,$library,$component,$version));


if($dest_dir ne "../views")
{
#print "XXXXXXXXXXXXXXXXXXX   Building $view   $library  $component $verison  $variant  $dest_dir    Dest_dir not ./views  \n" ;
}


#print "VVVVVVVV   Building $view  Verilog Lib RTL for  $prefix $library  $component $verison  $variant  $dest_dir  \n" ;




my $path  = "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}";
mkdir $path,0755             unless( -e $path );


my $path  = "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../defines";
mkdir $path,0755             unless( -e $path );

my $path  = "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../filelists";
mkdir $path,0755             unless( -e $path );


my $path  = "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/${view}";
mkdir $path,0755             unless( -e $path );



    #/**********************************************************************/
    #/*                                                                    */
    #/* build a `define file for module names                              */
    #/*                                                                    */ 
    #/*                                                                    */
    #/*                                                                    */
    #/*                                                                    */
    #/**********************************************************************/
   
    my $outfile ="${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../defines/${variant}.v";
    open DEFLIST,">$outfile" or die "unable to open $outfile";

        if(defined $configuration && length $configuration >0 )
          {
          print  DEFLIST "   \`define $ip_name_base_macro     ${module_name}_${configuration}  \n";
    my $outfile ="${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}_${configuration}.MOD";
    open FILELIST,">$outfile" or die "unable to open $outfile";      
          }
        else
          {
          print  DEFLIST "   \`define $ip_name_base_macro     ${module_name}  \n";
    my $outfile ="${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}.MOD";
    open FILELIST,">$outfile" or die "unable to open $outfile";      

    }





    my $outfile ="${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}.INC";
    open INCLIST,">$outfile" or die "unable to open $outfile";

    print INCLIST  "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../defines/${variant}.v\n";






    foreach my $comp_view ($spirit_component_file->findnodes("//ipxact:component/ipxact:model/ipxact:views/ipxact:view/ipxact:envIdentifier[./text() = '$envidentifier']")) 
      {
      my($view_name)     = $comp_view->findnodes('../ipxact:name/text()')->to_literal ;
      my($view_fileset)  = $comp_view->findnodes('../ipxact:fileSetRef/ipxact:localName/text()')->to_literal ;
   #   print "    VVVVVVVVVVVVVL    Found $view  --  $view_name  $view_fileset  $dest_dir  $configuration   \n" ;

if($view ne $view_name)
{
#print "XXXXXXXXXXXXXXXXXXXXX   Building $view   $view_name not equal   $vendor, $library, $component, $version    \n" ;
}




   my @includes = yp::lib::get_files($vendor,$library,$component,$version,$view_fileset,"include") ;

#      print "     VVVVVVVK  $vendor,$library,$component,$version,$view_fileset  include   $view_name \n";  

      foreach my $include (@includes)
        {
#        print "       VVVVVVVJ  |${include}| \n";
       print INCLIST  "${home}${prefix}/${include}\n";
        }

   my @modules   = yp::lib::get_files($vendor,$library,$component,$version,$view_fileset,"module") ;

      foreach my $module (@modules)
        {
#        print "       VVVVVVVI  |${module}|  $configuration   \n";
        #  need to tag the top module but no others

        if(defined $configuration && length $configuration >0 )
          {
          $_ = $module;
          if(/(\S+)${component}_${version}/)
            {
            $_ = $module;
          if(/(\S+)${component}_${version}(\S+)/)
            {
#            print "No_TAG    $module \n";       
            print FILELIST  "${home}${prefix}/${module}\n";
            }
            else
              {        
#              print "   TAG    $module \n";       
              print FILELIST  "${home}${prefix}/${module}_${configuration}\n";
              }
            }
          else
            {
#            print "No_TAG    $module \n";       
            print FILELIST  "${home}${prefix}/${module}\n";
            }
          }
        else
          {
          print FILELIST  "${home}${prefix}/${module}\n";
          }
        }

   my @libraryDirs   = yp::lib::get_files($vendor,$library,$component,$version,$view_fileset,"libraryDir") ;

      foreach my $libraryDir (@libraryDirs)
        {
#        print "       VVVVVVVM  |${libraryDir}| \n";
        }

      }









#print " VVVVVVVV   $envidentifier  $view  \n" ;


my  @filelist =       yp::lib::parse_component_brothers("$vendor","$library","$component","$version");

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

#     print "  VVVVVVVVVVVVVVVVVVVVV  Brother      $new_vendor  $new_library  $new_component $new_version \n" ;

    my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact_component($new_vendor,$new_library,$new_component,$new_version));

    foreach my $comp_view ($spirit_component_file->findnodes("//ipxact:component/ipxact:model/ipxact:views/ipxact:view/ipxact:envIdentifier[./text() = '$envidentifier']")) 
      {
      my($view_name)     = $comp_view->findnodes('../ipxact:name/text()')->to_literal ;
      my($view_fileset)  = $comp_view->findnodes('../ipxact:fileSetRef/ipxact:localName/text()')->to_literal ;
#      print "    VVVVVVVVVVVVVV    Found  $view_name  $view_fileset    \n" ;

    #/**********************************************************************/
    #/*                                                                    */
    #/* build a fileset in the following order                             */
    #/*                                                                    */
    #/* deflist for module names                                           */
    #/* all include files                                                  */
    #/* all module files                                                   */
    #/*                                                                    */
    #/*                                                                    */
    #/**********************************************************************/
   


   
    foreach  my   $i_name ($spirit_component_file->findnodes("//ipxact:fileSets/ipxact:fileSet/ipxact:file/ipxact:name"))
       {      
       my($file_name)          = $i_name ->findnodes('./text()')->to_literal ;
       my($file_logicalname)   = $i_name ->findnodes('../ipxact:logicalName/text()')->to_literal ;
       my($file_type)          = $i_name ->findnodes('../ipxact:fileType/text()')->to_literal ;
       my($file_usertype)      = $i_name ->findnodes('../ipxact:userFileType/text()')->to_literal ;
       my($view_file)          = $i_name ->findnodes('../../ipxact:name/text()')->to_literal ;



       if(($file_usertype eq "libraryDir")&& ($view_file eq $view_fileset)  &&   ($file_type eq "verilogSource")        )
         { 
#          print "       VVVVVMVV   ${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${file_name}\n";
        push @search_paths,  "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${file_name}";
         };


       if(($file_usertype eq "module") && ($view_file eq $view_fileset) &&   ($file_type eq "verilogSource")                     )
         { 

#          print "       VVVVVIVV   ${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${file_name}\n";
#         print FILELIST  "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${file_name}\n";
         if($file_logicalname )    
            {
            print  DEFLIST   sprintf( "\`define %s   _%s\n",   uc($file_logicalname) ,  $file_logicalname );
            }
         };
       }
      }
     }
   }
      #/**********************************************************************/
      #/*                                                                    */
      #/* Every leaf cell is processed through a the verilog preprocessor    */
      #/* to customize the module names,remove all verilog tic(`) statements */
      #/* and to create seperate versions for simulation and synthesys       */
      #/*                                                                    */
      #/*                                                                    */
      #/**********************************************************************/



        if(defined $configuration && length $configuration >0 )
             {
             $file_out  = "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/${view}/${variant}_${configuration}.v";
             }
        else
             {
             $file_out  = "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/${view}/${variant}.v";
             }

        if( -e $file_out )
        {
        $cmd ="rm  $file_out \n";
        if (system($cmd)) {}
        };
      
        my $cmd_path;

        foreach $search_path (@search_paths) 
              {        
               $cmd_path = " $cmd_path -I${search_path} " ;
              }




        if(defined $configuration && length $configuration >0 )
             {
        $cmd ="vppreproc --noline --noblank  $cmd_path  -f  ${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}.INC  -f  ${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}_${configuration}.MOD    >>  $file_out \n";
             }
        else
             {
        $cmd ="vppreproc --noline --noblank  $cmd_path  -f  ${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}.INC  -f  ${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}.MOD    >>  $file_out \n";
             }







        if (system($cmd)) {}




   

      
  
 

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.