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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [simulation/] [build_verilator_filelists] - Blame information for rev 128

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 125 jt_eaton
eval 'exec `which perl` -S $0 ${1+"$@"}'
2
   if 0;
3
 
4
#/**********************************************************************/
5
#/*                                                                    */
6
#/*             -------                                                */
7
#/*            /   SOC  \                                              */
8
#/*           /    GEN   \                                             */
9
#/*          /    TOOL    \                                            */
10
#/*          ==============                                            */
11
#/*          |            |                                            */
12
#/*          |____________|                                            */
13
#/*                                                                    */
14
#/*                                                                    */
15
#/*                                                                    */
16
#/*  Author(s):                                                        */
17
#/*      - John Eaton, jt_eaton@opencores.org                          */
18
#/*                                                                    */
19
#/**********************************************************************/
20
#/*                                                                    */
21
#/*    Copyright (C) <2010-2011>                */
22
#/*                                                                    */
23
#/*  This source file may be used and distributed without              */
24
#/*  restriction provided that this copyright statement is not         */
25
#/*  removed from the file and that any derivative work contains       */
26
#/*  the original copyright notice and the associated disclaimer.      */
27
#/*                                                                    */
28
#/*  This source file is free software; you can redistribute it        */
29
#/*  and/or modify it under the terms of the GNU Lesser General        */
30
#/*  Public License as published by the Free Software Foundation;      */
31
#/*  either version 2.1 of the License, or (at your option) any        */
32
#/*  later version.                                                    */
33
#/*                                                                    */
34
#/*  This source is distributed in the hope that it will be            */
35
#/*  useful, but WITHOUT ANY WARRANTY; without even the implied        */
36
#/*  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR           */
37
#/*  PURPOSE.  See the GNU Lesser General Public License for more      */
38
#/*  details.                                                          */
39
#/*                                                                    */
40
#/*  You should have received a copy of the GNU Lesser General         */
41
#/*  Public License along with this source; if not, download it        */
42
#/*  from http://www.opencores.org/lgpl.shtml                          */
43
#/*                                                                    */
44
#/**********************************************************************/
45
 
46
 
47
 
48
 
49
############################################################################
50
# General PERL config
51
############################################################################
52
use Getopt::Long;
53
use English;
54
use File::Basename;
55
use Cwd;
56
use XML::LibXML;
57
use lib './tools';
58
use sys::lib;
59
use yp::lib;
60
 
61
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
62
 
63
 
64
############################################################################
65
### Process the options
66
############################################################################
67
Getopt::Long::config("require_order", "prefix=-");
68
GetOptions("h","help",
69
           "work_site=s" => \$work_site,
70
           "vendor=s" => \$vendor,
71
           "project=s" => \$project,
72
           "component=s" => \$component,
73
           "version=s" => \$version
74
) || die "(use '$program_name -h' for help)";
75
 
76
 
77
 
78
##############################################################################
79
## Help option
80
##############################################################################
81
if ( $opt_h  or $opt_help)
82
  { print "\n build_sim_filelists -work_site /work  -vendor vendor_name  -project project_name  -component component_name   ";
83
    print "\n";
84
    exit 1;
85
  }
86
 
87
 
88
##############################################################################
89
##
90
##############################################################################
91
 
92
 
93
 
94
$home = cwd();
95
 
96
my $variant = "";
97
if($version) {$variant = "${component}_${version}"}
98
else         {$variant = "${component}"}
99
 
100
#############################################################################
101
##
102
##
103
#############################################################################
104
 
105
my $parser = XML::LibXML->new();
106
 
107
 
108
 
109
 
110
 
111
 
112
 
113
 
114
 
115
#############################################################################
116
##
117
##
118
#############################################################################
119
 
120
print "Building SIM filelists for  $work_site  $vendor $project   $component $version $variant \n" ;
121
 
122
my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$vendor,$project,$component,$version));
123
my $sogen_file           = $parser->parse_file(yp::lib::find_socgen("socgen:componentConfiguration",$vendor,$project,$component));
124
 
125 127 jt_eaton
my $sim_library_path = $sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:library_path/text()")->to_literal;
126 125 jt_eaton
 
127
 
128
 
129
#/*********************************************************************************************/
130
#/                                                                                            */
131
#/                                                                                            */
132
#/  Read each variants parameters and defaults into an array and their order into an array    */
133
#/  order must be preservered so that parameters can use the values of other parameters       */
134
#/                                                                                            */
135
#/*********************************************************************************************/
136
 
137
my %default_parameters = ();
138
my @parameter_order    = ();
139
 
140
 
