projects
/
Mograsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
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
diff --git
a/net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/atomic/BitVectorSplittingAtomicHighLevelStateHandler.java
b/net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/atomic/BitVectorSplittingAtomicHighLevelStateHandler.java
index
b17af6f
..
7ae2912
100644
(file)
--- a/
net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/atomic/BitVectorSplittingAtomicHighLevelStateHandler.java
+++ b/
net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/atomic/BitVectorSplittingAtomicHighLevelStateHandler.java
@@
-1,34
+1,38
@@
package net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.atomic;
import java.util.ArrayList;
package net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.atomic;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import net.mograsim.logic.core.types.Bit;
import net.mograsim.logic.core.types.BitVector;
import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
import java.util.List;
import net.mograsim.logic.core.types.Bit;
import net.mograsim.logic.core.types.BitVector;
import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
-import net.mograsim.logic.model.serializing.Identif
ierGetter
;
+import net.mograsim.logic.model.serializing.Identif
yParams
;
import net.mograsim.logic.model.snippets.SnippetDefinintion;
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
{
import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.StandardHighLevelStateHandlerSnippetSuppliers;
public class BitVectorSplittingAtomicHighLevelStateHandler implements AtomicHighLevelStateHandler
{
- private SubmodelComponent component;
+ private
final
SubmodelComponent component;
private final List<String> vectorPartTargets;
private final List<String> vectorPartTargets;
+ private final List<String> vectorPartTargetsUnmodifiable;
private final List<Integer> vectorPartLengthes;
private final List<Integer> vectorPartLengthes;
+ private final List<Integer> vectorPartLengthesUnmodifiable;
private int length;
private int length;
- public BitVectorSplittingAtomicHighLevelStateHandler(
HighLevelStateHandlerContext contex
t)
+ public BitVectorSplittingAtomicHighLevelStateHandler(
SubmodelComponent componen
t)
{
{
- this(co
ntex
t, null);
+ this(co
mponen
t, null);
}
}
- public BitVectorSplittingAtomicHighLevelStateHandler(
HighLevelStateHandlerContext contex
t,
+ public BitVectorSplittingAtomicHighLevelStateHandler(
SubmodelComponent componen
t,
BitVectorSplittingAtomicHighLevelStateHandlerParams params)
{
BitVectorSplittingAtomicHighLevelStateHandlerParams params)
{
- this.component = co
ntext.co
mponent;
+ this.component = component;
this.vectorPartTargets = new ArrayList<>();
this.vectorPartTargets = new ArrayList<>();
+ this.vectorPartTargetsUnmodifiable = Collections.unmodifiableList(vectorPartTargets);
this.vectorPartLengthes = new ArrayList<>();
this.vectorPartLengthes = new ArrayList<>();
+ this.vectorPartLengthesUnmodifiable = Collections.unmodifiableList(vectorPartLengthes);
if (params != null)
setVectorParts(params.vectorPartTargets, params.vectorPartLengthes);
}
if (params != null)
setVectorParts(params.vectorPartTargets, params.vectorPartLengthes);
}
@@
-62,6
+66,16
@@
public class BitVectorSplittingAtomicHighLevelStateHandler implements AtomicHigh
length += lengthes.stream().mapToInt(Integer::intValue).sum();
}
length += lengthes.stream().mapToInt(Integer::intValue).sum();
}
+ public List<String> getVectorPartTargets()
+ {
+ return vectorPartTargetsUnmodifiable;
+ }
+
+ public List<Integer> getVectorPartLenghtes()
+ {
+ return vectorPartLengthesUnmodifiable;
+ }
+
@Override
public Object getHighLevelState()
{
@Override
public Object getHighLevelState()
{
@@
-77,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));
if (vectorPart.length() != vectorPartLengthes.get(partIndex))
throw new IllegalArgumentException(
"Incorrect vector part length: " + vectorPart.length() + "; expected " + vectorPartLengthes.get(partIndex));
- result =
vectorPart.concat(resul
t);
+ result =
result.concat(vectorPar
t);
}
return result;
}
}
return result;
}
@@
-88,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);
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);
{
int vectorPartLength = vectorPartLengthes.get(partIndex);
BitVector vectorPart = newStateCasted.subVector(bitIndex, bitIndex + vectorPartLength);
@@
-98,7
+112,13
@@
public class BitVectorSplittingAtomicHighLevelStateHandler implements AtomicHigh
}
@Override
}
@Override
- public BitVectorSplittingAtomicHighLevelStateHandlerParams getParamsForSerializing(IdentifierGetter idGetter)
+ public String getIDForSerializing(IdentifyParams idParams)
+ {
+ return "bitVectorSplitting";
+ }
+
+ @Override
+ public BitVectorSplittingAtomicHighLevelStateHandlerParams getParamsForSerializing(IdentifyParams idParams)
{
BitVectorSplittingAtomicHighLevelStateHandlerParams params = new BitVectorSplittingAtomicHighLevelStateHandlerParams();
params.vectorPartTargets = new ArrayList<>(vectorPartTargets);
{
BitVectorSplittingAtomicHighLevelStateHandlerParams params = new BitVectorSplittingAtomicHighLevelStateHandlerParams();
params.vectorPartTargets = new ArrayList<>(vectorPartTargets);