import
numpy as np
import
matplotlib.pyplot as plt
import
operator
import
glob
import
pylab
from
matplotlib.ticker
import
MultipleLocator
files
=
sorted
(glob.glob(
'S:/netlist/netlist*'
))
file_dict
=
{}
cnt
=
1
for
filename
in
files:
f
=
open
(filename)
dict
=
{}
lines
=
f.readlines()
for
l
in
lines:
ind
=
l[
0
]
+
l[
2
]
+
l[
4
]
if
ind
not
in
dict
:
dict
[ind]
=
cnt
cnt
=
cnt
+
1
file_dict[filename]
=
dict
for
i
in
range
(
0
,
len
(files)):
sorted_dict
=
sorted
(file_dict[files[i]].items(), key
=
operator.itemgetter(
1
))
for
t
in
sorted_dict:
print
(t)
def
hex_string_to_bin_string(
input
):
lookup
=
{
"0"
:
"0000"
,
"1"
:
"0001"
,
"2"
:
"0010"
,
"3"
:
"0011"
,
"4"
:
"0100"
,
"5"
:
"0101"
,
"6"
:
"0110"
,
"7"
:
"0111"
,
"8"
:
"1000"
,
"9"
:
"1001"
,
"A"
:
"1010"
,
"B"
:
"1011"
,
"C"
:
"1100"
,
"D"
:
"1101"
,
"E"
:
"1110"
,
"F"
:
"1111"
}
result
=
""
for
byte
in
input
:
result
=
result
+
lookup[byte]
return
result
def
hex_string_to_hex_value(
input
):
value
=
hex_string_to_bin_string(
input
)
highest_order
=
len
(value)
-
1
result
=
0
for
bit
in
value:
result
=
result
+
int
(bit)
*
pow
(
2
,highest_order)
highest_order
=
highest_order
-
1
return
hex
(result)
def
on_press(event):
print
(
'you pressed'
, event.button, event.xdata, event.ydata)
event.canvas.figure.clear()
event.canvas.figure.gca().plot([
1
,
2
,
3
],[
0
,
0
,
0
],
'ro-'
)
event.canvas.figure.gca().grid()
event.canvas.figure.gca().legend()
event.canvas.draw()
a
=
open
(
'full_list.txt'
)
lines
=
a.readlines()
for
b
in
lines:
if
((b[
0
]
=
=
'0'
)
and
(b[
1
] !
=
' '
)):
X
=
b[
1
]
+
b[
2
]
else
:
index
=
b[
0
]
+
b[
2
]
+
b[
4
]
+
b[
6
]
hexa
=
hex_string_to_hex_value(index)
dec
=
int
(hexa, base
=
16
)
my_array
=
[]
while
(dec!
=
0
):
if
((dec
%
2
)
=
=
0
):
y
=
0
dec
=
int
(dec
/
2
)
my_array.append(y)
else
:
y
=
1
dec
=
int
(dec
/
2
)
my_array.append(y)
my_array.reverse()
i
=
len
(my_array)
while
(i <
16
):
my_array.insert(
0
,
0
)
i
=
i
+
1
if
(my_array[
0
]
=
=
0
):
if
(my_array[
1
]
=
=
1
):
iden1
=
(
256
*
b[
2
])
+
(
16
*
b[
4
])
+
b[
6
]
iden
=
int
(iden1, base
=
16
)
else
:
point
=
iden
-
2
ind2
=
b[
2
]
+
b[
4
]
+
b[
6
]
if
(file_dict[files[point]].get(ind2)):
Y
=
file_dict[files[point]][ind2]
plt.plot([X], [Y], marker
=
'o'
, markersize
=
2
, color
=
"black"
)
ax
=
plt.gca()
ax.xaxis.grid(
True
)
else
:
print
(
'Unknown Spike'
,
' '
,
'-'
,
' '
,ind2)
plt.show()
figure.canvas.mpl_connect(
'button_press_event'
, on_press)