mirror of
https://github.com/trebonian/visual6502.git
synced 2024-12-22 12:29:20 +00:00
Performance: Remove float state
This commit is contained in:
parent
33aa993c8d
commit
98ec727c50
55
chipsim.js
55
chipsim.js
@ -57,14 +57,11 @@ function recalcNode(node){
|
|||||||
if(node==ngnd) return;
|
if(node==ngnd) return;
|
||||||
if(node==npwr) return;
|
if(node==npwr) return;
|
||||||
group = getNodeGroup(node);
|
group = getNodeGroup(node);
|
||||||
var newv = getNodeValue();
|
var newState = getNodeValue(group);
|
||||||
var newState = (newv[0]=='h');
|
|
||||||
var newFloat = (newv[1]=='f');
|
|
||||||
if(ctrace && (traceTheseNodes.indexOf(node)!=-1))
|
if(ctrace && (traceTheseNodes.indexOf(node)!=-1))
|
||||||
console.log('recalc', node, group);
|
console.log('recalc', node, group);
|
||||||
for(var i in group){
|
for(var i in group){
|
||||||
var n = nodes[group[i]];
|
var n = nodes[group[i]];
|
||||||
n.float = newFloat;
|
|
||||||
if(n.state==newState)continue; /******Performance********/
|
if(n.state==newState)continue; /******Performance********/
|
||||||
n.state = newState;
|
n.state = newState;
|
||||||
n.gates.forEach(
|
n.gates.forEach(
|
||||||
@ -93,27 +90,16 @@ function turnTransistorOff(t){
|
|||||||
if(ctrace && (traceTheseTransistors.indexOf(t.name)!=-1))
|
if(ctrace && (traceTheseTransistors.indexOf(t.name)!=-1))
|
||||||
console.log(t.name, 'off', t.gate, t.c1, t.c2);
|
console.log(t.name, 'off', t.gate, t.c1, t.c2);
|
||||||
t.on = false;
|
t.on = false;
|
||||||
floatnode(t.c1);
|
|
||||||
floatnode(t.c2);
|
|
||||||
addRecalcNode(t.c1);
|
addRecalcNode(t.c1);
|
||||||
addRecalcNode(t.c2);
|
addRecalcNode(t.c2);
|
||||||
}
|
}
|
||||||
|
|
||||||
function floatnode(nn){
|
|
||||||
if(nn==ngnd) return;
|
|
||||||
if(nn==npwr) return;
|
|
||||||
var n = nodes[nn];
|
|
||||||
n.float = true;
|
|
||||||
if(ctrace && (traceTheseNodes.indexOf(nn)!=-1))
|
|
||||||
console.log('floating', nn, 'at', n.state);
|
|
||||||
}
|
|
||||||
|
|
||||||
function addRecalcNode(nn){
|
function addRecalcNode(nn){
|
||||||
if(nn==ngnd) return;
|
if(nn==ngnd) return;
|
||||||
if(nn==npwr) return;
|
if(nn==npwr) return;
|
||||||
if(recalcHash[nn] == 1)return;
|
if(recalcHash[nn] == 1)return;
|
||||||
recalclist.push(nn);
|
recalclist.push(nn);
|
||||||
recalcHash[nn] = 1;
|
recalcHash[nn] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNodeGroup(i){
|
function getNodeGroup(i){
|
||||||
@ -147,19 +133,16 @@ function addNodeTransistor(node, tr){
|
|||||||
|
|
||||||
|
|
||||||
function getNodeValue(){
|
function getNodeValue(){
|
||||||
if(arrayContains(group, ngnd)) return 'l ';
|
if(arrayContains(group, ngnd)) return false;
|
||||||
if(arrayContains(group, npwr)) return 'h ';
|
if(arrayContains(group, npwr)) return true;
|
||||||
var flstate;
|
|
||||||
for(var i in group){
|
for(var i in group){
|
||||||
var nn = group[i];
|
var nn = group[i];
|
||||||
var n = nodes[nn];
|
var n = nodes[nn];
|
||||||
if(n.pullup) return 'h ';
|
if(n.pullup) return true;
|
||||||
if(n.pulldown) return 'l ';
|
if(n.pulldown) return false;
|
||||||
if((!n.state && n.float)&&(flstate==undefined)) flstate = 'lf';
|
if(n.state) return true;
|
||||||
if(n.state && n.float) flstate = 'hf';
|
|
||||||
}
|
}
|
||||||
if(flstate==undefined && ctrace) console.log(group);
|
return false;
|
||||||
return flstate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -182,26 +165,26 @@ function allNodes(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function stateString(){
|
function stateString(){
|
||||||
var codes = ['g','l','h','f' ];
|
var codes = ['l','h'];
|
||||||
var res = '';
|
var res = '';
|
||||||
for(var i=0;i<1725;i++){
|
for(var i=0;i<1725;i++){
|
||||||
var n = nodes[i];
|
var n = nodes[i];
|
||||||
if(n==undefined) res+='x';
|
if(n==undefined) res+='x';
|
||||||
else if(i==ngnd) res+='g';
|
else if(i==ngnd) res+='g';
|
||||||
else if(i==npwr) res+='h';
|
else if(i==npwr) res+='v';
|
||||||
else res+= codes[n.state*2 + n.float];
|
else res+= codes[0+n.state];
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
function showState(str){
|
function showState(str){
|
||||||
var codes = {g: 'l ', h: 'h ', f: 'hf', l: 'lf'};
|
var codes = {g: false, h: true, v: true, l: false};
|
||||||
for(var i=0;i<str.length;i++){
|
for(var i=0;i<str.length;i++){
|
||||||
if(str[i]=='x') continue;
|
if(str[i]=='x') continue;
|
||||||
nodes[i].state = ((codes[str[i]])[0]=='h');
|
var state = codes[str[i]];
|
||||||
nodes[i].float = ((codes[str[i]])[1]=='f');
|
nodes[i].state = state;
|
||||||
var gates = nodes[i].gates;
|
var gates = nodes[i].gates;
|
||||||
gates.forEach(function(t){t.on=isNodeHigh(i);});
|
gates.forEach(function(t){t.on=state;});
|
||||||
}
|
}
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
@ -172,10 +172,6 @@ var goldenChecksum;
|
|||||||
|
|
||||||
// simulate a single clock phase, updating trace and highlighting layout
|
// simulate a single clock phase, updating trace and highlighting layout
|
||||||
function step(){
|
function step(){
|
||||||
if(!animateChipLayout){
|
|
||||||
halfStep();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var s=stateString();
|
var s=stateString();
|
||||||
var m=getMem();
|
var m=getMem();
|
||||||
trace[cycle]= {chip: s, mem: m};
|
trace[cycle]= {chip: s, mem: m};
|
||||||
|
2
wires.js
2
wires.js
@ -36,7 +36,7 @@ function setupNodes(){
|
|||||||
var w = seg[0];
|
var w = seg[0];
|
||||||
if(nodes[w]==undefined)
|
if(nodes[w]==undefined)
|
||||||
nodes[w] = {segs: new Array(), num: w, pullup: seg[1]=='+',
|
nodes[w] = {segs: new Array(), num: w, pullup: seg[1]=='+',
|
||||||
state: false, float: true, gates: new Array(), c1c2s: new Array()};
|
state: false, gates: new Array(), c1c2s: new Array()};
|
||||||
if(w==ngnd) continue;
|
if(w==ngnd) continue;
|
||||||
if(w==npwr) continue;
|
if(w==npwr) continue;
|
||||||
nodes[w].segs.push(seg.slice(3));
|
nodes[w].segs.push(seg.slice(3));
|
||||||
|
Loading…
Reference in New Issue
Block a user