Made WireForcingAtomicHighLevelStateHandler.getHighLevelState cleaner
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 2 Oct 2019 13:41:40 +0000 (15:41 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 2 Oct 2019 13:41:40 +0000 (15:41 +0200)
plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/atomic/WireForcingAtomicHighLevelStateHandler.java

index 276f541..aa509c9 100644 (file)
@@ -99,14 +99,20 @@ public class WireForcingAtomicHighLevelStateHandler implements AtomicHighLevelSt
        @Override
        public Object getHighLevelState()
        {
-               BitVector result = BitVector.of(Bit.ZERO, logicWidth);
-               for (ModelWire wire : wiresToForceInverted)
-                       if (wire.hasCoreModelBinding())
-                               result = result.or(wire.getWireValues());
-               result = result.not();
+               BitVector result = BitVector.of(Bit.Z, logicWidth);
+
+               if (!wiresToForceInverted.isEmpty())
+               {
+                       for (ModelWire wire : wiresToForceInverted)
+                               if (wire.hasCoreModelBinding())
+                                       result = result.join(wire.getWireValues());
+                       result = result.not();
+               }
+
                for (ModelWire wire : wiresToForce)
                        if (wire.hasCoreModelBinding())
-                               result = result.and(wire.getWireValues());
+                               result = result.join(wire.getWireValues());
+
                return result;
        }