Merge branch 'ed' into staging

This commit is contained in:
Barry Silverman 2010-09-27 13:48:54 -04:00
commit b8d2872246
5 changed files with 185 additions and 115 deletions

View File

@ -58,32 +58,37 @@ Enter your own program into the array of RAM
</div> </div>
<div class = "buttons"> <div class = "buttons">
<div style="position:relative; float:left;"> <div style="position:relative; float:left;">
<a href ="javascript:stopChip()"id="stop"><img class="navstop" src="images/stop.png"></a> <a href ="javascript:stopChip()"id="stop"><img class="navstop" src="images/stop.png" title="stop"></a>
<a href ="javascript:runChip()" id="start"><img class="navplay" src="images/play.png"></a> <a href ="javascript:runChip()" id="start"><img class="navplay" src="images/play.png" title="run"></a>
</div> </div>
<div style="float:left;"> <div style="float:left;">
<a href ="javascript:resetChip()"><img class="navbutton" src="images/up.png"></a> <a href ="javascript:resetChip()"><img class="navbutton" src="images/up.png" title="reset"></a>
<a href ="javascript:stepBack()"><img class="navbutton" src="images/prev.png"></a> <a href ="javascript:stepBack()"><img class="navbutton" src="images/prev.png" title="back"></a>
<a href ="javascript:stepForward()"><img class="navbutton" src="images/next.png"></a> <a href ="javascript:stepForward()"><img class="navbutton" src="images/next.png" title="step"></a>
<div id="expertMode" style="float:left;">Expert: <span id="expertMode">Expert:
<input type="checkbox" name="0" onchange="updateExpertMode(this.checked)" /> <input type="checkbox" name="0" onchange="updateExpertMode(this.checked)" />
</div> </span>
</div> </div>
</div> </div>
<p class="status" id="status">x: 0<br>y: 0</p> <p class="status" id="status">x: 0<br>y: 0</p>
<table class="memtable" id="memtable"></table> <table class="memtable" id="memtable"></table>
</div> </div>
<div id="controlPanel" style="visibility:hidden"> <div id="controlPanel" style="display:none">
<div id="updateShow"> Show: <form id="updateShow"> Show:
<input type="checkbox" name="0" id="updateShow0" onchange="updateShow(this.name,this.checked)" />(metal) <input type="checkbox" name="1" id="updateShow1" onchange="updateShow(this.name,this.checked)" />(diffusion)
<input type="checkbox" name="1" id="updateShow1" onchange="updateShow(this.name,this.checked)" />(switched diffusion)
<input type="checkbox" name="3" id="updateShow3" onchange="updateShow(this.name,this.checked)" />(grounded diffusion) <input type="checkbox" name="3" id="updateShow3" onchange="updateShow(this.name,this.checked)" />(grounded diffusion)
<input type="checkbox" name="4" id="updateShow4" onchange="updateShow(this.name,this.checked)" />(powered diffusion) <input type="checkbox" name="4" id="updateShow4" onchange="updateShow(this.name,this.checked)" />(powered diffusion)
<input type="checkbox" name="5" id="updateShow5" onchange="updateShow(this.name,this.checked)" />(polysilicon) <input type="checkbox" name="5" id="updateShow5" onchange="updateShow(this.name,this.checked)" />(polysilicon)
<input type="checkbox" name="2" id="updateShow2" onchange="updateShow(this.name,this.checked)" />(diode) <input type="checkbox" name="0" id="updateShow0" onchange="updateShow(this.name,this.checked)" />(metal)
</div> <input type="checkbox" name="2" id="updateShow2" onchange="updateShow(this.name,this.checked)" />(protection)
<br /> </form>
<table class="logstream" id="logstream"></table> <form>
<input type="button" value="Clear Highlighting" onclick="clearHighlight()" />
<input type="button" value="Trace more" onclick="updateLoglevel(1)" />
<input type="button" value="Trace less" onclick="updateLoglevel(-1)" />
</form>
<br />
<table class="logstream" id="logstream"></table>
</div> </div>
<br /> <br />
Source code is available on GitHub: <a href="http://github.com/trebonian/visual6502">http://github.com/trebonian/visual6502</a> Source code is available on GitHub: <a href="http://github.com/trebonian/visual6502">http://github.com/trebonian/visual6502</a>

116
macros.js
View File

