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

Subversion Repositories socgen

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

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
           "env=s" => \$env,
79
           "tool=s" => \$tool,
80
           "unit=s" => \$unit,
81
           "name=s" => \$name
82
 
83
) || die "(use '$program_name -h' for help)";
84
 
85
 
86
 
87
##############################################################################
88
## Help option
89
##############################################################################
90
if ( $opt_h  or $opt_help  )
91
  { print "\n gen_root -envidentifier {sim/syn}  -prefix /work -vendor vendor_name -library library_name  -component component_name  -version version_name -env env -tool tool -unit unit -name name     \n";
92
    exit 1;
93
  }
94
 
95
 
96
 
97
#############################################################################
98
##
99
##
100
#############################################################################
101
 
102
$home = cwd();
103
 
104
unless ($prefix)
105
 {
106
 $prefix   = yp::lib::get_workspace();
107
 $prefix   =  "/${prefix}";
108
 }
109
 
110
 
111
my   $variant;
112
 
113
 
114
 
115
 
116
 
117
my $destination       = yp::lib::get_module_name($vendor,$library,$component,$version);
118
 
119
unless ($env ) {$env = "none";}
120
unless ($tool ){$tool = "none";}
121
unless ($unit ){$unit = "none";}
122
 
123
if($name)
124
  {
125
  $destination   = "${destination}_${name}";
126
  }
127
else
128
  {
129
#  $name          = $version;
130
  $destination   = "${destination}";
131
  }
132
 
133
 
134
 
135
 
136
my $root                =      "root";
137
 
138
if($version)       {$variant   = "${component}_${version}";}
139
else               {$variant   = "${component}";}
140
 
141
#print "GEN_ROOT -prefix $prefix -vendor $vendor -library $library -component $component -version $version   -env $env -tool $tool -unit $unit -name $name     \n";
142
 
143
 
144
my $parser = XML::LibXML->new();
145
 
146
 
147
my $socgen_file              = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));
148
 
149
unless ($socgen_file)      { print "No socgen ip file   \n";};
150
 
151
 
152
my $comp_xml_sep    = yp::lib::find_comp_xml_sep($vendor,$library,$component,$version);
153
my $lib_comp_sep    = yp::lib::find_lib_comp_sep($vendor,$library,$component);
154
 
155
 
156
$dest_dir = yp::lib::get_io_ports();
157
 
158
my $path  = "${home}/${dest_dir}";
159
 
160
 
161
 
162
mkdir $path,0755      unless( -e $path );
163
 
164
$path ="${path}/${vendor}__${library}";
165
mkdir $path,0755    unless( -e $path );
166
$path ="${path}/${component}";
167
 
168
mkdir $path,0755    unless( -e $path );
169
 
170
 
171
 
172
  unless( -e "${path}/${destination}" )
173
      {
174
#      print "$path/${destination} does not exist... creating \n";
175
      my $cmd = "mkdir $path/${destination}  \n";
176
      if(system($cmd)){};
177
      }
178
 
179
 
180
 
181
if(defined $name)
182
{
183
$data_db_file  = "${home}/dbs/${vendor}_${library}_${component}_${version}_${name}.db";
184
}
185
else
186
{
187
$data_db_file  = "${home}/dbs/${vendor}_${library}_${component}_${version}.db";
188
}
189
 
190
#print "ELAB_XXXX gen_root $data_db_file  \n";
191
my $elab_db  = new BerkeleyDB::Hash( -Filename => "$data_db_file", -Flags => DB_CREATE ) or die "Cannot open $data_db_file: $!";
192
 
193
 
194
my $root                =      "root";
195
 
196
my $key;
197
my $value;
198
 
199
 
200
my @elab_list;
201
 
202
my $cursor = $elab_db ->db_cursor() ;
203
while ($cursor->c_get($key, $value, DB_NEXT) == 0)
204
   {
205
 
206
   ( ${key_type},@elab_list) = split( /\./ , $key);
207
 
208
   if(($key_type eq "component___${root}"))
209
      {
210
 
211
      build_hierarchy ($value,"${path}/${destination}",$root,@elab_list);
212
      }
213
   }
214
my $status = $cursor->c_close() ;
215
 
216
 
217
 
218
 
