mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-28 23:45:17 -04:00
fixed an model analyser issue concerning non zero default values in multi bit flip-flops.
This commit is contained in:
parent
04de28b577
commit
faf4844b63
@ -158,11 +158,11 @@ public class ModelAnalyser {
|
|||||||
String label = ff.getLabel();
|
String label = ff.getLabel();
|
||||||
if (label.length() == 0)
|
if (label.length() == 0)
|
||||||
label = createUniqueName(ff);
|
label = createUniqueName(ff);
|
||||||
for (int i = 0; i < ff.getBits(); 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);
|
||||||
spinput.add(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()));
|
||||||
out.add(newff);
|
out.add(newff);
|
||||||
@ -182,6 +182,7 @@ public class ModelAnalyser {
|
|||||||
nqout.setValue(~value);
|
nqout.setValue(~value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
spq.fireHasChanged();
|
||||||
|
|
||||||
} catch (NodeException e) {
|
} catch (NodeException e) {
|
||||||
throw new AnalyseException(e);
|
throw new AnalyseException(e);
|
||||||
|
@ -47,6 +47,17 @@ public class ObservableValues extends ImmutableList<ObservableValue> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a value at top of list
|
||||||
|
*
|
||||||
|
* @param val the value to add
|
||||||
|
* @return the builder
|
||||||
|
*/
|
||||||
|
public Builder addAtTop(ObservableValue val) {
|
||||||
|
values.add(0, val);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the {@link ObservableValues} instance
|
* @return the {@link ObservableValues} instance
|
||||||
*/
|
*/
|
||||||
|
@ -103,16 +103,16 @@ public class ModelAnalyserTest extends TestCase {
|
|||||||
public void testAnalyzerMultiBit() throws Exception {
|
public void testAnalyzerMultiBit() throws Exception {
|
||||||
Model model = new ToBreakRunner("dig/analyze/multiBitCounter.dig", false).getModel();
|
Model model = new ToBreakRunner("dig/analyze/multiBitCounter.dig", false).getModel();
|
||||||
TruthTable tt = new ModelAnalyser(model).analyse();
|
TruthTable tt = new ModelAnalyser(model).analyse();
|
||||||
assertEquals("Q0n+1", tt.getResultName(0));
|
assertEquals("Q0n+1", tt.getResultName(1));
|
||||||
final BoolTable r0 = tt.getResult(0);
|
final BoolTable r0 = tt.getResult(1);
|
||||||
assertEquals(4, r0.size());
|
assertEquals(4, r0.size());
|
||||||
assertEquals(one, r0.get(0));
|
assertEquals(one, r0.get(0));
|
||||||
assertEquals(one, r0.get(1));
|
assertEquals(zero, r0.get(1));
|
||||||
assertEquals(zero, r0.get(2));
|
assertEquals(one, r0.get(2));
|
||||||
assertEquals(zero, r0.get(3));
|
assertEquals(zero, r0.get(3));
|
||||||
|
|
||||||
assertEquals("Q1n+1", tt.getResultName(1));
|
assertEquals("Q1n+1", tt.getResultName(0));
|
||||||
final BoolTable r1 = tt.getResult(1);
|
final BoolTable r1 = tt.getResult(0);
|
||||||
assertEquals(4, r1.size());
|
assertEquals(4, r1.size());
|
||||||
assertEquals(zero, r1.get(0));
|
assertEquals(zero, r1.get(0));
|
||||||
assertEquals(one, r1.get(1));
|
assertEquals(one, r1.get(1));
|
||||||
@ -124,8 +124,8 @@ public class ModelAnalyserTest extends TestCase {
|
|||||||
final BoolTable y0 = tt.getResult(2);
|
final BoolTable y0 = tt.getResult(2);
|
||||||
final BoolTable y1 = tt.getResult(3);
|
final BoolTable y1 = tt.getResult(3);
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
assertEquals((i & 2) > 0, y0.get(i).invert().bool());
|
assertEquals((i & 1) > 0, y0.get(i).invert().bool());
|
||||||
assertEquals((i & 1) > 0, y1.get(i).invert().bool());
|
assertEquals((i & 2) > 0, y1.get(i).invert().bool());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
<int>2</int>
|
<int>2</int>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<string>Default</string>
|
<string>InDefault</string>
|
||||||
<int>1</int>
|
<value v="1" z="false"/>
|
||||||
</entry>
|
</entry>
|
||||||
</elementAttributes>
|
</elementAttributes>
|
||||||
<pos x="280" y="220"/>
|
<pos x="280" y="220"/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user