Browse Source

Add print of reg outputs table with normal outputs as inputs

Baglio Tabifata 4 years ago
parent
commit
f7dce201bf
2 changed files with 31 additions and 8 deletions
  1. 2 2
      .vscode/launch.json
  2. 29 6
      src/net/hkzlab/dupal/boardio/DuPALAnalyzer.java

+ 2 - 2
.vscode/launch.json

@@ -10,8 +10,8 @@
             "request": "launch",
             "mainClass": "${file}",
             //"args": ["/dev/ttyUSB0", "16R6", "/tmp", "C0"]
-            "args": ["/dev/ttyUSB0", "16R4", "/tmp", "80"]
-            //"args": ["/dev/ttyUSB0", "16R6", "/tmp"]
+            //"args": ["/dev/ttyUSB0", "16R4", "/tmp", "80"]
+            "args": ["/dev/ttyUSB0", "16R6", "/tmp"]
         },
         {
             "type": "java",

+ 29 - 6
src/net/hkzlab/dupal/boardio/DuPALAnalyzer.java

@@ -138,10 +138,19 @@ public class DuPALAnalyzer {
         
         try {
             fout = new FileOutputStream(tblPath_regout);
-            printLogicTableREGOUTPUTS(fout, pspecs, additionalOUTs, IOasOUT_Mask, mStates);
+            printLogicTableREGOUTPUTS(fout, pspecs, additionalOUTs, IOasOUT_Mask, mStates, false);
             fout.close();
         } catch(IOException e) {
-            logger.error("Error printing out the registered outputs table.");
+            logger.error("Error printing out the registered outputs table (not including outputs).");
+            e.printStackTrace();
+        }
+
+        try {
+            fout = new FileOutputStream(tblPath_regout+"_outs");
+            printLogicTableREGOUTPUTS(fout, pspecs, additionalOUTs, IOasOUT_Mask, mStates, true);
+            fout.close();
+        } catch(IOException e) {
+            logger.error("Error printing out the registered outputs table (including outputs).");
             e.printStackTrace();
         }
     }
@@ -571,11 +580,11 @@ public class DuPALAnalyzer {
         }
     }
 
-    static private void printLogicTableREGOUTPUTS(OutputStream out, PALSpecs specs, int additionalOUTs, int ioOUTMask, MacroState[] mStates) throws IOException {
-        logger.info("Printing logic table for registered outputs.");
+    static private void printLogicTableREGOUTPUTS(OutputStream out, PALSpecs specs, int additionalOUTs, int ioOUTMask, MacroState[] mStates, boolean includeOUTs) throws IOException {
+        logger.info("Printing logic table for registered outputs "+(includeOUTs? "(including outputs)":"(not including outputs)")+" .");
 
         out.write(("# OUTPUT logic table\n").getBytes(StandardCharsets.US_ASCII));
-        int totInputs = specs.getNumINPins() + (specs.getNumIOPins() - additionalOUTs);
+        int totInputs = specs.getNumINPins() + (specs.getNumIOPins()  - (includeOUTs ? 0 : additionalOUTs));
         StringBuffer strBuf = new StringBuffer();
 
         out.write((".i " + (totInputs + specs.getNumROUTPins()) + "\n").getBytes(StandardCharsets.US_ASCII));
@@ -595,6 +604,12 @@ public class DuPALAnalyzer {
             for(int idx = 0; idx < 8; idx++) {
                 if(((ioINMask >> idx) & 0x01) > 0) strBuf.append(specs.getIO_PinNames()[idx] + " ");
             }
+            
+            if(includeOUTs) {
+                for(int idx = 0; idx < 8; idx++) {
+                    if(((ioOUTMask >> idx) & 0x01) > 0) strBuf.append(specs.getIO_PinNames()[idx] + " ");
+                }
+            }
         }
         strBuf.append('\n');
         out.write(strBuf.toString().getBytes(StandardCharsets.US_ASCII));
@@ -642,10 +657,18 @@ public class DuPALAnalyzer {
                     }
 
                     // Add the inputs as inputs
-                    for(int bit_idx = 0; bit_idx < totInputs; bit_idx++) {
+                    for(int bit_idx = 0; bit_idx < (totInputs - additionalOUTs); bit_idx++) {
                         strBuf.append(((sl_idx >> bit_idx) & 0x01) > 0 ? '1' : '0');
                     }
 
+                    if(includeOUTs) {
+                        for(int bit_idx = 0; bit_idx < additionalOUTs; bit_idx++) {
+                            if(mStates[ms_idx].substates[sl_idx].pin_status[bit_idx] == 0) strBuf.append('0');
+                            else if (mStates[ms_idx].substates[sl_idx].pin_status[bit_idx] > 0) strBuf.append('1');
+                            else strBuf.append('-');
+                        }
+                    }
+
                     strBuf.append(' ');
 
                     // Add the registered outputs of the new state as outputs