1 |
131 |
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 |
131 |
jt_eaton |
|
32 |
|
|
|
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 |
|
|
"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 read_ports -vendor vendor_name -library library_name -component component_name -version version_name \n";
|
69 |
|
|
exit 1;
|
70 |
|
|
}
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
#############################################################################
|
78 |
|
|
##
|
79 |
|
|
##
|
80 |
|
|
#############################################################################
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
$home = cwd();
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
my $variant;
|
87 |
|
|
|
88 |
|
|
if($version) {$variant = "${component}_${version}";}
|
89 |
|
|
else {$variant = "${component}";}
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
my $main_module_name = yp::lib::get_module_name($vendor,$library,$component,$version) ;
|
93 |
|
|
my $parser = XML::LibXML->new();
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
my $spirit_component_file = $parser->parse_file(yp::lib::find_ipxact_component($vendor,$library,$component,$version));
|
97 |
|
|
|
98 |
|
|
if($opt_verbose) {print "\n READ_ports $vendor $library $component $version \n";}
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
my $io_ports = yp::lib::get_io_ports() ;
|
103 |
|
|
|
104 |
|
|
my $gen_port_outfile = yp::lib::get_io_ports_db_filename($vendor,$library,$component,$version);
|
105 |
|
|
$ports_db = new BerkeleyDB::Hash( -Filename => $gen_port_outfile, -Flags => DB_CREATE ) or die "Cannot open ${gen_port_outfile}: $!";
|
106 |
|
|
# print "XXXXXXXX $gen_port_outfile READ PORTS \n";
|
107 |
|
|
|
108 |
|
|
|
109 |
134 |
jt_eaton |
my $gen_bus_outfile = yp::lib::get_io_busses_db_filename($vendor,$library,$component,$version,"default");
|
110 |
131 |
jt_eaton |
$busses_db = new BerkeleyDB::Hash( -Filename => $gen_bus_outfile, -Flags => DB_CREATE ) or die "Cannot open ${gen_bus_outfile}: $!";
|
111 |
|
|
# print "XXXXXXXX $gen_bus_outfile READ PORTS \n";
|
112 |
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
my $key;
|
116 |
|
|
my $value;
|
117 |
|
|
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
my @bus_list;
|
121 |
|
|
my @adhoc_list;
|
122 |
|
|
|
123 |
|
|
my $cursor = $busses_db ->db_cursor() ;
|
124 |
|
|
while ($cursor->c_get($key, $value, DB_NEXT) == 0)
|
125 |
|
|
{
|
126 |
|
|
# print "INPUT $key, $value \n";
|
127 |
|
|
( ${key_type},${busref},${conn}) = split( /\./ , $key);
|
128 |
|
|
( ${log_name},${direction},${type},${vector},${left},${right},${phy_name}) = split ':', $value;
|
129 |
|
|
if(($key_type eq "BusRef"))
|
130 |
|
|
{
|
131 |
|
|
push (@bus_list, "${busref}_${conn} ${phy_name} ${log_name} ${direction} ${type} ${vector} ${left}:${right} ");
|
132 |
|
|
uplift_port( ${phy_name} , ${direction}, ${type} , ${vector}, ${left} , ${right} );
|
133 |
|
|
}
|
134 |
|
|
else
|
135 |
|
|
{
|
136 |
|
|
|
137 |
|
|
}
|
138 |
|
|
|
139 |
|
|
}
|
140 |
|
|
|
141 |
|
|
my $status = $cursor->c_close() ;
|
142 |
|
|
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
$cursor = $ports_db ->db_cursor() ;
|
146 |
|
|
while ($cursor->c_get($key, $value, DB_NEXT) == 0)
|
147 |
|
|
{
|
148 |
|
|
( ${key_type},${busref},${conn}) = split( /\./ , $key);
|
149 |
|
|
( ${log_name},${direction},${type},${vector},${left},${right},${phy_name}) = split ':', $value;
|
150 |
|
|
# print "OUTPUT $key, $value \n";
|
151 |
|
|
if(($key_type eq "BusRef"))
|
152 |
|
|
{
|
153 |
|
|
}
|
154 |
|
|
else
|
155 |
|
|
{
|
156 |
|
|
push (@adhoc_list," ${log_name} ${direction} ${type} ${vector} ${left}:${right} ");
|
157 |
|
|
}
|
158 |
|
|
}
|
159 |
|
|
|
160 |
|
|
my $status = $cursor->c_close() ;
|
161 |
|
|
|
162 |
|
|
|
163 |
|
|
$ports_db -> db_close();
|
164 |
|
|
$busses_db -> db_close();
|
165 |
|
|
|
166 |
|
|
|
167 |
|
|
|
168 |
|
|
@bus_list = sys::lib::trim_sort(@bus_list);
|
169 |
|
|
@adhoc_list = sys::lib::trim_sort(@adhoc_list);
|
170 |
|
|
my @busses = yp::lib::get_busses($vendor,$library,$component,$version);
|
171 |
|
|
|
172 |
|
|
if($opt_verbose)
|
173 |
|
|
{
|
174 |
|
|
foreach $list (@bus_list) { print "${list}\n"; }
|
175 |
|
|
foreach $list (@adhoc_list) { print "${list}\n"; }
|
176 |
|
|
foreach $list (@busses) { print "${list}\n"; }
|
177 |
|
|
}
|
178 |
|
|
|
179 |
|
|
|
180 |
|
|
|
181 |
|
|
#/*********************************************************************************************/
|
182 |
|
|
#/ */
|
183 |
|
|
#/ */
|
184 |
|
|
#/ */
|
185 |
|
|
#/ */
|
186 |
|
|
#/ */
|
187 |
|
|
#/ */
|
188 |
|
|
#/*********************************************************************************************/
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
sub uplift_port
|
192 |
|
|
{
|
193 |
|
|
my @params = @_;
|
194 |
|
|
my $right = pop(@params);
|
195 |
|
|
my $left = pop(@params);
|
196 |
|
|
my $vector = pop(@params);
|
197 |
|
|
my $type = pop(@params);
|
198 |
|
|
my $direction = pop(@params);
|
199 |
|
|
my $log_name = pop(@params);
|
200 |
|
|
|
201 |
|
|
if($opt_verbose){ print "PORT_UPLIFT $log_name $direction $type $vector $left $right \n";}
|
202 |
|
|
$ports_db->db_put( "kxcd","${log_name}:${direction}:${type}:${vector}:${left}:${right}:HIER_HOLD" );
|
203 |
|
|
|
204 |
|
|
|
205 |
|
|
my $uplift_data;
|
206 |
|
|
my $uplift_log_name ;
|
207 |
|
|
my $uplift_direction ;
|
208 |
|
|
my $uplift_type;
|
209 |
|
|
my $uplift_vector;
|
210 |
|
|
my $uplift_left;
|
211 |
|
|
my $uplift_right;
|
212 |
|
|
|
213 |
|
|
$ports_db->db_get("$log_name", $uplift_data );
|
214 |
|
|
(${uplift_log_name},${uplift_direction},${uplift_type},${uplift_vector},${uplift_left},${uplift_right} ) = split ':', $uplift_data;
|
215 |
|
|
|
216 |
|
|
$ports_db->db_get("kxcd", $uplift_data );
|
217 |
|
|
(${log_name},${direction},${type},${vector},${left},${right} ) = split ':', $uplift_data;
|
218 |
|
|
$ports_db->db_del("kxcd");
|
219 |
|
|
|
220 |
|
|
if(${uplift_log_name})
|
221 |
|
|
{
|
222 |
|
|
# print "REPLACING ${uplift_log_name} ${uplift_direction} ${uplift_type} ${uplift_vector} ${uplift_left} ${uplift_right} \n";
|
223 |
|
|
if(${uplift_direction} ne "node" ) { $direction =${uplift_direction};}
|
224 |
|
|
|
225 |
|
|
if(${type} eq "wire" ) { $type =${uplift_type};}
|
226 |
|
|
|
227 |
|
|
if(${uplift_vector} eq "vector")
|
228 |
|
|
{
|
229 |
|
|
if( $vector eq "vector" )
|
230 |
|
|
{
|
231 |
|
|
if( looks_like_number($uplift_left))
|
232 |
|
|
{
|
233 |
|
|
if( looks_like_number($left) )
|
234 |
|
|
{
|
235 |
|
|
if($uplift_left > $left ) {$left = $uplift_left;}
|
236 |
|
|
}
|
237 |
|
|
|
238 |
|
|
}
|
239 |
|
|
else
|
240 |
|
|
{
|
241 |
|
|
if( looks_like_number($left) ) {$left = ${uplift_left}; }
|
242 |
|
|
unless(${direction} ne "node") {$left = ${uplift_left}; }
|
243 |
|
|
}
|
244 |
|
|
if( looks_like_number($uplift_right) && looks_like_number($right) ) { if($uplift_right < $right ) {$right = $uplift_right;}}
|
245 |
|
|
}
|
246 |
|
|
else
|
247 |
|
|
{
|
248 |
|
|
$vector = "vector";
|
249 |
|
|
$left = ${uplift_left};
|
250 |
|
|
$right = ${uplift_right};
|
251 |
|
|
}
|
252 |
|
|
}
|
253 |
|
|
}
|
254 |
|
|
# print "WITH $log_name $direction $type $vector $left $right \n";
|
255 |
|
|
$ports_db->db_put( "${log_name}","${log_name}:${direction}:${type}:${vector}:${left}:${right}" );
|
256 |
|
|
if($opt_verbose) { print "XXXXXXXX WROTE ${log_name} ${log_name}:${direction}:${type}:${vector}:${left}:${right} \n";}
|
257 |
|
|
}
|
258 |
|
|
|
259 |
|
|
|
260 |
|
|
|
261 |
|
|
|
262 |
|
|
|
263 |
|
|
|
264 |
|
|
|
265 |
|
|
|
266 |
|
|
|
267 |
|
|
1
|