1 |
131 |
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 |
|
|
"vendor=s" => \$vendor,
|
71 |
|
|
"library=s" => \$library,
|
72 |
|
|
"version=s" => \$version,
|
73 |
|
|
"component=s" => \$component,
|
74 |
|
|
"debug","verbose"
|
75 |
|
|
) || die "(use '$program_name -h' for help)";
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
##############################################################################
|
79 |
|
|
## Help option
|
80 |
|
|
##############################################################################
|
81 |
|
|
if ( $opt_h or $opt_help )
|
82 |
|
|
{ print "\n gen_busdef -vendor vendor_name -library library_name -component component_name -version version_name ";
|
83 |
|
|
print "\n";
|
84 |
|
|
exit 1;
|
85 |
|
|
}
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
#############################################################################
|
89 |
|
|
##
|
90 |
|
|
##
|
91 |
|
|
#############################################################################
|
92 |
|
|
|
93 |
|
|
|
94 |
|
|
$home = cwd();
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
my $variant;
|
98 |
|
|
my $parser = XML::LibXML->new();
|
99 |
134 |
jt_eaton |
#print "\n GEN_busdef $vendor $library $component $version \n";
|
100 |
131 |
jt_eaton |
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
my $io_ports = yp::lib::get_io_ports() ;
|
104 |
|
|
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
my $path = "${io_ports}";
|
109 |
|
|
mkdir $path,0755 unless( -e $path );
|
110 |
|
|
$path = "${io_ports}/${vendor}__${library}";
|
111 |
|
|
mkdir $path,0755 unless( -e $path );
|
112 |
|
|
$path = "${io_ports}/${vendor}__${library}/${component}";
|
113 |
|
|
mkdir $path,0755 unless( -e $path );
|
114 |
|
|
$filename ="${io_ports}/${vendor}__${library}/${component}/${component}_${version}_ABSDEF.dbm";
|
115 |
|
|
|
116 |
|
|
if(-e ${filename} )
|
117 |
|
|
{
|
118 |
|
|
print " $filename Exists, exiting \n";
|
119 |
|
|
exit 0;
|
120 |
|
|
}
|
121 |
|
|
|
122 |
|
|
|
123 |
|
|
$absDef_db = new BerkeleyDB::Hash( -Filename => $filename, -Flags => DB_CREATE ) or die "Cannot open file: $!";
|
124 |
|
|
|
125 |
|
|
|
126 |
|
|
|
127 |
|
|
|
128 |
|
|
my $spirit_file = yp::lib::find_ipxact_abstractionDefinition($vendor,$library,$component,$version);
|
129 |
|
|
|
130 |
|
|
# print "\tFilename: ${spirit_file}\n";
|
131 |
|
|
unless ($spirit_file) {print "Error absDef $vendor $library $component $version file does not exist";}
|
132 |
|
|
|
133 |
|
|
my $spirit_absDef_file = $parser->parse_file($spirit_file);
|
134 |
|
|
foreach my $absDef ($spirit_absDef_file->findnodes("//spirit:abstractionDefinition/spirit:vendor"))
|
135 |
|
|
{
|
136 |
|
|
my($bd_vendor) = $absDef->findnodes('./text()')->to_literal ;
|
137 |
|
|
my($bd_library) = $absDef->findnodes('../spirit:library/text()')->to_literal ;
|
138 |
|
|
my($bd_name) = $absDef->findnodes('../spirit:name/text()')->to_literal ;
|
139 |
|
|
my($bd_version) = $absDef->findnodes('../spirit:version/text()')->to_literal ;
|
140 |
|
|
# print "\tVLNV-ad ${bd_vendor}_${bd_library}_${bd_name}_${bd_version}\n";
|
141 |
|
|
|
142 |
|
|
my %systemGroupNames = ();
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
foreach my $bus_type ($spirit_absDef_file->findnodes("//spirit:abstractionDefinition/spirit:busType"))
|
146 |
|
|
{
|
147 |
|
|
my($bt_vendor) = $bus_type->findnodes('./@spirit:vendor')->to_literal ;
|
148 |
|
|
my($bt_library) = $bus_type->findnodes('./@spirit:library')->to_literal ;
|
149 |
|
|
my($bt_name) = $bus_type->findnodes('./@spirit:name')->to_literal ;
|
150 |
|
|
my($bt_version) = $bus_type->findnodes('./@spirit:version')->to_literal ;
|
151 |
|
|
# print "\tVLNV-bt ${bt_vendor}_${bt_library}_${bt_name}_${bt_version}\n";
|
152 |
|
|
|
153 |
|
|
my $spirit_file = yp::lib::find_ipxact_busDefinition($bt_vendor,$bt_library,$bt_name,$bt_version);
|
154 |
|
|
|
155 |
|
|
unless ($spirit_file) {print "ERROR: No bus definition\n";}
|
156 |
|
|
else
|
157 |
|
|
{
|
158 |
|
|
my $spirit_busDef_file = $parser->parse_file($spirit_file);
|
159 |
|
|
foreach my $i_name ($spirit_busDef_file->findnodes("//spirit:busDefinition/spirit:systemGroupNames/spirit:systemGroupName"))
|
160 |
|
|
{
|
161 |
|
|
my($sysgroup_name) = $i_name ->findnodes('./text()')->to_literal;
|
162 |
|
|
# print "\t SystemGroup Name $sysgroup_name \n";
|
163 |
|
|
$systemGroupNames{$sysgroup_name} = 1;
|
164 |
|
|
}
|
165 |
|
|
}
|
166 |
|
|
}
|
167 |
|
|
|
168 |
|
|
foreach my $absDef ($spirit_absDef_file->findnodes("//spirit:abstractionDefinition/spirit:ports/spirit:port/spirit:logicalName"))
|
169 |
|
|
{
|
170 |
|
|
my($logical_name) = $absDef->findnodes('./text()')->to_literal ;
|
171 |
|
|
my($is_clock) = $absDef->findnodes('../spirit:wire/spirit:qualifier/spirit:isClock/text()')->to_literal ;
|
172 |
|
|
my($is_reset) = $absDef->findnodes('../spirit:wire/spirit:qualifier/spirit:isReset/text()')->to_literal ;
|
173 |
|
|
my($is_address) = $absDef->findnodes('../spirit:wire/spirit:qualifier/spirit:isAddress/text()')->to_literal ;
|
174 |
|
|
my($is_data) = $absDef->findnodes('../spirit:wire/spirit:qualifier/spirit:isData/text()')->to_literal ;
|
175 |
|
|
my($requires_driver) = $absDef->findnodes('../spirit:wire/spirit:requiresDriver/text()')->to_literal ;
|
176 |
|
|
my($driver_type) = $absDef->findnodes('../spirit:wire/spirit:requiresDriver/@spirit:driverType')->to_literal ;
|
177 |
|
|
my($default_value) = $absDef->findnodes('../spirit:wire/spirit:defaultValue/text()')->to_literal ;
|
178 |
|
|
|
179 |
|
|
# print "\nPort: ${logical_name} ";
|
180 |
|
|
|
181 |
|
|
|
182 |
|
|
my $Key = "port__${logical_name}" ;
|
183 |
|
|
my @info = ("$logical_name","$is_clock","$is_reset","$is_address","$is_data","$requires_driver","$driver_type","$default_value" );
|
184 |
|
|
$absDef_db->db_put( $Key, join(':', @info) );
|
185 |
|
|
|
186 |
|
|
|
187 |
|
|
|
188 |
|
|
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
my $master_presence;
|
192 |
|
|
my $master_width;
|
193 |
|
|
my $master_direction;
|
194 |
|
|
|
195 |
|
|
foreach my $onMaster ($spirit_absDef_file->findnodes("//spirit:abstractionDefinition/spirit:ports/spirit:port/spirit:logicalName[text() = '$logical_name']/../spirit:wire/spirit:onMaster/spirit:direction"))
|
196 |
|
|
{
|
197 |
|
|
$master_direction = $onMaster->findnodes('./text()')->to_literal ;
|
198 |
|
|
$master_width = $onMaster->findnodes('../spirit:width/text()')->to_literal ;
|
199 |
|
|
$master_presence = $onMaster->findnodes('../spirit:presence/text()')->to_literal ;
|
200 |
|
|
#print " onMaster presence $master_presence \n";
|
201 |
|
|
#unless($master_width) {$master_width = 1;}
|
202 |
|
|
#print "\n";
|
203 |
|
|
if($master_direction eq "in") {$master_direction = "input";}
|
204 |
|
|
if($master_direction eq "out"){$master_direction = "output";}
|
205 |
|
|
|
206 |
|
|
|
207 |
|
|
my $Key = "master__${logical_name}" ;
|
208 |
|
|
my @info = ("$logical_name","$master_presence","$master_width","$master_direction" );
|
209 |
|
|
$absDef_db->db_put( $Key, join(':', @info) );
|
210 |
|
|
#print "PUT $Key @info \n";
|
211 |
|
|
}
|
212 |
|
|
|
213 |
|
|
my $slave_presence;
|
214 |
|
|
my $slave_width;
|
215 |
|
|
my $slave_direction;
|
216 |
|
|
|
217 |
|
|
foreach my $onSlave ($spirit_absDef_file->findnodes("//spirit:abstractionDefinition/spirit:ports/spirit:port/spirit:logicalName[text() = '$logical_name']/../spirit:wire/spirit:onSlave/spirit:direction"))
|
218 |
|
|
{
|
219 |
|
|
$slave_direction = $onSlave->findnodes('./text()')->to_literal ;
|
220 |
|
|
$slave_width = $onSlave->findnodes('../spirit:width/text()')->to_literal ;
|
221 |
|
|
$slave_presence = $onSlave->findnodes('../spirit:presence/text()')->to_literal ;
|
222 |
|
|
#print " onSlave presence $slave_presence \n";
|
223 |
|
|
#unless($slave_width) {$slave_width = 1;}
|
224 |
|
|
#print "\n";
|
225 |
|
|
if($slave_direction eq "in") {$slave_direction = "input";}
|
226 |
|
|
if($slave_direction eq "out"){$slave_direction = "output";}
|
227 |
|
|
my $Key = "slave__${logical_name}" ;
|
228 |
|
|
my @info = ("$logical_name","$slave_presence","$slave_width","$slave_direction" );
|
229 |
|
|
$absDef_db->db_put( $Key, join(':', @info) );
|
230 |
|
|
#print "PUT $Key @info \n";
|
231 |
|
|
|
232 |
|
|
}
|
233 |
|
|
|
234 |
|
|
|
235 |
|
|
my %systemGroupPresence= ();
|
236 |
|
|
my %systemGroupWidth= ();
|
237 |
|
|
my %systemGroupDirection= ();
|
238 |
|
|
|
239 |
|
|
|
240 |
|
|
|
241 |
|
|
foreach my $onSystem ($spirit_absDef_file->findnodes("//spirit:abstractionDefinition/spirit:ports/spirit:port/spirit:logicalName[text() = '$logical_name']/../spirit:wire/spirit:onSystem/spirit:group"))
|
242 |
|
|
{
|
243 |
|
|
my($system_group) = $onSystem->findnodes('./text()')->to_literal ;
|
244 |
|
|
my($presence) = $onSystem->findnodes('../spirit:presence/text()')->to_literal ;
|
245 |
|
|
my($width) = $onSystem->findnodes('../spirit:width/text()')->to_literal ;
|
246 |
|
|
my($direction) = $onSystem->findnodes('../spirit:direction/text()')->to_literal ;
|
247 |
|
|
#print " onSystem Group $system_group \n";
|
248 |
|
|
#print " onSystem presence $presence \n";
|
249 |
|
|
#unless($width) {$width = 1;}
|
250 |
|
|
#print "\n";
|
251 |
|
|
|
252 |
|
|
my $Key = "system__${logical_name}" ;
|
253 |
|
|
my @info = ("$logical_name","$system_group","$presence","$width","$direction" );
|
254 |
|
|
$absDef_db->db_put( $Key, join(':', @info) );
|
255 |
|
|
#print "PUT $Key @info \n";
|
256 |
|
|
|
257 |
|
|
$systemGroupPresence{$system_group} =$presence ;
|
258 |
|
|
$systemGroupWidth{$system_group} =$width ;
|
259 |
|
|
$systemGroupDirection{$system_group} =$direction ;
|
260 |
|
|
}
|
261 |
|
|
# insert DRC checks here
|
262 |
|
|
|
263 |
|
|
}
|
264 |
|
|
}
|
265 |
|
|
|
266 |
|
|
$absDef_db->db_close();
|
267 |
|
|
#print "\n";
|
268 |
|
|
|
269 |
|
|
|
270 |
|
|
|
271 |
|
|
|
272 |
|
|
|
273 |
|
|
|