projects
/
Mograsim.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
bece767
)
GUIBitDisplay and GUIManualSwitch now support logicWidth != 1
author
Daniel Kirschten
<daniel.kirschten@gmx.de>
Sat, 10 Aug 2019 16:32:19 +0000
(18:32 +0200)
committer
Daniel Kirschten
<daniel.kirschten@gmx.de>
Sat, 10 Aug 2019 16:32:19 +0000
(18:32 +0200)
net.mograsim.logic.core/src/net/mograsim/logic/core/components/ManualSwitch.java
patch
|
blob
|
history
net.mograsim.logic.core/test/net/mograsim/logic/core/tests/GUITest.java
patch
|
blob
|
history
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/GUIComponentTestbench.java
patch
|
blob
|
history
net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/Am2901Testbench.java
patch
|
blob
|
history
net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/TestableAm2901Impl.java
patch
|
blob
|
history
net.mograsim.logic.model/src/net/mograsim/logic/model/examples/ClickableSubmodelComponentsTest.java
patch
|
blob
|
history
net.mograsim.logic.model/src/net/mograsim/logic/model/examples/RSLatchExample.java
patch
|
blob
|
history
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/GUIBitDisplay.java
patch
|
blob
|
history
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/GUIManualSwitch.java
patch
|
blob
|
history
net.mograsim.plugin.core/src/net/mograsim/plugin/SimulationPreview.java
patch
|
blob
|
history
net.mograsim.plugin.core/src/net/mograsim/plugin/views/LogicUIPart.java
patch
|
blob
|
history
diff --git
a/net.mograsim.logic.core/src/net/mograsim/logic/core/components/ManualSwitch.java
b/net.mograsim.logic.core/src/net/mograsim/logic/core/components/ManualSwitch.java
index
9ec98ed
..
26238fe
100644
(file)
--- a/
net.mograsim.logic.core/src/net/mograsim/logic/core/components/ManualSwitch.java
+++ b/
net.mograsim.logic.core/src/net/mograsim/logic/core/components/ManualSwitch.java
@@
-8,6
+8,7
@@
import net.mograsim.logic.core.LogicObservable;
import net.mograsim.logic.core.LogicObserver;
import net.mograsim.logic.core.timeline.Timeline;
import net.mograsim.logic.core.types.Bit;
import net.mograsim.logic.core.LogicObserver;
import net.mograsim.logic.core.timeline.Timeline;
import net.mograsim.logic.core.types.Bit;
+import net.mograsim.logic.core.types.BitVector;
import net.mograsim.logic.core.wires.Wire.ReadEnd;
import net.mograsim.logic.core.wires.Wire.ReadWriteEnd;
import net.mograsim.logic.core.wires.Wire.ReadEnd;
import net.mograsim.logic.core.wires.Wire.ReadWriteEnd;
@@
-26,49
+27,50
@@
public class ManualSwitch extends Component implements LogicObservable
{
super(timeline);
observers = new ArrayList<>();
{
super(timeline);
observers = new ArrayList<>();
- if (output.length() != 1)
- throw new IllegalArgumentException("Switch output can be only a single wire");
this.output = output;
}
this.output = output;
}
- public void switchOn()
+ public void switch
Full
On()
{
{
- setState(
true
);
+ setState(
BitVector.of(Bit.ONE, output.length())
);
}
}
- public void switchOff()
+ public void switch
Full
Off()
{
{
- setState(
false
);
+ setState(
BitVector.of(Bit.ZERO, output.length())
);
}
public void toggle()
{
}
public void toggle()
{
- setState(!isOn());
+ if (isFullOn())
+ switchFullOff();
+ else
+ switchFullOn();
}
}
- public void setState(
boolean isOn
)
+ public void setState(
Bit bit
)
{
{
- set
ToValueOf(isOn ? Bit.ONE : Bit.ZERO
);
+ set
State(BitVector.of(bit)
);
}
}
- public void set
ToValueOf(Bit bit
)
+ public void set
State(BitVector bits
)
{
{
- if (
!bit.isBinary
())
- throw new IllegalArgumentException("
Cannot set ManualSwitch to the value of Bit " + bit
);
- if (bit
== output.getInputValue(
))
+ if (
bits.length() != output.length
())
+ throw new IllegalArgumentException("
Incorrect bit vector length"
);
+ if (bit
s.equals(output.getInputValues()
))
return;
return;
- output.feedSignals(bit);
+ output.feedSignals(bit
s
);
notifyObservers();
}
notifyObservers();
}
- public boolean isOn()
+ public boolean is
Full
On()
{
{
- return
output.getInputValue() == Bit.ONE
;
+ return
BitVector.of(Bit.ONE, output.length()).equals(output.getInputValues())
;
}
}
- public Bit
getValue
()
+ public Bit
Vector getValues
()
{
{
- return output.getInputValue();
+ return output.getInputValue
s
();
}
@Override
}
@Override
diff --git
a/net.mograsim.logic.core/test/net/mograsim/logic/core/tests/GUITest.java
b/net.mograsim.logic.core/test/net/mograsim/logic/core/tests/GUITest.java
index
544b064
..
86eb115
100644
(file)
--- a/
net.mograsim.logic.core/test/net/mograsim/logic/core/tests/GUITest.java
+++ b/
net.mograsim.logic.core/test/net/mograsim/logic/core/tests/GUITest.java
@@
-66,7
+66,7
@@
public class GUITest extends JPanel
{
if (dim.getValue().contains(e.getPoint()))
{
{
if (dim.getValue().contains(e.getPoint()))
{
- dim.getKey().switchOff();
+ dim.getKey().switch
Full
Off();
repaint();
}
}
repaint();
}
}
@@
-79,7
+79,7
@@
public class GUITest extends JPanel
{
if (dim.getValue().contains(e.getPoint()))
{
{
if (dim.getValue().contains(e.getPoint()))
{
- dim.getKey().switchOn();
+ dim.getKey().switch
Full
On();
repaint();
}
}
repaint();
}
}
@@
-220,7
+220,7
@@
public class GUITest extends JPanel
switchMap.put(ms, r);
}
switchMap.put(ms, r);
}
- g.setColor(ms.isOn() ? Color.getHSBColor(.3f, .5f, 1f) : Color.WHITE);
+ g.setColor(ms.is
Full
On() ? Color.getHSBColor(.3f, .5f, 1f) : Color.WHITE);
g.fillRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
setBlack(g);
g.drawRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
g.fillRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
setBlack(g);
g.drawRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
diff --git
a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/GUIComponentTestbench.java
b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/GUIComponentTestbench.java
index
7f42c01
..
b745891
100644
(file)
--- a/
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/GUIComponentTestbench.java
+++ b/
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/GUIComponentTestbench.java
@@
-54,22
+54,16
@@
public class GUIComponentTestbench
for (int i = 0; i < inputPinNames.size(); i++)
{
String pinName = inputPinNames.get(i);
for (int i = 0; i < inputPinNames.size(); i++)
{
String pinName = inputPinNames.get(i);
- if (comp.getPin(pinName).logicWidth == 1)
- {
- GUIManualSwitch sw = new GUIManualSwitch(model);
- sw.moveTo(0, 20 * i);
- new GUIWire(model, comp.getPin(pinName), sw.getOutputPin());
- }
+ GUIManualSwitch sw = new GUIManualSwitch(model, comp.getPin(pinName).logicWidth);
+ sw.moveTo(0, 20 * i);
+ new GUIWire(model, comp.getPin(pinName), sw.getOutputPin());
}
for (int i = 0; i < outputPinNames.size(); i++)
{
String pinName = outputPinNames.get(i);
}
for (int i = 0; i < outputPinNames.size(); i++)
{
String pinName = outputPinNames.get(i);
- if (comp.getPin(pinName).logicWidth == 1)
- {
- GUIBitDisplay bd = new GUIBitDisplay(model);
- bd.moveTo(200, 20 * i);
- new GUIWire(model, comp.getPin(pinName), bd.getInputPin());
- }
+ GUIBitDisplay bd = new GUIBitDisplay(model, comp.getPin(pinName).logicWidth);
+ bd.moveTo(200, 20 * i);
+ new GUIWire(model, comp.getPin(pinName), bd.getInputPin());
}
}
}
\ No newline at end of file
}
}
}
\ No newline at end of file
diff --git
a/net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/Am2901Testbench.java
b/net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/Am2901Testbench.java
index
34154e6
..
731147c
100644
(file)
--- a/
net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/Am2901Testbench.java
+++ b/
net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/Am2901Testbench.java
@@
-31,7
+31,7
@@
public class Am2901Testbench
comp.moveTo(240, 0);
comp.moveTo(240, 0);
- GUIManualSwitch enable = new GUIManualSwitch(model);
+ GUIManualSwitch enable = new GUIManualSwitch(model
, 1
);
WireCrossPoint wcp0 = new WireCrossPoint(model, 1);
GUINotGate not1 = new GUINotGate(model, 1);
GUINotGate not2 = new GUINotGate(model, 1);
WireCrossPoint wcp0 = new WireCrossPoint(model, 1);
GUINotGate not1 = new GUINotGate(model, 1);
GUINotGate not2 = new GUINotGate(model, 1);
@@
-71,7
+71,7
@@
public class Am2901Testbench
WireCrossPoint wcp = new WireCrossPoint(model, 1);
GUIComponent d_ff = IndirectGUIComponentCreator.createComponent(model, "GUIdff");
WireCrossPoint wcp = new WireCrossPoint(model, 1);
GUIComponent d_ff = IndirectGUIComponentCreator.createComponent(model, "GUIdff");
- GUIManualSwitch sw = new GUIManualSwitch(model);
+ GUIManualSwitch sw = new GUIManualSwitch(model
, 1
);
tool.connect(last, wcp);
tool.connect(wcp, d_ff, "C");
tool.connect(last, wcp);
tool.connect(wcp, d_ff, "C");
@@
-91,7
+91,7
@@
public class Am2901Testbench
{
double x = 300 + 75 * (i % 2);
double y = 10 * i - 2.5;
{
double x = 300 + 75 * (i % 2);
double y = 10 * i - 2.5;
- GUIBitDisplay bd = new GUIBitDisplay(model);
+ GUIBitDisplay bd = new GUIBitDisplay(model
, 1
);
bd.moveTo(x, y);
tool.connect(bd.getInputPin(), comp, outputPinNames.get(i));
bd.moveTo(x, y);
tool.connect(bd.getInputPin(), comp, outputPinNames.get(i));
diff --git
a/net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/TestableAm2901Impl.java
b/net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/TestableAm2901Impl.java
index
7d44f8b
..
8985e53
100644
(file)
--- a/
net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/TestableAm2901Impl.java
+++ b/
net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/TestableAm2901Impl.java
@@
-117,7
+117,7
@@
public class TestableAm2901Impl implements TestableAm2901
HashMap<String, GUIManualSwitch> idSwitchMap = new HashMap<>();
for (String id : inputPinNames)
{
HashMap<String, GUIManualSwitch> idSwitchMap = new HashMap<>();
for (String id : inputPinNames)
{
- GUIManualSwitch sw = new GUIManualSwitch(viewModel);
+ GUIManualSwitch sw = new GUIManualSwitch(viewModel
, 1
);
new GUIWire(viewModel, am2901.getPin(id), sw.getOutputPin());
idSwitchMap.put(id, sw);
}
new GUIWire(viewModel, am2901.getPin(id), sw.getOutputPin());
idSwitchMap.put(id, sw);
}
@@
-125,7
+125,7
@@
public class TestableAm2901Impl implements TestableAm2901
HashMap<String, GUIBitDisplay> idDisplayMap = new HashMap<>();
for (String id : outputPinNames)
{
HashMap<String, GUIBitDisplay> idDisplayMap = new HashMap<>();
for (String id : outputPinNames)
{
- GUIBitDisplay bd = new GUIBitDisplay(viewModel);
+ GUIBitDisplay bd = new GUIBitDisplay(viewModel
, 1
);
// bd.addRedrawListener(() -> System.out.println(id + " " + bd.getBitDisplay().getDisplayedValue()));
new GUIWire(viewModel, am2901.getPin(id), bd.getInputPin());
idDisplayMap.put(id, bd);
// bd.addRedrawListener(() -> System.out.println(id + " " + bd.getBitDisplay().getDisplayedValue()));
new GUIWire(viewModel, am2901.getPin(id), bd.getInputPin());
idDisplayMap.put(id, bd);
@@
-168,53
+168,53
@@
public class TestableAm2901Impl implements TestableAm2901
public void setDest(Am2901_Dest dest)
{
var bits = of(dest.ordinal(), 3);
public void setDest(Am2901_Dest dest)
{
var bits = of(dest.ordinal(), 3);
- I8.set
ToValueOf
(bits.getLSBit(2));
- I7.set
ToValueOf
(bits.getLSBit(1));
- I6.set
ToValueOf
(bits.getLSBit(0));
+ I8.set
State
(bits.getLSBit(2));
+ I7.set
State
(bits.getLSBit(1));
+ I6.set
State
(bits.getLSBit(0));
}
@Override
public void setFunc(Am2901_Func func)
{
var bits = of(func.ordinal(), 3);
}
@Override
public void setFunc(Am2901_Func func)
{
var bits = of(func.ordinal(), 3);
- I5.set
ToValueOf
(bits.getLSBit(2));
- I4.set
ToValueOf
(bits.getLSBit(1));
- I3.set
ToValueOf
(bits.getLSBit(0));
+ I5.set
State
(bits.getLSBit(2));
+ I4.set
State
(bits.getLSBit(1));
+ I3.set
State
(bits.getLSBit(0));
}
@Override
public void setSrc(Am2901_Src src)
{
var bits = of(src.ordinal(), 3);
}
@Override
public void setSrc(Am2901_Src src)
{
var bits = of(src.ordinal(), 3);
- I2.set
ToValueOf
(bits.getLSBit(2));
- I1.set
ToValueOf
(bits.getLSBit(1));
- I0.set
ToValueOf
(bits.getLSBit(0));
+ I2.set
State
(bits.getLSBit(2));
+ I1.set
State
(bits.getLSBit(1));
+ I0.set
State
(bits.getLSBit(0));
}
@Override
public void setReg_A(String val_4_bit)
{
var bits = BitVector.parse(val_4_bit);
}
@Override
public void setReg_A(String val_4_bit)
{
var bits = BitVector.parse(val_4_bit);
- A3.set
ToValueOf
(bits.getLSBit(3));
- A2.set
ToValueOf
(bits.getLSBit(2));
- A1.set
ToValueOf
(bits.getLSBit(1));
- A0.set
ToValueOf
(bits.getLSBit(0));
+ A3.set
State
(bits.getLSBit(3));
+ A2.set
State
(bits.getLSBit(2));
+ A1.set
State
(bits.getLSBit(1));
+ A0.set
State
(bits.getLSBit(0));
}
@Override
public void setReg_B(String val_4_bit)
{
var bits = BitVector.parse(val_4_bit);
}
@Override
public void setReg_B(String val_4_bit)
{
var bits = BitVector.parse(val_4_bit);
- B3.set
ToValueOf
(bits.getLSBit(3));
- B2.set
ToValueOf
(bits.getLSBit(2));
- B1.set
ToValueOf
(bits.getLSBit(1));
- B0.set
ToValueOf
(bits.getLSBit(0));
+ B3.set
State
(bits.getLSBit(3));
+ B2.set
State
(bits.getLSBit(2));
+ B1.set
State
(bits.getLSBit(1));
+ B0.set
State
(bits.getLSBit(0));
}
@Override
public void setCarryIn(String val_1_bit)
{
}
@Override
public void setCarryIn(String val_1_bit)
{
- Cn.set
ToValueOf
(Bit.parse(val_1_bit));
+ Cn.set
State
(Bit.parse(val_1_bit));
}
@Override
}
@Override
@@
-227,40
+227,40
@@
public class TestableAm2901Impl implements TestableAm2901
public void setD(String val_4_bit)
{
var bits = BitVector.parse(val_4_bit);
public void setD(String val_4_bit)
{
var bits = BitVector.parse(val_4_bit);
- D4.set
ToValueOf
(bits.getLSBit(3));
- D3.set
ToValueOf
(bits.getLSBit(2));
- D2.set
ToValueOf
(bits.getLSBit(1));
- D1.set
ToValueOf
(bits.getLSBit(0));
+ D4.set
State
(bits.getLSBit(3));
+ D3.set
State
(bits.getLSBit(2));
+ D2.set
State
(bits.getLSBit(1));
+ D1.set
State
(bits.getLSBit(0));
}
@Override
public void setQ_0(String val_1_bit)
{
}
@Override
public void setQ_0(String val_1_bit)
{
- IQn.set
ToValueOf
(Bit.parse(val_1_bit));
+ IQn.set
State
(Bit.parse(val_1_bit));
}
@Override
public void setQ_3(String val_1_bit)
{
}
@Override
public void setQ_3(String val_1_bit)
{
- IQn_3.set
ToValueOf
(Bit.parse(val_1_bit));
+ IQn_3.set
State
(Bit.parse(val_1_bit));
}
@Override
public void setRAM_0(String val_1_bit)
{
}
@Override
public void setRAM_0(String val_1_bit)
{
- IRAMn.set
ToValueOf
(Bit.parse(val_1_bit));
+ IRAMn.set
State
(Bit.parse(val_1_bit));
}
@Override
public void setRAM_3(String val_1_bit)
{
}
@Override
public void setRAM_3(String val_1_bit)
{
- IRAMn_3.set
ToValueOf
(Bit.parse(val_1_bit));
+ IRAMn_3.set
State
(Bit.parse(val_1_bit));
}
@Override
public void clockOn(boolean isClockOn)
{
}
@Override
public void clockOn(boolean isClockOn)
{
- C.setState(isClockOn);
+ C.setState(isClockOn
? Bit.ONE : Bit.ZERO
);
}
@Override
}
@Override
diff --git
a/net.mograsim.logic.model/src/net/mograsim/logic/model/examples/ClickableSubmodelComponentsTest.java
b/net.mograsim.logic.model/src/net/mograsim/logic/model/examples/ClickableSubmodelComponentsTest.java
index
4ac98e3
..
4121200
100644
(file)
--- a/
net.mograsim.logic.model/src/net/mograsim/logic/model/examples/ClickableSubmodelComponentsTest.java
+++ b/
net.mograsim.logic.model/src/net/mograsim/logic/model/examples/ClickableSubmodelComponentsTest.java
@@
-23,8
+23,8
@@
public class ClickableSubmodelComponentsTest
setSubmodelScale(.4);
setOutputPins("O0");
setSubmodelScale(.4);
setOutputPins("O0");
- GUIManualSwitch sw = new GUIManualSwitch(submodelModifiable);
- GUIBitDisplay bd = new GUIBitDisplay(submodelModifiable);
+ GUIManualSwitch sw = new GUIManualSwitch(submodelModifiable
, 1
);
+ GUIBitDisplay bd = new GUIBitDisplay(submodelModifiable
, 1
);
sw.moveTo(10, 5);
bd.moveTo(50, 5);
sw.moveTo(10, 5);
bd.moveTo(50, 5);
diff --git
a/net.mograsim.logic.model/src/net/mograsim/logic/model/examples/RSLatchExample.java
b/net.mograsim.logic.model/src/net/mograsim/logic/model/examples/RSLatchExample.java
index
005b39a
..
58f7555
100644
(file)
--- a/
net.mograsim.logic.model/src/net/mograsim/logic/model/examples/RSLatchExample.java
+++ b/
net.mograsim.logic.model/src/net/mograsim/logic/model/examples/RSLatchExample.java
@@
-19,9
+19,9
@@
public class RSLatchExample
@SuppressWarnings("unused") // for GUIWires being created
public static void createRSLatchExample(ViewModelModifiable model)
{
@SuppressWarnings("unused") // for GUIWires being created
public static void createRSLatchExample(ViewModelModifiable model)
{
- GUIManualSwitch rIn = new GUIManualSwitch(model);
+ GUIManualSwitch rIn = new GUIManualSwitch(model
, 1
);
rIn.moveTo(100, 100);
rIn.moveTo(100, 100);
- GUIManualSwitch sIn = new GUIManualSwitch(model);
+ GUIManualSwitch sIn = new GUIManualSwitch(model
, 1
);
sIn.moveTo(100, 200);
GUIOrGate or1 = new GUIOrGate(model, 1);
sIn.moveTo(100, 200);
GUIOrGate or1 = new GUIOrGate(model, 1);
diff --git
a/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/GUIBitDisplay.java
b/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/GUIBitDisplay.java
index
c837fd4
..
b82d526
100644
(file)
--- a/
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/GUIBitDisplay.java
+++ b/
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/GUIBitDisplay.java
@@
-28,18
+28,18
@@
public class GUIBitDisplay extends GUIComponent
private final LogicObserver logicObs;
private BitDisplay bitDisplay;
private final LogicObserver logicObs;
private BitDisplay bitDisplay;
- public GUIBitDisplay(ViewModelModifiable model)
+ public GUIBitDisplay(ViewModelModifiable model
, int logicWidth
)
{
{
- this(model, null);
+ this(model,
logicWidth,
null);
}
}
- public GUIBitDisplay(ViewModelModifiable model, String name)
+ public GUIBitDisplay(ViewModelModifiable model,
int logicWidth,
String name)
{
super(model, name);
logicObs = (i) -> model.requestRedraw();
setSize(width, height);
{
super(model, name);
logicObs = (i) -> model.requestRedraw();
setSize(width, height);
- addPin(this.inputPin = new Pin(this, "",
1
, 0, height / 2));
+ addPin(this.inputPin = new Pin(this, "",
logicWidth
, 0, height / 2));
}
@Override
}
@Override
@@
-89,6
+89,7
@@
public class GUIBitDisplay extends GUIComponent
static
{
ViewLogicModelAdapter.addComponentAdapter(new BitDisplayAdapter());
static
{
ViewLogicModelAdapter.addComponentAdapter(new BitDisplayAdapter());
- IndirectGUIComponentCreator.setComponentSupplier(GUIBitDisplay.class.getCanonicalName(), (m, p, n) -> new GUIBitDisplay(m, n));
+ IndirectGUIComponentCreator.setComponentSupplier(GUIBitDisplay.class.getCanonicalName(),
+ (m, p, n) -> new GUIBitDisplay(m, p.getAsInt(), n));
}
}
\ No newline at end of file
}
}
\ No newline at end of file
diff --git
a/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/GUIManualSwitch.java
b/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/GUIManualSwitch.java
index
611d341
..
1d38516
100644
(file)
--- a/
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/GUIManualSwitch.java
+++ b/
net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/GUIManualSwitch.java
@@
-9,7
+9,7
@@
import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
import net.mograsim.logic.core.LogicObservable;
import net.mograsim.logic.core.LogicObserver;
import net.mograsim.logic.core.components.ManualSwitch;
import net.mograsim.logic.core.LogicObservable;
import net.mograsim.logic.core.LogicObserver;
import net.mograsim.logic.core.components.ManualSwitch;
-import net.mograsim.logic.core.types.Bit;
+import net.mograsim.logic.core.types.Bit
Vector
;
import net.mograsim.logic.core.types.BitVectorFormatter;
import net.mograsim.logic.core.wires.Wire.ReadEnd;
import net.mograsim.logic.model.model.ViewModelModifiable;
import net.mograsim.logic.core.types.BitVectorFormatter;
import net.mograsim.logic.core.wires.Wire.ReadEnd;
import net.mograsim.logic.model.model.ViewModelModifiable;
@@
-32,18
+32,18
@@
public class GUIManualSwitch extends GUIComponent
private ManualSwitch logicSwitch;
private ReadEnd end;
private ManualSwitch logicSwitch;
private ReadEnd end;
- public GUIManualSwitch(ViewModelModifiable model)
+ public GUIManualSwitch(ViewModelModifiable model
, int logicWidth
)
{
{
- this(model, null);
+ this(model,
logicWidth,
null);
}
}
- public GUIManualSwitch(ViewModelModifiable model, String name)
+ public GUIManualSwitch(ViewModelModifiable model,
int logicWidth,
String name)
{
super(model, name);
logicObs = (i) -> model.requestRedraw();
setSize(width, height);
{
super(model, name);
logicObs = (i) -> model.requestRedraw();
setSize(width, height);
- addPin(this.outputPin = new Pin(this, "",
1
, width, height / 2));
+ addPin(this.outputPin = new Pin(this, "",
logicWidth
, width, height / 2));
}
@Override
}
@Override
@@
-88,7
+88,7
@@
public class GUIManualSwitch extends GUIComponent
{
case "out":
if (logicSwitch != null)
{
case "out":
if (logicSwitch != null)
- return logicSwitch.getValue();
+ return logicSwitch.getValue
s
();
return null;
default:
return super.getHighLevelState(stateID);
return null;
default:
return super.getHighLevelState(stateID);
@@
-102,7
+102,7
@@
public class GUIManualSwitch extends GUIComponent
{
case "out":
if (logicSwitch != null)
{
case "out":
if (logicSwitch != null)
- logicSwitch.set
ToValueOf((Bit
) newState);
+ logicSwitch.set
State((BitVector
) newState);
break;
default:
super.setHighLevelState(stateID, newState);
break;
default:
super.setHighLevelState(stateID, newState);
@@
-143,6
+143,7
@@
public class GUIManualSwitch extends GUIComponent
static
{
ViewLogicModelAdapter.addComponentAdapter(new ManualSwitchAdapter());
static
{
ViewLogicModelAdapter.addComponentAdapter(new ManualSwitchAdapter());
- IndirectGUIComponentCreator.setComponentSupplier(GUIManualSwitch.class.getName(), (m, p, n) -> new GUIManualSwitch(m, n));
+ IndirectGUIComponentCreator.setComponentSupplier(GUIManualSwitch.class.getName(),
+ (m, p, n) -> new GUIManualSwitch(m, p.getAsInt(), n));
}
}
\ No newline at end of file
}
}
\ No newline at end of file
diff --git
a/net.mograsim.plugin.core/src/net/mograsim/plugin/SimulationPreview.java
b/net.mograsim.plugin.core/src/net/mograsim/plugin/SimulationPreview.java
index
03cdbb4
..
42fada8
100644
(file)
--- a/
net.mograsim.plugin.core/src/net/mograsim/plugin/SimulationPreview.java
+++ b/
net.mograsim.plugin.core/src/net/mograsim/plugin/SimulationPreview.java
@@
-41,9
+41,9
@@
public class SimulationPreview implements IThemePreview
params.gateProcessTime = 50;
params.wireTravelTime = 10;
params.gateProcessTime = 50;
params.wireTravelTime = 10;
- GUIManualSwitch rIn = new GUIManualSwitch(model);
+ GUIManualSwitch rIn = new GUIManualSwitch(model
, 1
);
rIn.moveTo(10, 10);
rIn.moveTo(10, 10);
- GUIManualSwitch sIn = new GUIManualSwitch(model);
+ GUIManualSwitch sIn = new GUIManualSwitch(model
, 1
);
sIn.moveTo(10, 70);
GUIOrGate or1 = new GUIOrGate(model, 1);
sIn.moveTo(10, 70);
GUIOrGate or1 = new GUIOrGate(model, 1);
diff --git
a/net.mograsim.plugin.core/src/net/mograsim/plugin/views/LogicUIPart.java
b/net.mograsim.plugin.core/src/net/mograsim/plugin/views/LogicUIPart.java
index
26d95cf
..
00b1956
100644
(file)
--- a/
net.mograsim.plugin.core/src/net/mograsim/plugin/views/LogicUIPart.java
+++ b/
net.mograsim.plugin.core/src/net/mograsim/plugin/views/LogicUIPart.java
@@
-100,13
+100,13
@@
public class LogicUIPart extends ViewPart
comp.moveTo(100, 0);
for (int i = 0; i < inputPinNames.size(); i++)
{
comp.moveTo(100, 0);
for (int i = 0; i < inputPinNames.size(); i++)
{
- GUIManualSwitch sw = new GUIManualSwitch(model);
+ GUIManualSwitch sw = new GUIManualSwitch(model
, 1
);
sw.moveTo(0, 20 * i);
new GUIWire(model, comp.getPin(inputPinNames.get(i)), sw.getOutputPin());
}
for (int i = 0; i < outputPinNames.size(); i++)
{
sw.moveTo(0, 20 * i);
new GUIWire(model, comp.getPin(inputPinNames.get(i)), sw.getOutputPin());
}
for (int i = 0; i < outputPinNames.size(); i++)
{
- GUIBitDisplay bd = new GUIBitDisplay(model);
+ GUIBitDisplay bd = new GUIBitDisplay(model
, 1
);
bd.moveTo(200, 20 * i);
new GUIWire(model, comp.getPin(outputPinNames.get(i)), bd.getInputPin());
}
bd.moveTo(200, 20 * i);
new GUIWire(model, comp.getPin(outputPinNames.get(i)), bd.getInputPin());
}