@ -86,7 +86,6 @@ function testNMI(n){
for(var i=0;i<16;i++){step();} for(var i=0;i<16;i++){step();}
} }
function initChip(){ function initChip(){
var start = now(); var start = now();
for(var nn in nodes) nodes[nn].state = 'fl'; for(var nn in nodes) nodes[nn].state = 'fl';
@ -100,35 +99,49 @@ function initChip(){
recalcNodeList(allNodes()); recalcNodeList(allNodes());
for(var i=0;i<8;i++){setHigh('clk0'), setLow('clk0');} for(var i=0;i<8;i++){setHigh('clk0'), setLow('clk0');}
setHigh('res'); setHigh('res');
for(var i=0;i<18;i++){resetStep();} for(var i=0;i<18;i++){halfStep();}
refresh(); refresh();
cycle = 0; cycle = 0;
trace = Array(); trace = Array();
initLogbox(logThese); initLogbox(signalSet(loglevel));
chipStatus(); chipStatus();
if(ctrace)console.log('initChip done after', now()-start); 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<logThese[i].length; j++){
signals.push(logThese[i][j]);
}
}
return signals;
}
// simulate a single clock phase, updating trace and highlighting layout
function step(){ function step(){
trace[cycle]= {chip: stateString(), mem: getMem()}; trace[cycle]= {chip: stateString(), mem: getMem()};
halfStep(); halfStep();
refresh();
cycle++; cycle++;
chipStatus(); chipStatus();
} }
// simulate a single clock phase with no update to graphics or trace
function halfStep(){ function halfStep(){
var clk = isNodeHigh(nodenames['clk0']); var clk = isNodeHigh(nodenames['clk0']);
if (clk) {setLow('clk0'); handleBusRead(); } if (clk) {setLow('clk0'); handleBusRead(); }
else {setHigh('clk0'); handleBusWrite();} else {setHigh('clk0'); handleBusWrite();}
refresh();
}
function resetStep(){
var clk = isNodeHigh(nodenames['clk0']);
if (clk) {setLow('clk0'); handleBusRead(); }
else {setHigh('clk0'); handleBusWrite();}
} }
function handleBusRead(){ function handleBusRead(){
@ -179,22 +192,57 @@ function readBits(name, n){
return res; return res;
} }
function hexBus(busname){ function busToString(busname){
var nodenamelist=[]; // takes a signal name or prefix
// console.log('hexBus called: ' + busname); // returns an appropriate string representation
for(i in nodenames){nodenamelist.push(i)}; if(busname=='cycle')
return cycle>>1;
if(busname=='pc') 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 width=0;
var hit=-1;
var r=new RegExp('(\\b|_)' + busname + '([_0-9]|\\b)');
for(var i in nodenamelist){ for(var i in nodenamelist){
if(nodenamelist[i].search("^"+busname+"[0-9]")==0) if(r.test(nodenamelist[i])) {
width++; width++;
hit=i;
}
} }
if(width==0)
return isNodeHigh(nodenames[busname])?1:0;
if(width>16) if(width>16)
return -1; 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){ function writeDataBus(x){
@ -282,15 +330,17 @@ function chipStatus(){
' SP:' + hexByte(readSP()) + ' SP:' + hexByte(readSP()) +
' ' + readPstring(); ' ' + readPstring();
setStatus(machine1 + "<br>" + machine2); setStatus(machine1 + "<br>" + machine2);
if (loglevel>1) { if (loglevel>0) {
updateLogbox(logThese); updateLogbox(signalSet(loglevel));
} }
selectCell(ab); selectCell(ab);
} }
function initLogbox(names){ function initLogbox(names){
var logbox=document.getElementById('logstream');
logStream = []; logStream = [];
logStream.push("<td>" + names.join("</td><td>") + "</td>"); logStream.push("<td>" + names.join("</td><td>") + "</td>");
logbox.innerHTML = "<tr>"+logStream.join("</tr><tr>")+"</tr>";
} }
function updateLogbox(names){ function updateLogbox(names){
@ -298,31 +348,11 @@ function updateLogbox(names){
var signals=[]; var signals=[];
for(i in names){ for(i in names){
signals.push(hexBus(names[i])); signals.push(busToString(names[i]));
} }
logStream.push("<td>" + signals.join("</td><td>") + "</td>"); logStream.push("<td>" + signals.join("</td><td>") + "</td>");
logbox.innerHTML = "<tr>"+logStream.join("</tr><tr>")+"</tr>"; logbox.innerHTML = "<tr>"+logStream.join("</tr><tr>")+"</tr>";
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(){ function getMem(){

View File

@ -119,7 +119,7 @@ p1: 1444,
p2: 1421, p2: 1421,
p3: 439, p3: 439,
p4: 1119, // there is no bit4 in the status register! 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, p6: 77,
p7: 1370, p7: 1370,
s0: 1403, // machine state: stack pointer s0: 1403, // machine state: stack pointer
@ -201,6 +201,15 @@ alu4: 606,
alu5: 314, alu5: 314,
alu6: 331, alu6: 331,
alu7: 765, 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 adl0: 413, // internal state: address latch low
adl1: 1282, adl1: 1282,
adl2: 1242, adl2: 1242,
@ -473,76 +482,82 @@ pipeVectorA2: 45,
// internal state: datapath control drivers // internal state: datapath control drivers
pipedpc28: 683, pipedpc28: 683,
// internal signals: alu internal (private) busses // internal signals: alu internal (private) busses
alua0: 1167, alua0: 1167,
alua1: 1248,
alua2: 1332,
alua3: 1680,
alua4: 1142,
alua5: 530,
alua6: 1627,
alua7: 1522,
alub0: 977, alub0: 977,
alub1: 1432,
alub2: 704,
alub3: 96,
alub4: 1645,
alub5: 1678,
alub6: 235,
alub7: 1535,
aluanorb0: 143, aluanorb0: 143,
aluanandb0: 1628, aluanandb0: 1628,
aluaorb0: 693, aluaorb0: 693,
notaluoutmux0: 957, // alu result latch input notaluoutmux0: 957, // alu result latch input
alua1: 1248,
alub1: 1432,
aluanorb1: 155, aluanorb1: 155,
aluanandb1: 841, aluanandb1: 841,
aluaorb1: 1021, aluaorb1: 1021,
notaluoutmux1: 250, // alu result latch input notaluoutmux1: 250, // alu result latch input
// internal signals: datapath control signals // internal signals: datapath control signals
dpc0: 801, // drive sb from y dpc0_YSB: 801, // drive sb from y
dpc1: 325, // load y from sb dpc1_SBY: 325, // load y from sb
dpc2: 1263, // drive sb from x dpc2_XSB: 1263, // drive sb from x
dpc3: 1186, // load x from sb dpc3_SBX: 1186, // load x from sb
dpc4: 1700, // drive sb from stack pointer dpc4_SSB: 1700, // drive sb from stack pointer
dpc5: 1468, // drive adl from stack pointer dpc5_SADL: 1468, // drive adl from stack pointer
dpc6: 874, // load stack pointer from sb dpc6_SBS: 874, // load stack pointer from sb
dpc7: 654, // recirculate stack pointer dpc7_SS: 654, // recirculate stack pointer
dpc8: 1068, // alu b side: select not-idb input dpc8_nDBADD: 1068, // alu b side: select not-idb input
dpc9: 859, // alu b side: select idb input dpc9_DBADD: 859, // alu b side: select idb input
dpc10: 437, // alu b side: select adl input dpc10_ADLADD: 437, // alu b side: select adl input
dpc11: 549, // alu a side: select sb dpc11_SBADD: 549, // alu a side: select sb
dpc12: 984, // alu a side: select zero dpc12_0ADD: 984, // alu a side: select zero
dpc13: 59, // alu op: a or b dpc13_ORS: 59, // alu op: a or b
dpc14: 362, // alu op: logical right shift dpc14_SRS: 362, // alu op: logical right shift
dpc15: 574, // alu op: a and b dpc15_ANDS: 574, // alu op: a and b
dpc16: 1666, // alu op: a xor b (?) dpc16_EORS: 1666, // alu op: a xor b (?)
dpc17: 921, // alu op: a plus b (?) dpc17_SUMS: 921, // alu op: a plus b (?)
notalucin: 1165, // alu carry in notalucin: 1165, // alu carry in
dpc18: 1201, // decimal related dpc18_DAA: 1201, // decimal related
dpc19: 214, // alu to sb bit 7 only dpc19_ADDSB7: 214, // alu to sb bit 7 only
dpc20: 129, // alu to sb bits 6-0 only dpc20_ADDSB06: 129, // alu to sb bits 6-0 only
dpc21: 1015, // alu to adl dpc21_ADDADL: 1015, // alu to adl
alucout: 938, // alu carry out (latched) alucout: 938, // alu carry out (latched)
dpc22: 725, // decimal related/SBC only dpc22_DSA: 725, // decimal related/SBC only
dpc23: 534, // (optionalls decimal-adjusted) sb to acc dpc23_SBAC: 534, // (optionalls decimal-adjusted) sb to acc
dpc24: 1698, // acc to sb dpc24_ACSB: 1698, // acc to sb
dpc25: 1060, // sb pass-connects to idb dpc25_SBDB: 1060, // sb pass-connects to idb
dpc26: 1331, // acc to idb dpc26_ACDB: 1331, // acc to idb
dpc27: 140, // sb pass-connects to adh dpc27_SBADH: 140, // sb pass-connects to adh
dpc28: 229, // zero to adh0 bit0 only dpc28_0ADH0: 229, // zero to adh0 bit0 only
dpc29: 203, // zero to adh bits 7-1 only dpc29_0ADH17: 203, // zero to adh bits 7-1 only
dpc30: 48, // load pch from adh dpc30_ADHPCH: 48, // load pch from adh
dpc31: 741, // load pch from pch incremented dpc31_PCHPCH: 741, // load pch from pch incremented
dpc32: 1235, // drive adh from pch incremented dpc32_PCHADH: 1235, // drive adh from pch incremented
dpc33: 247, // drive idb from pch incremented dpc33_PCHDB: 247, // drive idb from pch incremented
dpc34: 1704, // pch carry in and pcl FF detect? dpc34_PCLC: 1704, // pch carry in and pcl FF detect?
dpc35: 1334, // pcl 0x?F detect - half-carry dpc35: 1334, // pcl 0x?F detect - half-carry
dpc36: 379, // pcl carry in dpc36_IPC: 379, // pcl carry in
dpc37: 283, // drive idb from pcl incremented dpc37_PCLDB: 283, // drive idb from pcl incremented
dpc38: 438, // drive adl from pcl incremented dpc38_PCLADL: 438, // drive adl from pcl incremented
dpc39: 898, // load pcl 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 dpc41: 1564, // pass-connect adl to mux node driven by idl
dpc42: 41, // pass-connect adh 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 dpc43: 863, // pass-connect idb to mux node driven by idl

View File

@ -82,7 +82,8 @@ img.navstop{
table.logstream { table.logstream {
font-family: monospace; font-family: monospace;
font-size: 12px; font-size: 12px;
border-spacing: 1px; border-spacing: 2px;
text-align:center;
} }
table.memtable { table.memtable {

View File

@ -34,6 +34,7 @@ var drawlayers = [true, true, true, true, true, true];
var nodes = new Array(); var nodes = new Array();
var transistors = {}; var transistors = {};
var nodenamelist=[];
var ngnd = nodenames['vss']; var ngnd = nodenames['vss'];
var npwr = nodenames['vcc']; var npwr = nodenames['vcc'];
@ -65,6 +66,7 @@ function setup_part2(){
recenter(); recenter();
refresh(); refresh();
setupTable(); setupTable();
setupNodeNameList();
window.onkeypress = function(e){handleKey(e);} window.onkeypress = function(e){handleKey(e);}
hilite.onmousedown = function(e){mouseDown(e);} hilite.onmousedown = function(e){mouseDown(e);}
setStatus('resetting 6502...'); setStatus('resetting 6502...');
@ -319,16 +321,28 @@ function findNodeNumber(x,y){
return (high<<8)+(mid<<4)+low; return (high<<8)+(mid<<4)+low;
} }
function updateLoglevel(delta){
loglevel += delta;
initLogbox(signalSet(loglevel));
}
function updateExpertMode(on){ function updateExpertMode(on){
if(on){ if(on){
document.getElementById('controlPanel').style.visibility = 'visible'; document.getElementById('controlPanel').style.display = 'block';
loglevel=4; loglevel=1;
initLogbox(signalSet(loglevel));
} else { } else {
document.getElementById('controlPanel').style.visibility = 'hidden'; document.getElementById('controlPanel').style.display = 'none';
loglevel=0; 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){ function updateShow(layer, on){
drawlayers[layer]=on; drawlayers[layer]=on;
setupBackground(); setupBackground();
@ -364,6 +378,11 @@ function setStatus(){
statbox.innerHTML = res; statbox.innerHTML = res;
} }
function setupNodeNameList(){
for(var i in nodenames)
nodenamelist.push(i);
}
function nodeName(n) { function nodeName(n) {
for(var i in nodenames){ for(var i in nodenames){
if(nodenames[i]==n) return i; if(nodenames[i]==n) return i;