import net.mograsim.logic.model.model.ViewModelModifiable;
import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent;
import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position;
{
super(model, name, "Register/\nCounter");
setSize(40, 40);
- addPin(new Pin(this, "D", 12, 20, 0), Usage.INPUT, Position.BOTTOM);
- addPin(new Pin(this, "_RLD", 1, 0, 5), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "WE", 1, 0, 20), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "DEC", 1, 0, 30), Usage.INPUT, Position.RIGHT);
- addPin(new Pin(this, "C", 1, 40, 20), Usage.INPUT, Position.LEFT);
- addPin(new Pin(this, "Y", 12, 20, 40), Usage.OUTPUT, Position.TOP);
+ addPin(new Pin(this, "D", 12, PinUsage.INPUT, 20, 0), Position.BOTTOM);
+ addPin(new Pin(this, "_RLD", 1, PinUsage.INPUT, 0, 5), Position.RIGHT);
+ addPin(new Pin(this, "WE", 1, PinUsage.INPUT, 0, 20), Position.RIGHT);
+ addPin(new Pin(this, "DEC", 1, PinUsage.INPUT, 0, 30), Position.RIGHT);
+ addPin(new Pin(this, "C", 1, PinUsage.INPUT, 40, 20), Position.LEFT);
+ addPin(new Pin(this, "Y", 12, PinUsage.OUTPUT, 20, 40), Position.TOP);
}
@Override
- protected Object recalculate(Object lastState, Map<String, ReadEnd> readEnds, Map<String, ReadWriteEnd> readWriteEnds)
+ public Object recalculate(Object lastState, Map<String, ReadEnd> readEnds, Map<String, ReadWriteEnd> readWriteEnds)
{
Bit[] QC = (Bit[]) lastState;
if (QC == null)
for (int i = 11; i >= 0; i--)
{
Bit a = QC[i];
- Bit z;
- if (a.isBinary() && carry.isBinary())
- {
- boolean aBool = a == ONE;
- boolean carryBool = carry == ONE;
- z = !aBool ^ carryBool ? ONE : ZERO;
- carry = aBool || carryBool ? ONE : ZERO;
- } else
- {
- carry = carry.join(a);
- z = carry;
- }
- QC[i] = z;
+ QC[i] = a.xnor(carry);
+ carry = a.or(carry);
}
}
}