From e2e88cfae1704a1f407436fea3bfbe002d9eea91 Mon Sep 17 00:00:00 2001 From: BigEd Date: Sat, 18 Sep 2010 17:25:33 +0000 Subject: [PATCH 1/5] more internal busses and latches named --- nodenames.js | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 93 insertions(+), 1 deletion(-) diff --git a/nodenames.js b/nodenames.js index 9e3f80b..78b7f6b 100644 --- a/nodenames.js +++ b/nodenames.js @@ -29,6 +29,14 @@ db5: 175, db4: 1393, db7: 1349, db6: 1591, +idl0: 116, +idl1: 576, +idl2: 1485, +idl3: 1284, +idl4: 1516, +idl5: 498, +idl6: 1537, +idl7: 529, a1: 1234, ab1: 451, ab2: 1340, @@ -67,6 +75,14 @@ s7: 1435, s6: 1212, s5: 1098, s4: 1702, +nots0: 418, +nots1: 1064, +nots2: 752, +nots3: 828, +nots4: 1603, +nots5: 601, +nots6: 1029, +nots7: 181, rw: 1156, x2: 1, x3: 1648, @@ -113,5 +129,81 @@ y5: 615, y4: 989, y7: 843, y6: 115, -cclk: 943 +cclk: 943, // aka cp2 +clock1: 156, +clock2: 1536, +notir7: 1320, +notir6: 895, // OK +notir5: 1394, // OK +notir4: 26, +notir3: 1125, +notir2: 1182, +notir1: 702, +notir0: 194, +t2: 971, +t3: 1567, +t4: 690, +t5: 909, +cp1: 710, +fetch: 879, +clearIR: 1077, +D1x1: 827, +notRdy0: 248, +alu0: 394, +alu1: 697, +alu2: 276, +alu3: 495, +alu4: 1490, +alu5: 893, +alu6: 68, +alu7: 1123, +adl0: 413, +adl1: 1282, +adl2: 1242, +adl3: 684, +adl4: 1437, +adl5: 1630, +adl6: 121, +adl7: 1299, +adh0: 407, +adh1: 52, +adh2: 1651, +adh3: 315, +adh4: 1160, +adh5: 483, +adh6: 13, +adh7: 1539, +sb0: 54, +sb1: 1150, +sb2: 1287, +sb3: 1188, +sb4: 1405, +sb5: 166, +sb6: 1336, +sb7: 1001, +idb0: 1108, +idb1: 991, +idb2: 1473, +idb3: 1302, +idb4: 892, +idb5: 1503, +idb6: 833, +idb7: 493, +dor0: 222, +dor1: 527, +dor2: 1288, +dor3: 823, +dor4: 873, +dor5: 1266, +dor6: 1418, +dor7: 158, +pd0: 758, +pd1: 361, +pd2: 955, +pd3: 894, +pd4: 369, +pd5: 829, +pd6: 1669, +pd7: 1690, +h1x1: 1042, // drive status byte onto databus } From 0ecb753ec612b2c994afb6b0bd472157cf300476 Mon Sep 17 00:00:00 2001 From: BigEd Date: Sat, 18 Sep 2010 17:29:45 +0000 Subject: [PATCH 2/5] fixup nav button positioning --- wires.css | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/wires.css b/wires.css index 2123311..a62e6c4 100644 --- a/wires.css +++ b/wires.css @@ -24,7 +24,7 @@ body { background: white; color: black; font-family: cursive; - font-size: 30px; + font-size: 12px; } div.frame { @@ -64,19 +64,17 @@ p.status { } img.navbutton{ - margin-left: -5px; border: 0px; } img.navplay{ - margin-left: -5px; + position: relative; + margin-right: 5px; border: 0px; } img.navstop{ position: absolute; - left: -5px; - top: 9px; border: 0px; } From d0325802013bb67dcee4862401e34b7175104dc3 Mon Sep 17 00:00:00 2001 From: BigEd Date: Sat, 18 Sep 2010 17:46:24 +0000 Subject: [PATCH 3/5] improve load sequencing, add layer choosing, link to python sim, add keyboard tips, add example nmi test, tweak navbuttons, enhance chipstatus output --- chipsim.js | 2 + index.html | 45 ++++++++++++++++---- macros.js | 119 ++++++++++++++++++++++++++++++++++++++++++++++------- wires.js | 44 ++++++++++++++++---- 4 files changed, 179 insertions(+), 31 deletions(-) diff --git a/chipsim.js b/chipsim.js index 9842c45..ffa0f30 100644 --- a/chipsim.js +++ b/chipsim.js @@ -21,6 +21,8 @@ */ var ctrace = false; +var noGraphics = false; +var loglevel = 3; var ridx = 0; function recalcNodeList(list){ diff --git a/index.html b/index.html index e3e6e06..c876891 100644 --- a/index.html +++ b/index.html @@ -8,12 +8,26 @@ +
- -

