mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-13 14:56:29 -04:00
minor changes
This commit is contained in:
parent
da0646b53f
commit
289b15bac9
@ -22,8 +22,9 @@ public class ObservableValue extends Value {
|
||||
observers = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void addObserver(Observer observer) {
|
||||
public ObservableValue addObserver(Observer observer) {
|
||||
observers.add(observer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void removeObserver(Observer observer) {
|
||||
|
@ -53,12 +53,9 @@ public class Add extends Node implements Part {
|
||||
|
||||
@Override
|
||||
public void setInputs(ObservableValue... inputs) throws BitsException {
|
||||
a = inputs[0];
|
||||
a.addObserver(this);
|
||||
b = inputs[1];
|
||||
b.addObserver(this);
|
||||
c_in = inputs[2];
|
||||
c_in.addObserver(this);
|
||||
a = inputs[0].addObserver(this);
|
||||
b = inputs[1].addObserver(this);
|
||||
c_in = inputs[2].addObserver(this);
|
||||
|
||||
if (a.getBits() != bits)
|
||||
throw new BitsException("wrongBitCount", a);
|
||||
|
@ -39,10 +39,8 @@ public class Mul extends Node implements Part {
|
||||
|
||||
@Override
|
||||
public void setInputs(ObservableValue... inputs) throws NodeException {
|
||||
a = inputs[0];
|
||||
a.addObserver(this);
|
||||
b = inputs[1];
|
||||
b.addObserver(this);
|
||||
a = inputs[0].addObserver(this);
|
||||
b = inputs[1].addObserver(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -38,8 +38,7 @@ public class Not extends Node implements Part {
|
||||
|
||||
@Override
|
||||
public void setInputs(ObservableValue... inputs) throws NodeException {
|
||||
input = inputs[0];
|
||||
input.addObserver(this);
|
||||
input = inputs[0].addObserver(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -38,10 +38,8 @@ public class XOr extends Node implements Part {
|
||||
|
||||
@Override
|
||||
public void setInputs(ObservableValue... inputs) throws BitsException {
|
||||
a = inputs[0];
|
||||
a.addObserver(this);
|
||||
b = inputs[1];
|
||||
b.addObserver(this);
|
||||
a = inputs[0].addObserver(this);
|
||||
b = inputs[1].addObserver(this);
|
||||
|
||||
if (a.getBits() != bits)
|
||||
throw new BitsException("wrongBitCount", a);
|
||||
|
@ -45,10 +45,8 @@ public class D_FF extends Node implements Part {
|
||||
|
||||
@Override
|
||||
public void setInputs(ObservableValue... inputs) throws BitsException {
|
||||
dVal = inputs[0];
|
||||
dVal.addObserver(this);
|
||||
clockVal = inputs[1];
|
||||
clockVal.addObserver(this);
|
||||
dVal = inputs[0].addObserver(this);
|
||||
clockVal = inputs[1].addObserver(this);
|
||||
|
||||
if (dVal.getBits() != bits)
|
||||
throw new BitsException("wrongBitCount", dVal);
|
||||
|
@ -49,12 +49,9 @@ public class JK_FF extends Node implements Part {
|
||||
|
||||
@Override
|
||||
public void setInputs(ObservableValue... inputs) throws BitsException {
|
||||
jVal = inputs[0];
|
||||
jVal.addObserver(this);
|
||||
clockVal = inputs[1];
|
||||
clockVal.addObserver(this);
|
||||
kVal = inputs[2];
|
||||
kVal.addObserver(this);
|
||||
jVal = inputs[0].addObserver(this);
|
||||
clockVal = inputs[1].addObserver(this);
|
||||
kVal = inputs[2].addObserver(this);
|
||||
|
||||
if (jVal.getBits() != 1)
|
||||
throw new BitsException("wrongBitCount", jVal);
|
||||
|
@ -48,12 +48,9 @@ public class RS_FF extends Node implements Part {
|
||||
|
||||
@Override
|
||||
public void setInputs(ObservableValue... inputs) throws BitsException {
|
||||
jVal = inputs[0];
|
||||
jVal.addObserver(this);
|
||||
clockVal = inputs[1];
|
||||
clockVal.addObserver(this);
|
||||
kVal = inputs[2];
|
||||
kVal.addObserver(this);
|
||||
jVal = inputs[0].addObserver(this);
|
||||
clockVal = inputs[1].addObserver(this);
|
||||
kVal = inputs[2].addObserver(this);
|
||||
|
||||
if (jVal.getBits() != 1)
|
||||
throw new BitsException("wrongBitCount", jVal);
|
||||
|
@ -42,8 +42,7 @@ public class T_FF extends Node implements Part {
|
||||
|
||||
@Override
|
||||
public void setInputs(ObservableValue... inputs) throws BitsException {
|
||||
clockVal = inputs[0];
|
||||
clockVal.addObserver(this);
|
||||
clockVal = inputs[0].addObserver(this);
|
||||
|
||||
if (clockVal.getBits() != 1)
|
||||
throw new BitsException("carryIsABit", clockVal);
|
||||
|
@ -42,8 +42,7 @@ public class Delay extends Node implements Part {
|
||||
|
||||
@Override
|
||||
public void setInputs(ObservableValue... inputs) throws NodeException {
|
||||
input = inputs[0];
|
||||
input.addObserver(this);
|
||||
input = inputs[0].addObserver(this);
|
||||
|
||||
if (input.getBits() != bits)
|
||||
throw new BitsException("wrongBitCountInDelay", input, output);
|
||||
|
Loading…
x
Reference in New Issue
Block a user