Browse Source

Create a class to handle high-level DuPAL commands

Fabio Battaglia 4 years ago
parent
commit
a58121c67a

+ 15 - 0
pom.xml

@@ -55,6 +55,21 @@
       <version>4.11</version>
       <scope>test</scope>
     </dependency>
+    
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-core</artifactId>
+      <version>3.5.10</version>
+     <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-junit-jupiter</artifactId>
+      <version>3.5.10</version>
+      <scope>test</scope>
+    </dependency>
+
   </dependencies>
 
   <build>

+ 51 - 0
src/main/java/info/hkzlab/dupal/analyzer/board/boardio/DuPALCmdInterface.java

@@ -0,0 +1,51 @@
+package info.hkzlab.dupal.analyzer.board.boardio;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import info.hkzlab.dupal.analyzer.board.dupalproto.DuPALProto;
+import info.hkzlab.dupal.analyzer.devices.PALSpecs;
+import info.hkzlab.dupal.analyzer.exceptions.DuPALBoardException;
+import info.hkzlab.dupal.analyzer.utilities.BitUtils;
+
+public class DuPALCmdInterface {
+    private static final Logger logger = LoggerFactory.getLogger(DuPALCmdInterface.class);
+
+    private final DuPALManager dpm;
+    public final PALSpecs palSpecs;
+
+    public DuPALCmdInterface(DuPALManager dpm, PALSpecs palSpecs) {
+        this.dpm = dpm;
+        this.palSpecs = palSpecs;
+    }
+
+    public int read() {
+        dpm.writeCommand(DuPALProto.buildREADCommand());
+        return DuPALProto.handleREADResponse(dpm.readResponse());
+    }
+
+    public int write(int data) throws DuPALBoardException {
+        int res;
+        dpm.writeCommand(DuPALProto.buildWRITECommand(data));
+        res = DuPALProto.handleWRITEResponse(dpm.readResponse());
+
+        if(res < 0) {
+            logger.error("write("+String.format("%08X", data)+") -> FAILED!");
+            throw new DuPALBoardException("write("+String.format("%08X", data)+") command failed!");
+        }
+
+        return res;
+    }
+
+    public int build_WData(int in, int io, boolean clk, boolean oe) {
+        int data = 0;
+
+        data |= BitUtils.scatterBitField(in, palSpecs.getMask_IN());
+        data |= BitUtils.scatterBitField(io, palSpecs.getMask_IO_W());
+
+        if(clk) data |= BitUtils.scatterBitField(1, palSpecs.getMask_CLK());
+        if(oe) data |= BitUtils.scatterBitField(1, palSpecs.getMask_OE());
+
+        return data;
+    }
+}

+ 6 - 0
src/main/java/info/hkzlab/dupal/analyzer/palanalisys/explorers/OSExplorer.java

@@ -1,5 +1,11 @@
 package info.hkzlab.dupal.analyzer.palanalisys.explorers;
 
+import info.hkzlab.dupal.analyzer.devices.PALSpecs;
+
 public class OSExplorer {
     private OSExplorer() {};
+
+    private void exploreOutStates() {
+        
+    }
 }