Skip to content

Commit 96b1c09

Browse files
author
Leo
committed
Merge branch 'first_version' of https://github.com/Semi-ATE/PyLab-ML into first_version
2 parents 7d333d4 + dc0acfd commit 96b1c09

File tree

5 files changed

+1684
-38
lines changed

5 files changed

+1684
-38
lines changed

pylab_ml/common/memorytest.py

Lines changed: 122 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class MER:
1616

1717
def __init__(self, log_error):
1818
self.log_error = log_error
19-
self._values = ["read 0"] * self.SIZE # define 4 March Element Register, default value = "read 0"
19+
self._values = ["read 0"] * self.SIZE # define 4 March Element Register, default value = "read 0"
2020

2121
def __getitem__(self, index):
2222
if not isinstance(index, int) or not (1 <= index < self.SIZE+1):
@@ -40,10 +40,78 @@ def __setitem__(self, index, value):
4040

4141
class Memory_test():
4242
"""
43+
44+
TODO:
45+
- only data background = sdb implemented, missing: 'bdb', 'rdb', 'cdb'
46+
- Address counting according to the actual layout structure is missing.
47+
- bin x = linear counting
48+
- bin y missing
49+
- operation next missing
50+
- operation hammer missing
4351
"""
44-
pdata_background = ['sdb', 'bdb', 'rdb', 'cdb']
52+
pdata_background = ['sdb', # solid DB - all bits with same data
53+
'bdb' # checkerboard DB - adjacent cells with different data not implemented
54+
'rdb' # row stripes DB not implemented
55+
'cdb' # column striped DB not implemented
56+
]
4557
pcount_method = ['bin x', 'complement']
4658
padr_order = ['up', 'down']
59+
60+
algo_ops = {'Scan': {'len' :4, 'ops': [['up', 'w0'],
61+
['r0'],
62+
['down', 'w1'],
63+
['r1']]},
64+
'Scan Complement': {'len': 4, 'ops': [['up', 'w0'],
65+
['complement', 'r0'],
66+
['bin x', 'down', 'w1'],
67+
['complement', 'r1']]},
68+
'Scan+': {'len': 8, 'ops': [['up', 'w0'],
69+
['r0'],
70+
['down', 'w1'],
71+
['r1'],
72+
['w0'],
73+
['r0'],
74+
['up', 'w1'],
75+
['r1']]},
76+
'MATS+': {'len': 5, 'ops': [['up', 'w0'],
77+
['r0', 'w1'],
78+
['down', 'r1', 'w0']]},
79+
'March C-': {'len': 10, 'ops': [['up', 'w0'],
80+
['r0', 'w1'],
81+
['r1', 'w0'],
82+
['down', 'r0', 'w1'],
83+
['r1', 'w0'],
84+
['r0']]},
85+
'PMOVI': {'len': 13, 'ops': [['down', 'w0'],
86+
['up', 'r0', 'w1', 'r1'],
87+
['r1', 'w0', 'r0'],
88+
['down', 'r0', 'w1', 'r1'],
89+
['r1', 'w0', 'r0']]},
90+
'March U': {'len': 13, 'ops': [['up', 'w0'],
91+
['r0', 'w1', 'r1', 'w0'],
92+
['r0', 'w1'],
93+
['down', 'r1', 'w0', 'r0', 'w1'],
94+
['r1', 'w0']]},
95+
'March LR': {'len': 14, 'ops': [['up', 'w0'],
96+
['down', 'r0', 'w1'],
97+
['up', 'r1', 'w0', 'r0', 'w1'],
98+
['r1', 'w0'],
99+
['r0', 'w1', 'r1', 'w0'],
100+
['r0']]},
101+
# 'BLIF = 10n': # TODO implement next command
102+
# 'HAMW8 = 41n': # TODO implement hammer command
103+
'BLIF-': {'len': 8, 'ops': [['up', 'w0'],
104+
['w1', 'r1', 'w0'],
105+
['w1'],
106+
['w0', 'r0', 'w1']]},
107+
'Algor. B': {'len': 17, 'ops': [['up', 'w0'],
108+
['r0', 'w1', 'w0', 'w1'],
109+
['r1', 'w0', 'r0', 'w1'],
110+
['down', 'r1', 'w0', 'w1', 'w0'],
111+
['r0', 'w1', 'r1']]},
112+
# 'HAMR8 = 18n': # TODO implement hammer command
113+
}
114+
47115

