8
8
import java .util .Collections ;
9
9
import java .util .List ;
10
10
11
+ import javax .swing .JOptionPane ;
12
+
11
13
import com .modsim .modules .ports .BidirPort ;
14
+ import com .modsim .Main ;
12
15
import com .modsim .modules .parts .Port ;
16
+ import com .modsim .modules .parts .SSText ;
13
17
import com .modsim .res .Colors ;
14
18
import com .modsim .simulator .PickableEntity ;
15
19
import com .modsim .util .BezierCurve ;
@@ -74,6 +78,14 @@ public SplitMerge() {
74
78
cs [8 ] = new BezierCurve (new Vec2 (B + b1 , 23 ), new Vec2 (d - b0 , -23 ), // B1-d0
75
79
new Vec2 (B + b1 , -15 ), new Vec2 (d - b0 , 15 ));
76
80
curves = Collections .unmodifiableList (Arrays .asList (cs ));
81
+
82
+ parts .add (new SSText (A -10 , 24 , "DCBA" , 7 , Colors .labelText ));
83
+ parts .add (new SSText (B -10 , 24 , "XXDC" , 7 , Colors .labelText ));
84
+ parts .add (new SSText (a +10 , -24 , "ABXX" , -7 , Colors .labelText ));
85
+ parts .add (new SSText (b +10 , -24 , "BXXX" , -7 , Colors .labelText ));
86
+ parts .add (new SSText (c +10 , -24 , "CDXX" , -7 , Colors .labelText ));
87
+ parts .add (new SSText (d +10 , -24 , "DXXX" , -7 , Colors .labelText ));
88
+
77
89
}
78
90
79
91
@ Override
@@ -133,12 +145,22 @@ public void propagate() {
133
145
134
146
// Switch based on propagation direction
135
147
if (portA0 .wasUpdated () || portA1 .wasUpdated ()) {
148
+ if (portA0 .isConnected () && portA1 .isConnected ())
149
+ {
150
+ JOptionPane .showMessageDialog (Main .ui .pane , "Error: There must only be one connection to that size of split/merge." );
151
+ Port port = portA0 .wasUpdated ()?portA0 :portA1 ;
152
+ synchronized (Main .sim )
153
+ {
154
+ Main .sim .removeLink (port .link );
155
+ }
156
+ return ;
157
+ }
136
158
b0_val .setBit (0 , a0_val .getBit (0 )); // A0-a0
137
159
b1_val .setBit (0 , a0_val .getBit (1 )); // A1-b1
138
160
b0_val .setBit (1 , a0_val .getBit (1 )); // A1-a1
139
161
140
162
// Resolution of 3-state logic for merges
141
- b3_val .setBit (0 , a0_val .getBit (3 )); // A3-d0
163
+ b3_val .setBit (0 , a0_val .getBit (3 )); // A3-d0
142
164
b3_val .resolveBit (0 , a1_val .getBit (1 )); // B1-d0
143
165
144
166
b2_val .setBit (0 , a0_val .getBit (2 )); // A2-c0
@@ -151,15 +173,15 @@ else if ( portB0.wasUpdated() || portB1.wasUpdated() ||
151
173
portB2 .wasUpdated () || portB3 .wasUpdated ()) {
152
174
a0_val .setBit (0 , b0_val .getBit (0 )); // a0-A0
153
175
a0_val .setBit (2 , b2_val .getBit (0 )); // c0-A2
154
- a0_val .setBit (3 , b2_val .getBit (1 )); // c1-A3
155
176
a1_val .setBit (0 , b2_val .getBit (0 )); // c0-B0
156
177
157
178
// Resolution of 3-state logic for merges
158
- a1_val .setBit (1 , b2_val .getBit (1 )); // c1-B1
159
- a1_val .resolveBit (1 , b3_val .getBit (0 )); // d0-B1
160
-
161
- a0_val .setBit (1 , b0_val .getBit (1 )); // a1-A1
162
- a0_val .resolveBit (1 , b1_val .getBit (0 )); // b0-A1
179
+ int val = b2_val .getBit (1 ) | b3_val .getBit (0 );
180
+ a1_val .setBit (1 , val );
181
+ a0_val .setBit (3 , val );
182
+
183
+ val = b0_val .getBit (1 ) | b1_val .getBit (0 );
184
+ a0_val .setBit (1 , val );
163
185
}
164
186
165
187
// Set the values
0 commit comments