Browse Source

Begin preparing a check on wrong IO mask in the OutState generation

Baglio Tabifata 5 năm trước cách đây
mục cha
commit
daf3193915

+ 13 - 2
src/main/java/info/hkzlab/dupal/analyzer/palanalisys/explorers/OSExplorer.java

@@ -81,7 +81,7 @@ public class OSExplorer {
     }
 
     private static OutState getOutStateForIdx(final DuPALCmdInterface dpci, final int idx, final int ioAsOutMask, final int maxLinks, final Map<Integer, OutState> statesMap)
-            throws DuPALBoardException {
+            throws DuPALBoardException, DuPALAnalyzerException {
         PALSpecs pSpecs = dpci.palSpecs;
         int ioAsOut_W = BitUtils.scatterBitField(BitUtils.consolidateBitField(ioAsOutMask, pSpecs.getMask_IO_R()), pSpecs.getMask_IO_W());
         int pinState_A, pinState_B;
@@ -93,7 +93,18 @@ public class OSExplorer {
         dpci.write(w_idx | pSpecs.getMask_O_W() | ioAsOut_W); // Try to force the outputs
         pinState_B = dpci.read();
 
-        // TODO: Check that the IOs that we consider as inputs are actually inputs, and are not remaining set to other values (which would mean they're actually outputs)
+        // Check that the IOs that we consider as inputs are actually inputs, and are not remaining set to other values (which would mean they're actually outputs)
+        int io_in_r = BitUtils.consolidateBitField(pinState_A, pSpecs.getMask_IO_R() & ~ioAsOutMask);
+        int io_in_w = BitUtils.consolidateBitField(w_idx, pSpecs.getMask_IO_W() & ~ioAsOut_W);
+        if(io_in_r != io_in_w) {
+                int newMask = BitUtils.scatterBitField(io_in_r, pSpecs.getMask_IO_R() ^ BitUtils.scatterBitField(io_in_w, pSpecs.getMask_IO_R()));
+                newMask |= ioAsOutMask;
+
+                logger.error("");
+
+               throw new DuPALAnalyzerException("");
+           }
+
 
         OutStatePins osp = extractOutPinStates(pSpecs, ioAsOutMask, pinState_A, pinState_B);
 

+ 17 - 0
src/test/java/info/hkzlab/dupal/analyzer/PathFinderTest.java

@@ -0,0 +1,17 @@
+package info.hkzlab.dupal.analyzer;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+import info.hkzlab.dupal.analyzer.exceptions.DuPALBoardException;
+
+public class PathFinderTest 
+{
+    @Test
+    public void PathFinderShouldProvideShortestPathToDestination() throws DuPALBoardException {
+        // TODO: Implement this
+
+        assertEquals("PathFinder should find the shortest path to an incomplete State", true, true);
+    }
+}