URL
https://opencores.org/ocsvn/socgen/socgen/trunk
Subversion Repositories socgen
[/] [socgen/] [trunk/] [tools/] [simulation/] [build_lint_filelists] - 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",
"work_site=s" => \$work_site,
"vendor=s" => \$vendor,
"library=s" => \$library,
"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 -library library_name -component component_name ";
print "\n";
exit 1;
}
##############################################################################
##
##############################################################################
$home = cwd();
my $child_dir = yp::lib::get_child_dir;
my $variant = "";
if($version) {$variant = "${component}_${version}"}
else {$variant = "${component}"}
#############################################################################
##
##
#############################################################################
my $parser = XML::LibXML->new();
#/*********************************************************************************************/
#/ */
#/ Create filelists for simulation and linting */
#/ */
#/ */
#/*********************************************************************************************/
@filelist_sim = ( );
my @filelist = yp::lib::parse_component_file("$vendor","$library","$component","$version");
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_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_vendor eq $vendor ) && ($new_proj eq $library ) && ($new_comp eq $component ) && ($new_version eq $version ) )
{
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_type) = $i_name ->findnodes('../ipxact:userFileType/text()')->to_literal ;
my($logical_name) = $i_name ->findnodes('../ipxact:logicalName/text()')->to_literal ;
my($view_file) = $i_name ->findnodes('../../ipxact:name/text()')->to_literal ;
my $comp_xml_sep = yp::lib::find_comp_xml_sep($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}${comp_xml_sep}/${file_name}${new_variant}.v\n");
};
}
}
else
{
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_type) = $i_name ->findnodes('../ipxact:userFileType/text()')->to_literal ;
my($logical_name) = $i_name ->findnodes('../ipxact:logicalName/text()')->to_literal ;
my($view_file) = $i_name ->findnodes('../../ipxact:name/text()')->to_literal ;
my $comp_xml_sep = yp::lib::find_comp_xml_sep($new_vendor,$new_proj,$new_comp,$new_version);
my $lib_comp_sep = yp::lib::find_lib_comp_sep($new_vendor,$new_proj,$new_comp);
my $library_path = "${lib_comp_sep}${component}${comp_xml_sep}";
if(($file_type eq "libraryDir")&& (($view_file eq "fs-lint") ) && ($logical_name eq "dest_dir") )
{
push(@filelist_sim,"../../../../../../${child_dir}/${new_vendor}__${new_proj}${library_path}/${file_name}${new_variant}.v\n");
};
}
}
}
#############################################################################
##
##
#############################################################################
print "Building rtl_check filelists for $work_site $vendor $library $component $version $variant \n" ;
my $spirit_component_file = $parser->parse_file(yp::lib::find_ipxact_component($vendor,$library,$component,$version));
my $socgen_file = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$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 ($socgen_file->findnodes("//socgen:testbenches/socgen:testbench[socgen:variant/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('//ipxact:component'))
{
my($vendor) = $comp->findnodes('./ipxact:vendor/text()')->to_literal ;
my($library) = $comp->findnodes('./ipxact:library/text()')->to_literal ;
my($name) = $comp->findnodes('./ipxact:name/text()')->to_literal ;
my($version) = $comp->findnodes('./ipxact:version/text()')->to_literal ;
my $variant = "";
if($version) {$variant = "${name}_${version}"}
else {$variant = "${name}"}
print "rtl/gen directories for $library - $component VLNV $vendor - $library - $name - $variant \n";
}
push(@filelist_sim," ./TestBench\n");
print "CREATING componentRef filelists for $library $component $name $variant \n";
@filelist_sim = sys::lib::trim_sort(@filelist_sim);
#/*********************************************************************************************/
#/ */
#/ Make simulation file set */
#/ */
#/ */
#/ */
#/ */
#/*********************************************************************************************/
print "CREATING sim files for $library $component $chip $name $variant \n";
my $socgen_file = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));
foreach my $i_name ($socgen_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 $library $component $variant $simulation $configuration \n";
my $sim_library_path ;
my $lib_comp_sep = yp::lib::find_lib_comp_sep($vendor,$library,$component);
my $sim_comp_path = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:comp_path/text()")->to_literal;
if ($sim_comp_path)
{
$sim_library_path ="${lib_comp_sep}${sim_comp_path}";
}
else
{
$sim_library_path = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:library_path/text()")->to_literal;
}
my $path = "${home}${work_site}/${vendor}__${library}${sim_library_path}/rtl_check";
mkdir $path,0755 unless (-e $path) ;
$path = "${home}${work_site}/${vendor}__${library}${sim_library_path}/rtl_check/${simulation}";
mkdir $path,0755 unless (-e $path);
$outfile ="${home}${work_site}/${vendor}__${library}${sim_library_path}/rtl_check/${simulation}/TestBench";
open SIM_PARM_FILE,">$outfile" or die "unable to open $outfile";
my %local_parameters = %default_parameters;
my @local_order = @parameter_order;
foreach my $i_name ($socgen_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 ($socgen_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;
}
my $module_name = yp::lib::get_module_name($vendor,$library,$component,$version);
print SIM_PARM_FILE "// Testbench for $library $component $variant $configuration $simulation\n";
print SIM_PARM_FILE " \n";
print SIM_PARM_FILE "module TB(input clk,input reset); \n";
print SIM_PARM_FILE " \n\n";
print SIM_PARM_FILE " $module_name \n";
my $first =1;
foreach my $parameter_name (@local_order)
{
my($parameter_default) = $local_parameters{$parameter_name};
# if a parameter is used to define a paramter then use its value instead. Only works for lookup- no alterations
if($local_parameters{$parameter_default}) { $parameter_default = $local_parameters{$parameter_default} }
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 (.clk(clk),.reset(reset)); \n\n\n\n endmodule \n ";
}