diff --git a/sim/allocator.ts b/sim/allocator.ts index 1881a14f..813ca724 100644 --- a/sim/allocator.ts +++ b/sim/allocator.ts @@ -195,12 +195,14 @@ namespace pxsim { const GROUND_COLOR = "blue"; const POWER_COLOR = "red"; const wires: WireInst[] = []; + let groundStep = 0; + let threeVoltStep = (powerUsage.bottomGround || powerUsage.topGround) ? 1 : 0; if (powerUsage.bottomGround && powerUsage.topGround) { //bb top - <==> bb bot - wires.push({ start: this.allocateLocation("ground", {nearestBBPin: top}), end: this.allocateLocation("ground", {nearestBBPin: bot}), - color: GROUND_COLOR, assemblyStep: 0 + color: GROUND_COLOR, assemblyStep: groundStep }); } if (powerUsage.topGround) { @@ -208,14 +210,14 @@ namespace pxsim { wires.push({ start: this.allocateLocation("ground", {nearestBBPin: top}), end: {type: "dalboard", pin: boardGround}, - color: GROUND_COLOR, assemblyStep: 0 + color: GROUND_COLOR, assemblyStep: groundStep }); } else if (powerUsage.bottomGround) { //board - <==> bb bot - wires.push({ start: this.allocateLocation("ground", {nearestBBPin: bot}), end: {type: "dalboard", pin: boardGround}, - color: GROUND_COLOR, assemblyStep: 0 + color: GROUND_COLOR, assemblyStep: groundStep }); } if (powerUsage.bottomThreeVolt && powerUsage.bottomGround) { @@ -223,7 +225,7 @@ namespace pxsim { wires.push({ start: this.allocateLocation("threeVolt", {nearestBBPin: top}), end: this.allocateLocation("threeVolt", {nearestBBPin: bot}), - color: POWER_COLOR, assemblyStep: 1 + color: POWER_COLOR, assemblyStep: threeVoltStep }); } if (powerUsage.topThreeVolt) { @@ -231,14 +233,14 @@ namespace pxsim { wires.push({ start: this.allocateLocation("threeVolt", {nearestBBPin: top}), end: {type: "dalboard", pin: threeVoltPin}, - color: POWER_COLOR, assemblyStep: 1 + color: POWER_COLOR, assemblyStep: threeVoltStep }); } else if (powerUsage.bottomThreeVolt) { //board + <==> bb bot + wires.push({ start: this.allocateLocation("threeVolt", {nearestBBPin: bot}), end: {type: "dalboard", pin: threeVoltPin}, - color: POWER_COLOR, assemblyStep: 1 + color: POWER_COLOR, assemblyStep: threeVoltStep }); } return wires; diff --git a/sim/instructions/instructions.ts b/sim/instructions/instructions.ts index 431e8477..f2724e65 100644 --- a/sim/instructions/instructions.ts +++ b/sim/instructions/instructions.ts @@ -321,7 +321,7 @@ namespace pxsim.instructions { (stepToWires[step] || (stepToWires[step] = [])).push(w) }); let getMaxStep = (ns: {assemblyStep: number}[]) => ns.reduce((m, n) => Math.max(m, n.assemblyStep), 0); - let stepOffset = getMaxStep(powerWires) + 2; + let stepOffset = powerWires.length > 0 ? getMaxStep(powerWires) + 2 : 1; components.forEach(cAndWs => { let {component, wires} = cAndWs; let cStep = component.assemblyStep + stepOffset;