-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloadFile.js
More file actions
266 lines (210 loc) · 8.13 KB
/
Copy pathloadFile.js
File metadata and controls
266 lines (210 loc) · 8.13 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
document.getElementById('file-input').addEventListener('change', readSingleFile, false);
var DATA = {name:"", line:"", pattern:"", state:"", dut:"", lines:"", dutList:""};
function readSingleFile(event) {
var file = event.target.files[0];
if (!file) {
return;
}
var reader = new FileReader();
reader.onload = function(event) {
var contents = event.target.result;
document.getElementById("pattern-container").innerHTML = "";
loopRead(contents);
};
reader.readAsText(file);
}
function loopRead(contents){
var lines = contents.split('\n');
var patternList = [];
var lineIndex = [];
var element = document.getElementById('pattern-container');
var lineCount = 0;
var loopCount = 1;
var loopIndex = [];
var dutCount = false;
var dutList = [];
var dutState;
var dutArray = [];
var dutIndex = [];
for(var i in lines) {
if(!lines[i].includes("Loop ")){
var patternString = lines[i].split(" ");
var stateCount = 0;
dutArray = [];
if (patternString[0]) {
patternList.push(patternString[0]);
lineIndex.push(lineCount);
loopIndex.push(loopCount);
dutIndex.push(dutArray);
}
} else {
var patternString = lines[i].split(" ");
var loopString = patternString[1].split(",");
loopCount = loopString[0];
var failString = lines[i].split(",");
var dutState;
if (failString[3].includes(" Failures 1")){
dutArray.push("FAIL")
} else if (failString[3].includes(" Failures 0")) {
dutArray.push("PASS")
} else if (failString[3].startsWith(" TDO was Not found")) {
dutArray[stateCount] = "DISABLED"
stateCount += 1;
} else if (failString[3].startsWith(" TDO DUT was disabled")){
dutArray[stateCount] = "OFF";
stateCount += 1;
} else {
stateCount += 1;
}
//Populate DUT list
if(!dutCount) {
var dutString = patternString[3].split(",");
if (!dutList.includes(dutString[0])) {
dutList.push(dutString[0]);
} else {
dutCount = true;
}
}
}
lineCount+=1;
}
for (var i in patternList) {
var text = document.createTextNode(patternList[i]+ " Loop " + loopIndex[i])
element.appendChild(text);
for (var j in dutList){
var btn = createButton(dutList[j], lineIndex[i], patternList[i], dutIndex[i][j], j);
element.appendChild(btn);
}
element.appendChild(document.createElement("br"));
}
function createButton(name, line, pattern, state, dut) {
var button = document.createElement("button");
button.classList.add("btn");
button.classList.add("btn-sm");
if (state == "PASS") {
button.classList.add("btn-green");
} else if (state == "FAIL") {
button.classList.add("btn-red");
} else if (state == "OFF") {
button.classList.add("btn-black")
} else if (state == "DISABLED") {
button.classList.add("btn-gray")
}
button.innerHTML=name;
button.onclick = function () {
ICXSBFT(name, line, pattern, state, dut, lines, dutList);
DATA.name = name;
DATA.line = line;
DATA.pattern = pattern;
DATA.state = state;
DATA.dut = dut;
DATA.lines = lines;
DATA.dutList = dutList;
};
return button
}
}
function coresOnclick() {
if(document.getElementById('file-input').files.length==0)return
var cores = document.getElementById("Cores").options[document.getElementById("Cores").selectedIndex].value;
ICXSBFT(DATA.name, DATA.line, DATA.pattern, DATA.state, DATA.dut, DATA.lines, DATA.dutList);
}
function lineButton(line) {
var failingDiv = document.getElementById('fails');
var button = document.createElement("button");
button.classList.add("btn");
button.classList.add("btn-sm");
button.classList.add("line-buttons");
button.innerHTML=line;
button.onclick = function () {
var lineString = "line " + line;
console.log(lineString)
//var lineMatch = $("span:contains(lineString)");
//$( "span:contains('line 81')" ).addClass( "highlighted" );
//$("span:contains(lineString)").first().prepend('<a class="highlighted" name="hightlighted" />');
//window.location.hash = '#highlighted';
$( "span" ).each(function( index ) {
if ($(this).text().trim() == lineString) {
var offset = $("#output-div").height()/2;
$("#output-div").scrollTop(0);
//offset = (offset > $(this).position().top) ? offset : 0;
if (offset > $(this).position().top) {
offset = 0;
}
$("#output-div").scrollTop($(this).position().top - offset);
console.log($(this).position().top)
}
});
//lineMatch.scrollIntoView();
//$(window).scrollTop($("span:contains(lineString):last").offset().top);
//$(document.getElementById("output-div")).scrollTop(100);
}
failingDiv.appendChild(button);
failingDiv.appendChild(document.createElement("br"));
}
function ICXSBFT(name, line, pattern, state, dut, lines, dutList) {
var rawOutput = lines[line + dutList.length + parseInt(dut) + 1].split(" ");
rawOutput = rawOutput[7];
//document.getElementById("output-div").innerHTML = output;
var cores = document.getElementById("Cores").options[document.getElementById("Cores").selectedIndex].value;
var output = document.getElementById("output-div");
var failing = document.getElementById("fails");
var patternName = document.getElementById("pattern-name-div");
output.innerHTML = "";
failing.innerHTML = "";
var lineOutput;
var outputLineCount = 1;
var coreSlice;
var colorToggle = true;
var failingLines = [];
var failCount;
var failBool = false;
var bitlength = 5;
var passingBit = "10010";
patternName.innerHTML = pattern + " DUT#" + (parseInt(dut)+1) + " ";
for (i=0; i<((rawOutput.length)/(cores*bitlength))-1; i++){
lineOutput = rawOutput.slice(cores*bitlength*i,cores*bitlength*(i+1));
failBool=false;
for (j=0; j<(lineOutput.length/bitlength); j++){
coreSlice = lineOutput.slice(bitlength*j,bitlength*(j+1));
if (coreSlice != passingBit) {
coreSlice = document.createTextNode(coreSlice);
var redSpan = document.createElement('span');
redSpan.className = 'failing-core';
redSpan.appendChild(coreSlice);
output.appendChild(redSpan);
failBool = true;
colorToggle = !colorToggle;
}
else if (colorToggle) {
coreSlice = document.createTextNode(coreSlice);
var graySpan = document.createElement('span');
graySpan.className = 'gray-toggle';
graySpan.appendChild(coreSlice);
output.appendChild(graySpan);
//console.log("true");
colorToggle = !colorToggle;
} else {
coreSlice = document.createTextNode(coreSlice);
var whiteSpan = document.createElement('span');
whiteSpan.className = 'white-toggle';
whiteSpan.appendChild(coreSlice);
output.appendChild(whiteSpan);
colorToggle = !colorToggle;
//console.log("false");
}
}
var lineOutput = document.createTextNode(" line " + outputLineCount + "\n");
if (failBool) {
failingLines.push(outputLineCount);
failCount = document.createTextNode(outputLineCount + "\n");
lineButton(outputLineCount);
//failing.appendChild(failCount);
}
var lineP = document.createElement("span");
lineP.appendChild(lineOutput);
output.appendChild(lineP);
outputLineCount += 1;
colorToggle = true;
}
}