Fixed a bug in Am2900; created dlatch8/80; relayouted some components
[Mograsim.git] / net.mograsim.logic.model / src / net / mograsim / logic / model / snippets / highlevelstatehandlers / standard / atomic / BitVectorSplittingAtomicHighLevelStateHandler.java
index 4b9e2d6..7ae2912 100644 (file)
@@ -9,7 +9,6 @@ import net.mograsim.logic.core.types.BitVector;
 import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
 import net.mograsim.logic.model.serializing.IdentifyParams;
 import net.mograsim.logic.model.snippets.SnippetDefinintion;
-import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.HighLevelStateHandlerContext;
 import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.StandardHighLevelStateHandlerSnippetSuppliers;
 
 public class BitVectorSplittingAtomicHighLevelStateHandler implements AtomicHighLevelStateHandler
@@ -21,15 +20,15 @@ public class BitVectorSplittingAtomicHighLevelStateHandler implements AtomicHigh
        private final List<Integer> vectorPartLengthesUnmodifiable;
        private int length;
 
-       public BitVectorSplittingAtomicHighLevelStateHandler(HighLevelStateHandlerContext context)
+       public BitVectorSplittingAtomicHighLevelStateHandler(SubmodelComponent component)
        {
-               this(context, null);
+               this(component, null);
        }
 
-       public BitVectorSplittingAtomicHighLevelStateHandler(HighLevelStateHandlerContext context,
+       public BitVectorSplittingAtomicHighLevelStateHandler(SubmodelComponent component,
                        BitVectorSplittingAtomicHighLevelStateHandlerParams params)
        {
-               this.component = context.component;
+               this.component = component;
                this.vectorPartTargets = new ArrayList<>();
                this.vectorPartTargetsUnmodifiable = Collections.unmodifiableList(vectorPartTargets);
                this.vectorPartLengthes = new ArrayList<>();
@@ -92,7 +91,7 @@ public class BitVectorSplittingAtomicHighLevelStateHandler implements AtomicHigh
                        if (vectorPart.length() != vectorPartLengthes.get(partIndex))
                                throw new IllegalArgumentException(
                                                "Incorrect vector part length: " + vectorPart.length() + "; expected " + vectorPartLengthes.get(partIndex));
-                       result = vectorPart.concat(result);
+                       result = result.concat(vectorPart);
                }
                return result;
        }
@@ -103,7 +102,7 @@ public class BitVectorSplittingAtomicHighLevelStateHandler implements AtomicHigh
                BitVector newStateCasted = (BitVector) newState;
                if (newStateCasted.length() != length)
                        throw new IllegalArgumentException("Incorrect vector length: " + newStateCasted.length() + "; expected " + length);
-               for (int partIndex = vectorPartTargets.size() - 1, bitIndex = 0; partIndex >= 0; partIndex--)
+               for (int partIndex = 0, bitIndex = 0; partIndex < vectorPartTargets.size(); partIndex++)
                {
                        int vectorPartLength = vectorPartLengthes.get(partIndex);
                        BitVector vectorPart = newStateCasted.subVector(bitIndex, bitIndex + vectorPartLength);