mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-14 07:17:13 -04:00
Model analyser preserves the ff default values.
This commit is contained in:
parent
285404dea9
commit
48a1e1fb0a
@ -70,6 +70,8 @@ public class ModelAnalyser {
|
|||||||
|
|
||||||
outputs.add(i++, new Signal(label + "+1", ff.getDInput()));
|
outputs.add(i++, new Signal(label + "+1", ff.getDInput()));
|
||||||
|
|
||||||
|
modelAnalyzerInfo.setSequentialInitValue(label, ff.getDefault());
|
||||||
|
|
||||||
ObservableValue q = ff.getOutputs().get(0);
|
ObservableValue q = ff.getOutputs().get(0);
|
||||||
final Signal sig = new Signal(label, q);
|
final Signal sig = new Signal(label, q);
|
||||||
if (inputs.contains(sig))
|
if (inputs.contains(sig))
|
||||||
@ -229,10 +231,11 @@ public class ModelAnalyser {
|
|||||||
String label = ff.getLabel();
|
String label = ff.getLabel();
|
||||||
if (label.length() == 0)
|
if (label.length() == 0)
|
||||||
label = createOutputBasedName(ff);
|
label = createOutputBasedName(ff);
|
||||||
|
long def = ff.getDefault();
|
||||||
for (int i = ff.getBits() - 1; i >= 0; i--) {
|
for (int i = ff.getBits() - 1; i >= 0; i--) {
|
||||||
ObservableValue qn = new ObservableValue("", 1);
|
ObservableValue qn = new ObservableValue("", 1);
|
||||||
ObservableValue nqn = new ObservableValue("", 1);
|
ObservableValue nqn = new ObservableValue("", 1);
|
||||||
FlipflopD newff = new FlipflopD(label + i, qn, nqn);
|
FlipflopD newff = new FlipflopD(label + i, qn, nqn, (def & (1L<<i))!=0 ?1:0);
|
||||||
spinput.addAtTop(qn);
|
spinput.addAtTop(qn);
|
||||||
model.add(newff);
|
model.add(newff);
|
||||||
newff.setInputs(new ObservableValues(insp.getOutputs().get(i), getClock()));
|
newff.setInputs(new ObservableValues(insp.getOutputs().get(i), getClock()));
|
||||||
|
@ -40,6 +40,7 @@ public class FlipflopD extends Node implements Element {
|
|||||||
private ObservableValue qn;
|
private ObservableValue qn;
|
||||||
private boolean lastClock;
|
private boolean lastClock;
|
||||||
private long value;
|
private long value;
|
||||||
|
private long defaultValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance
|
* Creates a new instance
|
||||||
@ -58,9 +59,13 @@ public class FlipflopD extends Node implements Element {
|
|||||||
* @param label the label
|
* @param label the label
|
||||||
* @param q output
|
* @param q output
|
||||||
* @param qn inverted output
|
* @param qn inverted output
|
||||||
|
* @param def the default value
|
||||||
*/
|
*/
|
||||||
public FlipflopD(String label, ObservableValue q, ObservableValue qn) {
|
public FlipflopD(String label, ObservableValue q, ObservableValue qn, long def) {
|
||||||
this(new ElementAttributes().set(Keys.LABEL, label).setBits(q.getBits()), q, qn);
|
this(new ElementAttributes()
|
||||||
|
.set(Keys.LABEL, label)
|
||||||
|
.setBits(q.getBits())
|
||||||
|
.set(Keys.DEFAULT, def), q, qn);
|
||||||
if (qn.getBits() != q.getBits())
|
if (qn.getBits() != q.getBits())
|
||||||
throw new RuntimeException("wrong bit count given!");
|
throw new RuntimeException("wrong bit count given!");
|
||||||
}
|
}
|
||||||
@ -73,7 +78,8 @@ public class FlipflopD extends Node implements Element {
|
|||||||
isProbe = attributes.get(Keys.VALUE_IS_PROBE);
|
isProbe = attributes.get(Keys.VALUE_IS_PROBE);
|
||||||
label = attributes.getLabel();
|
label = attributes.getLabel();
|
||||||
|
|
||||||
value = attributes.get(Keys.DEFAULT);
|
defaultValue = attributes.get(Keys.DEFAULT);
|
||||||
|
value = defaultValue;
|
||||||
q.setValue(value);
|
q.setValue(value);
|
||||||
qn.setValue(~value);
|
qn.setValue(~value);
|
||||||
}
|
}
|
||||||
@ -145,4 +151,11 @@ public class FlipflopD extends Node implements Element {
|
|||||||
void setValue(long value) {
|
void setValue(long value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the default value
|
||||||
|
*/
|
||||||
|
public long getDefault() {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,10 @@
|
|||||||
<string>Inputs</string>
|
<string>Inputs</string>
|
||||||
<int>1</int>
|
<int>1</int>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<string>generic</string>
|
||||||
|
<string>this.Default=orig.Default;</string>
|
||||||
|
</entry>
|
||||||
</elementAttributes>
|
</elementAttributes>
|
||||||
<pos x="240" y="60"/>
|
<pos x="240" y="60"/>
|
||||||
</visualElement>
|
</visualElement>
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<circuit>
|
<circuit>
|
||||||
<version>1</version>
|
<version>1</version>
|
||||||
<attributes/>
|
<attributes>
|
||||||
|
<entry>
|
||||||
|
<string>isGeneric</string>
|
||||||
|
<boolean>true</boolean>
|
||||||
|
</entry>
|
||||||
|
</attributes>
|
||||||
<visualElements>
|
<visualElements>
|
||||||
<visualElement>
|
<visualElement>
|
||||||
<elementName>D_FF</elementName>
|
<elementName>D_FF</elementName>
|
||||||
@ -14,6 +19,10 @@
|
|||||||
<string>Inputs</string>
|
<string>Inputs</string>
|
||||||
<int>1</int>
|
<int>1</int>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<string>generic</string>
|
||||||
|
<string>this.Default=orig.Default;</string>
|
||||||
|
</entry>
|
||||||
</elementAttributes>
|
</elementAttributes>
|
||||||
<pos x="240" y="60"/>
|
<pos x="240" y="60"/>
|
||||||
</visualElement>
|
</visualElement>
|
||||||
|
@ -19,6 +19,10 @@
|
|||||||
<string>Inputs</string>
|
<string>Inputs</string>
|
||||||
<int>1</int>
|
<int>1</int>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<string>generic</string>
|
||||||
|
<string>this.Default=orig.Default;</string>
|
||||||
|
</entry>
|
||||||
</elementAttributes>
|
</elementAttributes>
|
||||||
<pos x="240" y="60"/>
|
<pos x="240" y="60"/>
|
||||||
</visualElement>
|
</visualElement>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user