| 1 |
119 |
jt_eaton |
eval 'exec `which perl` -S $0 ${1+"$@"}'
|
| 2 |
|
|
if 0;
|
| 3 |
|
|
#/**********************************************************************/
|
| 4 |
|
|
#/* */
|
| 5 |
|
|
#/* ------- */
|
| 6 |
|
|
#/* / SOC \ */
|
| 7 |
|
|
#/* / GEN \ */
|
| 8 |
|
|
#/* / TOOL \ */
|
| 9 |
|
|
#/* ============== */
|
| 10 |
|
|
#/* | | */
|
| 11 |
|
|
#/* |____________| */
|
| 12 |
|
|
#/* */
|
| 13 |
|
|
#/* */
|
| 14 |
|
|
#/* */
|
| 15 |
|
|
#/* Author(s): */
|
| 16 |
|
|
#/* - John Eaton, jt_eaton@opencores.org */
|
| 17 |
|
|
#/* */
|
| 18 |
|
|
#/**********************************************************************/
|
| 19 |
|
|
#/* */
|
| 20 |
|
|
#/* Copyright (C) <2010-2012> */
|
| 21 |
|
|
#/* */
|
| 22 |
|
|
#/* This source file may be used and distributed without */
|
| 23 |
|
|
#/* restriction provided that this copyright statement is not */
|
| 24 |
|
|
#/* removed from the file and that any derivative work contains */
|
| 25 |
|
|
#/* the original copyright notice and the associated disclaimer. */
|
| 26 |
|
|
#/* */
|
| 27 |
|
|
#/* This source file is free software; you can redistribute it */
|
| 28 |
|
|
#/* and/or modify it under the terms of the GNU Lesser General */
|
| 29 |
|
|
#/* Public License as published by the Free Software Foundation; */
|
| 30 |
|
|
#/* either version 2.1 of the License, or (at your option) any */
|
| 31 |
|
|
#/* later version. */
|
| 32 |
|
|
#/* */
|
| 33 |
|
|
#/* This source is distributed in the hope that it will be */
|
| 34 |
|
|
#/* useful, but WITHOUT ANY WARRANTY; without even the implied */
|
| 35 |
|
|
#/* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR */
|
| 36 |
|
|
#/* PURPOSE. See the GNU Lesser General Public License for more */
|
| 37 |
|
|
#/* details. */
|
| 38 |
|
|
#/* */
|
| 39 |
|
|
#/* You should have received a copy of the GNU Lesser General */
|
| 40 |
|
|
#/* Public License along with this source; if not, download it */
|
| 41 |
|
|
#/* from http://www.opencores.org/lgpl.shtml */
|
| 42 |
|
|
#/* */
|
| 43 |
|
|
#/**********************************************************************/
|
| 44 |
|
|
|
| 45 |
|
|
|
| 46 |
|
|
|
| 47 |
|
|
############################################################################
|
| 48 |
|
|
# General PERL config
|
| 49 |
|
|
############################################################################
|
| 50 |
|
|
use Getopt::Long;
|
| 51 |
|
|
use English;
|
| 52 |
|
|
use File::Basename;
|
| 53 |
|
|
use Cwd;
|
| 54 |
|
|
use XML::LibXML;
|
| 55 |
|
|
use lib './tools';
|
| 56 |
|
|
use sys::lib;
|
| 57 |
|
|
use yp::lib;
|
| 58 |
|
|
|
| 59 |
|
|
|
| 60 |
|
|
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
|
| 61 |
|
|
|
| 62 |
|
|
|
| 63 |
|
|
############################################################################
|
| 64 |
|
|
### Process the options
|
| 65 |
|
|
############################################################################
|
| 66 |
|
|
|
| 67 |
|
|
Getopt::Long::config("require_order", "prefix=-");
|
| 68 |
|
|
GetOptions("h","help",
|
| 69 |
|
|
"view=s" => \$view,
|
| 70 |
|
|
"prefix=s" => \$prefix,
|
| 71 |
|
|
"vendor=s" => \$vendor,
|
| 72 |
|
|
"project=s" => \$project,
|
| 73 |
|
|
"component=s" => \$component,
|
| 74 |
|
|
"version=s" => \$version,
|
| 75 |
|
|
"dest_dir=s" => \$dest_dir
|
| 76 |
|
|
) || die "(use '$program_name -h' for help)";
|
| 77 |
|
|
|
| 78 |
|
|
|
| 79 |
|
|
##############################################################################
|
| 80 |
|
|
## Help option
|
| 81 |
|
|
##############################################################################
|
| 82 |
|
|
if ( $opt_h or ($opt_help) )
|
| 83 |
|
|
{
|
| 84 |
|
|
print "\n gen_verilogLib -view {sim|syn} -prefix /work -vendor vendor_name -project project_name -component component_name -version version_name -dest_dir dest_dir";
|
| 85 |
|
|
print "\n";
|
| 86 |
|
|
exit 1;
|
| 87 |
|
|
}
|
| 88 |
|
|
|
| 89 |
|
|
|
| 90 |
|
|
##############################################################################
|
| 91 |
|
|
##
|
| 92 |
|
|
##############################################################################
|
| 93 |
|
|
|
| 94 |
|
|
|
| 95 |
|
|
|
| 96 |
|
|
$home = cwd();
|
| 97 |
|
|
my $variant;
|
| 98 |
|
|
|
| 99 |
|
|
if($version) {$variant = "${component}_${version}";}
|
| 100 |
|
|
else {$variant = "${component}";}
|
| 101 |
|
|
|
| 102 |
|
|
my $lib_comp_sep = yp::lib::find_lib_comp_sep($vendor,$project);
|
| 103 |
|
|
my $comp_xml_sep = yp::lib::find_ipxact_component_path("spirit:component",$vendor,$project,$component,$version);
|
| 104 |
|
|
|
| 105 |
|
|
#############################################################################
|
| 106 |
|
|
##
|
| 107 |
|
|
##
|
| 108 |
|
|
#############################################################################
|
| 109 |
|
|
|
| 110 |
|
|
print "\n Building $view Verilog Lib RTL for $prefix $project $component $verison $variant $dest_dir \n" ;
|
| 111 |
|
|
|
| 112 |
|
|
my $path = "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}";
|
| 113 |
|
|
mkdir $path,0755 unless( -e $path );
|
| 114 |
|
|
|
| 115 |
|
|
my $path = "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}/${view}";
|
| 116 |
|
|
mkdir $path,0755 unless( -e $path );
|
| 117 |
|
|
|
| 118 |
|
|
my $parser = XML::LibXML->new();
|
| 119 |
|
|
my $spirit_component_file = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$vendor,$project,$component,$version));
|
| 120 |
|
|
|
| 121 |
|
|
|
| 122 |
|
|
foreach my $comp_view ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:name[./text() = '$view']"))
|
| 123 |
|
|
{
|
| 124 |
|
|
my($view_fileset) = $comp_view->findnodes('../spirit:fileSetRef/spirit:localName/text()')->to_literal ;
|
| 125 |
|
|
|
| 126 |
|
|
#/**********************************************************************/
|
| 127 |
|
|
#/* */
|
| 128 |
|
|
#/* build a `define file for module names */
|
| 129 |
|
|
#/* */
|
| 130 |
|
|
#/* */
|
| 131 |
|
|
#/* */
|
| 132 |
|
|
#/* */
|
| 133 |
|
|
#/**********************************************************************/
|
| 134 |
|
|
|
| 135 |
|
|
my $outfile ="${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}/deflist";
|
| 136 |
|
|
open DEFLIST,">$outfile" or die "unable to open $outfile";
|
| 137 |
|
|
print DEFLIST " \n";
|
| 138 |
|
|
foreach my $i_name ($spirit_component_file->findnodes("//spirit:fileSets/spirit:fileSet/spirit:file/spirit:logicalName"))
|
| 139 |
|
|
{
|
| 140 |
|
|
my($def_logic) = $i_name ->findnodes('./text()')->to_literal ;
|
| 141 |
|
|
if($def_logic ) {print DEFLIST sprintf( "\`define %s _%s\n", uc($def_logic) , $def_logic );}
|
| 142 |
|
|
}
|
| 143 |
|
|
|
| 144 |
|
|
|
| 145 |
|
|
#/**********************************************************************/
|
| 146 |
|
|
#/* */
|
| 147 |
|
|
#/* build a fileset in the following order */
|
| 148 |
|
|
#/* */
|
| 149 |
|
|
#/* deflist for module names */
|
| 150 |
|
|
#/* all include files */
|
| 151 |
120 |
jt_eaton |
#/* all module files */
|
| 152 |
119 |
jt_eaton |
#/* */
|
| 153 |
|
|
#/* */
|
| 154 |
|
|
#/**********************************************************************/
|
| 155 |
|
|
|
| 156 |
|
|
my $outfile ="${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}/filelist";
|
| 157 |
|
|
open FILELIST,">$outfile" or die "unable to open $outfile";
|
| 158 |
|
|
|
| 159 |
|
|
print FILELIST "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}/deflist\n";
|
| 160 |
|
|
|
| 161 |
|
|
foreach my $i_name ($spirit_component_file->findnodes("//spirit:fileSets/spirit:fileSet/spirit:file/spirit:name"))
|
| 162 |
|
|
{
|
| 163 |
|
|
my($file_name) = $i_name ->findnodes('./text()')->to_literal ;
|
| 164 |
120 |
jt_eaton |
my($file_type) = $i_name ->findnodes('../spirit:userFileType/text()')->to_literal ;
|
| 165 |
119 |
jt_eaton |
my($view_file) = $i_name ->findnodes('../../spirit:name/text()')->to_literal ;
|
| 166 |
120 |
jt_eaton |
if(($file_type eq "include")&& (($view_file eq $view_fileset)))
|
| 167 |
119 |
jt_eaton |
{ print FILELIST "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${file_name}\n"};
|
| 168 |
|
|
}
|
| 169 |
|
|
|
| 170 |
|
|
foreach my $i_name ($spirit_component_file->findnodes("//spirit:fileSets/spirit:fileSet/spirit:file/spirit:name"))
|
| 171 |
|
|
{
|
| 172 |
|
|
my($file_name) = $i_name ->findnodes('./text()')->to_literal ;
|
| 173 |
120 |
jt_eaton |
my($file_type) = $i_name ->findnodes('../spirit:userFileType/text()')->to_literal ;
|
| 174 |
119 |
jt_eaton |
my($view_file) = $i_name ->findnodes('../../spirit:name/text()')->to_literal ;
|
| 175 |
120 |
jt_eaton |
if(($file_type eq "module")&& (($view_file eq $view_fileset)))
|
| 176 |
119 |
jt_eaton |
{ print FILELIST "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${file_name}\n"};
|
| 177 |
|
|
}
|
| 178 |
|
|
|
| 179 |
|
|
|
| 180 |
|
|
|
| 181 |
|
|
#/**********************************************************************/
|
| 182 |
|
|
#/* */
|
| 183 |
|
|
#/* Every leaf cell is processed through a the verilog preprocessor */
|
| 184 |
|
|
#/* to customize the module names,remove all verilog tic(`) statements */
|
| 185 |
|
|
#/* and to create seperate versions for simulation and synthesys */
|
| 186 |
|
|
#/* */
|
| 187 |
|
|
#/* */
|
| 188 |
|
|
#/**********************************************************************/
|
| 189 |
|
|
|
| 190 |
|
|
|
| 191 |
|
|
my $file_out = "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}/${view}/${variant}.v";
|
| 192 |
|
|
|
| 193 |
|
|
if( -e $file_out )
|
| 194 |
|
|
{
|
| 195 |
|
|
$cmd ="rm $file_out \n";
|
| 196 |
|
|
if (system($cmd)) {}
|
| 197 |
|
|
};
|
| 198 |
|
|
|
| 199 |
|
|
$cmd ="vppreproc --noline --noblank -DVARIANT=${variant} -I${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/../verilog -f ${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}/filelist >> $file_out \n";
|
| 200 |
|
|
|
| 201 |
|
|
if (system($cmd)) {}
|
| 202 |
|
|
|
| 203 |
|
|
|
| 204 |
|
|
|
| 205 |
|
|
|
| 206 |
|
|
|
| 207 |
|
|
|
| 208 |
|
|
|
| 209 |
|
|
}
|
| 210 |
|
|
|
| 211 |
|
|
|
| 212 |
|
|
1
|
| 213 |
|
|
|
| 214 |
|
|
|
| 215 |
|
|
|
| 216 |
|
|
|
| 217 |
|
|
|
| 218 |
|
|
|
| 219 |
|
|
|
| 220 |
|
|
|
| 221 |
|
|
|
| 222 |
|
|
|
| 223 |
|
|
|
| 224 |
|
|
|
| 225 |
|
|
|
| 226 |
|
|
|
| 227 |
|
|
|