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

Subversion Repositories socgen

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

powered by: WebSVN 2.1.0

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