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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [verilog/] [gen_design] - 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
           "name=s"      => \$name,
77
           "dest_dir=s"  => \$dest_dir
78
 
79
) || die "(use '$program_name -h' for help)";
80
 
81
 
82
 
83
##############################################################################
84
## Help option
85
##############################################################################
86
if ( $opt_h  or $opt_help  )
87
  { print "\n gen_design -envidentifier {sim/syn}  -prefix /work -vendor vendor_name -library library_name  -component component_name  -version version_name      \n";
88
    exit 1;
89
  }
90
 
91
 
92
 
93
#############################################################################
94
##
95
##
96
#############################################################################
97
 
98
$home = cwd();
99
 
100
 
101
unless ($prefix)
102
 {
103
 $prefix   = yp::lib::get_workspace();
104
 $prefix   =  "/${prefix}";
105
 }
106
 
107
 
108
my   $variant;
109
my   $configuration;
110
my   $config_index;
111
 
112
 
113
 
114
 
115
my $main_module_name = yp::lib::get_module_name($vendor,$library,$component,$version) ;
116
my $destination         = "${main_module_name}";
117
 
118
if(defined $name)
119
{
120
$destination = "${destination}_${name}";
121
}
122
 
123
 
124
my $root_name = "${vendor}_${library}_${component}_${version}";
125
 
126
 
127
 
128
 
129
my $root                =      "root";
130
 
131
if($version)       {$variant   = "${component}_${version}";}
132
else               {$variant   = "${component}";}
133
 
134
if($name)         {$variant   = "${variant}_${name}";}
135
 
136
 
137
 
138
#print "gen_design -prefix $prefix -vendor $vendor -library $library -component $component -version $version  -name $name    \n";
139
 
140
 
141
my $parser = XML::LibXML->new();
142
 
143
 
144
my $socgen_file              = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));
145
 
146
unless ($socgen_file)      { print "No socgen ip file   \n";};
147
 
148
 
149
my $comp_xml_sep    = yp::lib::find_comp_xml_sep($vendor,$library,$component,$version);
150
my $lib_comp_sep    = yp::lib::find_lib_comp_sep($vendor,$library,$component);
151
 
152
 
153
 
154
my $path;
155
 
156
my $dest_dir    = yp::lib::get_io_ports;
157
 
158
$path  = "${home}/${dest_dir}";
159
 
160
mkdir $path,0755       unless( -e $path );
161
 
162
 
163
$data_db_file  = "${home}/dbs/${vendor}_${library}_${variant}.db";
164
 
165
 
166
 
167
if(-e  $data_db_file  )
168
        {
169
#        print "$data_db_file  does exist  \n";
170
 
171
        }
172
 
173
 
174
 
175
#print "ELAB_XXXXX gen design $data_db_file  \n";
176
 
177
my $elab_db  = new BerkeleyDB::Hash( -Filename => "$data_db_file", -Flags => DB_CREATE ) or die "Cannot open $data_db_file: $!";
178
 
179
 
180
 
181
 
182
 
183
my $repo_data;
184
$elab_db->db_get("VLNV___${vendor}:${library}:${component}:${version}", $repo_data );
185
 
186
#print "GEN_DESIGN  $data_db_file $repo_data \n";
187
 
188
 
189
$design_db_file  = "${home}/dbs/design.dbm";
190
 
191
my $design_db  = new BerkeleyDB::Hash( -Filename => "$design_db_file", -Flags => DB_CREATE ) or die "Cannot open $design_db_file: $!";
192
 
193
$design_db->db_get("INDEX", $config_index );
194
 
195
unless(defined $config_index)
196
{
197
$config_index = 1;
198
}
199
$design_db->db_put( "INDEX","$config_index"  );
200
 
201
 
202
my $key;
203
my $value;
204
 
205
 
206
   $cursor = $elab_db ->db_cursor() ;
207
   while ($cursor->c_get($key, $value, DB_NEXT) == 0)
