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

Subversion Repositories socgen

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

powered by: WebSVN 2.1.0

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