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

Subversion Repositories socgen

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

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

powered by: WebSVN 2.1.0

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