-
Notifications
You must be signed in to change notification settings - Fork 0
/
vml_browser.js
1301 lines (1230 loc) · 43.8 KB
/
vml_browser.js
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function customerMode() {
if (typeof vmlBrowserCustomerMode === 'undefined' || vmlBrowserCustomerMode === null) {
return false;
} else if (vmlBrowserCustomerMode) {
return true;
} else {
return false;
}
} // customerMode
function asText(name) {
var public_text = customerMode() ? "Long description" : "Public text";
var translator = {
"addr": "Address",
"base_addr": "Base address",
"ccb": "Conversion callback function",
"chip": "Chip",
"chip_sim_path_gl_prefix": "Top-most part of HDL path in gatelevel",
"chip_sim_path_rtl_prefix": "Top-most part of HDL path in RTL",
"debug": "Debug",
"default": "Default value",
"docname": customerMode() ? "Name" : "Datasheet name",
"ercb": "Examined read callback function",
"field": "Field",
"field_enc": "Encoding",
"field_private_text": "Private text",
"field_public_text": customerMode() ? "Description" : "Public text", // No "short description" for fields
"fwcb": "Forced write callback function",
"icb": "Instance change callback function",
"id": "Target ID",
"inst": "Instance name",
"interface_type": "Interface type",
"name": "Name",
"offset": "Address offset",
"pos": "Lsbit position",
"rcb": "Read callback function",
"reg": "Register",
"reg_private_text": "Private text",
"reg_public_text": public_text,
"reg_short_dscr": "Short description",
"reggrp": "Register Group",
"reggrp_private_text": "Private text",
"reggrp_public_text": public_text,
"reggrp_short_dscr": "Short description",
"reggrpcoll": "Register Group Collection",
"reggrpcoll_private_text": "Private text",
"reggrpcoll_public_text": public_text,
"reggrpcoll_short_dscr": "Short description",
"remove": "Remove",
"repl_cnt": "Replication count",
"repl_prefix": "Replication prefix",
"repl_width": "Replication width",
"target": "Target",
"target_private_text": "Private text",
"target_public_text": public_text,
"target_short_dscr": "Short description",
"target_sim_path_gl": "HDL path in gatelevel",
"target_sim_path_rtl": "HDL path in RTL",
"type": "Access type",
"type_cnt_incr_width": "CNT incr. width",
"type_cnt_saturates_at": "CNT saturates at",
"type_ha": "HA only",
"type_ha_alignment": "HA alignment",
"type_ha_bits_per_row": "HA bits per row",
"type_ha_mode": "HA mode",
"type_ha_user_addr_per_row": "HA user addresses per row",
"type_he_provide_val": "HE provide value",
"wcb": "Write callback function",
"width": "Width",
"vml_target_size": "Target size",
};
var postfix = "";
if (name.substr(-5) == "_orig") {
name = name.substr(0, name.lastIndexOf("_orig"));
postfix = " (original value)";
}
if (name == "chip_info" || name == "target_info" ||
name == "save_date" || name == "save_time" || name == "saved_by") {
return null;
}
var result = translator[name];
if (result == null) {
return null;
}
return result + postfix;
}
function $(e) {
return document.getElementById(e);
}
function createSavedValue(node) {
var result = "";
if (node.hasAttribute('save_date')) {
result += node.getAttribute('save_date') + " ";
}
if (node.hasAttribute('save_time')) {
result += "@" + node.getAttribute('save_time') + " ";
}
if (node.hasAttribute('saved_by')) {
result += "by " + node.getAttribute('saved_by');
}
if (result != "") {
var tr = document.createElement('tr');
tr.setAttribute('class', "vml");
var th = document.createElement('th');
th.setAttribute('class', "vml");
th.appendChild(document.createTextNode("Last saved"))
tr.appendChild(th);
var td = document.createElement('td');
td.setAttribute('class', "vml");
td.appendChild(document.createTextNode(result));
tr.appendChild(td);
return tr;
} else {
return document.createTextNode("");
}
}
function rega(e) {
if (vmlSearchActive) {
createOutline();
}
if (e.target.hasAttribute('data-path')) {
navigateTo(e.target.getAttribute('data-path').split(","), true);
}
e.stopPropagation();
}
function completePath(path) {
while (path.length > 1 && path[path.length - 1] == "" && path[path.length - 2] == "") {
path.pop();
}
if (path.length == 0) {
return null;
}
var levelOffset;
if (vmlType == "CML") {
levelOffset = 1;
} else {
levelOffset = 0;
}
var element = vml;
for (var level = 0; level < 4; level++) {
if (path[level] != "") {
var elementList = element.getElementsByTagName(vmlLevels[levelOffset + level]);
var elementFound = false;
for (var i = 0; i < elementList.length; i++) {
if (getName(elementList[i]).toLowerCase() == path[level]) {
element = elementList[i];
elementFound = true;
break;
}
}
if (!elementFound) {
return null;
}
var parentElement = element;
for (var i = level - 1; i >= 0; i--) {
if (path[i] == "") {
parentElement = parentElement.parentNode;
path[i] = getName(parentElement).toLowerCase();
} else {
break;
}
}
if (path.length == level + 1 || (path.length == level + 2 && path[level + 1] == "")) {
return path;
}
}
}
return path.slice(0, 4);
}
function createTextValue(text) {
var result = document.createElement('p');
result.setAttribute('class', "vml");
var textArray = text.split(/\r?\n/);
for (var i = 0; i < textArray.length; i++) {
if (i > 0) {
result.appendChild(document.createElement('br'));
}
var line = textArray[i];
do {
var firstIndex = line.search(/[A-Z0-9_]+:([A-Z0-9_]+(\[[^\]]*\])?)?(:[A-Z0-9_]+(\[[[^\]]]*\])?(\.[A-Z0-9_]+)?)?/);
if (firstIndex > -1) {
var firstMatch = line.match(/([A-Z0-9_]+):(([A-Z0-9_]+)(\[[^\]]*\])?)?(:([A-Z0-9_]+)(\[[^\]]*\])?(\.([A-Z0-9_]+))?)?/);
var match = firstMatch[0];
result.appendChild(document.createTextNode(line.slice(0, firstIndex)));
var path = [firstMatch[1].toLowerCase(), (firstMatch[3] == null ? "" : firstMatch[3].toLowerCase())];
if (firstMatch[6] != null) {
path.push(firstMatch[6].toLowerCase());
if (firstMatch[9] != null) {
path.push(firstMatch[9].toLowerCase());
}
}
var pathVal = null;
if (!(path.length == 2 && path[1] == "")) {
pathVal = completePath(path);
}
if (pathVal == null) {
result.appendChild(document.createTextNode(match));
} else {
var a = document.createElement('a');
a.setAttribute('class', "vml");
a.setAttribute('onclick', "rega(event)");
a.setAttribute('data-path', path.join(","));
a.appendChild(document.createTextNode(match));
result.appendChild(a);
}
line = line.slice(firstIndex + match.length);
} else {
result.appendChild(document.createTextNode(line));
}
} while (firstIndex > -1);
}
return result;
}
function createValue(node, parent) {
var value;
if (node.nodeType == 2) {
if ((node.nodeName == 'base_addr' || node.nodeName == 'id' || node.nodeName == 'offset') && isFinite(node.value)) {
value = "0x" + parseInt(node.value).toString(16).toUpperCase();
} else if (node.nodeName == 'addr') {
var addr = node.value.split(" ")[0];
if (isFinite(addr)) {
value = "0x" + parseInt(addr).toString(16).toUpperCase();
}
} else if (node.nodeName == 'vml_target_size') {
value = node.value + " (" + Math.ceil(Math.log2(node.value)) + " bit)";
} else {
value = node.value;
}
if (parent != null && parent.hasAttribute(node.nodeName + "_orig")) {
value += " (resolved from '" + parent.getAttribute(node.nodeName + "_orig") + "')";
}
} else {
value = node.textContent;
}
return value;
}
function createValueRow(node, parent, className) {
var nameText = asText(node.nodeName);
var name;
var value;
if (nameText == null) {
return document.createTextNode("");
}
if (node.nodeType == 2) {
name = document.createTextNode(nameText);
value = document.createTextNode(createValue(node, parent));
} else {
name = document.createElement('p');
name.setAttribute('class', "vml");
name.appendChild(document.createTextNode(nameText));
value = createTextValue(createValue(node, parent));
}
var tr = document.createElement('tr');
tr.setAttribute('class', className);
var th = document.createElement('th');
th.setAttribute('class', "vml");
th.appendChild(name);
tr.appendChild(th);
var td = document.createElement('td');
td.setAttribute('class', "vml");
td.appendChild(value);
tr.appendChild(td);
return tr;
}
function getName(node) {
return node.getAttribute('vml_name');
}
function getReplications(node) {
return [node.getAttribute('vml_repl_min'),
node.getAttribute('vml_repl_max'),
node.getAttribute('vml_repl_str')];
}
function getReplName(node) {
var name = getName(node);
var repl = getReplications(node);
if (repl[1] != repl[0]) {
name += "[" + repl[2] + "]";
} else if (repl[0] != 0) {
name += "[" + repl[0] + "]";
}
return name;
}
function getOutlineName(node, level) {
var name = getName(node, level);
var repl = getReplications(node, level);
var outline_name = name;
if (repl[1] != repl[0]) {
// outline_name += "[" + repl[0] + "-" + repl[1] + "]";
outline_name += "[" + repl[2] + "]";
} else if (repl[0] != 0) {
outline_name += "[" + repl[0] + "]";
}
if (node.hasAttribute('vml_inst_name') && !customerMode()) {
outline_name += "\u00a0(" + node.getAttribute('vml_inst_name') + ")";
}
return outline_name;
}
function getFullName(node, level, show_repl, show_group) {
if (vmlType == "CML") {
if (level == 0) {
return getName(node, level);
} else {
level--;
}
}
var parentNames = [];
if (show_repl) {
parentNames[level] = getReplName(node);
} else {
parentNames[level] = getName(node);
}
for (var i = level - 1; i >= 0; i--) {
node = node.parentNode;
if (!show_group && i == 1 && level > 1) {
parentNames[i] = "";
} else {
if (show_repl) {
parentNames[i] = getReplName(node);
} else {
parentNames[i] = getName(node);
}
}
}
var result = "";
var delims = [":", ":", "."];
for (var i = 0; i <= level; i++) {
result += parentNames[i];
if (i < level) {
result += delims[i];
}
}
return result;
}
function hideTarget(node) {
if (node.hasAttribute('vml_hide_target') && node.getAttribute('vml_hide_target') == "true") {
return true;
} else {
return false;
}
}
function getDocName(node) {
if (node.hasAttribute('docname')) {
return node.getAttribute('docname');
} else {
return node.getAttribute('name');
}
}
function parseName(node, level) {
if (vmlType == "CML" && level == 1) {
var sim_nodes = node.parentNode.getElementsByTagName('target_sim_info');
if (sim_nodes.length > 0 && sim_nodes[0].hasAttribute('name')) {
var name = sim_nodes[0].getAttribute('name').replace(/_\d+$/, "");
} else {
var name = getDocName(node, level);
}
var repl = getReplications(node, level);
var inst_name = getDocName(node);
if (repl[1] != repl[0] || repl[0] != 0) {
node.setAttribute('vml_name', name);
node.setAttribute('vml_inst_name', inst_name);
} else {
var nodes = node.parentNode.parentNode.getElementsByTagName('target');
var found = false;
for (var i = 0; i < nodes.length; i++) {
if (getDocName(nodes[i]) == inst_name) {
if (found) {
node.setAttribute('vml_name', name);
node.setAttribute('vml_inst_name', inst_name);
return;
} else {
found = true;
}
}
}
if (inst_name != name) {
node.setAttribute('vml_name', inst_name);
node.setAttribute('vml_inst_name', name);
} else {
node.setAttribute('vml_name', name);
}
}
} else {
node.setAttribute('vml_name', getDocName(node));
}
}
function parseReplications(node, level) {
if (vmlType == "CML" && level == 1) {
var sim_nodes = node.parentNode.getElementsByTagName('target_sim_info');
if (sim_nodes.length > 0 && sim_nodes[0].hasAttribute('name') && sim_nodes[0].getAttribute('name').match(/_\d+$/)) {
var name = sim_nodes[0].getAttribute('name').replace(/_\d+$/, "");
var repl_min = -1;
var repl_max = 0;
var repl_list = [];
var tgt_info_nodes = node.parentNode.parentNode.getElementsByTagName('target_info');
for (var i = 0; i < tgt_info_nodes.length; i++) {
var tgt_sim_nodes = tgt_info_nodes[i].getElementsByTagName('target_sim_info');
var tgt_nodes = tgt_info_nodes[i].getElementsByTagName('target');
if (tgt_sim_nodes.length > 0 && tgt_nodes.length > 0 && node.hasAttribute('name') &&
tgt_sim_nodes[0].hasAttribute('name') && tgt_sim_nodes[0].getAttribute('name').match(name + "_\\d+$") &&
tgt_nodes[0].hasAttribute('name') && tgt_nodes[0].getAttribute('name') == node.getAttribute('name')) {
var tgt_repl = parseInt(tgt_sim_nodes[0].getAttribute('name').match(name + "_(\\d+)$")[1]);
if (repl_min < 0 || tgt_repl < repl_min) {
repl_min = tgt_repl;
}
if (tgt_repl > repl_max) {
repl_max = tgt_repl;
}
repl_list.push(tgt_repl);
}
}
node.setAttribute('vml_repl_min', repl_min);
node.setAttribute('vml_repl_max', repl_max);
node.setAttribute('vml_repl_list', repl_list);
} else {
node.setAttribute('vml_repl_min', 0);
node.setAttribute('vml_repl_max', 0);
node.setAttribute('vml_repl_list', [0]);
}
} else if (node.hasAttribute('repl_cnt')) {
node.setAttribute('vml_repl_min', 0);
var repl_cnt = parseInt(node.getAttribute('repl_cnt'));
var repl_list = [];
if (isFinite(repl_cnt)) {
node.setAttribute('vml_repl_max', repl_cnt - 1);
for (var i = 0; i < repl_cnt; i++) {
repl_list.push(i);
}
node.setAttribute('vml_repl_list', repl_list);
} else {
node.setAttribute('vml_repl_max', 0);
node.setAttribute('vml_repl_list', [0]);
}
} else {
node.setAttribute('vml_repl_min', 0);
node.setAttribute('vml_repl_max', 0);
node.setAttribute('vml_repl_list', [0]);
}
var repl_min = node.getAttribute('vml_repl_min');
var repl_max = node.getAttribute('vml_repl_max');
var repl_list = (node.getAttribute('vml_repl_list')).split(",");
if (repl_list.length == repl_max - repl_min + 1) {
// Consecutive range
node.setAttribute('vml_repl_str', `${repl_min}-${repl_max}`);
} else {
// Non-consecutive range
var repl_str = "";
var first_range_idx = parseInt(repl_list[0]);
var prev_idx = parseInt(repl_list[0]);
for (var i = 1; i < repl_list.length; i++) {
var idx = parseInt(repl_list[i]);
if (idx != prev_idx+1) {
if (repl_str != "") {
repl_str += ",";
}
repl_str += `${first_range_idx}-${prev_idx}`;
prev_idx = idx;
first_range_idx = idx;
} else {
prev_idx = idx;
}
if (i == repl_list.length-1) {
// Last idx
if (repl_str != "") {
repl_str += ",";
}
if (first_range_idx == idx) {
repl_str += idx;
} else {
repl_str += first_range_idx + "-" + idx;
}
}
}
node.setAttribute('vml_repl_str', repl_str);
}
} // parseReplications
function parseHideTarget(node, level) {
if (vmlType == "CML" && level == 1) {
var sim_nodes = node.parentNode.getElementsByTagName('target_sim_info');
if (sim_nodes.length > 0 && sim_nodes[0].hasAttribute('name') && sim_nodes[0].getAttribute('name').match(/_\d+$/)) {
var name = sim_nodes[0].getAttribute('name').replace(/_\d+$/, "");
var repl = parseInt(sim_nodes[0].getAttribute('name').match(name + "_(\\d+)$")[1]);
var tgt_info_nodes = node.parentNode.parentNode.getElementsByTagName('target_info');
for (var i = 0; i < tgt_info_nodes.length; i++) {
var tgt_sim_nodes = tgt_info_nodes[i].getElementsByTagName('target_sim_info');
var tgt_nodes = tgt_info_nodes[i].getElementsByTagName('target');
if (tgt_sim_nodes.length > 0 && tgt_nodes.length > 0 && node.hasAttribute('name') &&
tgt_sim_nodes[0].hasAttribute('name') && tgt_sim_nodes[0].getAttribute('name').match(name + "_\\d+$") &&
tgt_nodes[0].hasAttribute('name') && tgt_nodes[0].getAttribute('name') == node.getAttribute('name')) {
var tgt_repl = parseInt(tgt_sim_nodes[0].getAttribute('name').match(name + "_(\\d+)$")[1]);
if (tgt_repl < repl) {
node.setAttribute('vml_hide_target', "true");
return;
}
}
}
}
}
}
function parseTargetSize(node, level) {
if ((vmlType == "CML" && level == 1) || (vmlType != "CML" && level == 0)) {
var reggrps = node.getElementsByTagName(vmlLevels[level + 1]);
if (reggrps.length > 0) {
var last_reggrp = 0;
var last_reggrp_addr = parseInt(reggrps[0].getAttribute('base_addr'));
for (var reggrp = 1; reggrp < reggrps.length; reggrp++) {
var reggrp_addr = parseInt(reggrps[reggrp].getAttribute('base_addr'));
if (reggrp_addr > last_reggrp_addr) {
last_reggrp = reggrp;
last_reggrp_addr = reggrp_addr
}
}
if (reggrps[last_reggrp].hasAttribute('repl_width') && isFinite(reggrps[last_reggrp].getAttribute('repl_width')) &&
reggrps[last_reggrp].hasAttribute('repl_cnt') && isFinite(reggrps[last_reggrp].getAttribute('repl_cnt'))) {
var repl_width = parseInt(reggrps[last_reggrp].getAttribute('repl_width'));
var repl_cnt = parseInt(reggrps[last_reggrp].getAttribute('repl_cnt'));
if (repl_width > 0 && repl_cnt > 1) {
last_reggrp_addr += repl_width * (repl_cnt - 1);
}
}
var regs = reggrps[last_reggrp].getElementsByTagName(vmlLevels[level + 2]);
if (regs.length > 0) {
var last_reg = 0;
var last_reg_addr = parseInt(regs[0].getAttribute('addr').split(" ").slice(-1)[0]);
for (var reg = 1; reg < regs.length; reg++) {
var reg_addr = parseInt(regs[reg].getAttribute('addr').split(" ").slice(-1)[0]);
if (reg_addr > last_reg_addr) {
last_reg = reg;
last_reg_addr = reg_addr;
}
}
if (!customerMode()) {
node.setAttribute('vml_target_size', last_reggrp_addr + last_reg_addr + 1);
}
}
}
}
}
function createValueHeader(header) {
var tr = document.createElement('tr');
tr.setAttribute('class', "vml");
var th = document.createElement('th');
th.setAttribute('class', "vml");
th.setAttribute('colspan', "2");
var h3 = document.createElement('h3');
h3.setAttribute('class', "vml");
tr.appendChild(th).appendChild(h3).appendChild(document.createTextNode(header));
return tr;
}
function createValueTable(node, level) {
while ($('vml_vheader').hasChildNodes()) {
$('vml_vheader').removeChild($('vml_vheader').lastChild);
}
if (customerMode() && vmlLevels[level] == "chip") {
// Avoid "Chip chip"
$('vml_vheader').appendChild(document.createTextNode("Values of " + asText(vmlLevels[level])));
} else {
$('vml_vheader').appendChild(document.createTextNode("Values of " + asText(vmlLevels[level]) + " " + getFullName(node, level, true, true)));
}
var result = document.createElement('table');
result.appendChild(createValueHeader("Attributes"));
result.appendChild(createSavedValue(node));
var anodes = node.attributes;
for (var a = 0; a < anodes.length; a++) {
if (anodes[a].nodeName.substr(-5) != "_orig" && anodes[a].value != "") {
if (customerMode() &&
anodes[a].nodeName == 'name' &&
node.hasAttribute('docname')) {
// Skip 'name', only show 'docname'
} else {
result.appendChild(createValueRow(anodes[a], node, "vml vml_a"));
}
}
}
var cnodes = node.childNodes;
var enodes = [];
for (var i = 0; i < cnodes.length; i++) {
if (cnodes[i].nodeType == 1 && cnodes[i].nodeName != vmlLevels[level + 1] && asText(cnodes[i].nodeName) != null && cnodes[i].textContent != "") {
enodes.push(cnodes[i]);
}
}
if (enodes.length > 0) {
result.appendChild(createValueHeader("Elements"));
for (var i = 0; i < enodes.length - 1; i++) {
result.appendChild(createValueRow(enodes[i], node, "vml vml_e"));
}
result.appendChild(createValueRow(enodes[enodes.length - 1], node, "vml vml_e vml_last"));
}
if (vmlType == "CML" && level <= 1) {
var sim_nodes;
if (level == 0) {
sim_nodes = node.getElementsByTagName('chip_sim_info');
} else {
sim_nodes = node.parentNode.getElementsByTagName('target_sim_info');
}
if (sim_nodes.length > 0) {
if (!customerMode()) {
if (level == 0) {
result.appendChild(createValueHeader("Chip Simulation Info"));
} else {
result.appendChild(createValueHeader("Target Simulation Info"));
}
}
var sim_anodes = sim_nodes[0].attributes;
for (var a = 0; a < sim_anodes.length; a++) {
result.appendChild(createValueRow(sim_anodes[a], sim_nodes[0], "vml vml_a"));
}
var sim_cnodes = sim_nodes[0].childNodes;
var sim_enodes = [];
for (var i = 0; i < sim_cnodes.length; i++) {
if (sim_cnodes[i].nodeType == 1 && asText(sim_cnodes[i].nodeName) != null && sim_cnodes[i].textContent != "") {
sim_enodes.push(sim_cnodes[i]);
}
}
if (sim_enodes.length > 0) {
for (var i = 0; i < sim_enodes.length - 1; i++) {
result.appendChild(createValueRow(sim_enodes[i], sim_nodes[0], "vml vml_e"));
}
result.appendChild(createValueRow(sim_enodes[sim_enodes.length - 1], sim_nodes[0], "vml vml_e vml_last"));
}
if (level == 0) {
var inst_nodes = node.getElementsByTagName('chip_inst');
if (inst_nodes.length > 0) {
result.appendChild(createValueHeader("Instance Address Offsets"));
for (var i = 0; i < inst_nodes.length; i++) {
var name = inst_nodes[i].getAttribute('name');
var value = 0;
if (inst_nodes[i].hasAttribute('offset') && isFinite(inst_nodes[i].getAttribute('offset'))) {
value = parseInt(inst_nodes[i].getAttribute('offset'));
}
value = "0x" + parseInt(value).toString(16).toUpperCase();
var tr = document.createElement('tr');
tr.setAttribute('class', "vml vml_a");
var th = document.createElement('th');
th.setAttribute('class', "vml");
th.appendChild(document.createTextNode(name));
tr.appendChild(th);
var td = document.createElement('td');
td.setAttribute('class', "vml");
td.appendChild(document.createTextNode(value));
tr.appendChild(td);
result.appendChild(tr);
}
}
}
}
}
if (level < vmlLevels.length - 1) {
result.appendChild(createValueHeader(asText(vmlLevels[level + 1]) + "s"));
var fnodes = node.getElementsByTagName(vmlLevels[level + 1]);
for (var i = 0; i < fnodes.length; i++) {
if (vmlType == "CML" && level == 0 && hideTarget(fnodes[i])) {
continue;
}
var descriptions = fnodes[i].getElementsByTagName(vmlDescriptions[level]);
var tr = document.createElement('tr');
tr.setAttribute('class', "vml vml_f");
var th = document.createElement('th');
th.setAttribute('class', "vml");
if (fnodes[i].hasAttribute('pos') && fnodes[i].hasAttribute('width') &&
isFinite(fnodes[i].getAttribute('pos')) && isFinite(fnodes[i].getAttribute('width'))) {
var width = parseInt(fnodes[i].getAttribute('width'));
var lsbit_pos = parseInt(fnodes[i].getAttribute('pos'));
if (width > 1) {
var msbit_pos = lsbit_pos + width - 1;
th.appendChild(document.createTextNode(getOutlineName(fnodes[i], level + 1) + "\u00a0(" + msbit_pos + ":" + lsbit_pos + ")"));
} else {
th.appendChild(document.createTextNode(getOutlineName(fnodes[i], level + 1) + "\u00a0(" + lsbit_pos + ")"));
}
} else {
th.appendChild(document.createTextNode(getOutlineName(fnodes[i], level + 1)));
}
tr.appendChild(th);
var td = document.createElement('td');
td.setAttribute('class', "vml");
if (descriptions.length > 0) {
var description = createTextValue(descriptions[0].textContent);
while (description.hasChildNodes()) {
td.appendChild(description.firstChild);
}
}
var subtext = "";
if (vmlType == "CML" && level == 0) {
var sim_nodes = fnodes[i].parentNode.getElementsByTagName('target_sim_info');
if (sim_nodes.length > 0) {
if (sim_nodes[0].hasAttribute('id')) {
subtext = asText('id') + ": " + createValue(sim_nodes[0].getAttributeNode('id'), null);
}
if (sim_nodes[0].hasAttribute('offset')) {
if (subtext != "") {
subtext += ", ";
}
subtext += asText('offset') + ": " + createValue(sim_nodes[0].getAttributeNode('offset'), null);
}
}
} else if (fnodes[i].hasAttribute('base_addr')) {
subtext = asText('base_addr') + ": " + createValue(fnodes[i].getAttributeNode('base_addr'), null);
} else if (fnodes[i].hasAttribute('addr')) {
subtext = asText('addr') + ": " + createValue(fnodes[i].getAttributeNode('addr'), null);
} else if (fnodes[i].hasAttribute('default')) {
subtext = asText('default') + ": " + createValue(fnodes[i].getAttributeNode('default'), null);
}
if (subtext != "") {
if (td.hasChildNodes()) {
td.appendChild(document.createElement('br'));
}
var span = document.createElement('span');
span.setAttribute('class', "vml_subtext");
span.appendChild(document.createTextNode(subtext));
td.appendChild(span);
}
tr.appendChild(td);
result.appendChild(tr);
}
}
while ($('vml_values').hasChildNodes()) {
$('vml_values').removeChild($('vml_values').lastChild);
}
$('vml_values').appendChild(result);
}
window.onpopstate = function(event) {
if (vmlFile != null) {
vmlSelect = [];
parseUrl();
if (vmlType == "CML") {
vmlSelect = vmlSelect.slice(0,4);
} else {
vmlSelect = vmlSelect.slice(0,3);
}
var path = completePath(vmlSelect);
if (path != null) {
vmlSelect = path;
}
if (vmlSearchActive) {
createOutline();
}
selLi.className = "vml";
selLi = $('vml_outline').getElementsByTagName('li')[0].firstChild;
selLi.className = "vml vml_selected";
createValueTable(vml.getElementsByTagName(vmlLevels[0])[0], 0);
if (vmlSelect.length > 0) {
expandTo(0);
navigateTo(vmlSelect, false);
}
} else if (selLi != null) {
history.go(0);
}
}
function selectElement(e, updateHistory) {
if (e.hasAttribute('data-ids')) {
var ids = e.getAttribute('data-ids').split(",");
} else {
return;
}
if (selLi != null) {
selLi.className = "vml";
}
e.className = "vml vml_selected";
selLi = e;
if (updateHistory) {
vmlSelect = [];
}
var node = vml;
for (var i = 0; i < ids.length; i++) {
node = node.getElementsByTagName(vmlLevels[i])[ids[i]];
if ((vmlType != "CML" || i > 0) && updateHistory) {
if ((vmlType == "CML" && i == 1) || (vmlType != "CML" && i == 0)) {
vmlSelect.push(getReplName(node).toLowerCase());
} else {
vmlSelect.push(getName(node).toLowerCase());
}
}
}
if (customerMode() && updateHistory) {
history.pushState(null, "", vmlBrowserUrl + "?select=" + vmlSelect.join(","));
} else {
if (vmlFile != null && updateHistory) {
history.pushState(null, "", vmlBrowserUrl + "?file=" + vmlFile + "&select=" + vmlSelect.join(","));
}
}
createValueTable(node, ids.length - 1);
}
function lia(e) {
selectElement(e.target, true);
e.stopPropagation();
}
function li(e) {
if (e.target.className == "vml vml_exp") {
e.target.className = "vml vml_notexp";
} else if (e.target.className == "vml vml_notexp") {
e.target.className = "vml vml_exp";
}
e.stopPropagation();
}
function navigateTo(path, updateHistory, currentLi) {
if (path.length > 0) {
var ul;
if (currentLi == null) {
currentLi = $('vml_outline').getElementsByTagName('li')[0];
if (vmlType == "CML") {
currentLi.className = "vml vml_exp";
ul = currentLi.getElementsByTagName('ul');
} else {
ul = $('vml_outline').getElementsByTagName('ul');
}
} else {
ul = currentLi.getElementsByTagName('ul');
}
if (ul.length > 0) {
var li = ul[0].childNodes;
for (var i = 0; i < li.length; i++) {
if (li[i].firstChild.firstChild.nodeValue.split("\u00a0")[0].toLowerCase() == path[0] ||
li[i].firstChild.firstChild.nodeValue.split("\u00a0")[0].split("[")[0].toLowerCase() == path[0]) {
var new_path = path.slice(1);
if (new_path.length > 0) {
li[i].className = "vml vml_exp";
}
navigateTo(new_path, updateHistory, li[i]);
return;
}
}
selectElement(currentLi.firstChild, updateHistory);
$('vml_outline').scrollTop = currentLi.offsetTop;
}
} else {
if (currentLi == null) {
currentLi = $('vml_outline').getElementsByTagName('li')[0];
}
selectElement(currentLi.firstChild, updateHistory);
$('vml_outline').scrollTop = currentLi.offsetTop;
}
}
function expandTo(level) {
var li = $('vml_outline').getElementsByTagName('li');
for (var i = 0; i < li.length; i++) {
if (li[i].className == "vml vml_notexp") {
li[i].className = "vml vml_exp";
}
}
var ul = $('vml_outline').getElementsByClassName("vml_level" + level);
for (var l = 0; l < ul.length; l++) {
li = ul[l].getElementsByTagName('li');
for (var i = 0; i < li.length; i++) {
if (li[i].className == "vml vml_exp") {
li[i].className = "vml vml_notexp";
}
}
}
navigateTo([], false);
if (vmlSelect.length > 0) {
navigateTo(vmlSelect, false);
}
}
function levelClass(level) {
var maxLevel = 2;
if (vmlType == "CML" || vmlSelect.length > 0) {
maxLevel = 1;
}
if (level < maxLevel) {
return "vml_exp";
} else if (level < vmlLevels.length - 1) {
return "vml_notexp";
} else {
return "vml_leaf";
}
}
function createOutlineLevel(node, level, ids) {
var result = document.createElement('ul');
result.setAttribute('class', "vml vml_level" + level);
var nodeList = node.getElementsByTagName(vmlLevels[level]);
for (var i = 0; i < nodeList.length; i++) {
if (vmlType == "CML" && level == 1 && hideTarget(nodeList[i])) {
continue;
}
var li = document.createElement('li');
li.setAttribute('class', "vml " + levelClass(level));
li.setAttribute('onclick', "li(event)");
var a = document.createElement('a');
a.setAttribute('class', "vml");
a.setAttribute('onclick', "lia(event)");
a.setAttribute('data-ids', ids.concat(i).join(","));
a.appendChild(document.createTextNode(getOutlineName(nodeList[i], level)));
li.appendChild(a);
if (level < vmlLevels.length - 1) {
li.appendChild(createOutlineLevel(nodeList[i], level + 1, ids.concat(i)));
}
result.appendChild(li);
}
return result;
}
function createOutline() {
var expand = document.createElement('p');
expand.setAttribute('class', "vml");
expand.appendChild(document.createElement('strong'))
.appendChild(document.createTextNode("Expand to:"));
expand.appendChild(document.createTextNode(" "));
for (var i = 0; i < vmlLevels.length; i++) {
var a = document.createElement('a');
a.setAttribute('class', "vml");
a.setAttribute('onclick', "expandTo(" + i + ")");
a.appendChild(document.createTextNode(asText(vmlLevels[i])));
expand.appendChild(a);
if (i < vmlLevels.length - 1) {
expand.appendChild(document.createTextNode(", "));
}
}
while ($('vml_expand').hasChildNodes()) {
$('vml_expand').removeChild($('vml_expand').lastChild);
}
$('vml_expand').appendChild(expand);
while ($('vml_outline').hasChildNodes()) {
$('vml_outline').removeChild($('vml_outline').lastChild);
}
$('vml_expand').appendChild(expand);
$('vml_outline').appendChild(createOutlineLevel(vml, 0, []));
navigateTo([], false);
var path = completePath(vmlSelect);
if (path != null) {
vmlSelect = path;
}
if (vmlSelect.length > 0) {
navigateTo(vmlSelect, false);
}
vmlSearchActive = false;
}
function checkErrorXML(n, error) {
var l, name;
name = n.nodeName;
if (error == null) {
error = "";
}
if (name == "h3") {
return "";
}
if (name == "#text") {
error = "<p>" + error + n.nodeValue + "</p>";
}
l = n.childNodes.length;
for (var i = 0; i < l; i++) {
error = error + checkErrorXML(n.childNodes[i], error);
}
return error;
}
function loadXMLDoc(fileurl) {
var xmlDoc = null;
try {
if (!customerMode()) {
xhttp = new XMLHttpRequest();
xhttp.open("GET", fileurl, false);
xhttp.send();
xmlDoc = xhttp.responseXML;
} else {