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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [verilog/] [gen_root] - Blame information for rev 134

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

Line No. Rev Author Line
1 133 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
#/*                                                                    */
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
# General PERL config
49
############################################################################
50
use Getopt::Long;
51
use English;
52
use File::Basename;
53
use Cwd;
54
use Scalar::Util qw(looks_like_number);
55
use XML::LibXML;
56
use lib './tools';
57
use sys::lib;
58
use yp::lib;
59
use BerkeleyDB;
60
 
61
 
62
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
63
 
64
 
65
############################################################################
66
### Process the options
67
############################################################################
68
Getopt::Long::config("require_order", "prefix=-");
69
GetOptions("h","help",
70
           "envidentifier=s" => \$envidentifier,
71
           "prefix=s" => \$prefix,
72
           "vendor=s" => \$vendor,
73
           "library=s" => \$library,
74
           "component=s" => \$component,
75
           "version=s" => \$version,
76
           "configuration=s" => \$configuration,
77
           "dest_dir=s" => \$dest_dir,
78
           "name=s" => \$name
79
 
80
) || die "(use '$program_name -h' for help)";
81
 
82
 
83
 
84
##############################################################################
85
## Help option
86
##############################################################################
87
if ( $opt_h  or $opt_help  )
88 134 jt_eaton
  { print "\n gen_root -envidentifier {sim/syn}  -prefix /work -vendor vendor_name -library library_name  -component component_name  -version version_name   -name name     \n";
89 133 jt_eaton
    exit 1;
90
  }
91
 
92
 
93
 
94
#############################################################################
95
##
96
##
97
#############################################################################
98
 
99
$home = cwd();
100
 
101
unless ($prefix)
102
 {
103
 $prefix   = yp::lib::get_workspace();
104
 $prefix   =  "/${prefix}";
105
 }
106
 
107 134 jt_eaton
my $variant;
108 133 jt_eaton
my $destination       = yp::lib::get_module_name($vendor,$library,$component,$version);
109
 
110
if($name)
111
  {
112 134 jt_eaton
  $destination   = "${destination}";
113 133 jt_eaton
  }
114
else
115
  {
116
  $destination   = "${destination}";
117
  }
118
 
119
my $root                =      "root";
120
 
121
if($version)       {$variant   = "${component}_${version}";}
122
else               {$variant   = "${component}";}
123
 
124 134 jt_eaton
print "GEN_ROOT  -vendor $vendor -library $library -component $component -version $version  -name $name     \n";
125 133 jt_eaton
 
126
 
127
my $parser = XML::LibXML->new();
128
 
129
 
130
my $socgen_file              = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));
131
 
132
unless ($socgen_file)      { print "No socgen ip file   \n";};
133
 
134
 
135
my $comp_xml_sep    = yp::lib::find_comp_xml_sep($vendor,$library,$component,$version);
136
my $lib_comp_sep    = yp::lib::find_lib_comp_sep($vendor,$library,$component);
137
 
138 134 jt_eaton
my $elab_db_file;
139 133 jt_eaton
 
140 134 jt_eaton
if(defined $name)
141
{
142
$elab_db_file = yp::lib::get_elab_db_filename($vendor,$library,$component,$version,$name);
143
}
144
else
145
{
146
$elab_db_file = yp::lib::get_elab_db_filename($vendor,$library,$component,$version,"default");
147
}
148
 
149
my $elab_db  = new BerkeleyDB::Hash( -Filename => "$elab_db_file", -Flags => DB_CREATE ) or die "Cannot open $elab_db_file: $!";
150
 
151
$design_db_file  = yp::lib::get_design_db_file;
152
my $design_db  = new BerkeleyDB::Hash( -Filename => "$design_db_file", -Flags => DB_CREATE ) or die "Cannot open $design_db_file: $!";
153
 
154
 
155
unless (defined $configuration && length $configuration > 0)
156
{
157
my $h_ven;
158
my $h_lib;
159
my $h_cmp;
160
my $h_ver;
161
my $h_config;
162
 
163
    my $config_key;
164
    my $config_index;
165
 
166
    if(defined $name)
167
    {
168
    $config_key ="instance_${vendor}_${library}_${component}_${version}_${name}_root";
169
     }
170
    else
171
    {
172
    $config_key ="instance_${vendor}_${library}_${component}_${version}_root";
173
     }
174
    $design_db->db_get($config_key, $config_index );
175
   ( ${h_ven},${h_lib},${h_cmp},${h_ver},${h_config}) = split( /\:/ , $config_index);
176
 
177
$configuration = $h_config;
178
}
179
 
180
 
181
 
182
 
183
 
184
 
185
 
186
 
187
 
