Quellcode durchsuchen

Begin adding link between states

Baglio Tabifata vor 4 Jahren
Ursprung
Commit
36b57f00a9

+ 3 - 3
src/net/hkzlab/dupal/App.java

@@ -35,9 +35,9 @@ public class App {
         //System.out.println(ss.toString());
         //System.out.println(ss.hashCode());
 
-        MacroState ms = new MacroState("TEST", new boolean[] {true, true, false, true}, 3);
-        System.out.println(ms.toString());
-        System.out.println(ms.hashCode());
+        //MacroState ms = new MacroState("TEST", new boolean[] {true, true, false, true}, 3);
+        //System.out.println(ms.toString());
+        //System.out.println(ms.hashCode());
 
     }
 }

+ 7 - 4
src/net/hkzlab/palanalisys/MacroState.java

@@ -8,11 +8,14 @@ public class MacroState {
     public final String tag;
     public final boolean[] rpin_status;
     public final SubState[] substates;
+    public final StateLink[] links;
 
-    public MacroState(final String tag, final boolean[] rpin_status, int outPins) {
+    public MacroState(final String tag, final boolean[] rpin_status, int outPins, int inPins) {
         this.tag = tag;
         this.rpin_status = rpin_status;
 
+        links = new StateLink[2^inPins]; // Create space for the future links out of this
+
         int possible_bin_sstates = 2 ^ outPins;
         ArrayList<SubState> sStates = new ArrayList<>();
         byte[] pstatus;
@@ -24,7 +27,7 @@ public class MacroState {
                 pstatus[idx_bit] = (byte)((idx >> idx_bit) & 0x01);
             }
 
-            sStates.add(new SubState(tag, pstatus));
+            sStates.add(new SubState(tag, this, pstatus));
 
             // Generate the remaining combinations with hi-z
             for(int hiz_idx = 0; hiz_idx < possible_bin_sstates; hiz_idx++) {
@@ -33,7 +36,7 @@ public class MacroState {
                     oc_pstatus[idx_bit] = ((hiz_idx >> idx_bit) & 0x01) > 0 ? -1 : pstatus[idx_bit];
                 }  
 
-                sStates.add(new SubState(tag, pstatus));
+                sStates.add(new SubState(tag, this, pstatus));
             }
         }
 
@@ -58,6 +61,6 @@ public class MacroState {
             hash ^= ((rpin_status[idx] ? 1 : 0) << (idx % 32));
         }
 
-        return hash;
+        return hash ^ tag.hashCode();
     }
 }

+ 11 - 0
src/net/hkzlab/palanalisys/StateLink.java

@@ -0,0 +1,11 @@
+package net.hkzlab.palanalisys;
+
+public class StateLink {
+    public final boolean[] inputs;
+    public final SubState destSState;
+
+    public StateLink(final boolean[] inputs, final SubState destSState) {
+        this.inputs = inputs;
+        this.destSState = destSState;
+    }
+}

+ 4 - 2
src/net/hkzlab/palanalisys/SubState.java

@@ -6,10 +6,12 @@ public class SubState {
     public static final String SS_PRE_TAG = "SS_";
 
     public final String tag;
+    public final MacroState macroState;
     public final byte[] pin_status;
 
-    public SubState(final String tag, final byte[] pin_status) {
+    public SubState(final String tag, final MacroState macroState, final byte[] pin_status) {
         this.tag = tag;
+        this.macroState = macroState;
         this.pin_status = pin_status;
     } 
 
@@ -36,7 +38,7 @@ public class SubState {
             hash ^= (pin_status[idx] & 0xFF) << (8 * byte_idx);
         }
 
-        return hash;
+        return hash ^ tag.hashCode();
     }
 
     @Override