141
foreach  my   $i_name ($sogen_file->findnodes("//socgen:configurations/socgen:configuration[socgen:name/text() = '$variant']/socgen:parameters/socgen:parameter"))
142
      {
143
      my($parameter_name)     = $i_name ->findnodes('socgen:name/text()')->to_literal ;
144
      my($parameter_default)  = $i_name ->findnodes('socgen:value/text()')->to_literal ;
145
      $default_parameters{$parameter_name}  = $parameter_default;
146
      push  @parameter_order ,$parameter_name ;
147
      }
148
 
149
 
150
 
151
 
152
 
153
 
154
 
155
 
156
 
157
foreach my $comp ($spirit_component_file->findnodes('//spirit:component'))
158
   {
159
   my($vendor)   = $comp->findnodes('./spirit:vendor/text()')->to_literal ;
160
   my($library)  = $comp->findnodes('./spirit:library/text()')->to_literal ;
161
   my($name)     = $comp->findnodes('./spirit:name/text()')->to_literal ;
162
   my($version)  = $comp->findnodes('./spirit:version/text()')->to_literal ;
163
   my $variant = "";
164
   if($version) {$variant = "${name}_${version}"}
165
   else         {$variant = "${name}"}
166
   print "rtl/gen directories  for    $project - $component         VLNV        $vendor - $library -  $name -  $variant \n";
167
   }
168
 
169
   print "CREATING componentRef filelists for   $project   $component  $name $variant \n";
170
 
171
 
172
   #/*********************************************************************************************/
173
   #/                                                                                            */
174
   #/                                                                                            */
175
   #/                                                                                            */
176
   #/                                                                                            */
177
   #/                                                                                            */
178
   #/                                                                                            */
179
   #/*********************************************************************************************/
180
 
181
 
182
foreach  my   $i_name ($sogen_file->findnodes("//socgen:testbench[socgen:variant/text() = '$variant']/socgen:code_coverage"))
183
   {
184 128 jt_eaton
 
185 127 jt_eaton
   my $path ="${home}${work_site}/${vendor}__${project}${sim_library_path}/cov";
186 125 jt_eaton
   mkdir $path,0755          unless( -e $path );
187 127 jt_eaton
   $path ="${home}${work_site}/${vendor}__${project}${sim_library_path}/cov/${variant}";
188 125 jt_eaton
   mkdir $path,0755          unless( -e $path );
189
 
190
 
191 127 jt_eaton
   my $outfile ="${home}${work_site}/${vendor}__${project}${sim_library_path}/cov/${variant}/TestBench";
192 125 jt_eaton
   open  DUTFILE,">$outfile" or die "unable to open $outfile";
193
   print  DUTFILE  "`timescale    1ns/1ns   \n";
194
   print  DUTFILE  " module TB();   \n";
195 128 jt_eaton
 
196
 
197
      print DUTFILE  "     $variant   \n";
198
      my $first =1;
199
      foreach  my  $parameter_name  (@parameter_order)
200
         {
201
         my($parameter_default)  =    $default_parameters{$parameter_name};
202
         if($first)
203
           {
204
           print DUTFILE  "   #(  .${parameter_name}(${parameter_default})";
205
           $first = 0;
206
           }
207
         else
208
           {
209
           print DUTFILE  ",\n       .${parameter_name}(${parameter_default})";
210
           }
211
         }
212
         if($first)
213
           {
214
           print DUTFILE  "  test \n (); \n\n\n\n";
215
           }
216
          else
217
           {
218
           print DUTFILE  ") test \n (); \n\n\n\n";
219
           }
220
 
221
 
222
   print  DUTFILE  " endmodule   \n";
223
 
224
 
225
 
226
 
227
 
228
 
229
 
230
 
231
 
232 125 jt_eaton
   }
233
 
234
 
235
 
236 128 jt_eaton
 
237
 
238
 
239
 
240
 
241
 
242
 
243
 
244
 
245
 
246
 
247
 
248
 
249
 
250
 
251
 
252
 
253
 
254
 
255
 
256
 
257
 
258
 
259 125 jt_eaton
   #/*********************************************************************************************/
260
   #/                                                                                            */
261
   #/ Make simulation file set                                                                   */
262
   #/                                                                                            */
263
   #/                                                                                            */
264
   #/                                                                                            */
265
   #/                                                                                            */
266
   #/*********************************************************************************************/
267
 
268
   print "CREATING sim files for   $project  $component   $chip   $name  $variant \n";
269
 
270
 
271
 
272
 
273
 
274
 
