| 
					
				 | 
			
			
				@@ -14,18 +14,27 @@ public class EspressoFormatter { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private EspressoFormatter() {}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public static String formatEspressoTableHeader(PALSpecs pSpecs, int ioAsOutMask) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return formatEspressoTableHeader(pSpecs, ioAsOutMask, false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public static String formatEspressoTableHeader(PALSpecs pSpecs, int ioAsOutMask, boolean ignoreFeedbacks) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         StringBuffer strBuf = new StringBuffer(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         int ioAsOut_W = BitUtils.scatterBitField(BitUtils.consolidateBitField(ioAsOutMask, pSpecs.getMask_IO_R()), pSpecs.getMask_IO_W()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        int outCount = pSpecs.getPinCount_O() + BitUtils.countBits(ioAsOutMask); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int io_outCount = BitUtils.countBits(ioAsOutMask); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int io_inCount = BitUtils.countBits(pSpecs.getMask_IO_R() & ~ioAsOutMask); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int outCount = pSpecs.getPinCount_O() + io_outCount + pSpecs.getPinCount_RO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int outCount_oe = pSpecs.getPinCount_O() + io_outCount; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int inCount = pSpecs.getPinCount_IN() + io_inCount + (ignoreFeedbacks ? 0 : io_outCount) + pSpecs.getPinCount_RO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         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(".o " + ((outCount*2)+pSpecs.getPinCount_RO()) + "\n"); // Outputs, IO as outputs, Registered Outputs, then an out for all of those as OE 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        strBuf.append(".i " + inCount + "\n"); // Inputs, IO as inputs, IO as outputs (as feedbacks), registered outputs (as feedbacks) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        strBuf.append(".o " + (outCount_oe + outCount) + "\n"); // Outputs, IO as outputs, Registered Outputs, then an out for all of those as OE 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         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_IO_W() & ~ioAsOut_W) >> idx) & 0x01) > 0) strBuf.append(pSpecs.getLabels_IO()[idx] + " "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for(int idx = 0; idx < 32; idx++) if((((pSpecs.getMask_IO_W() & ioAsOut_W) >> idx) & 0x01) > 0) strBuf.append("f" + pSpecs.getLabels_IO()[idx] + " "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(!ignoreFeedbacks) for(int idx = 0; idx < 32; idx++) if((((pSpecs.getMask_IO_W() & ioAsOut_W) >> idx) & 0x01) > 0) strBuf.append("f" + pSpecs.getLabels_IO()[idx] + " "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for(int idx = 0; idx < 32; idx++) if(((pSpecs.getMask_RO_W() >> idx) & 0x01) > 0) strBuf.append("ps"+pSpecs.getLabels_RO()[idx] + " "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         strBuf.append("\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -38,14 +47,18 @@ public class EspressoFormatter { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         strBuf.append("\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         strBuf.append(".phase "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for(int idx = 0; idx < outCount+pSpecs.getPinCount_RO(); idx++) strBuf.append(pSpecs.isActiveLow() ? '0' : '1'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for(int idx = 0; idx < outCount; idx++) strBuf.append('1'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for(int idx = 0; idx < outCount; idx++) strBuf.append(pSpecs.isActiveLow() ? '0' : '1'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for(int idx = 0; idx < outCount_oe; idx++) strBuf.append('1'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         strBuf.append("\n\n"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return strBuf.toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public static String[] formatEspressoTable(PALSpecs pSpecs, int ioAsOutMask, OutState[] states) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return formatEspressoTable(pSpecs, ioAsOutMask, states, false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public static String[] formatEspressoTable(PALSpecs pSpecs, int ioAsOutMask, OutState[] states, boolean ignoreFeedbacks) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         int ioAsOut_W = BitUtils.scatterBitField(BitUtils.consolidateBitField(ioAsOutMask, pSpecs.getMask_IO_R()), pSpecs.getMask_IO_W()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         HashSet<String> tableRows = new HashSet<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -73,10 +86,14 @@ public class EspressoFormatter { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 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)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(!ignoreFeedbacks) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    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(' '); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -120,10 +137,14 @@ public class EspressoFormatter { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 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)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(!ignoreFeedbacks) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    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(' '); 
			 |