1 package com.atmel.fpslic;
5 import org.ibex.util.Log;
7 public abstract class Fpslic {
9 public static class Util {
10 public static int lutSwap(int x) {
23 /** issue a command to the device in Mode4 format; see Gosset's documentation for further details */
24 public int getWidth() { return 24; }
25 public int getHeight() { return 24; }
27 private static String hex2(int i) {
28 String ret = Integer.toString(i, 16);
29 while(ret.length() < 2) ret = "0"+ret;
30 return ret.toUpperCase();
33 public void readMode4(InputStream in) throws IOException {
35 BufferedReader br = new BufferedReader(new InputStreamReader(in));
36 for(String str = br.readLine(); str != null; str = br.readLine()) {
37 long foo = Long.parseLong(str, 16);
38 mode4((int)(foo >> 24), (int)(foo >> 16), (int)(foo >> 8), (int)(foo >> 0));
45 public abstract void flush();
47 public void writeMode4(Writer w) throws IOException {
48 for(int x=0; x<getWidth(); x++)
49 for(int y=0; y<getWidth(); y++)
50 for(int z=0; z<255; z++) {
51 if ((z > 0x09 && z < 0x10) ||
52 (z > 0x11 && z < 0x20) ||
53 (z > 0x29 && z < 0x30) ||
54 (z > 0x39 && z < 0x40) ||
55 (z > 0x41 && z < 0x60) ||
56 (z > 0x67 && z < 0x70) ||
57 (z > 0x77 && z < 0xD0) ||
63 w.write(hex2(mode4(z, y, x) & 0xff));
70 public abstract void mode4(int z, int y, int x, int d);
71 public abstract byte mode4(int z, int y, int x);
72 public byte mode4zyx(int zyx) { return mode4(zyx>>24, (zyx>>16)&0xff, (zyx>>8)&0xff); }
73 public void mode4zyx(int zyx, int d, int invmask) { mode4(zyx>>24, (zyx>>16)&0xff, (zyx>>8)&0xff, d, invmask); }
74 public void mode4(int z, int y, int x, int d, int invmask) {
75 int old = mode4(z, y, x);
80 public void mode4zyx(int zyx, int bit, boolean set) { mode4(zyx>>24, (zyx>>16)&0xff, (zyx>>8)&0xff, bit, set); }
81 public void mode4(int z, int y, int x, int bit, boolean set) {
82 int old = mode4(z, y, x);
84 old |= set ? (1 << bit) : 0;