forked from trabucayre/ipyxact
-
Notifications
You must be signed in to change notification settings - Fork 0
/
print_businterfaces.py
53 lines (47 loc) · 2.1 KB
/
print_businterfaces.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import sys
from ipyxact.ipyxact import Component
def get_businterfaces(busInterfaces):
ifs = []
for busInterface in busInterfaces.busInterface:
print('='*20)
print('name : ' + busInterface.name)
_vendor = busInterface.busType.vendor
_library = busInterface.busType.library
_name = busInterface.busType.name
_version = busInterface.busType.version
print(busInterface.busType.name)
print('busType : {}/{}/{}/{}'.format(_vendor,
_library,
_name,
_version))
print('abstractionType : {}/{}/{}/{}'.format(_vendor,
_library,
_name,
_version))
if busInterface.portMaps:
for portMap in busInterface.portMaps.portMap:
if portMap.logicalPort.vector:
log_range = '[{}:{}]'.format(portMap.logicalPort.vector.left,
portMap.logicalPort.vector.right)
else:
log_range = ''
if portMap.physicalPort.vector:
phy_range = '[{}:{}]'.format(portMap.physicalPort.vector.left,
portMap.physicalPort.vector.right)
else:
phy_range = ''
print("{}{} => {}{}".format(portMap.logicalPort.name,
log_range,
portMap.physicalPort.name,
phy_range))
return ifs
if __name__ == "__main__":
f = open(sys.argv[1])
component = Component()
component.load(f)
if component.busInterfaces is not None:
ifs = get_businterfaces(component.busInterfaces)
print(ifs)
else:
print("No bus interfaces found in file")
f.close()