88import java .util .Collections ;
99import java .util .List ;
1010
11+ import javax .swing .JOptionPane ;
12+
1113import com .modsim .modules .ports .BidirPort ;
14+ import com .modsim .Main ;
1215import com .modsim .modules .parts .Port ;
1316import com .modsim .res .Colors ;
1417import com .modsim .simulator .PickableEntity ;
@@ -133,12 +136,22 @@ public void propagate() {
133136
134137 // Switch based on propagation direction
135138 if (portA0 .wasUpdated () || portA1 .wasUpdated ()) {
139+ if (portA0 .isConnected () && portA1 .isConnected ())
140+ {
141+ JOptionPane .showMessageDialog (Main .ui .pane , "Error: There must only be one connection to that size of split/merge." );
142+ Port port = portA0 .wasUpdated ()?portA0 :portA1 ;
143+ synchronized (Main .sim )
144+ {
145+ Main .sim .removeLink (port .link );
146+ }
147+ return ;
148+ }
136149 b0_val .setBit (0 , a0_val .getBit (0 )); // A0-a0
137150 b1_val .setBit (0 , a0_val .getBit (1 )); // A1-b1
138151 b0_val .setBit (1 , a0_val .getBit (1 )); // A1-a1
139152
140153 // Resolution of 3-state logic for merges
141- b3_val .setBit (0 , a0_val .getBit (3 )); // A3-d0
154+ b3_val .setBit (0 , a0_val .getBit (3 )); // A3-d0
142155 b3_val .resolveBit (0 , a1_val .getBit (1 )); // B1-d0
143156
144157 b2_val .setBit (0 , a0_val .getBit (2 )); // A2-c0
@@ -151,15 +164,15 @@ else if ( portB0.wasUpdated() || portB1.wasUpdated() ||
151164 portB2 .wasUpdated () || portB3 .wasUpdated ()) {
152165 a0_val .setBit (0 , b0_val .getBit (0 )); // a0-A0
153166 a0_val .setBit (2 , b2_val .getBit (0 )); // c0-A2
154- a0_val .setBit (3 , b2_val .getBit (1 )); // c1-A3
155167 a1_val .setBit (0 , b2_val .getBit (0 )); // c0-B0
156168
157169 // 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
170+ int val = b2_val .getBit (1 ) | b3_val .getBit (0 );
171+ a1_val .setBit (1 , val );
172+ a0_val .setBit (3 , val );
173+
174+ val = b0_val .getBit (1 ) | b1_val .getBit (0 );
175+ a0_val .setBit (1 , val );
163176 }
164177
165178 // Set the values
0 commit comments