From dff0fa8af5e0bfb1cdc1dc6bfb408bb99c1c9a15 Mon Sep 17 00:00:00 2001 From: Christopher Mosher Date: Tue, 3 Dec 2013 15:03:55 -0500 Subject: [PATCH] minor refactor --- cpu.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cpu.cpp b/cpu.cpp index 8a90265..6de29ce 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -434,7 +434,7 @@ void CPU::recalc(const std::set& riSeg) { * gets what their group value is (or should be), goes through all * those segments and sets their "on" value. For all connected gates, * turn on/off, and indicate that the segments connected to those - * transistors's source and drain legs have changed, by adding them + * transistors' source and drain legs have changed, by adding them * to riSegChanged. */ void CPU::recalcNode(const int iSeg, std::set& riSegChanged) { @@ -448,7 +448,7 @@ void CPU::recalcNode(const int iSeg, std::set& riSegChanged) { if (s.on != groupOn) { s.on = groupOn; for (std::vector::iterator iTrnGate = s.gates.begin(); iTrnGate != s.gates.end(); ++iTrnGate) { - setTrans(trns[*iTrnGate], s.on, riSegChanged); + setTrans(trns[*iTrnGate], groupOn, riSegChanged); } } } @@ -501,15 +501,17 @@ void CPU::addToGroup(int iSeg, std::set& riSeg) { } bool CPU::getGroupValue(const std::set& riSeg) { - /* If group contain ground, it's OFF. */ + /* If group contains ground, it's OFF, */ if (riSeg.find(VSS) != riSeg.end()) { return false; } - /* If group contain voltage supply, it's ON. */ - if (riSeg.find(VCC) != riSeg.end()) { + /* otherwise, if group contains voltage supply, it's ON. */ + else if (riSeg.find(VCC) != riSeg.end()) { return true; } + + for (std::set::const_iterator iSeg = riSeg.begin(); iSeg != riSeg.end(); ++iSeg) { const seg& s = segs[*iSeg]; if (s.pullup) {