projects
/
Mograsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merged SampleERCP into master
[Mograsim.git]
/
era.mi
/
src
/
era
/
mi
/
logic
/
components
/
ManualSwitch.java
diff --git
a/era.mi/src/era/mi/logic/components/ManualSwitch.java
b/era.mi/src/era/mi/logic/components/ManualSwitch.java
index
5e6a00c
..
0ad4a76
100644
(file)
--- a/
era.mi/src/era/mi/logic/components/ManualSwitch.java
+++ b/
era.mi/src/era/mi/logic/components/ManualSwitch.java
@@
-2,9
+2,8
@@
package era.mi.logic.components;
import java.util.List;
import java.util.List;
-import era.mi.logic.Bit;
-import era.mi.logic.wires.WireArray;
-import era.mi.logic.wires.WireArray.WireArrayInput;
+import era.mi.logic.types.Bit;
+import era.mi.logic.wires.Wire.WireEnd;
/**
* This class models a simple on/off (ONE/ZERO) switch for user interaction.
/**
* This class models a simple on/off (ONE/ZERO) switch for user interaction.
@@
-12,60
+11,60
@@
import era.mi.logic.wires.WireArray.WireArrayInput;
* @author Christian Femers
*
*/
* @author Christian Femers
*
*/
-public
final class ManualSwitch implements Component
+public
class ManualSwitch implements Component
{
{
- private WireArray output;
- private WireArrayInput outputI;
+ private WireEnd output;
private boolean isOn;
private boolean isOn;
-
- public ManualSwitch(Wire
Array output)
+
+ public ManualSwitch(Wire
End output)
{
{
- if
(output.length
!= 1)
+ if
(output.length()
!= 1)
throw new IllegalArgumentException("Switch output can be only a single wire");
this.output = output;
throw new IllegalArgumentException("Switch output can be only a single wire");
this.output = output;
- this.outputI = output.createInput();
}
}
-
+
public void switchOn()
{
setState(true);
}
public void switchOn()
{
setState(true);
}
-
+
public void switchOff()
{
setState(false);
}
public void switchOff()
{
setState(false);
}
-
+
public void toggle()
{
setState(!isOn);
}
public void toggle()
{
setState(!isOn);
}
-
+
public void setState(boolean isOn)
{
public void setState(boolean isOn)
{
- if(this.isOn == isOn)
+ if
(this.isOn == isOn)
return;
this.isOn = isOn;
return;
this.isOn = isOn;
- output
I
.feedSignals(getValue());
+ output.feedSignals(getValue());
}
}
-
+
public boolean isOn()
{
return isOn;
}
public boolean isOn()
{
return isOn;
}
-
+
public Bit getValue()
{
return isOn ? Bit.ONE : Bit.ZERO;
}
@Override
public Bit getValue()
{
return isOn ? Bit.ONE : Bit.ZERO;
}
@Override
- public List<WireArray> getAllInputs() {
+ public List<WireEnd> getAllInputs()
+ {
return List.of();
}
@Override
return List.of();
}
@Override
- public List<WireArray> getAllOutputs() {
+ public List<WireEnd> getAllOutputs()
+ {
return List.of(output);
}
return List.of(output);
}