The 6502

+ +
+The Visual 6502

+ +If the chip does not load, try another browser: Chrome, Safari, or Firefox +
+
+Hit '>' to zoom in, '<' to zoom out +
+Right-click to scroll around +
+Enter your own program into the array of RAM +
+
+
@@ -22,15 +36,30 @@
- - - - - +
+ + +
+
+ + + +

x: 0
y: 0

+
Show: + (metal) + (diff) + (diode) + (diff0) + (diff1) + (poly) +
+
+
+In addition to this JavaScript project, see our Python-based simulator which may be easier to customize, verify, and apply to the study of long programs.
+
- diff --git a/macros.js b/macros.js index cec2a70..dcba25e 100644 --- a/macros.js +++ b/macros.js @@ -39,11 +39,55 @@ function go(n){ } function steps(){ - if(running) step(); - setTimeout(steps, 200); + if(running) { + step(); + setTimeout(steps, 0); // schedule the next poll + } } +function testNMI(n){ + initChip(); + + mWrite(0x0000, 0x38); // set carry + mWrite(0x0001, 0x4c); // jump to test code + mWrite(0x0002, 0x06); + mWrite(0x0003, 0x23); + + mWrite(0x22ff, 0x38); // set carry + mWrite(0x2300, 0xea); + mWrite(0x2301, 0xea); + mWrite(0x2302, 0xea); + mWrite(0x2303, 0xea); + mWrite(0x2304, 0xb0); // branch carry set to self + mWrite(0x2305, 0xfe); + + mWrite(0x2306, 0xb0); // branch carry set to self + mWrite(0x2307, 0x01); + mWrite(0x2308, 0x00); // brk should be skipped + mWrite(0x2309, 0xa9); // anything + mWrite(0x230a, 0xde); // anything + mWrite(0x230b, 0xb0); // branch back with page crossing + mWrite(0x230c, 0xf2); + + mWrite(0xc018, 0x40); // nmi handler + + mWrite(0xfffa, 0x18); // nmi vector + mWrite(0xfffb, 0xc0); + mWrite(0xfffc, 0x00); // reset vector + mWrite(0xfffd, 0x00); + + for(var i=0;i', - 'A:', hexByte(readA()), - 'X:', hexByte(readX()), - 'Y:', hexByte(readY()), - 'P:', hexByte(readP()) - ); - selectCell(pc); + var ab = readAddressBus(); + var machine1 = + ' halfcyc:' + cycle + + ' phi0:' + readBit('clk0') + + ' AB:' + hexWord(ab) + + ' D:' + hexByte(readDataBus()) + + ' RnW:' + readBit('rw'); + var machine2 = + ' PC:' + hexWord(readPC()) + + ' A:' + hexByte(readA()) + + ' X:' + hexByte(readX()) + + ' Y:' + hexByte(readY()) + + ' SP:' + hexByte(readSP()) + + ' ' + readPstring(); + var machine3 = + ' Sync:' + readBit('sync') + ' IRQ:' + readBit('irq') + + ' NMI:' + readBit('nmi'); + var machine4 = + ' IR:' + hexByte(255 - readBits('notir', 8)) + + ' idl:' + hexByte(255 - readBits('idl', 8)) + + ' alu:' + hexByte(255 - readBits('alu', 8)) + + ' TCstate:' + readBit('clock1') + readBit('clock2') + + readBit('t2') + readBit('t3') + readBit('t4') + readBit('t5'); + var machine5 = + ' notRdy0:' + readBit('notRdy0') + + ' fetch:' + readBit('fetch') + + ' clearIR:' + readBit('clearIR') + + ' D1x1:' + readBit('D1x1'); + setStatus(machine1 + "
" + machine2); + if (loglevel>2) { + console.log(machine1 + " " + machine2 + " " + machine3 + " " + machine4 + " " + machine5); + } + selectCell(ab); } function getMem(){ diff --git a/wires.js b/wires.js index f136bb0..1430a96 100644 --- a/wires.js +++ b/wires.js @@ -26,8 +26,10 @@ var zoom=1; var dragMouseX, dragMouseY, moved; var statbox; -var colors = ['rgba(128,128,128,0.4)','#FFFF00','#FF00FF','#4DFF4D', +var layernames = ['metal', 'diff', 'inputdiode', 'diff0', 'diff1', 'poly']; +var colors = ['rgba(128,128,192,0.4)','#FFFF00','#FF00FF','#4DFF4D', '#FF4D4D','#801AC0','rgba(128,0,255,0.75)']; +var drawlayers = [true, true, false, false, false, false]; var nodes = new Array(); var transistors = {}; @@ -42,11 +44,19 @@ var npwr = nodenames['vcc']; // ///////////////////////// +// try to present a meaningful page before starting expensive work function setup(){ + statbox = document.getElementById('status'); + setStatus('loading 6502...'); + setTimeout(setup_part2, 0); +} + +function setup_part2(){ frame = document.getElementById('frame'); statbox = document.getElementById('status'); setupNodes(); setupTransistors(); + setupLayerVisibility(); setupBackground(); setupOverlay(); setupHilite(); @@ -56,6 +66,11 @@ function setup(){ setupTable(); window.onkeypress = function(e){handleKey(e);} hilite.onmousedown = function(e){mouseDown(e);} + setStatus('resetting 6502...'); + setTimeout(setup_part3, 0); +} + +function setup_part3(){ initChip(); document.getElementById('stop').style.visibility = 'hidden'; go(); @@ -89,8 +104,17 @@ function setupTransistors(){ } } +function setupLayerVisibility(){ + var x=document.getElementById('updateShow'); + for (var i=0;i Date: Sat, 18 Sep 2010 17:56:34 +0000 Subject: [PATCH 4/5] fixup space above memtable --- index.html | 1 - wires.css | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/index.html b/index.html index c876891..90f93bb 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,6 @@ -
diff --git a/wires.css b/wires.css index a62e6c4..abbc6f3 100644 --- a/wires.css +++ b/wires.css @@ -80,7 +80,7 @@ img.navstop{ table.memtable { position: absolute; - top: 63px; + top: 78px; left: 820px; font-family: monospace; font-size: 12px; From bc901566e351d8a82b8254eead32fca64ca38e36 Mon Sep 17 00:00:00 2001 From: BigEd Date: Sat, 18 Sep 2010 18:06:42 +0000 Subject: [PATCH 5/5] all layers start off visible --- wires.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wires.js b/wires.js index 1430a96..df0c8bb 100644 --- a/wires.js +++ b/wires.js @@ -29,7 +29,7 @@ var statbox; var layernames = ['metal', 'diff', 'inputdiode', 'diff0', 'diff1', 'poly']; var colors = ['rgba(128,128,192,0.4)','#FFFF00','#FF00FF','#4DFF4D', '#FF4D4D','#801AC0','rgba(128,0,255,0.75)']; -var drawlayers = [true, true, false, false, false, false]; +var drawlayers = [true, true, true, true, true, true]; var nodes = new Array(); var transistors = {};