188
 
189
 
190
 
191 133 jt_eaton
$dest_dir = yp::lib::get_io_ports();
192
my $path  = "${home}/${dest_dir}";
193
 
194
 
195
mkdir $path,0755      unless( -e $path );
196
 
197
$path ="${path}/${vendor}__${library}";
198
mkdir $path,0755    unless( -e $path );
199
$path ="${path}/${component}";
200
 
201
mkdir $path,0755    unless( -e $path );
202
 
203
 
204
 
205
  unless( -e "${path}/${destination}" )
206
      {
207
      my $cmd = "mkdir $path/${destination}  \n";
208
      if(system($cmd)){};
209
      }
210
 
211
 
212 134 jt_eaton
$destination ="${destination}/${configuration}";
213 133 jt_eaton
 
214
 
215 134 jt_eaton
  unless( -e "${path}/${destination}" )
216
      {
217
      my $cmd = "mkdir $path/${destination}  \n";
218
      if(system($cmd)){};
219
      }
220 133 jt_eaton
 
221
 
222 134 jt_eaton
  if( -e "${path}/${destination}/root" )
223
      {
224
      exit;
225
      #print "${path}/${destination}/root exists \n";
226
 
227
      }
228
 
229
 
230
 
231 133 jt_eaton
my $root                =      "root";
232
 
233
my $key;
234
my $value;
235
 
236
 
237
my @elab_list;
238
 
239
my $cursor = $elab_db ->db_cursor() ;
240
while ($cursor->c_get($key, $value, DB_NEXT) == 0)
241
   {
242
 
243
   ( ${key_type},@elab_list) = split( /\./ , $key);
244
 
245
   if(($key_type eq "component___${root}"))
246
      {
247
 
248
      build_hierarchy ($value,"${path}/${destination}",$root,@elab_list);
249
      }
250
   }
251
my $status = $cursor->c_close() ;
252
 
253
 
254 134 jt_eaton
my @file_names = ();
255
my $file_name = "${path}/${destination}/${root}/Index.db";
256
push @file_names, $file_name;
257 133 jt_eaton
 
258
 
259 134 jt_eaton
 
260
 
261 133 jt_eaton
$cursor = $elab_db ->db_cursor() ;
262
while ($cursor->c_get($key, $value, DB_NEXT) == 0)
263
   {
264
   $_ = $key;
265 134 jt_eaton
   if($key eq "component___root")
266
    {
267
 
268
    my $file_name = "${path}/${destination}/${root}/Index.db";
269
    my $param_db  = new BerkeleyDB::Hash( -Filename => "$file_name", -Flags => DB_CREATE ) or die "Cannot open ${file_name}: $!";
270
       $param_db->db_put( "PATH","root");
271
       $param_db->db_put( "VLNV","${value}");
272
       $param_db->db_close();
273
    }
274
   elsif (/component___root\.(\S+)/)
275
    {
276
 
277
    my $xpath = $1;
278
    my $ypath = $1;
279
    $xpath =~ s/\./\//g;
280
 
281
 
282
    my $file_name = "${path}/${destination}/root/${xpath}/Index.db";
283
    push @file_names, $file_name;
284
 
285
 
286
    my $param_db  = new BerkeleyDB::Hash( -Filename => "$file_name", -Flags => DB_CREATE ) or die "Cannot open ${file_name}: $!";
287
       $param_db->db_put( "PATH","root.${ypath}");
288
       $param_db->db_put( "VLNV","${value}");
289
       $param_db->db_close();
290
    }
291
   }
292
$status = $cursor->c_close() ;
293
 
294
 
295
 
296
 
297
 
298
 
299
 
300
 
301
 
302
 
303
 
304
$cursor = $elab_db ->db_cursor() ;
305
while ($cursor->c_get($key, $value, DB_NEXT) == 0)
306
   {
307
   $_ = $key;
308 133 jt_eaton
   if(/parameter_${root}__(\S+)/)
309
    {
310
    my $file_name = "${path}/${destination}/${root}/Index.db";
311
    my $param_db  = new BerkeleyDB::Hash( -Filename => "$file_name", -Flags => DB_CREATE ) or die "Cannot open ${file_name}: $!";
312
       $param_db->db_put( "$key","${value}");
313
       $param_db->db_close();
314
    }
315
   elsif (/parameter_${root}(\S+)__(\S+)/)
316
    {
317
    my $xpath = $1;
318 134 jt_eaton
    my $ypath = $1;
319 133 jt_eaton
    $xpath =~ s/\./\//g;
320 134 jt_eaton
    my $file_name = "${path}/${destination}/${root}${xpath}/Index.db";
321
    push @file_names, $file_name;
322 133 jt_eaton
    my $param_db  = new BerkeleyDB::Hash( -Filename => "$file_name", -Flags => DB_CREATE ) or die "Cannot open ${file_name}: $!";
323
       $param_db->db_put( "$key","${value}");
324
       $param_db->db_close();
325
    }
326
   }
