浏览代码

Begin filling in the formatter

Baglio Tabifata 5 年之前
父节点
当前提交
cfb6c3ab58

+ 2 - 1
src/main/java/info/hkzlab/dupal/analyzer/board/boardio/DuPALAnalyzer.java

@@ -114,8 +114,9 @@ public class DuPALAnalyzer {
                     logger.info("startAnalisys() -> Detected the following IO Type mask: " + String.format("%06X", ioAsOutMask));
                     logger.info("startAnalisys() -> Detected the following IO Type mask: " + String.format("%06X", ioAsOutMask));
                 }
                 }
                 
                 
-                header = EspressoFormatter.formatEspressoTableHeader(dpci.palSpecs, ioAsOutMask);
                 OutState[] osArray = OSExplorer.exploreOutStates(dpci, ioAsOutMask);
                 OutState[] osArray = OSExplorer.exploreOutStates(dpci, ioAsOutMask);
+                header = EspressoFormatter.formatEspressoTableHeader(dpci.palSpecs, ioAsOutMask);
+                table = EspressoFormatter.formatEspressoTable(dpci.palSpecs, ioAsOutMask, osArray);
 
 
                 logger.info("Got " + osArray.length + " output states!");
                 logger.info("Got " + osArray.length + " output states!");
             }
             }

+ 60 - 5
src/main/java/info/hkzlab/dupal/analyzer/palanalisys/formatter/EspressoFormatter.java

@@ -3,7 +3,9 @@ package info.hkzlab.dupal.analyzer.palanalisys.formatter;
 import java.util.ArrayList;
 import java.util.ArrayList;
 
 
 import info.hkzlab.dupal.analyzer.devices.PALSpecs;
 import info.hkzlab.dupal.analyzer.devices.PALSpecs;
+import info.hkzlab.dupal.analyzer.palanalisys.graph.OutLink;
 import info.hkzlab.dupal.analyzer.palanalisys.graph.OutState;
 import info.hkzlab.dupal.analyzer.palanalisys.graph.OutState;
+import info.hkzlab.dupal.analyzer.palanalisys.graph.RegLink;
 import info.hkzlab.dupal.analyzer.palanalisys.simple.SimpleState;
 import info.hkzlab.dupal.analyzer.palanalisys.simple.SimpleState;
 import info.hkzlab.dupal.analyzer.utilities.BitUtils;
 import info.hkzlab.dupal.analyzer.utilities.BitUtils;
 
 
