fixed a bug in the counter, ovf is now high for a complete cycle.

This commit is contained in:
hneemann 2016-12-21 13:41:55 +01:00
parent 8a0cabe4a5
commit 399d1b3ff4
3 changed files with 26 additions and 34 deletions

View File

@ -1218,7 +1218,7 @@ An dieser Adresse muss sich die ISR befinden.</string>
<int>11</int>
</entry>
</elementAttributes>
<pos x="1020" y="660"/>
<pos x="980" y="660"/>
</visualElement>
<visualElement>
<elementName>Tunnel</elementName>
@ -1232,12 +1232,12 @@ An dieser Adresse muss sich die ISR befinden.</string>
<string>C</string>
</entry>
</elementAttributes>
<pos x="940" y="660"/>
<pos x="960" y="660"/>
</visualElement>
<visualElement>
<elementName>Ground</elementName>
<elementAttributes/>
<pos x="1000" y="700"/>
<pos x="960" y="700"/>
</visualElement>
<visualElement>
<elementName>Tunnel</elementName>
@ -1249,11 +1249,6 @@ An dieser Adresse muss sich die ISR befinden.</string>
</elementAttributes>
<pos x="1280" y="80"/>
</visualElement>
<visualElement>
<elementName>Not</elementName>
<elementAttributes/>
<pos x="960" y="660"/>
</visualElement>
</visualElements>
<wires>
<wire>
@ -1321,7 +1316,7 @@ An dieser Adresse muss sich die ISR befinden.</string>
<p2 x="1340" y="640"/>
</wire>
<wire>
<p1 x="1100" y="640"/>
<p1 x="1080" y="640"/>
<p2 x="1120" y="640"/>
</wire>
<wire>
@ -1473,12 +1468,8 @@ An dieser Adresse muss sich die ISR befinden.</string>
<p2 x="1340" y="660"/>
</wire>
<wire>
<p1 x="940" y="660"/>
<p2 x="960" y="660"/>
</wire>
<wire>
<p1 x="1000" y="660"/>
<p2 x="1020" y="660"/>
<p1 x="960" y="660"/>
<p2 x="980" y="660"/>
</wire>
<wire>
<p1 x="1320" y="340"/>
@ -1573,12 +1564,12 @@ An dieser Adresse muss sich die ISR befinden.</string>
<p2 x="1240" y="420"/>
</wire>
<wire>
<p1 x="1080" y="680"/>
<p2 x="1100" y="680"/>
<p1 x="1040" y="680"/>
<p2 x="1080" y="680"/>
</wire>
<wire>
<p1 x="1000" y="680"/>
<p2 x="1020" y="680"/>
<p1 x="960" y="680"/>
<p2 x="980" y="680"/>
</wire>
<wire>
<p1 x="1320" y="680"/>
@ -1720,6 +1711,10 @@ An dieser Adresse muss sich die ISR befinden.</string>
<p1 x="320" y="260"/>
<p2 x="320" y="440"/>
</wire>
<wire>
<p1 x="960" y="680"/>
<p2 x="960" y="700"/>
</wire>
<wire>
<p1 x="580" y="460"/>
<p2 x="580" y="560"/>
@ -1760,10 +1755,6 @@ An dieser Adresse muss sich die ISR befinden.</string>
<p1 x="1420" y="80"/>
<p2 x="1420" y="180"/>
</wire>
<wire>
<p1 x="1100" y="640"/>
<p2 x="1100" y="680"/>
</wire>
<wire>
<p1 x="400" y="680"/>
<p2 x="400" y="700"/>
@ -1864,10 +1855,6 @@ An dieser Adresse muss sich die ISR befinden.</string>
<p1 x="420" y="680"/>
<p2 x="420" y="700"/>
</wire>
<wire>
<p1 x="1000" y="680"/>
<p2 x="1000" y="700"/>
</wire>
<wire>
<p1 x="360" y="680"/>
<p2 x="360" y="700"/>
@ -1896,6 +1883,10 @@ An dieser Adresse muss sich die ISR befinden.</string>
<p1 x="500" y="680"/>
<p2 x="500" y="700"/>
</wire>
<wire>
<p1 x="1080" y="640"/>
<p2 x="1080" y="680"/>
</wire>
<wire>
<p1 x="440" y="680"/>
<p2 x="440" y="700"/>

View File

@ -32,6 +32,7 @@ public class Counter extends Node implements Element {
private ObservableValue clrIn;
private boolean lastClock;
private int counter;
private boolean ovfOut=false;
/**
* Creates a new instance
@ -51,6 +52,11 @@ public class Counter extends Node implements Element {
boolean clock = clockIn.getBool();
if (clock && !lastClock) {
counter++;
if (counter == ovfValue) {
counter = 0;
ovfOut = true;
} else
ovfOut = false;
}
lastClock = clock;
if (clrIn.getBool())
@ -59,12 +65,7 @@ public class Counter extends Node implements Element {
@Override
public void writeOutputs() throws NodeException {
if (counter == ovfValue) {
counter = 0;
ovf.setValue(1);
} else
ovf.setValue(0);
ovf.setBool(ovfOut);
out.setValue(counter);
}

View File

@ -40,7 +40,7 @@ public class CounterTest extends TestCase {
}
sc.check(0, 0, 255, 0);
sc.check(1, 0, 0, 1);
sc.check(0, 0, 0, 0);
sc.check(0, 0, 0, 1);
sc.check(1, 0, 1, 0);
}