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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [sys/] [build_generate] - Blame information for rev 117

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 117 jt_eaton
eval 'exec `which perl` -S $0 ${1+"$@"}'
2
   if 0;
3
 
4
#/**********************************************************************/
5
#/*                                                                    */
6
#/*             -------                                                */
7
#/*            /   SOC  \                                              */
8
#/*           /    GEN   \                                             */
9
#/*          /    TOOL    \                                            */
10
#/*          ==============                                            */
11
#/*          |            |                                            */
12
#/*          |____________|                                            */
13
#/*                                                                    */
14
#/*                                                                    */
15
#/*                                                                    */
16
#/*                                                                    */
17
#/*  Author(s):                                                        */
18
#/*      - John Eaton, jt_eaton@opencores.org                          */
19
#/*                                                                    */
20
#/**********************************************************************/
21
#/*                                                                    */
22
#/*    Copyright (C) <2010-2011>                */
23
#/*                                                                    */
24
#/*  This source file may be used and distributed without              */
25
#/*  restriction provided that this copyright statement is not         */
26
#/*  removed from the file and that any derivative work contains       */
27
#/*  the original copyright notice and the associated disclaimer.      */
28
#/*                                                                    */
29
#/*  This source file is free software; you can redistribute it        */
30
#/*  and/or modify it under the terms of the GNU Lesser General        */
31
#/*  Public License as published by the Free Software Foundation;      */
32
#/*  either version 2.1 of the License, or (at your option) any        */
33
#/*  later version.                                                    */
34
#/*                                                                    */
35
#/*  This source is distributed in the hope that it will be            */
36
#/*  useful, but WITHOUT ANY WARRANTY; without even the implied        */
37
#/*  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR           */
38
#/*  PURPOSE.  See the GNU Lesser General Public License for more      */
39
#/*  details.                                                          */
40
#/*                                                                    */
41
#/*  You should have received a copy of the GNU Lesser General         */
42
#/*  Public License along with this source; if not, download it        */
43
#/*  from http://www.opencores.org/lgpl.shtml                          */
44
#/*                                                                    */
45
#/**********************************************************************/
46
 
47
 
48
############################################################################
49
# General PERL config
50
############################################################################
51
use Getopt::Long;
52
use English;
53
use File::Basename;
54
use Cwd;
55
use XML::LibXML;
56
use lib './tools';
57
use sys::lib;
58
use yp::lib;
59
 
60
 
61
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
62
 
63
 
64
 
65
############################################################################
66
### Process the options
67
############################################################################
68
 
69
Getopt::Long::config("require_order", "prefix=-");
70
GetOptions("h","help",
71
           "prefix=s" => \$prefix,
72
           "vendor=s" => \$vendor,
73
           "project=s" => \$project,
74
           "component=s" => \$component,
75
           "comp_xml_sep=s" => \$comp_xml_sep,
76
           "version=s" => \$version
77
) || die "(use '$program_name -h' for help)";
78
 
79
 
80
##############################################################################
81
## Help option
82
##############################################################################
83
if ( $opt_h or $opt_help )   { print "\n build_generate -prefix /work/ -project project_name -component component_name -comp_xml_sep /rtl/xml/ ";
84
    print "\n";
85
    exit 1;
86
  }
87
 
88
 
89
##############################################################################
90
##
91
##############################################################################
92
 
93
 
94
my $home = cwd();
95
my $tool_path ="./tools/generators/";
96
 
97
#############################################################################
98
##
99
##
100
#############################################################################
101
 
102
 
103
 
104
 
105
print "  GENERATE    $prefix $vendor  $project  $component $version  \n" ;
106
 
107
 
108
my $parser = XML::LibXML->new();
109
 
110
my $lib_comp_sep    = yp::lib::find_lib_comp_sep($vendor,$project);
111
my $spirit_component_file    = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$vendor,$project,$component,$version));
112
 
