diff --git a/index.html b/index.html
index 4bdc747..22ab52e 100644
--- a/index.html
+++ b/index.html
@@ -58,32 +58,37 @@ Enter your own program into the array of RAM
-
Source code is available on GitHub:
http://github.com/trebonian/visual6502
diff --git a/macros.js b/macros.js
index 3b12fbb..8fcd6bf 100644
--- a/macros.js
+++ b/macros.js
@@ -86,7 +86,6 @@ function testNMI(n){
for(var i=0;i<16;i++){step();}
}
-
function initChip(){
var start = now();
for(var nn in nodes) nodes[nn].state = 'fl';
@@ -100,35 +99,49 @@ function initChip(){
recalcNodeList(allNodes());
for(var i=0;i<8;i++){setHigh('clk0'), setLow('clk0');}
setHigh('res');
- for(var i=0;i<18;i++){resetStep();}
+ for(var i=0;i<18;i++){halfStep();}
refresh();
cycle = 0;
trace = Array();
- initLogbox(logThese);
+ initLogbox(signalSet(loglevel));
chipStatus();
if(ctrace)console.log('initChip done after', now()-start);
}
-var logThese=['sync','irq','nmi','ab','db','rw','pc','a','x','y','s'];
+var logThese=[
+ ['cycle'],
+ ['sync','irq','nmi'],
+ ['ab','db','rw','pc','a','x','y','s','p'],
+ ['adl','adh','sb','alu'],
+ ['notalucin','alucout','alua','alub','dasb'],
+ ['idb','dor'],
+ ['ir','tcstate','pd'],
+ ];
+function signalSet(n){
+ var signals=[];
+ for (var i=0; i<=n; i++){
+ for (var j=0; j
>1;
if(busname=='pc')
- return hexBus('pch') + hexBus('pcl');
+ return busToHex('pch') + busToHex('pcl');
+ if(busname=='p')
+ return readPstring();
+ if(busname=='tcstate')
+ return busToHex('clock1') + busToHex('clock2') +
+ busToHex('t2') + busToHex('t3') + busToHex('t4') + busToHex('t5');
+ return busToHex(busname);
+}
+
+function busToHex(busname){
+ // may be passed a bus or a signal, so allow multiple signals
+ // signals may have multi-part names like pla51_T0SBC which should match either part
+ // this is quite difficult to deal with, perhaps indicating that it is not such a good idea
var width=0;
+ var hit=-1;
+ var r=new RegExp('(\\b|_)' + busname + '([_0-9]|\\b)');
for(var i in nodenamelist){
- if(nodenamelist[i].search("^"+busname+"[0-9]")==0)
+ if(r.test(nodenamelist[i])) {
width++;
+ hit=i;
+ }
}
- if(width==0)
- return isNodeHigh(nodenames[busname])?1:0;
if(width>16)
return -1;
- return (0x10000+readBits(busname,width)).toString(16).slice(-width/4);
+ if(hit<0)
+ return -1;
+ // we may have a partial match, so find the full name of the last match
+ // we might have matched the first part, second part, or the whole thing (maybe with a numeric suffix)
+ var match1 = '^(' + busname + '_.*[^0-9])([0-9]*$|$)';
+ var match2 = '^(.*_' + busname + ')([0-9]*$|$)';
+ var match3 = '^(' + busname + ')([0-9]*$|$)';
+ r=new RegExp(match1);
+ var fullname=r.exec(nodenamelist[hit]);
+ if(fullname==undefined){
+ r=new RegExp(match2);
+ fullname=r.exec(nodenamelist[hit]);
+ if(fullname==undefined){
+ r=new RegExp(match3);
+ fullname=r.exec(nodenamelist[hit]);
+ }
+ }
+ // finally, convert from logic values to hex
+ if(width==1)
+ return isNodeHigh(nodenames[fullname[1]])?1:0;
+ return (0x10000+readBits(fullname[1],width)).toString(16).slice(-(width-1)/4-1);
}
function writeDataBus(x){
@@ -282,15 +330,17 @@ function chipStatus(){
' SP:' + hexByte(readSP()) +
' ' + readPstring();
setStatus(machine1 + "
" + machine2);
- if (loglevel>1) {
- updateLogbox(logThese);
+ if (loglevel>0) {
+ updateLogbox(signalSet(loglevel));
}
selectCell(ab);
}
function initLogbox(names){
+ var logbox=document.getElementById('logstream');
logStream = [];
logStream.push("" + names.join(" | ") + " | ");
+ logbox.innerHTML = ""+logStream.join("
")+"
";
}
function updateLogbox(names){
@@ -298,31 +348,11 @@ function updateLogbox(names){
var signals=[];
for(i in names){
- signals.push(hexBus(names[i]));
+ signals.push(busToString(names[i]));
}
logStream.push("" + signals.join(" | ") + " | ");
logbox.innerHTML = ""+logStream.join("
")+"
";
-
-
- var machine3 =
- ' Sync:' + readBit('sync') +
- ' IRQ:' + readBit('irq') +
- ' NMI:' + readBit('nmi');
- var machine4 =
- ' IR:' + hexByte(readBits('ir', 8)) +
- ' TCstate:' + readBit('clock1') + readBit('clock2') +
- readBit('t2') + readBit('t3') + readBit('t4') + readBit('t5');
- var machine5 =
- ' idl:' + hexByte(readBits('idl', 8)) +
- ' alu:' + hexByte(readBits('alu', 8)) +
- ' idb:' + hexByte(readBits('idb',8)) +
- ' dor:' + hexByte(readBits('dor',8));
- var machine6 =
- ' notRdy0:' + readBit('notRdy0') +
- ' fetch:' + readBit('fetch') +
- ' clearIR:' + readBit('clearIR') +
- ' D1x1:' + readBit('D1x1');
}
function getMem(){
diff --git a/nodenames.js b/nodenames.js
index 44c146d..b341250 100644
--- a/nodenames.js
+++ b/nodenames.js
@@ -119,7 +119,7 @@ p1: 1444,
p2: 1421,
p3: 439,
p4: 1119, // there is no bit4 in the status register!
-p5: 999999, // there is no bit5 in the status register!
+p5: -1, // there is no bit5 in the status register!
p6: 77,
p7: 1370,
s0: 1403, // machine state: stack pointer
@@ -201,6 +201,15 @@ alu4: 606,
alu5: 314,
alu6: 331,
alu7: 765,
+ // datapath signal: decimally adjusted special bus
+dasb0: 54, // same node as sb0
+dasb1: 1009,
+dasb2: 450,
+dasb3: 1475,
+dasb4: 1405, // same node as sb4
+dasb5: 263,
+dasb6: 679,
+dasb7: 1494,
adl0: 413, // internal state: address latch low
adl1: 1282,
adl2: 1242,
@@ -473,76 +482,82 @@ pipeVectorA2: 45,
// internal state: datapath control drivers
pipedpc28: 683,
-
-
-
-
-
-
-
// internal signals: alu internal (private) busses
alua0: 1167,
+alua1: 1248,
+alua2: 1332,
+alua3: 1680,
+alua4: 1142,
+alua5: 530,
+alua6: 1627,
+alua7: 1522,
alub0: 977,
+alub1: 1432,
+alub2: 704,
+alub3: 96,
+alub4: 1645,
+alub5: 1678,
+alub6: 235,
+alub7: 1535,
+
aluanorb0: 143,
aluanandb0: 1628,
aluaorb0: 693,
notaluoutmux0: 957, // alu result latch input
-alua1: 1248,
-alub1: 1432,
aluanorb1: 155,
aluanandb1: 841,
aluaorb1: 1021,
notaluoutmux1: 250, // alu result latch input
// internal signals: datapath control signals
-dpc0: 801, // drive sb from y
-dpc1: 325, // load y from sb
-dpc2: 1263, // drive sb from x
-dpc3: 1186, // load x from sb
-dpc4: 1700, // drive sb from stack pointer
-dpc5: 1468, // drive adl from stack pointer
-dpc6: 874, // load stack pointer from sb
-dpc7: 654, // recirculate stack pointer
-dpc8: 1068, // alu b side: select not-idb input
-dpc9: 859, // alu b side: select idb input
+dpc0_YSB: 801, // drive sb from y
+dpc1_SBY: 325, // load y from sb
+dpc2_XSB: 1263, // drive sb from x
+dpc3_SBX: 1186, // load x from sb
+dpc4_SSB: 1700, // drive sb from stack pointer
+dpc5_SADL: 1468, // drive adl from stack pointer
+dpc6_SBS: 874, // load stack pointer from sb
+dpc7_SS: 654, // recirculate stack pointer
+dpc8_nDBADD: 1068, // alu b side: select not-idb input
+dpc9_DBADD: 859, // alu b side: select idb input
-dpc10: 437, // alu b side: select adl input
-dpc11: 549, // alu a side: select sb
-dpc12: 984, // alu a side: select zero
-dpc13: 59, // alu op: a or b
-dpc14: 362, // alu op: logical right shift
-dpc15: 574, // alu op: a and b
-dpc16: 1666, // alu op: a xor b (?)
-dpc17: 921, // alu op: a plus b (?)
-notalucin: 1165, // alu carry in
-dpc18: 1201, // decimal related
-dpc19: 214, // alu to sb bit 7 only
+dpc10_ADLADD: 437, // alu b side: select adl input
+dpc11_SBADD: 549, // alu a side: select sb
+dpc12_0ADD: 984, // alu a side: select zero
+dpc13_ORS: 59, // alu op: a or b
+dpc14_SRS: 362, // alu op: logical right shift
+dpc15_ANDS: 574, // alu op: a and b
+dpc16_EORS: 1666, // alu op: a xor b (?)
+dpc17_SUMS: 921, // alu op: a plus b (?)
+notalucin: 1165, // alu carry in
+dpc18_DAA: 1201, // decimal related
+dpc19_ADDSB7: 214, // alu to sb bit 7 only
-dpc20: 129, // alu to sb bits 6-0 only
-dpc21: 1015, // alu to adl
-alucout: 938, // alu carry out (latched)
-dpc22: 725, // decimal related/SBC only
-dpc23: 534, // (optionalls decimal-adjusted) sb to acc
-dpc24: 1698, // acc to sb
-dpc25: 1060, // sb pass-connects to idb
-dpc26: 1331, // acc to idb
-dpc27: 140, // sb pass-connects to adh
-dpc28: 229, // zero to adh0 bit0 only
-dpc29: 203, // zero to adh bits 7-1 only
+dpc20_ADDSB06: 129, // alu to sb bits 6-0 only
+dpc21_ADDADL: 1015, // alu to adl
+alucout: 938, // alu carry out (latched)
+dpc22_DSA: 725, // decimal related/SBC only
+dpc23_SBAC: 534, // (optionalls decimal-adjusted) sb to acc
+dpc24_ACSB: 1698, // acc to sb
+dpc25_SBDB: 1060, // sb pass-connects to idb
+dpc26_ACDB: 1331, // acc to idb
+dpc27_SBADH: 140, // sb pass-connects to adh
+dpc28_0ADH0: 229, // zero to adh0 bit0 only
+dpc29_0ADH17: 203, // zero to adh bits 7-1 only
-dpc30: 48, // load pch from adh
-dpc31: 741, // load pch from pch incremented
-dpc32: 1235, // drive adh from pch incremented
-dpc33: 247, // drive idb from pch incremented
-dpc34: 1704, // pch carry in and pcl FF detect?
-dpc35: 1334, // pcl 0x?F detect - half-carry
-dpc36: 379, // pcl carry in
-dpc37: 283, // drive idb from pcl incremented
-dpc38: 438, // drive adl from pcl incremented
-dpc39: 898, // load pcl from pcl incremented
+dpc30_ADHPCH: 48, // load pch from adh
+dpc31_PCHPCH: 741, // load pch from pch incremented
+dpc32_PCHADH: 1235, // drive adh from pch incremented
+dpc33_PCHDB: 247, // drive idb from pch incremented
+dpc34_PCLC: 1704, // pch carry in and pcl FF detect?
+dpc35: 1334, // pcl 0x?F detect - half-carry
+dpc36_IPC: 379, // pcl carry in
+dpc37_PCLDB: 283, // drive idb from pcl incremented
+dpc38_PCLADL: 438, // drive adl from pcl incremented
+dpc39_PCLPCL: 898, // load pcl from pcl incremented
-dpc40: 414, // load pcl from adl
+dpc40_ADLPCL: 414, // load pcl from adl
dpc41: 1564, // pass-connect adl to mux node driven by idl
dpc42: 41, // pass-connect adh to mux node driven by idl
dpc43: 863, // pass-connect idb to mux node driven by idl
diff --git a/wires.css b/wires.css
index 8345762..6e04f8e 100644
--- a/wires.css
+++ b/wires.css
@@ -82,7 +82,8 @@ img.navstop{
table.logstream {
font-family: monospace;
font-size: 12px;
- border-spacing: 1px;
+ border-spacing: 2px;
+ text-align:center;
}
table.memtable {
diff --git a/wires.js b/wires.js
index 816a5e3..d911800 100644
--- a/wires.js
+++ b/wires.js
@@ -34,6 +34,7 @@ var drawlayers = [true, true, true, true, true, true];
var nodes = new Array();
var transistors = {};
+var nodenamelist=[];
var ngnd = nodenames['vss'];
var npwr = nodenames['vcc'];
@@ -65,6 +66,7 @@ function setup_part2(){
recenter();
refresh();
setupTable();
+ setupNodeNameList();
window.onkeypress = function(e){handleKey(e);}
hilite.onmousedown = function(e){mouseDown(e);}
setStatus('resetting 6502...');
@@ -319,16 +321,28 @@ function findNodeNumber(x,y){
return (high<<8)+(mid<<4)+low;
}
+function updateLoglevel(delta){
+ loglevel += delta;
+ initLogbox(signalSet(loglevel));
+}
+
function updateExpertMode(on){
if(on){
- document.getElementById('controlPanel').style.visibility = 'visible';
- loglevel=4;
+ document.getElementById('controlPanel').style.display = 'block';
+ loglevel=1;
+ initLogbox(signalSet(loglevel));
} else {
- document.getElementById('controlPanel').style.visibility = 'hidden';
+ document.getElementById('controlPanel').style.display = 'none';
loglevel=0;
}
}
+function clearHighlight(){
+ // remove red/white overlay according to logic value
+ // for easier layout navigation
+ ctx.clearRect(0,0,10000,10000);
+}
+
function updateShow(layer, on){
drawlayers[layer]=on;
setupBackground();
@@ -364,6 +378,11 @@ function setStatus(){
statbox.innerHTML = res;
}
+function setupNodeNameList(){
+ for(var i in nodenames)
+ nodenamelist.push(i);
+}
+
function nodeName(n) {
for(var i in nodenames){
if(nodenames[i]==n) return i;