1
0
Эх сурвалжийг харах

Add pin names to logic table

Baglio Tabifata 4 жил өмнө
parent
commit
ab4622491c

+ 19 - 0
src/net/hkzlab/devices/PAL16R4Specs.java

@@ -1,6 +1,10 @@
 package net.hkzlab.devices;
 
 public class PAL16R4Specs implements PALSpecs {
+    private static final String[] ROUT_PIN_NAMES = { "ro14", "ro15", "ro16", "ro17" };
+    private static final String[] IN_PIN_NAMES = {"i2", "i3", "i4", "i5", "i6", "i7", "i8", "i9"};
+    private static final String[] IO_PIN_NAMES = {"io18", null, null, null, null, "io13", "io19", "io12"};
+
 
     @Override
     public int getNumINPins() {
@@ -61,4 +65,19 @@ public class PAL16R4Specs implements PALSpecs {
     public int getROUT_READMaskShift() {
         return 1;
     }
+
+    @Override
+    public String[] getROUT_PinNames() {
+        return ROUT_PIN_NAMES;
+    }
+
+    @Override
+    public String[] getIN_PinNames() {
+        return IN_PIN_NAMES;
+    }
+
+    @Override
+    public String[] getIO_PinNames() {
+        return IO_PIN_NAMES;
+    }
 }

+ 18 - 0
src/net/hkzlab/devices/PAL16R6Specs.java

@@ -1,6 +1,9 @@
 package net.hkzlab.devices;
 
 public class PAL16R6Specs implements PALSpecs {
+    private static final String[] ROUT_PIN_NAMES = { "ro13", "ro14", "ro15", "ro16", "ro17", "ro18" };
+    private static final String[] IN_PIN_NAMES = { "i2", "i3", "i4", "i5", "i6", "i7", "i8", "i9" };
+    private static final String[] IO_PIN_NAMES = { null, null, null, null, null, null, "io19", "io12" };
 
     @Override
     public int getNumINPins() {
@@ -61,4 +64,19 @@ public class PAL16R6Specs implements PALSpecs {
     public int getROUT_READMaskShift() {
         return 0;
     }
+
+    @Override
+    public String[] getROUT_PinNames() {
+        return ROUT_PIN_NAMES;
+    }
+
+    @Override
+    public String[] getIN_PinNames() {
+        return IN_PIN_NAMES;
+    }
+
+    @Override
+    public String[] getIO_PinNames() {
+        return IO_PIN_NAMES;
+    }
 }

+ 4 - 0
src/net/hkzlab/devices/PALSpecs.java

@@ -16,4 +16,8 @@ public interface PALSpecs {
     public int getROUT_WRITEMask();
 
     public int getROUT_READMaskShift();
+
+    public String[] getROUT_PinNames();
+    public String[] getIN_PinNames();
+    public String[] getIO_PinNames();
 }

+ 18 - 9
src/net/hkzlab/dupal/boardio/DuPALAnalyzer.java

@@ -102,7 +102,7 @@ public class DuPALAnalyzer {
         if(serObjPath != null) saveStatus(serObjPath);
 
         //try { printStateStructure(System.out, pspecs, mStates); } catch(IOException e){};
-        try { printLogicTableOUTPUTS(System.out, pspecs, additionalOUTs, mStates); } catch(IOException e){};
+        try { printLogicTableOUTPUTS(System.out, pspecs, additionalOUTs, IOasOUT_Mask, mStates); } catch(IOException e){};
     }
 
     private int guessIOs() {
@@ -525,7 +525,7 @@ public class DuPALAnalyzer {
      * - Outputs (non-registered) as binary outputs. In case they're hi-z, we'll set the state as ignore ('-')
      * - OE status for each output
      */
-    static private void printLogicTableOUTPUTS(OutputStream out, PALSpecs specs, int additionalOUTs, MacroState[] mStates) throws IOException {
+    static private void printLogicTableOUTPUTS(OutputStream out, PALSpecs specs, int additionalOUTs, int ioOUTMask, MacroState[] mStates) throws IOException {
         out.write(("OUTPUT logic table\n").getBytes(StandardCharsets.US_ASCII));
         int totInputs = specs.getNumINPins() + (specs.getNumIOPins() - additionalOUTs);
         StringBuffer strBuf = new StringBuffer();
@@ -535,19 +535,28 @@ public class DuPALAnalyzer {
         
         strBuf.delete(0, strBuf.length()); // TODO: map the label onto the actual pins instead of a simple incremental number
         strBuf.append(".ilb ");
-        for(int idx = 0; idx < (totInputs + specs.getNumROUTPins()); idx++) {
-            strBuf.append("i"+idx+" ");
+        for(int idx = 0; idx < specs.getNumROUTPins(); idx++) {
+            strBuf.append(specs.getROUT_PinNames()[idx]+" ");
+        }
+        for(int idx = 0; idx < specs.getNumINPins(); idx++) {
+            strBuf.append(specs.getIN_PinNames()[idx]+" ");
+        }
+        if(totInputs > specs.getNumINPins()) {
+            int ioINMask = specs.getIO_READMask() & ~ioOUTMask;
+            for(int idx = 0; idx < 8; idx++) {
+                if(((ioINMask >> idx) & 0x01) > 0) strBuf.append(specs.getIO_PinNames()[idx] + " ");
+            }
         }
         strBuf.append('\n');
         out.write(strBuf.toString().getBytes(StandardCharsets.US_ASCII));
 
         strBuf.delete(0, strBuf.length());
         strBuf.append(".ob ");
-        for(int idx = 0; idx < additionalOUTs; idx++) {
-            strBuf.append("o"+idx+" ");
+        for(int idx = 0; idx < 8; idx++) {
+            if(((ioOUTMask >> idx) & 0x01) > 0) strBuf.append(specs.getIO_PinNames()[idx] + " ");
         }
-        for(int idx = 0; idx < additionalOUTs; idx++) {
-            strBuf.append("oe"+idx+" ");
+        for(int idx = 0; idx < 8; idx++) {
+            if(((ioOUTMask >> idx) & 0x01) > 0) strBuf.append(specs.getIO_PinNames()[idx] + "oe ");
         }
         strBuf.append("\n\n");
 
@@ -568,7 +577,7 @@ public class DuPALAnalyzer {
 
                 // Add the inputs as inputs
                 for(int bit_idx = 0; bit_idx < totInputs; bit_idx++) {
-                    strBuf.append(((ss_idx >> ((totInputs - 1) - bit_idx)) & 0x01) > 0 ? '1' : '0');
+                    strBuf.append(((ss_idx >> bit_idx) & 0x01) > 0 ? '1' : '0');
                 }
 
                 strBuf.append(' ');