48116
def __init__(self, parent, bitwidth, start, end, readfunc, writefunc, beforefunc=None, afterfunc=None):
49117
self.parent = parent
@@ -60,11 +128,28 @@ def __init__(self, parent, bitwidth, start, end, readfunc, writefunc, beforefunc
60128

61129
self.mer = MER(self.parent.log_error)
62130
self.error_values = []
131+
132+
def algorithmen(self, alist):
133+
if type(alist) != list:
134+
self.parent.log_error(f'Argument have to be a list. Values are {list(self.algo_ops.keys())}')
135+
return 1
136+
errors = 0
137+
for name in alist:
138+
if name not in self.algo_ops.keys():
139+
self.parent.log_error(f'Name from algorithmus not availabe, values are {list(self.algo_ops.keys())}')
140+
errors += 1
141+
else:
142+
errors += self.algorithmus(f"{name} = {self.algo_ops[name]['len']}n", self.algo_ops[name]['ops'])
143+
return errors
63144

64-
def algorithm(self, name, operations):
145+
def algorithmus(self, name, operations):
65146
starttime = time()
66147
self.parent.log_info(f'Memory-Test: will run {name}')
67148
errors = 0
149+
# set default values
150+
self._ao = 'up' # address order
151+
self._cm = 'bin x' # counting method posible values = self.pcount_method
152+
self._db = 'sdb' # data background = self.pdata_background
68153
for operation in operations:
69154
mer_index = 1
70155
for sop in operation:
@@ -78,9 +163,9 @@ def algorithm(self, name, operations):
78163
self.mer[mer_index] = sop
79164
mer_index += 1
80165
else:
81-
self.parent.log_error(f'Memory_test operation {sop} not valid')
166+
self.parent.log_error(f' Memory_test operation {sop} not valid')
82167
errors += self.run()
83-
msg = f" Memory_test result: {name} run in {time()-starttime:.2f}s, found {errors} Errors"
168+
msg = f" Memory_test result: {name} run in {time()-starttime:.2f}s, found {errors} Errors"
84169
if errors != 0:
85170
self.parent.log_error(msg)
86171
else:
@@ -105,17 +190,19 @@ def run(self, start=None, end=None):
105190
self.parent.log_info(f' Memory_test: from 0x{self._startadr:0x} to 0x{self._endadr-self._inc:0x} {counting} = {self._space} values do {self.mer._values}')
106191

107192
adr = self._startadr
108-
read_data = [[] for _ in range(self.mer.SIZE)]
193+
compare_data = [[] for _ in range(self.mer.SIZE)]
109194
errors = 0
110195
docomp = False
196+
dump = []
111197
for cnt in range(self._space):
112198
mer_cnt = 1
113199
while mer_cnt != self.mer.cnt+1:
114200
operand, dat = self.mer[mer_cnt].split(' ')
115-
cdata = int(f"{dat*self.bitwidth}", 2)
116-
data = getattr(self, operand)(adr, cdata)
201+
cdata = int(f"{dat*self.bitwidth}", 2) # data to write, or target read data
202+
data = getattr(self, operand)(adr, cdata) # call read/write
117203
if operand == 'read':
118-
read_data[mer_cnt-1].append([adr, data])
204+
compare_data[mer_cnt-1].append([adr, cdata])
205+
dump.append(data)
119206
mer_cnt += 1
120207

121208
if self._cm == 'complement' and not docomp:
@@ -127,33 +214,35 @@ def run(self, start=None, end=None):
127214
adr = lastadr + self._inc
128215
else:
129216
adr += self._inc
130-
217+
131218
if self.afterfunc is not None:
132-
dump = self.afterfunc() # list from all read (=captured) values
133-
compare_data_length = sum(len(row) for row in read_data)
134-
if len(dump) != compare_data_length:
135-
self.parent.log_error(f' Memory_test: dump error, read {len(dump)} values, should be {compare_data_length}')
136-
return 1
137-
len_read_data = [len(adata) for adata in read_data]
138-
cntarrays = len(read_data) - len_read_data.count(0)
139-
pdump_start = 0
140-
for length, index in zip(len_read_data, range(len(len_read_data))):
141-
if length > 0:
142-
pdump = dump[pdump_start::cntarrays]
143-
pdump_start += 1
144-
read_data[index] = [[x[0], y] for x, y in zip(read_data[index], pdump)]
145-
read_data[index].sort(key=lambda x: x[0])
146-
_, dat = self.mer[index+1].split(' ')
147-
cdata = int(f"{dat*self.bitwidth}", 2)
148-
result = [d[1] == cdata for d in read_data[index]]
149-
mer_error = result.count(False)
150-
if mer_error > 0:
151-
self.parent.log_error(f'Memorytest {self.mer[index]} found {mer_error}')
152-
#TODO: Ouput wrong values
153-
errors += mer_error
219+
dump = self.afterfunc() # get list from all read (=captured) values,
220+
compare_data_length = sum(len(row) for row in compare_data)
221+
if len(dump) != compare_data_length:
222+
self.parent.log_error(f' Memory_test: dump error, read {len(dump)} values, should be {compare_data_length}')
223+
return 1
224+
len_compare_data = [len(adata) for adata in compare_data]
225+
cntarrays = len(compare_data) - len_compare_data.count(0)
226+
pdump_start = 0
227+
read_data = compare_data.copy()
228+
for length, index in zip(len_compare_data, range(len(len_compare_data))):
229+
if length > 0:
230+
pdump = dump[pdump_start::cntarrays] # assign the result to the correct operation (=array)
231+
pdump_start += 1
232+
read_data[index] = [[x[0], y] for x, y in zip(read_data[index], pdump)]
233+
read_data[index].sort(key=lambda x: x[0])
234+
compare_data[index].sort(key=lambda x: x[0])
235+
mer_error = 0
236+
if read_data[index] != compare_data[index]:
237+
for rd, cd in zip(read_data[index], compare_data[index]):
238+
if rd[1] != cd[1]:
239+
mer_error += 1
240+
self.parent.log_error(f" read error 0x{rd[0]:0x} = 0x{rd[1]:0x} != target 0x{cd[1]:0x}")
241+
self.parent.log_error(f"Memorytest '{self.mer[index+1]}' found {mer_error} errors")
242+
errors += mer_error
154243
return errors
155244

156-
def read(self, adr, dat=None):
245+
def read(self, adr, compare=None):
157246
dat = self.readfunc(adr)
158247
return dat
159248

pylab_ml/misc/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# $Id: __init__.py 1814 2020-08-20 08:58:57Z semi-ate $
2+
3+
"""
4+
Register Categories
5+
6+
"""
7+
8+
__all__ = [
9+
]
10+
11+

0 commit comments

Comments
 (0)