@@ -13,11 +15,11 @@ public class EspressoFormatter {
     public static String formatEspressoTableHeader(PALSpecs pSpecs, int ioAsOutMask) {
     public static String formatEspressoTableHeader(PALSpecs pSpecs, int ioAsOutMask) {
         StringBuffer strBuf = new StringBuffer();
         StringBuffer strBuf = new StringBuffer();
         int ioAsOut_W = BitUtils.scatterBitField(BitUtils.consolidateBitField(ioAsOutMask, pSpecs.getMask_IO_R()), pSpecs.getMask_IO_W());
         int ioAsOut_W = BitUtils.scatterBitField(BitUtils.consolidateBitField(ioAsOutMask, pSpecs.getMask_IO_R()), pSpecs.getMask_IO_W());
-        int outCount = (pSpecs.getPinCount_O() + BitUtils.countBits(ioAsOutMask) + pSpecs.getPinCount_RO());
+        int outCount = pSpecs.getPinCount_O() + BitUtils.countBits(ioAsOutMask);
 
 
         strBuf.append("# " + pSpecs.toString() + "\n");
         strBuf.append("# " + pSpecs.toString() + "\n");
         strBuf.append(".i " + (pSpecs.getPinCount_IN() + pSpecs.getPinCount_IO() + pSpecs.getPinCount_RO()) + "\n"); // Inputs, IO as inputs, IO as outputs (as feedbacks), registered outputs (as feedbacks)
         strBuf.append(".i " + (pSpecs.getPinCount_IN() + pSpecs.getPinCount_IO() + pSpecs.getPinCount_RO()) + "\n"); // Inputs, IO as inputs, IO as outputs (as feedbacks), registered outputs (as feedbacks)
-        strBuf.append(".o " + outCount*2 + "\n"); // Outputs, IO as outputs, Registered Outputs, then an out for all of those as OE
+        strBuf.append(".o " + ((outCount*2)+pSpecs.getPinCount_RO()) + "\n"); // Outputs, IO as outputs, Registered Outputs, then an out for all of those as OE
         
         
         strBuf.append(".ilb ");
         strBuf.append(".ilb ");
         for(int idx = 0; idx < 32; idx++) if(((pSpecs.getMask_IN() >> idx) & 0x01) > 0) strBuf.append(pSpecs.getLabels_IN()[idx] + " ");
         for(int idx = 0; idx < 32; idx++) if(((pSpecs.getMask_IN() >> idx) & 0x01) > 0) strBuf.append(pSpecs.getLabels_IN()[idx] + " ");
@@ -32,7 +34,6 @@ public class EspressoFormatter {
         for(int idx = 0; idx < 32; idx++) if(((pSpecs.getMask_RO_W() >> idx) & 0x01) > 0) strBuf.append(pSpecs.getLabels_RO()[idx] + " ");
         for(int idx = 0; idx < 32; idx++) if(((pSpecs.getMask_RO_W() >> idx) & 0x01) > 0) strBuf.append(pSpecs.getLabels_RO()[idx] + " ");
         for(int idx = 0; idx < 32; idx++) if(((pSpecs.getMask_O_W() >> idx) & 0x01) > 0) strBuf.append(pSpecs.getLabels_O()[idx] + "oe ");
         for(int idx = 0; idx < 32; idx++) if(((pSpecs.getMask_O_W() >> idx) & 0x01) > 0) strBuf.append(pSpecs.getLabels_O()[idx] + "oe ");
         for(int idx = 0; idx < 32; idx++) if((((pSpecs.getMask_IO_W() & ioAsOut_W) >> idx) & 0x01) > 0) strBuf.append(pSpecs.getLabels_IO()[idx] + "oe ");
         for(int idx = 0; idx < 32; idx++) if((((pSpecs.getMask_IO_W() & ioAsOut_W) >> idx) & 0x01) > 0) strBuf.append(pSpecs.getLabels_IO()[idx] + "oe ");
-        for(int idx = 0; idx < 32; idx++) if(((pSpecs.getMask_RO_W() >> idx) & 0x01) > 0) strBuf.append(pSpecs.getLabels_RO()[idx] + "oe ");
         strBuf.append("\n");
         strBuf.append("\n");
        
        
         strBuf.append(".phase ");
         strBuf.append(".phase ");
@@ -43,11 +44,65 @@ public class EspressoFormatter {
         return strBuf.toString();
         return strBuf.toString();
     }
     }
    
    
-    public static String[] formatEspressoTable(PALSpecs pSpecs, OutState[] states) {
+    public static String[] formatEspressoTable(PALSpecs pSpecs, int ioAsOutMask, OutState[] states) {
+        int ioAsOut_W = BitUtils.scatterBitField(BitUtils.consolidateBitField(ioAsOutMask, pSpecs.getMask_IO_R()), pSpecs.getMask_IO_W());
         ArrayList<String> tableRows = new ArrayList<>();
         ArrayList<String> tableRows = new ArrayList<>();
 
 
-        for(OutState ss : states) {
+        int ins, io_ins, io_fio, io_fio_hiz, ro_ps, outs, outs_hiz, io_outs, io_outs_hiz, ro;
+        StringBuffer strBuf = new StringBuffer();
+        for(OutState os : states) {
+            OutLink[] outLinks = os.getOutLinks();
+            for(OutLink ol : outLinks) {
+                strBuf.delete(0, strBuf.length());
+
+                ins = BitUtils.consolidateBitField(ol.inputs, pSpecs.getMask_IN()); // inputs
+                io_ins = BitUtils.consolidateBitField(ol.inputs, pSpecs.getMask_IO_W() & ~ioAsOut_W); // IOs as inputs
+                io_fio = BitUtils.consolidateBitField(ol.src.pins.out, pSpecs.getMask_IO_R() & ioAsOutMask); // IO as outputs (feedbacks)
+                io_fio_hiz = BitUtils.consolidateBitField(ol.src.pins.hiz, pSpecs.getMask_IO_R() & ioAsOutMask); // IO as outputs (feedbacks) - hiz flags
+                ro_ps = BitUtils.consolidateBitField(ol.src.pins.out, pSpecs.getMask_RO_R()); // Old Registered Outputs
+
+                outs = BitUtils.consolidateBitField(ol.dest.pins.out, pSpecs.getMask_O_R()); // Outputs
+                outs_hiz = BitUtils.consolidateBitField(ol.dest.pins.hiz, pSpecs.getMask_O_R()); // Outputs - hiz flags
+                io_outs = BitUtils.consolidateBitField(ol.dest.pins.out, ioAsOutMask); // IO as outputs (feedbacks)
+                io_outs_hiz = BitUtils.consolidateBitField(ol.dest.pins.hiz, ioAsOutMask); // IO as outputs (feedbacks)
+                ro = 0x00; // We'll set these as "don't care" for this type of link, as they can only be changed via a registered link
+
+                // Print the inputs
+                int io_ins_count = BitUtils.countBits(pSpecs.getMask_IO_W() & ~ioAsOut_W);
+                int io_fio_count = BitUtils.countBits(pSpecs.getMask_IO_R() & ioAsOutMask);
+                for(int idx = 0; idx < pSpecs.getPinCount_IN(); idx++) strBuf.append((char)(((ins >> idx) & 0x01) + 0x30));
+                for(int idx = 0; idx < io_ins_count; idx++) strBuf.append((char)(((io_ins >> idx) & 0x01) + 0x30));
+                for(int idx = 0; idx < io_fio_count; idx++) {
+                    boolean fio_pin_hiz = ((io_fio_hiz >> idx) & 0x01) != 0;
+                    strBuf.append(fio_pin_hiz ? '-' : (char)(((io_fio >> idx) & 0x01) + 0x30));
+                }
+                for(int idx = 0; idx < pSpecs.getPinCount_RO(); idx++) strBuf.append((char)(((ro_ps >> idx) & 0x01) + 0x30));
 
 
+                strBuf.append(' ');
+                // Print the outputs
+                int io_outs_count = BitUtils.countBits(ioAsOutMask);
+                for(int idx = 0; idx < pSpecs.getPinCount_O(); idx++) {
+                    boolean out_pin_hiz = ((outs_hiz >> idx) & 0x01) != 0;
+                    strBuf.append(out_pin_hiz ? '-' : (char)(((outs >> idx) & 0x01) + 0x30));
+                }
+                for(int idx = 0; idx < io_outs_count; idx++) {
+                    boolean io_pin_hiz = ((io_outs_hiz >> idx) & 0x01) != 0;
+                    strBuf.append(io_pin_hiz ? '-' : (char)(((io_outs >> idx) & 0x01) + 0x30));
+                }
+                for(int idx = 0; idx < pSpecs.getPinCount_RO(); idx++) strBuf.append('-');
+                // Print the outputs (hiz flags)
+                for(int idx = 0; idx < pSpecs.getPinCount_O(); idx++) strBuf.append((char)(((outs_hiz >> idx) & 0x01) + 0x30));
+                for(int idx = 0; idx < io_outs_count; idx++) strBuf.append((char)(((io_outs_hiz >> idx) & 0x01) + 0x30));
+
+                strBuf.append('\n');
+                tableRows.add(strBuf.toString());
+            }
+
+            RegLink[] regLinks = os.getRegLinks();
+            for(RegLink rl : regLinks) {
+                strBuf.delete(0, strBuf.length());
+
+            }
         }
         }
 
 
         return tableRows.toArray(new String[tableRows.size()]);
         return tableRows.toArray(new String[tableRows.size()]);

+ 4 - 0
src/main/java/info/hkzlab/dupal/analyzer/palanalisys/graph/OutState.java

@@ -129,4 +129,8 @@ public class OutState implements GraphState {
     public OutLink[] getOutLinks() {
     public OutLink[] getOutLinks() {
         return outLinks.clone();
         return outLinks.clone();
     }
     }
+
+    public RegLink[] getRegLinks() {
+        return regLinks.clone();
+    }
 }
 }