From d7bcbeee8e4be20cc539c9d5c6b0a6155a99e1de Mon Sep 17 00:00:00 2001 From: adam Date: Sat, 24 Feb 2007 20:21:15 +0100 Subject: [PATCH] fix bugs in software implementation of Choice ship --- ships/Choice.ship | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ships/Choice.ship b/ships/Choice.ship index 28fcd96..2aa8129 100644 --- a/ships/Choice.ship +++ b/ships/Choice.ship @@ -72,7 +72,7 @@ public void service() { if (port.startsWith("mux") && (!box_in1.dataReadyForShip() || !box_in2.dataReadyForShip())) return; if (port.startsWith("deMux") && (!box_in1.dataReadyForShip())) return; - long val = box_in.removeDataForShip(); + long val = selector.value; boolean condition = false; if (port.endsWith("IfZero")) condition = val==0; if (port.endsWith("IfNonZero")) condition = val!=0; @@ -84,14 +84,18 @@ public void service() { if (condition) { box_out1.addDataFromShip(box_in2.removeDataForShip()); box_out2.addDataFromShip(box_in1.removeDataForShip()); + selector = null; } else { box_out1.addDataFromShip(box_in1.removeDataForShip()); box_out2.addDataFromShip(box_in2.removeDataForShip()); + selector = null; } } else if (port.startsWith("mux")) { box_out1.addDataFromShip(condition ? box_in2.removeDataForShip() : box_in1.removeDataForShip()); + selector = null; } else if (port.startsWith("deMux")) { (condition ? box_out2 : box_out1).addDataFromShip(box_in1.removeDataForShip()); + selector = null; } } -- 1.7.10.4