327
$status = $cursor->c_close() ;
328
 
329
 
330
 
331 134 jt_eaton
 
332
 
333
 
334
 
335
 
336
 
337 133 jt_eaton
$cursor = $elab_db ->db_cursor() ;
338
while ($cursor->c_get($key, $value, DB_NEXT) == 0)
339
   {
340
   $_ = $key;
341
   if(/busInterface_${root}__(\S+)/)
342
    {
343
    my $file_name = "${path}/${destination}/${root}/Index.db";
344
    my $param_db  = new BerkeleyDB::Hash( -Filename => "$file_name", -Flags => DB_CREATE ) or die "Cannot open ${file_name}: $!";
345
       $param_db->db_put( "$key","${value}");
346 134 jt_eaton
 
347 133 jt_eaton
       $param_db->db_close();
348
    }
349
   elsif(/busInterface_${root}(\S+)__(\S+)/)
350
    {
351 134 jt_eaton
    my $xpath = $1;
352
    my $ypath = $1;
353 133 jt_eaton
    my $parname = $2;
354
    $xpath =~ s/\./\//g;
355 134 jt_eaton
    my $file_name = "${path}/${destination}/${root}${xpath}/Index.db";
356 133 jt_eaton
    my $param_db  = new BerkeleyDB::Hash( -Filename => "$file_name", -Flags => DB_CREATE ) or die "Cannot open ${file_name}: $!";
357
       $param_db->db_put( "$key","${value}");
358
       $param_db->db_close();
359
    }
360 134 jt_eaton
   }
361
$status = $cursor->c_close() ;
362 133 jt_eaton
 
363
 
364
 
365 134 jt_eaton
 # here we read the vlnv from param_db
366
 # open it's BUSSES.dbm
367
 # copy all contents
368
 # modify vector left:right by parsing parameters
369
 
370
# print "IIIIIIIIX  $VLNV_copy  \n";
371
 
372
 foreach my $param_c (@param_copy)
373
 {
374
 #print "IIIIIIIII  $param_c  \n";
375
 }
376
 
377 133 jt_eaton
 
378
 
379
 
380
$elab_db->db_close();
381
 
382
 
383 134 jt_eaton
@file_names      = sys::lib::trim_sort(@file_names);
384
 foreach my $file_name (@file_names)
385
  {
386
  my $cmd ="./tools/verilog/tag_Index.db $file_name \n";
387
  if(system($cmd)){}
388 133 jt_eaton
 
389 134 jt_eaton
  }
390 133 jt_eaton
 
391
 
392
 
393
 
394 134 jt_eaton
 
395 133 jt_eaton
#/*********************************************************************************************/
396
#/                                                                                            */
397
#/                                                                                            */
398
#/                                                                                            */
399
#/                                                                                            */
400
#/                                                                                            */
401
#/                                                                                            */
402
#/*********************************************************************************************/
403
 
404
sub build_hierarchy
405
   {
406
   my @params     = @_;
407
   my $vlnv       = shift(@params);
408
   my $path       = shift(@params);
409
   my $root       = shift(@params);
410
   my $top        = shift(@params);
411
   my $new_elab_db ;
412
   my $new_elab_db_file_name ;
413
 
414
   $path ="${path}/${root}";
415
   unless(-e $path)
416
     {
417
     $cmd ="mkdir ${path} \n";
418
     if(system($cmd)){}
419
     }
420
 
421
   unless (-e "${path}/${top}")
422
     {
423
     $cmd ="mkdir ${path}/${top} \n";
424
     if(system($cmd)){}
425
     }
426
 
427
   $new_elab_db_file_name  = "${path}/${top}/Index.db";
428
 
429
   if(@params)
430
     {
431
     build_hierarchy ("$vlnv","${path}","${top}",@params);
432
     }
433
   else
434
     {
435
     $new_elab_db  = new BerkeleyDB::Hash( -Filename => "$new_elab_db_file_name", -Flags => DB_CREATE ) or die "Cannot open $new_elab_db_file_name    : $!";
436
     $new_elab_db->db_put( "VLNV","${vlnv}"  );
437 134 jt_eaton
 
438
     $new_elab_db->db_close();
439 133 jt_eaton
     }
440
 
441
   return(0);
442
 
443
   }
444
 
445
 
446
 
447
 
448
1

powered by: WebSVN 2.1.0

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