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 |
128 |
jt_eaton |
"envidentifier=s" => \$envidentifier,
|
70 |
119 |
jt_eaton |
"prefix=s" => \$prefix,
|
71 |
|
|
"vendor=s" => \$vendor,
|
72 |
|
|
"project=s" => \$project,
|
73 |
|
|
"component=s" => \$component,
|
74 |
|
|
"version=s" => \$version,
|
75 |
128 |
jt_eaton |
"dest_dir=s" => \$dest_dir,
|
76 |
|
|
"view=s" => \$view
|
77 |
119 |
jt_eaton |
) || die "(use '$program_name -h' for help)";
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
##############################################################################
|
81 |
|
|
## Help option
|
82 |
|
|
##############################################################################
|
83 |
|
|
if ( $opt_h or ($opt_help) )
|
84 |
|
|
{
|
85 |
128 |
jt_eaton |
print "\n gen_verilogLib -envidentifier *simulation* -prefix /work -vendor vendor_name -project project_name -component component_name -version version_name -dest_dir dest_dir";
|
86 |
119 |
jt_eaton |
print "\n";
|
87 |
|
|
exit 1;
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
##############################################################################
|
92 |
|
|
##
|
93 |
|
|
##############################################################################
|
94 |
|
|
|
95 |
128 |
jt_eaton |
my $parser = XML::LibXML->new();
|
96 |
119 |
jt_eaton |
|
97 |
128 |
jt_eaton |
my $sogen_file = $parser->parse_file(yp::lib::find_socgen("socgen:componentConfiguration",$vendor,$project,$component));
|
98 |
|
|
my $ip_name_base_macro = $sogen_file->findnodes("//socgen:componentConfiguration/socgen:ip_name_base_macro/text()")->to_literal;
|
99 |
119 |
jt_eaton |
|
100 |
128 |
jt_eaton |
|
101 |
|
|
|
102 |
|
|
|
103 |
119 |
jt_eaton |
$home = cwd();
|
104 |
128 |
jt_eaton |
my @search_paths = ();
|
105 |
119 |
jt_eaton |
my $variant;
|
106 |
|
|
|
107 |
128 |
jt_eaton |
|
108 |
119 |
jt_eaton |
if($version) {$variant = "${component}_${version}";}
|
109 |
|
|
else {$variant = "${component}";}
|
110 |
|
|
|
111 |
127 |
jt_eaton |
my $lib_comp_sep = yp::lib::find_lib_comp_sep($vendor,$project,$component);
|
112 |
119 |
jt_eaton |
my $comp_xml_sep = yp::lib::find_ipxact_component_path("spirit:component",$vendor,$project,$component,$version);
|
113 |
128 |
jt_eaton |
my $module_name = yp::lib::get_module_name($vendor,$project,$component,$version);
|
114 |
119 |
jt_eaton |
|
115 |
|
|
|
116 |
128 |
jt_eaton |
|
117 |
|
|
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
|
|
my $parser = XML::LibXML->new();
|
123 |
|
|
my $spirit_component_file = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$vendor,$project,$component,$version));
|
124 |
|
|
|
125 |
|
|
|
126 |
|
|
|
127 |
|
|
|
128 |
119 |
jt_eaton |
print "\n Building $view Verilog Lib RTL for $prefix $project $component $verison $variant $dest_dir \n" ;
|
129 |
|
|
|
130 |
|
|
my $path = "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}";
|
131 |
|
|
mkdir $path,0755 unless( -e $path );
|
132 |
|
|
|
133 |
128 |
jt_eaton |
|
134 |
|
|
my $path = "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}/../defines";
|
135 |
|
|
mkdir $path,0755 unless( -e $path );
|
136 |
|
|
|
137 |
|
|
my $path = "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}/../filelists";
|
138 |
|
|
mkdir $path,0755 unless( -e $path );
|
139 |
|
|
|
140 |
|
|
|
141 |
119 |
jt_eaton |
my $path = "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}/${view}";
|
142 |
|
|
mkdir $path,0755 unless( -e $path );
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
#/**********************************************************************/
|
147 |
|
|
#/* */
|
148 |
|
|
#/* build a `define file for module names */
|
149 |
|
|
#/* */
|
150 |
|
|
#/* */
|
151 |
|
|
#/* */
|
152 |
|
|
#/* */
|
153 |
|
|
#/**********************************************************************/
|
154 |
|
|
|
155 |
128 |
jt_eaton |
my $outfile ="${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}/../defines/${variant}.v";
|
156 |
119 |
jt_eaton |
open DEFLIST,">$outfile" or die "unable to open $outfile";
|
157 |
128 |
jt_eaton |
print DEFLIST " \`define $ip_name_base_macro ${module_name} \n";
|
158 |
|
|
|
159 |
|
|
my $outfile ="${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}.MOD";
|
160 |
|
|
open FILELIST,">$outfile" or die "unable to open $outfile";
|
161 |
|
|
|
162 |
|
|
my $outfile ="${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}.INC";
|
163 |
|
|
open INCLIST,">$outfile" or die "unable to open $outfile";
|
164 |
|
|
|
165 |
|
|
print INCLIST "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}/../defines/${variant}.v\n";
|
166 |
|
|
|
167 |
|
|
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
|
171 |
|
|
#print " FFFFFFFFFFFFFFFF $envidentifier $view \n" ;
|
172 |
|
|
|
173 |
|
|
|
174 |
|
|
my @filelist = yp::lib::parse_component_brothers("$vendor","$project","$component","$version");
|
175 |
|
|
|
176 |
|
|
foreach $line (@filelist)
|
177 |
|
|
{
|
178 |
|
|
$_ = $line;
|
179 |
|
|
if(/::(\S+)::(\S+)::(\S+)::(\S+)::/)
|
180 |
|
|
{
|
181 |
|
|
$new_project = $2;
|
182 |
|
|
$new_component = $3;
|
183 |
|
|
$new_vendor = $1;
|
184 |
|
|
$new_version = $4;
|
185 |
|
|
|
186 |
|
|
# print " FFFFFFFFFFFFFFFF Brother $new_vendor $new_project $new_component $new_version \n" ;
|
187 |
|
|
|
188 |
|
|
my $spirit_component_file = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$new_vendor,$new_project,$new_component,$new_version));
|
189 |
|
|
|
190 |
|
|
foreach my $comp_view ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:envIdentifier[./text() = '$envidentifier']"))
|
191 |
|
|
{
|
192 |
|
|
my($view_name) = $comp_view->findnodes('../spirit:name/text()')->to_literal ;
|
193 |
|
|
my($view_fileset) = $comp_view->findnodes('../spirit:fileSetRef/spirit:localName/text()')->to_literal ;
|
194 |
|
|
# print " FFFFFFFFFFFFFFFF Found $view_name $view_fileset \n" ;
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
|
198 |
|
|
|
199 |
|
|
|
200 |
119 |
jt_eaton |
#/**********************************************************************/
|
201 |
|
|
#/* */
|
202 |
|
|
#/* build a fileset in the following order */
|
203 |
|
|
#/* */
|
204 |
|
|
#/* deflist for module names */
|
205 |
|
|
#/* all include files */
|
206 |
120 |
jt_eaton |
#/* all module files */
|
207 |
119 |
jt_eaton |
#/* */
|
208 |
|
|
#/* */
|
209 |
|
|
#/**********************************************************************/
|
210 |
|
|
|
211 |
128 |
jt_eaton |
|
212 |
119 |
jt_eaton |
|
213 |
|
|
foreach my $i_name ($spirit_component_file->findnodes("//spirit:fileSets/spirit:fileSet/spirit:file/spirit:name"))
|
214 |
|
|
{
|
215 |
128 |
jt_eaton |
my($file_name) = $i_name ->findnodes('./text()')->to_literal ;
|
216 |
|
|
my($file_logicalname) = $i_name ->findnodes('../spirit:logicalName/text()')->to_literal ;
|
217 |
|
|
my($file_type) = $i_name ->findnodes('../spirit:fileType/text()')->to_literal ;
|
218 |
|
|
my($file_usertype) = $i_name ->findnodes('../spirit:userFileType/text()')->to_literal ;
|
219 |
|
|
my($view_file) = $i_name ->findnodes('../../spirit:name/text()')->to_literal ;
|
220 |
|
|
|
221 |
|
|
# print " FFFFFFFFFFFFFFFX $file_name $file_logicalname $file_type $file_usertype $view_file \n" ;
|
222 |
|
|
|
223 |
|
|
|
224 |
|
|
if(($file_usertype eq "include")&& ($view_file eq $view_fileset) && ($file_type eq "verilogSource") )
|
225 |
|
|
{
|
226 |
|
|
print INCLIST "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${file_name}\n";
|
227 |
|
|
};
|
228 |
|
|
|
229 |
|
|
|
230 |
|
|
if(($file_usertype eq "libraryDir")&& ($view_file eq $view_fileset) && ($file_type eq "verilogSource") )
|
231 |
|
|
{
|
232 |
|
|
push @search_paths, "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${file_name}";
|
233 |
|
|
};
|
234 |
|
|
|
235 |
|
|
|
236 |
|
|
if(($file_usertype eq "module") && ($view_file eq $view_fileset) && ($file_type eq "verilogSource") )
|
237 |
|
|
{
|
238 |
|
|
print FILELIST "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${file_name}\n";
|
239 |
|
|
if($file_logicalname )
|
240 |
|
|
{
|
241 |
|
|
print DEFLIST sprintf( "\`define %s _%s\n", uc($file_logicalname) , $file_logicalname );
|
242 |
|
|
}
|
243 |
|
|
};
|
244 |
|
|
|
245 |
|
|
|
246 |
119 |
jt_eaton |
}
|
247 |
128 |
jt_eaton |
|
248 |
|
|
|
249 |
|
|
|
250 |
|
|
|
251 |
|
|
|
252 |
|
|
}
|
253 |
|
|
}
|
254 |
|
|
}
|
255 |
|
|
|
256 |
119 |
jt_eaton |
|
257 |
|
|
#/**********************************************************************/
|
258 |
|
|
#/* */
|
259 |
|
|
#/* Every leaf cell is processed through a the verilog preprocessor */
|
260 |
|
|
#/* to customize the module names,remove all verilog tic(`) statements */
|
261 |
|
|
#/* and to create seperate versions for simulation and synthesys */
|
262 |
|
|
#/* */
|
263 |
|
|
#/* */
|
264 |
|
|
#/**********************************************************************/
|
265 |
|
|
|
266 |
|
|
|
267 |
|
|
my $file_out = "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}/${view}/${variant}.v";
|
268 |
|
|
|
269 |
|
|
if( -e $file_out )
|
270 |
|
|
{
|
271 |
|
|
$cmd ="rm $file_out \n";
|
272 |
|
|
if (system($cmd)) {}
|
273 |
|
|
};
|
274 |
128 |
jt_eaton |
|
275 |
|
|
my $cmd_path;
|
276 |
119 |
jt_eaton |
|
277 |
128 |
jt_eaton |
foreach $search_path (@search_paths)
|
278 |
|
|
{
|
279 |
|
|
$cmd_path = " $cmd_path -I${search_path} " ;
|
280 |
|
|
}
|
281 |
119 |
jt_eaton |
|
282 |
128 |
jt_eaton |
|
283 |
|
|
|
284 |
|
|
$cmd ="vppreproc --noline --noblank $cmd_path -f ${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}.INC -f ${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}${comp_xml_sep}/${dest_dir}/../filelists/${variant}.MOD >> $file_out \n";
|
285 |
|
|
|
286 |
119 |
jt_eaton |
if (system($cmd)) {}
|
287 |
|
|
|
288 |
|
|
|
289 |
|
|
|
290 |
|
|
|
291 |
|
|
|
292 |
|
|
|
293 |
|
|
|
294 |
128 |
jt_eaton |
|
295 |
119 |
jt_eaton |
|
296 |
|
|
|
297 |
|
|
1
|
298 |
|
|
|
299 |
|
|
|
300 |
|
|
|
301 |
|
|
|
302 |
|
|
|
303 |
|
|
|
304 |
|
|
|
305 |
|
|
|
306 |
|
|
|
307 |
|
|
|
308 |
|
|
|
309 |
|
|
|
310 |
|
|
|
311 |
|
|
|
312 |
|
|
|