219
$cursor = $elab_db ->db_cursor() ;
220
while ($cursor->c_get($key, $value, DB_NEXT) == 0)
221
   {
222
   $_ = $key;
223
   if(/parameter_${root}__(\S+)/)
224
    {
225
    my $file_name = "${path}/${destination}/${root}/Index.db";
226
    my $param_db  = new BerkeleyDB::Hash( -Filename => "$file_name", -Flags => DB_CREATE ) or die "Cannot open ${file_name}: $!";
227
       $param_db->db_put( "$key","${value}");
228
       $param_db->db_close();
229
    }
230
   elsif (/parameter_${root}(\S+)__(\S+)/)
231
    {
232
    my $xpath = $1;
233
    $xpath =~ s/\./\//g;
234
    my $file_name = "${path}/${destination}/${root}/${xpath}/Index.db";
235
    my $param_db  = new BerkeleyDB::Hash( -Filename => "$file_name", -Flags => DB_CREATE ) or die "Cannot open ${file_name}: $!";
236
       $param_db->db_put( "$key","${value}");
237
       $param_db->db_close();
238
    }
239
   }
240
$status = $cursor->c_close() ;
241
 
242
 
243
 
244
$cursor = $elab_db ->db_cursor() ;
245
while ($cursor->c_get($key, $value, DB_NEXT) == 0)
246
   {
247
   $_ = $key;
248
   if(/busInterface_${root}__(\S+)/)
249
    {
250
    my $file_name = "${path}/${destination}/${root}/Index.db";
251
    my $param_db  = new BerkeleyDB::Hash( -Filename => "$file_name", -Flags => DB_CREATE ) or die "Cannot open ${file_name}: $!";
252
       $param_db->db_put( "$key","${value}");
253
       $param_db->db_close();
254
    }
255
   elsif(/busInterface_${root}(\S+)__(\S+)/)
256
    {
257
    my $xpath = $1;
258
    my $parname = $2;
259
    $xpath =~ s/\./\//g;
260
    my $file_name = "${path}/${destination}/${root}/${xpath}/Index.db";
261
    my $param_db  = new BerkeleyDB::Hash( -Filename => "$file_name", -Flags => DB_CREATE ) or die "Cannot open ${file_name}: $!";
262
       $param_db->db_put( "$key","${value}");
263
       $param_db->db_close();
264
    }
265
 
266
 
267
 
268
 
269
   }
270
$status = $cursor->c_close() ;
271
 
272
 
273
$elab_db->db_close();
274
 
275
 
276
 
277
 
278
 
279
 
280
 
281
#/*********************************************************************************************/
282
#/                                                                                            */
283
#/                                                                                            */
284
#/                                                                                            */
285
#/                                                                                            */
286
#/                                                                                            */
287
#/                                                                                            */
288
#/*********************************************************************************************/
289
 
290
sub build_hierarchy
291
   {
292
   my @params     = @_;
293
   my $vlnv       = shift(@params);
294
   my $path       = shift(@params);
295
   my $root       = shift(@params);
296
   my $top        = shift(@params);
297
   my $new_elab_db ;
298
   my $new_elab_db_file_name ;
299
 
300
 
301
 
302
#   print "Hier  $path \nHier- $root       $top    --- @params  \n";
303
   $path ="${path}/${root}";
304
   unless(-e $path)
305
     {
306
     $cmd ="mkdir ${path} \n";
307
     if(system($cmd)){}
308
#     print "Create Dir  ${path} \n";
309
     }
310
 
311
   unless (-e "${path}/${top}")
312
     {
313
     $cmd ="mkdir ${path}/${top} \n";
314
     if(system($cmd)){}
315
     }
316
 
317
   $new_elab_db_file_name  = "${path}/${top}/Index.db";
318
 
319
   if(@params)
320
     {
321
     build_hierarchy ("$vlnv","${path}","${top}",@params);
322
     }
323
   else
324
     {
325
#     print "CREATE $new_elab_db_file_name  \n";
326
     $new_elab_db  = new BerkeleyDB::Hash( -Filename => "$new_elab_db_file_name", -Flags => DB_CREATE ) or die "Cannot open $new_elab_db_file_name    : $!";
327
     $new_elab_db->db_put( "VLNV","${vlnv}"  );
328
#     print "VLNV  $vlnv \nVLNV -> $new_elab_db_file_name  \n";
329
     }
330
 
331
   return(0);
332
 
333
   }
334
 
335
 
336
 
337
 
338
1

powered by: WebSVN 2.1.0

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