1 |
131 |
jt_eaton |
eval 'exec `which perl` -S $0 ${1+"$@"}'
|
2 |
|
|
if 0;
|
3 |
|
|
|
4 |
135 |
jt_eaton |
#/****************************************************************************/
|
5 |
|
|
#/* */
|
6 |
|
|
#/* SOCGEN Design for Reuse toolset */
|
7 |
|
|
#/* */
|
8 |
|
|
#/* Version 1.0.0 */
|
9 |
|
|
#/* */
|
10 |
|
|
#/* Author(s): */
|
11 |
|
|
#/* - John Eaton, z3qmtr45@gmail.com */
|
12 |
|
|
#/* */
|
13 |
|
|
#/****************************************************************************/
|
14 |
|
|
#/* */
|
15 |
|
|
#/* */
|
16 |
|
|
#/* Copyright 2016 John T Eaton */
|
17 |
|
|
#/* */
|
18 |
|
|
#/* Licensed under the Apache License, Version 2.0 (the "License"); */
|
19 |
|
|
#/* you may not use this file except in compliance with the License. */
|
20 |
|
|
#/* You may obtain a copy of the License at */
|
21 |
|
|
#/* */
|
22 |
|
|
#/* http://www.apache.org/licenses/LICENSE-2.0 */
|
23 |
|
|
#/* */
|
24 |
|
|
#/* Unless required by applicable law or agreed to in writing, software */
|
25 |
|
|
#/* distributed under the License is distributed on an "AS IS" BASIS, */
|
26 |
|
|
#/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
|
27 |
|
|
#/* See the License for the specific language governing permissions and */
|
28 |
|
|
#/* limitations under the License. */
|
29 |
|
|
#/* */
|
30 |
|
|
#/* */
|
31 |
|
|
#/****************************************************************************/
|
32 |
131 |
jt_eaton |
|
33 |
|
|
############################################################################
|
34 |
|
|
# General PERL config
|
35 |
|
|
############################################################################
|
36 |
|
|
use Getopt::Long;
|
37 |
|
|
use English;
|
38 |
|
|
use File::Basename;
|
39 |
|
|
use Cwd;
|
40 |
|
|
use Scalar::Util qw(looks_like_number);
|
41 |
|
|
use XML::LibXML;
|
42 |
|
|
use lib './tools';
|
43 |
|
|
use sys::lib;
|
44 |
|
|
use yp::lib;
|
45 |
|
|
use BerkeleyDB;
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
############################################################################
|
52 |
|
|
### Process the options
|
53 |
|
|
############################################################################
|
54 |
|
|
Getopt::Long::config("require_order", "prefix=-");
|
55 |
|
|
GetOptions("h","help",
|
56 |
|
|
"vendor=s" => \$vendor,
|
57 |
|
|
"library=s" => \$library,
|
58 |
|
|
"version=s" => \$version,
|
59 |
|
|
"component=s" => \$component,
|
60 |
|
|
"debug","verbose"
|
61 |
|
|
) || die "(use '$program_name -h' for help)";
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
##############################################################################
|
65 |
|
|
## Help option
|
66 |
|
|
##############################################################################
|
67 |
|
|
if ( $opt_h or $opt_help )
|
68 |
|
|
{ print "\n gen_busdef -vendor vendor_name -library library_name -component component_name -version version_name ";
|
69 |
|
|
print "\n";
|
70 |
|
|
exit 1;
|
71 |
|
|
}
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
#############################################################################
|
75 |
|
|
##
|
76 |
|
|
##
|
77 |
|
|
#############################################################################
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
$home = cwd();
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
my $variant;
|
84 |
|
|
my $parser = XML::LibXML->new();
|
85 |
134 |
jt_eaton |
#print "\n GEN_busdef $vendor $library $component $version \n";
|
86 |
131 |
jt_eaton |
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
my $io_ports = yp::lib::get_io_ports() ;
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
|
93 |
|
|
|
94 |
|
|
my $path = "${io_ports}";
|
95 |
|
|
mkdir $path,0755 unless( -e $path );
|
96 |
|
|
$path = "${io_ports}/${vendor}__${library}";
|
97 |
|
|
mkdir $path,0755 unless( -e $path );
|
98 |
|
|
$path = "${io_ports}/${vendor}__${library}/${component}";
|
99 |
|
|
mkdir $path,0755 unless( -e $path );
|
100 |
|
|
$filename ="${io_ports}/${vendor}__${library}/${component}/${component}_${version}_ABSDEF.dbm";
|
101 |
|
|
|
102 |
|
|
if(-e ${filename} )
|
103 |
|
|
{
|
104 |
|
|
print " $filename Exists, exiting \n";
|
105 |
|
|
exit 0;
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
$absDef_db = new BerkeleyDB::Hash( -Filename => $filename, -Flags => DB_CREATE ) or die "Cannot open file: $!";
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
|
114 |
|
|
my $spirit_file = yp::lib::find_ipxact_abstractionDefinition($vendor,$library,$component,$version);
|
115 |
|
|
|
116 |
|
|
# print "\tFilename: ${spirit_file}\n";
|
117 |
|
|
unless ($spirit_file) {print "Error absDef $vendor $library $component $version file does not exist";}
|
118 |
|
|
|
119 |
|
|
my $spirit_absDef_file = $parser->parse_file($spirit_file);
|
120 |
135 |
jt_eaton |
foreach my $absDef ($spirit_absDef_file->findnodes("//ipxact:abstractionDefinition/ipxact:vendor"))
|
121 |
131 |
jt_eaton |
{
|
122 |
|
|
my($bd_vendor) = $absDef->findnodes('./text()')->to_literal ;
|
123 |
135 |
jt_eaton |
my($bd_library) = $absDef->findnodes('../ipxact:library/text()')->to_literal ;
|
124 |
|
|
my($bd_name) = $absDef->findnodes('../ipxact:name/text()')->to_literal ;
|
125 |
|
|
my($bd_version) = $absDef->findnodes('../ipxact:version/text()')->to_literal ;
|
126 |
131 |
jt_eaton |
# print "\tVLNV-ad ${bd_vendor}_${bd_library}_${bd_name}_${bd_version}\n";
|
127 |
|
|
|
128 |
|
|
my %systemGroupNames = ();
|
129 |
|
|
|
130 |
|
|
|
131 |
135 |
jt_eaton |
foreach my $bus_type ($spirit_absDef_file->findnodes("//ipxact:abstractionDefinition/ipxact:busType"))
|
132 |
131 |
jt_eaton |
{
|
133 |
135 |
jt_eaton |
my($bt_vendor) = $bus_type->findnodes('./@vendor')->to_literal ;
|
134 |
|
|
my($bt_library) = $bus_type->findnodes('./@library')->to_literal ;
|
135 |
|
|
my($bt_name) = $bus_type->findnodes('./@name')->to_literal ;
|
136 |
|
|
my($bt_version) = $bus_type->findnodes('./@version')->to_literal ;
|
137 |
131 |
jt_eaton |
# print "\tVLNV-bt ${bt_vendor}_${bt_library}_${bt_name}_${bt_version}\n";
|
138 |
|
|
|
139 |
|
|
my $spirit_file = yp::lib::find_ipxact_busDefinition($bt_vendor,$bt_library,$bt_name,$bt_version);
|
140 |
|
|
|
141 |
135 |
jt_eaton |
unless ($spirit_file) {print "ERROR: No bus definition ${bd_vendor}:${bd_library}:${bd_name}:${bd_version} \n";}
|
142 |
131 |
jt_eaton |
else
|
143 |
|
|
{
|
144 |
|
|
my $spirit_busDef_file = $parser->parse_file($spirit_file);
|
145 |
135 |
jt_eaton |
foreach my $i_name ($spirit_busDef_file->findnodes("//ipxact:busDefinition/ipxact:systemGroupNames/ipxact:systemGroupName"))
|
146 |
131 |
jt_eaton |
{
|
147 |
|
|
my($sysgroup_name) = $i_name ->findnodes('./text()')->to_literal;
|
148 |
|
|
# print "\t SystemGroup Name $sysgroup_name \n";
|
149 |
|
|
$systemGroupNames{$sysgroup_name} = 1;
|
150 |
|
|
}
|
151 |
|
|
}
|
152 |
|
|
}
|
153 |
|
|
|
154 |
135 |
jt_eaton |
foreach my $absDef ($spirit_absDef_file->findnodes("//ipxact:abstractionDefinition/ipxact:ports/ipxact:port/ipxact:logicalName"))
|
155 |
131 |
jt_eaton |
{
|
156 |
|
|
my($logical_name) = $absDef->findnodes('./text()')->to_literal ;
|
157 |
135 |
jt_eaton |
my($is_clock) = $absDef->findnodes('../ipxact:wire/ipxact:qualifier/ipxact:isClock/text()')->to_literal ;
|
158 |
|
|
my($is_reset) = $absDef->findnodes('../ipxact:wire/ipxact:qualifier/ipxact:isReset/text()')->to_literal ;
|
159 |
|
|
my($is_address) = $absDef->findnodes('../ipxact:wire/ipxact:qualifier/ipxact:isAddress/text()')->to_literal ;
|
160 |
|
|
my($is_data) = $absDef->findnodes('../ipxact:wire/ipxact:qualifier/ipxact:isData/text()')->to_literal ;
|
161 |
|
|
my($requires_driver) = $absDef->findnodes('../ipxact:wire/ipxact:requiresDriver/text()')->to_literal ;
|
162 |
|
|
my($driver_type) = $absDef->findnodes('../ipxact:wire/ipxact:requiresDriver/@ipxact:driverType')->to_literal ;
|
163 |
|
|
my($default_value) = $absDef->findnodes('../ipxact:wire/ipxact:defaultValue/text()')->to_literal ;
|
164 |
131 |
jt_eaton |
|
165 |
|
|
# print "\nPort: ${logical_name} ";
|
166 |
|
|
|
167 |
|
|
|
168 |
|
|
my $Key = "port__${logical_name}" ;
|
169 |
|
|
my @info = ("$logical_name","$is_clock","$is_reset","$is_address","$is_data","$requires_driver","$driver_type","$default_value" );
|
170 |
|
|
$absDef_db->db_put( $Key, join(':', @info) );
|
171 |
|
|
|
172 |
|
|
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
my $master_presence;
|
178 |
|
|
my $master_width;
|
179 |
|
|
my $master_direction;
|
180 |
|
|
|
181 |
135 |
jt_eaton |
foreach my $onMaster ($spirit_absDef_file->findnodes("//ipxact:abstractionDefinition/ipxact:ports/ipxact:port/ipxact:logicalName[text() = '$logical_name']/../ipxact:wire/ipxact:onMaster/ipxact:direction"))
|
182 |
131 |
jt_eaton |
{
|
183 |
|
|
$master_direction = $onMaster->findnodes('./text()')->to_literal ;
|
184 |
135 |
jt_eaton |
$master_width = $onMaster->findnodes('../ipxact:width/text()')->to_literal ;
|
185 |
|
|
$master_presence = $onMaster->findnodes('../ipxact:presence/text()')->to_literal ;
|
186 |
131 |
jt_eaton |
#print " onMaster presence $master_presence \n";
|
187 |
|
|
#unless($master_width) {$master_width = 1;}
|
188 |
|
|
#print "\n";
|
189 |
|
|
if($master_direction eq "in") {$master_direction = "input";}
|
190 |
|
|
if($master_direction eq "out"){$master_direction = "output";}
|
191 |
|
|
|
192 |
|
|
|
193 |
|
|
my $Key = "master__${logical_name}" ;
|
194 |
|
|
my @info = ("$logical_name","$master_presence","$master_width","$master_direction" );
|
195 |
|
|
$absDef_db->db_put( $Key, join(':', @info) );
|
196 |
|
|
#print "PUT $Key @info \n";
|
197 |
|
|
}
|
198 |
|
|
|
199 |
|
|
my $slave_presence;
|
200 |
|
|
my $slave_width;
|
201 |
|
|
my $slave_direction;
|
202 |
|
|
|
203 |
135 |
jt_eaton |
foreach my $onSlave ($spirit_absDef_file->findnodes("//ipxact:abstractionDefinition/ipxact:ports/ipxact:port/ipxact:logicalName[text() = '$logical_name']/../ipxact:wire/ipxact:onSlave/ipxact:direction"))
|
204 |
131 |
jt_eaton |
{
|
205 |
|
|
$slave_direction = $onSlave->findnodes('./text()')->to_literal ;
|
206 |
135 |
jt_eaton |
$slave_width = $onSlave->findnodes('../ipxact:width/text()')->to_literal ;
|
207 |
|
|
$slave_presence = $onSlave->findnodes('../ipxact:presence/text()')->to_literal ;
|
208 |
131 |
jt_eaton |
#print " onSlave presence $slave_presence \n";
|
209 |
|
|
#unless($slave_width) {$slave_width = 1;}
|
210 |
|
|
#print "\n";
|
211 |
|
|
if($slave_direction eq "in") {$slave_direction = "input";}
|
212 |
|
|
if($slave_direction eq "out"){$slave_direction = "output";}
|
213 |
|
|
my $Key = "slave__${logical_name}" ;
|
214 |
|
|
my @info = ("$logical_name","$slave_presence","$slave_width","$slave_direction" );
|
215 |
|
|
$absDef_db->db_put( $Key, join(':', @info) );
|
216 |
|
|
#print "PUT $Key @info \n";
|
217 |
|
|
|
218 |
|
|
}
|
219 |
|
|
|
220 |
|
|
|
221 |
|
|
my %systemGroupPresence= ();
|
222 |
|
|
my %systemGroupWidth= ();
|
223 |
|
|
my %systemGroupDirection= ();
|
224 |
|
|
|
225 |
|
|
|
226 |
|
|
|
227 |
135 |
jt_eaton |
foreach my $onSystem ($spirit_absDef_file->findnodes("//ipxact:abstractionDefinition/ipxact:ports/ipxact:port/ipxact:logicalName[text() = '$logical_name']/../ipxact:wire/ipxact:onSystem/ipxact:group"))
|
228 |
131 |
jt_eaton |
{
|
229 |
|
|
my($system_group) = $onSystem->findnodes('./text()')->to_literal ;
|
230 |
135 |
jt_eaton |
my($presence) = $onSystem->findnodes('../ipxact:presence/text()')->to_literal ;
|
231 |
|
|
my($width) = $onSystem->findnodes('../ipxact:width/text()')->to_literal ;
|
232 |
|
|
my($direction) = $onSystem->findnodes('../ipxact:direction/text()')->to_literal ;
|
233 |
131 |
jt_eaton |
#print " onSystem Group $system_group \n";
|
234 |
|
|
#print " onSystem presence $presence \n";
|
235 |
|
|
#unless($width) {$width = 1;}
|
236 |
|
|
#print "\n";
|
237 |
|
|
|
238 |
|
|
my $Key = "system__${logical_name}" ;
|
239 |
|
|
my @info = ("$logical_name","$system_group","$presence","$width","$direction" );
|
240 |
|
|
$absDef_db->db_put( $Key, join(':', @info) );
|
241 |
|
|
#print "PUT $Key @info \n";
|
242 |
|
|
|
243 |
|
|
$systemGroupPresence{$system_group} =$presence ;
|
244 |
|
|
$systemGroupWidth{$system_group} =$width ;
|
245 |
|
|
$systemGroupDirection{$system_group} =$direction ;
|
246 |
|
|
}
|
247 |
|
|
# insert DRC checks here
|
248 |
|
|
|
249 |
|
|
}
|
250 |
|
|
}
|
251 |
|
|
|
252 |
|
|
$absDef_db->db_close();
|
253 |
|
|
#print "\n";
|
254 |
|
|
|
255 |
|
|
|
256 |
|
|
|
257 |
|
|
|
258 |
|
|
|
259 |
|
|
|