113
foreach my $view ($spirit_component_file->findnodes('//spirit:component/spirit:model/spirit:views/spirit:view'))
114
       {
115
       my($view_name)   = $view->findnodes('./spirit:name/text()')->to_literal ;
116
 
117
       #/**********************************************************************/
118
       #/*                                                                    */
119
       #/*                                                                    */
120
       #/*                                                                    */
121
       #/*                                                                    */
122
       #/*                                                                    */
123
       #/**********************************************************************/
124
 
125
       foreach  my   $i_name ($spirit_component_file->findnodes("//spirit:componentGenerator/spirit:name"))
126
          {
127
          my($gen_name)            = $i_name ->findnodes('./text()')->to_literal ;
128
          my($gen_phase)           = $i_name ->findnodes('../spirit:phase/text()')->to_literal ;
129
          my($gen_apiType)         = $i_name ->findnodes('../spirit:apiType/text()')->to_literal ;
130
          my($gen_generatorExe)    = $i_name ->findnodes('../spirit:generatorExe/text()')->to_literal ;
131
          my($gen_group)           = $i_name ->findnodes('../spirit:group/text()')->to_literal ;
132
 
133
          my $cmd;
134
          $cmd =
135
          "${tool_path}${gen_generatorExe} -view $view_name -prefix $prefix   -vendor $vendor -version $version             -project $project      -lib_comp_sep $lib_comp_sep -component $component -comp_xml_sep $comp_xml_sep  ";
136
 
137
          foreach  my   $i_name ($spirit_component_file->findnodes("//spirit:componentGenerator[spirit:name/text() = '$gen_name']/spirit:parameters/spirit:parameter"))
138
             {
139
             my($gen_param)             = $i_name ->findnodes('./spirit:value/text()')->to_literal ;
140
             my($gen_param_name)        = $i_name ->findnodes('./spirit:name/text()')->to_literal ;
141
 
142
             if   ($gen_param_name eq "in_pipe")     {$cmd =  "$cmd <${home}${prefix}${project}${lib_comp_sep}/${component}/${gen_param}";}
143
             elsif($gen_param_name eq "out_pipe")    {$cmd =  "$cmd >${home}${prefix}${project}${lib_comp_sep}/${component}/${gen_param}";}
144
             elsif($gen_param_name)                  {$cmd =  "$cmd -${gen_param_name} $gen_param ";}
145
             else                                    {$cmd =  "$cmd $gen_param";}
146
             }
147
             $cmd =  "${cmd}\n";
148
             my $cpu_load = 180;
149
             while ( $cpu_load > 175) {        $cpu_load = load();}
150
 
151
             if($gen_group)
152
               {
153
               if($gen_group eq $view_name )
154
                 {
155
                 if (system($cmd)) {}
156
                 }
157
               }
158
             else
159
               {
160
#               print "ZZZZZZH   $cmd ";
161
               if (system($cmd)) {}
162
               }
163
          }
164
       }
165
 
166
 
167
 
168
 
169
 
170
 
171
 
172
sub load
173
{
174
 
175
   open(INFIL,"< /proc/stat") or die("Unable To Open /proc/stat: $!\n");
176
 
177
   my @loads;
178
   my $cpuload = 0;
179
   for (0,1)
180
   {
181
      my $in = ;
182
      (warn "something wrong!\n"), next unless $in =~ /^cpu\b/;
183
      push @loads,  ($in =~ /\d+/g)[0..2];
184
      seek INFIL, 0, 0;
185
      select (undef, undef, undef, 1) unless $_;
186
   }
187
   redo unless defined $loads[0];
188
   for (0..2) { $cpuload += ($loads[$_+3] - $loads[$_]); }
189
 
190
   close(INFIL);
191
   return( ${cpuload});
192
}
193
 
194
 
195
1
196
 
197
 
198
 
199
 
200
 
201
 
202
 
203
 
204
 
205
 
206
 
207
 
208
 
209
 
210
 
211
 
212
 
213
 
214
 

powered by: WebSVN 2.1.0

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