275
    foreach  my   $i_name ($sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:verilator/socgen:test[socgen:variant/text() = '$variant']"))
276
      {
277
      my($simulation)      = $i_name ->findnodes('socgen:name/text()')->to_literal ;
278
      my($configuration)   = $i_name ->findnodes('socgen:configuration/text()')->to_literal ;
279
      print " sim files for   $project  $component   $variant  $simulation $configuration          \n";
280
 
281 127 jt_eaton
      my $path ="${home}${work_site}/${vendor}__${project}${sim_library_path}/verilator";
282 125 jt_eaton
      mkdir $path,0755          unless( -e $path );
283 127 jt_eaton
      $path ="${home}${work_site}/${vendor}__${project}${sim_library_path}/verilator/${simulation}";
284 125 jt_eaton
      mkdir $path,0755          unless( -e $path );
285
 
286 127 jt_eaton
      my $outfile ="${home}${work_site}/${vendor}__${project}${sim_library_path}/verilator/${simulation}/Makefile";
287 125 jt_eaton
      open  MAKSIMFILE,">$outfile" or die "unable to open $outfile";
288
 
289
 
290 127 jt_eaton
      my $outfile ="${home}${work_site}/${vendor}__${project}${sim_library_path}/verilator/${simulation}/TestBench";
291 125 jt_eaton
      open SIM_PARM_FILE,">$outfile" or die "unable to open $outfile";
292
 
293
 
294
 
295
 
296
 
297
      my %local_parameters =  %default_parameters;
298
      my @local_order      =  @parameter_order;
299
 
300
 
301
 
302
      foreach  my   $i_name ($sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:testbenches/socgen:testbench[socgen:variant/text() = '$variant']/./socgen:parameters/socgen:parameter/socgen:name"))
303
         {
304
         my($par_name)   = $i_name ->findnodes('./text()')->to_literal ;
305
         my($par_value)  = $i_name ->findnodes('../socgen:value/text()')->to_literal ;
306
         if  ( $local_parameters{$par_name} eq '' )  { push @local_order , $par_name; }
307
         $local_parameters{$par_name} = $par_value;
308
         }
309
 
310
 
311
 
312
      foreach  my   $i_name ($sogen_file->findnodes("//socgen:configurations/socgen:configuration[socgen:name/text() = '$configuration']/./socgen:parameters/socgen:parameter/socgen:name"))
313
         {
314
         my($par_name)   = $i_name ->findnodes('./text()')->to_literal ;
315
         my($par_value)  = $i_name ->findnodes('../socgen:value/text()')->to_literal ;
316
         if($local_parameters{$par_name} eq '' )  { push @local_order , $par_name; }
317
         $local_parameters{$par_name} = $par_value;
318
         }
319
 
320
 
321
 
322
      foreach  my   $i_name ($sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:verilator/socgen:test[socgen:name/text() = '$simulation']/./socgen:parameters/socgen:parameter/socgen:name"))
323
         {
324
         my($par_name)   = $i_name ->findnodes('./text()')->to_literal ;
325
         my($par_value)  = $i_name ->findnodes('../socgen:value/text()')->to_literal ;
326
         if  ( $local_parameters{$par_name} eq '' )  { push @local_order , $par_name; }
327
         $local_parameters{$par_name} = $par_value;
328
         }
329
 
330
     my $timeout = $local_parameters{"TIMEOUT"};
331
 
332 128 jt_eaton
      print MAKSIMFILE  "include ${home}/tools/bin/Makefile.root\n";
333 125 jt_eaton
      print MAKSIMFILE  "comp=${variant}\n";
334
      print MAKSIMFILE  "test=${simulation}\n";
335
      print MAKSIMFILE  "timeout=${timeout}\n";
336 128 jt_eaton
      print MAKSIMFILE  "simulator=verilator\n";
337 125 jt_eaton
 
338
 
339
 
340 128 jt_eaton
 
341 125 jt_eaton
      my $module_name = yp::lib::get_module_name($vendor,$project,$component,$version);
342
 
343
 
344
 
345
 
346
      print SIM_PARM_FILE  "//  Testbench  for  $project    $component    $variant   $configuration    $simulation\n";
347
      print SIM_PARM_FILE  "                \n";
348
      print SIM_PARM_FILE  "module TB(input clk, input START,     output FINISH,output FAIL                 );                                \n";
349
      print SIM_PARM_FILE  "                                \n";
350
      print SIM_PARM_FILE  "     $module_name   \n";
351
 
352
      my $first =1;
353
 
354
      foreach  my  $parameter_name  (@local_order)
355
         {
356
         my($parameter_default)  =    $local_parameters{$parameter_name};
357
         if($first)
358
           {
359
           print SIM_PARM_FILE  "   #(  .${parameter_name}(${parameter_default})";
360
           $first = 0;
361
           }
362
         else
363
           {
364
           print SIM_PARM_FILE  ",\n       .${parameter_name}(${parameter_default})";
365
           }
366
         }
367
      print SIM_PARM_FILE  ") test \n (.clk(clk),.START(START),.FAIL(FAIL),.FINISH(FINISH)); \n\n\n\n";
368 128 jt_eaton
      print SIM_PARM_FILE  "`include \"./test_define\"  \n";
369 125 jt_eaton
      print SIM_PARM_FILE  "endmodule                                \n";
370
 
371
 
372
      }
373
 
374
 
375
 
376
 
377
 
378
 

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.