mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-27 15:03:21 -04:00
fixed a bug in the counter, ovf is now high for a complete cycle.
This commit is contained in:
parent
8a0cabe4a5
commit
399d1b3ff4
@ -1218,7 +1218,7 @@ An dieser Adresse muss sich die ISR befinden.</string>
|
|||||||
<int>11</int>
|
<int>11</int>
|
||||||
</entry>
|
</entry>
|
||||||
</elementAttributes>
|
</elementAttributes>
|
||||||
<pos x="1020" y="660"/>
|
<pos x="980" y="660"/>
|
||||||
</visualElement>
|
</visualElement>
|
||||||
<visualElement>
|
<visualElement>
|
||||||
<elementName>Tunnel</elementName>
|
<elementName>Tunnel</elementName>
|
||||||
@ -1232,12 +1232,12 @@ An dieser Adresse muss sich die ISR befinden.</string>
|
|||||||
<string>C</string>
|
<string>C</string>
|
||||||
</entry>
|
</entry>
|
||||||
</elementAttributes>
|
</elementAttributes>
|
||||||
<pos x="940" y="660"/>
|
<pos x="960" y="660"/>
|
||||||
</visualElement>
|
</visualElement>
|
||||||
<visualElement>
|
<visualElement>
|
||||||
<elementName>Ground</elementName>
|
<elementName>Ground</elementName>
|
||||||
<elementAttributes/>
|
<elementAttributes/>
|
||||||
<pos x="1000" y="700"/>
|
<pos x="960" y="700"/>
|
||||||
</visualElement>
|
</visualElement>
|
||||||
<visualElement>
|
<visualElement>
|
||||||
<elementName>Tunnel</elementName>
|
<elementName>Tunnel</elementName>
|
||||||
@ -1249,11 +1249,6 @@ An dieser Adresse muss sich die ISR befinden.</string>
|
|||||||
</elementAttributes>
|
</elementAttributes>
|
||||||
<pos x="1280" y="80"/>
|
<pos x="1280" y="80"/>
|
||||||
</visualElement>
|
</visualElement>
|
||||||
<visualElement>
|
|
||||||
<elementName>Not</elementName>
|
|
||||||
<elementAttributes/>
|
|
||||||
<pos x="960" y="660"/>
|
|
||||||
</visualElement>
|
|
||||||
</visualElements>
|
</visualElements>
|
||||||
<wires>
|
<wires>
|
||||||
<wire>
|
<wire>
|
||||||
@ -1321,7 +1316,7 @@ An dieser Adresse muss sich die ISR befinden.</string>
|
|||||||
<p2 x="1340" y="640"/>
|
<p2 x="1340" y="640"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="1100" y="640"/>
|
<p1 x="1080" y="640"/>
|
||||||
<p2 x="1120" y="640"/>
|
<p2 x="1120" y="640"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
@ -1473,12 +1468,8 @@ An dieser Adresse muss sich die ISR befinden.</string>
|
|||||||
<p2 x="1340" y="660"/>
|
<p2 x="1340" y="660"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="940" y="660"/>
|
<p1 x="960" y="660"/>
|
||||||
<p2 x="960" y="660"/>
|
<p2 x="980" y="660"/>
|
||||||
</wire>
|
|
||||||
<wire>
|
|
||||||
<p1 x="1000" y="660"/>
|
|
||||||
<p2 x="1020" y="660"/>
|
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="1320" y="340"/>
|
<p1 x="1320" y="340"/>
|
||||||
@ -1573,12 +1564,12 @@ An dieser Adresse muss sich die ISR befinden.</string>
|
|||||||
<p2 x="1240" y="420"/>
|
<p2 x="1240" y="420"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="1080" y="680"/>
|
<p1 x="1040" y="680"/>
|
||||||
<p2 x="1100" y="680"/>
|
<p2 x="1080" y="680"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="1000" y="680"/>
|
<p1 x="960" y="680"/>
|
||||||
<p2 x="1020" y="680"/>
|
<p2 x="980" y="680"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="1320" y="680"/>
|
<p1 x="1320" y="680"/>
|
||||||
@ -1720,6 +1711,10 @@ An dieser Adresse muss sich die ISR befinden.</string>
|
|||||||
<p1 x="320" y="260"/>
|
<p1 x="320" y="260"/>
|
||||||
<p2 x="320" y="440"/>
|
<p2 x="320" y="440"/>
|
||||||
</wire>
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="960" y="680"/>
|
||||||
|
<p2 x="960" y="700"/>
|
||||||
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="580" y="460"/>
|
<p1 x="580" y="460"/>
|
||||||
<p2 x="580" y="560"/>
|
<p2 x="580" y="560"/>
|
||||||
@ -1760,10 +1755,6 @@ An dieser Adresse muss sich die ISR befinden.</string>
|
|||||||
<p1 x="1420" y="80"/>
|
<p1 x="1420" y="80"/>
|
||||||
<p2 x="1420" y="180"/>
|
<p2 x="1420" y="180"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
|
||||||
<p1 x="1100" y="640"/>
|
|
||||||
<p2 x="1100" y="680"/>
|
|
||||||
</wire>
|
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="400" y="680"/>
|
<p1 x="400" y="680"/>
|
||||||
<p2 x="400" y="700"/>
|
<p2 x="400" y="700"/>
|
||||||
@ -1864,10 +1855,6 @@ An dieser Adresse muss sich die ISR befinden.</string>
|
|||||||
<p1 x="420" y="680"/>
|
<p1 x="420" y="680"/>
|
||||||
<p2 x="420" y="700"/>
|
<p2 x="420" y="700"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
|
||||||
<p1 x="1000" y="680"/>
|
|
||||||
<p2 x="1000" y="700"/>
|
|
||||||
</wire>
|
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="360" y="680"/>
|
<p1 x="360" y="680"/>
|
||||||
<p2 x="360" y="700"/>
|
<p2 x="360" y="700"/>
|
||||||
@ -1896,6 +1883,10 @@ An dieser Adresse muss sich die ISR befinden.</string>
|
|||||||
<p1 x="500" y="680"/>
|
<p1 x="500" y="680"/>
|
||||||
<p2 x="500" y="700"/>
|
<p2 x="500" y="700"/>
|
||||||
</wire>
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="1080" y="640"/>
|
||||||
|
<p2 x="1080" y="680"/>
|
||||||
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="440" y="680"/>
|
<p1 x="440" y="680"/>
|
||||||
<p2 x="440" y="700"/>
|
<p2 x="440" y="700"/>
|
||||||
|
@ -32,6 +32,7 @@ public class Counter extends Node implements Element {
|
|||||||
private ObservableValue clrIn;
|
private ObservableValue clrIn;
|
||||||
private boolean lastClock;
|
private boolean lastClock;
|
||||||
private int counter;
|
private int counter;
|
||||||
|
private boolean ovfOut=false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance
|
* Creates a new instance
|
||||||
@ -51,6 +52,11 @@ public class Counter extends Node implements Element {
|
|||||||
boolean clock = clockIn.getBool();
|
boolean clock = clockIn.getBool();
|
||||||
if (clock && !lastClock) {
|
if (clock && !lastClock) {
|
||||||
counter++;
|
counter++;
|
||||||
|
if (counter == ovfValue) {
|
||||||
|
counter = 0;
|
||||||
|
ovfOut = true;
|
||||||
|
} else
|
||||||
|
ovfOut = false;
|
||||||
}
|
}
|
||||||
lastClock = clock;
|
lastClock = clock;
|
||||||
if (clrIn.getBool())
|
if (clrIn.getBool())
|
||||||
@ -59,12 +65,7 @@ public class Counter extends Node implements Element {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeOutputs() throws NodeException {
|
public void writeOutputs() throws NodeException {
|
||||||
if (counter == ovfValue) {
|
ovf.setBool(ovfOut);
|
||||||
counter = 0;
|
|
||||||
ovf.setValue(1);
|
|
||||||
} else
|
|
||||||
ovf.setValue(0);
|
|
||||||
|
|
||||||
out.setValue(counter);
|
out.setValue(counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public class CounterTest extends TestCase {
|
|||||||
}
|
}
|
||||||
sc.check(0, 0, 255, 0);
|
sc.check(0, 0, 255, 0);
|
||||||
sc.check(1, 0, 0, 1);
|
sc.check(1, 0, 0, 1);
|
||||||
sc.check(0, 0, 0, 0);
|
sc.check(0, 0, 0, 1);
|
||||||
sc.check(1, 0, 1, 0);
|
sc.check(1, 0, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user