208
   {
209
   my $vlnv;
210
   my $VLNV;
211
 
212
   ( ${VLNV},${vlnv}) = split( /___/ , $key);
213
   if($VLNV eq "VLNV")
214
     {
215
     my $ven;
216
     my $lib;
217
     my $cmp;
218
     my $ver;
219
   ( ${ven},${lib},${cmp},${ver}) = split( /:/ , $vlnv);
220
 
221
my $design_lib  = "${path}/${ven}__${lib}";
222
 
223
 
224
mkdir $design_lib,0755    unless(-e  $design_lib  );
225
my $design_cmp  = "${path}/${ven}__${lib}/${cmp}";
226
 
227
mkdir $design_cmp,0755  unless(-e  $design_cmp  );
228
 
229
 
230
 
231
$main_module_name = yp::lib::get_module_name($ven,$lib,$cmp,$ver) ;
232
 
233
my $design_ver  = "${path}/${ven}__${lib}/${cmp}/${main_module_name}";
234
 
235
 
236
 
237
if("${vendor}_${library}_${component}_${version}" eq "${ven}_${lib}_${cmp}_${ver}")
238
  {
239
  if(defined $name)
240
    {
241
    $design_ver  = "${path}/${ven}__${lib}/${cmp}/${main_module_name}_${name}";
242
    }
243
  else
244
    {
245
    $design_ver  = "${path}/${ven}__${lib}/${cmp}/${main_module_name}";
246
    }
247
  }
248
 
249
 
250
mkdir $design_ver,0755  unless(-e  $design_ver  );
251
 
252
 
253
my @insts;
254
 
255
 
256
   ( @insts) = split( /:::/ , $value);
257
  foreach my $inst (@insts)
258
   {
259
   my @params;
260
   $P_cursor = $elab_db ->db_cursor() ;
261
   while ($P_cursor->c_get($key, $value, DB_NEXT) == 0)
262
   {
263
   my $vlnv;
264
   my $VLNV;
265
 
266
   ( ${VLNV},${vlnv}) = split( /__/ , $key);
267
    if(${VLNV}  eq "parameter_${inst}"   )
268
     {
269
     push @params, "${vlnv}--${value}";
270
     }
271
 
272
   }
273
 
274
  my $design_name ="$${root_name}_${inst}";
275
     $design_name =~s/_root//;
276
 
277
 
278
 
279
  my $outfile = "${design_ver}/${root_name}_${inst}";
280
     $outfile =~s/_root//;
281
if(defined $name)
282
  {
283
  $outfile = "${outfile}_${name}";
284
  }
285
 
286
  open  DEST_FILE,">$outfile" or die "unable to open $outfile";
287
  @params = sys::lib::trim_sort(@params);
288
 
289
 
290
 
291
 
292
my $param_str;
293
 
294
  foreach my $param (@params)
295
   {
296
   print DEST_FILE "${param}  \n";
297
   $param_str = "${param}:::${param_str}";
298
   }
299
   close  DEST_FILE;
300
 
301
   my $status = $P_cursor->c_close() ;
302
 
303
 
304
 
305
 
306
 
307
 
308
 
309
my $config_data = "none";
310
 
311
$design_db->db_get("CONFIG___${param_str}", $config_data );
312
 
313
 
314
 
315
 
316
 
317
 
318
if( $config_data eq "none" )
319
  {
320
  $config_index = $config_index + 1;
321
  $design_db->db_put( "CONFIG___${param_str}","config_${config_index}"  );
322
  $config_data ="config_${config_index}"
323
  }
324
 
325
 
326
if(defined $name)
327
  {
328
  $design_db->db_put( "TOP_${ven}__${lib}_${cmp}_${main_module_name}_${name}","$param_str"  );
329
  $design_db->db_put( "TAP_${ven}__${lib}_${cmp}_${main_module_name}_${name}","$config_data"  );
330
  }
331
 
332
 
333
 
334
 
335
$Index_file = "${design_ver}/Config.db";
336
 
337
if(-e"${design_ver}/root/Index.db" )
338
  {
339
#  print "TOP LEVEL  gen_design Config.db   $Index_file \n";
340
  }
341
 
342
 
343
    $Index_db  = new BerkeleyDB::Hash( -Filename => "$Index_file", -Flags => DB_CREATE ) or die "Cannot open ${Index_file}: $!";
344
    $Index_db->db_put( "CONFIG","${config_data}");
345
    $Index_db->db_close();
346
 
347
 
348
 
349
 
350
my $outfile = "${design_ver}/${config_data}";
351
open  DEST_FILE,">$outfile" or die "unable to open $outfile";
352
 
353
  foreach my $param (@params)
354
   {
355
   print DEST_FILE "${param}  \n";
356
   }
357
 
358
close  DEST_FILE;
359
 
360
 
361
 
362
 
363
 
364
if($param_str)
365
 {
366
 $design_db->db_put( "instance_${root_name}_${inst}","${ven}:${lib}:${cmp}:${ver}:${config_data}"  );
367
 $design_db->db_put( "params__${ven}_${lib}_${cmp}_${ver}__${param_str}"  ,"${root_name}_${inst}"  );
368
 }
369
   }
370
     }
371
   }
372
 
373
   my $status = $cursor->c_close() ;
374
   $design_db->db_put( "INDEX","${config_index}"  );
375
   $elab_db     -> db_close();
376
   $design_db   -> db_close();
377
 
378
 
379
 
380
 
381
 
382
 
383
1
384
 

powered by: WebSVN 2.1.0

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