1 package edu.berkeley.slipway.gui;
3 import com.atmel.fpslic.*;
4 import static com.atmel.fpslic.FpslicConstants.*;
8 public static final int BORDER_COLOR = 0x00BBBBBB;
9 public static final int BODY_COLOR = 0x00555555;
10 public static final int GLOBAL_WIRE_COLOR = 0x00008000;
11 public static final int LOCAL_WIRE_COLOR = 0x000FF000;
12 public static final int XGATE_COLOR = 0x00800000;
13 public static final int YGATE_COLOR = 0x00000080;
14 double MAIN_AREA = 0.75;
16 private final Fpslic.Cell fpslicCell;
17 private GuiGate xgate = new GuiGate();
18 private GuiGate ygate = new GuiGate();
20 public GuiCell(Fpslic.Cell fpslicCell) {
21 this.fpslicCell = fpslicCell;
25 * The graphics context argument must already be translated such
26 * that the space allocated to this cell is from (-1,-1) to (1,1)
28 public void draw(G g, R r, boolean selected) {
33 drawGlobalRouting(g, r);
34 if (fpslicCell.relevant()) {
35 xgate.disabled = !fpslicCell.xlut_relevant();
36 ygate.disabled = !fpslicCell.ylut_relevant();
41 private void drawGlobalRouting(G g, R r) {
42 g.color(GLOBAL_WIRE_COLOR);
43 for(int i=1; i<6; i++) {
44 g.line(r.minx() + 2*i, r.miny(),
45 r.minx() + 2*i, r.maxy());
46 g.line(r.minx(), r.miny() + 2*i,
47 r.maxx(), r.miny() + 2*i);
51 private void drawBody(G g, R r) {
52 if (xgate == null && ygate == null) return;
56 double TSQR = TSIZE / Math.sqrt(2.0);
61 R gateArea = body.plus(12+N, 12+N, -(4+N), -(4+N));
62 double factor = gateArea.width()/2;
63 R ygater = xgate.disabled || ygate.disabled ? gateArea : gateArea.plus(0, 0, -factor, -factor);
64 R xgater = xgate.disabled || ygate.disabled ? gateArea : gateArea.plus(factor, 0, 0, -factor);
66 R xring = gateArea.plus(-4, -4, 4, 4);
67 R yring = gateArea.plus(-6, -6, 6, 6);
68 P xip = r.corner(fpslicCell.xi());
69 P yip = r.corner(fpslicCell.yi());
71 xgate.rotation(fpslicCell.yi());
72 xgate.gateArea = gateArea;
74 if (xip != null) xgate.route(g, xip, xring, 0, XGATE_COLOR);
75 if (yip != null) xgate.route(g, yip, yring, 2, YGATE_COLOR);
77 ygate.rotation(fpslicCell.yi());
78 ygate.gateArea = gateArea;
80 if (xip != null) ygate.route(g, xip, xring, 2, XGATE_COLOR);
81 if (yip != null) ygate.route(g, yip, yring, 0, YGATE_COLOR);
83 int layer = fpslicCell.wi() - L0;
84 P p2 = r.corner(SW).translate(2*(layer+1), 2*(layer+1));
85 R r2 = r.plus(2*(layer+1), 2*(layer+1), -2*(layer+1), -2*(layer+1));
86 ygate.route(g, p2, r2, 1, LOCAL_WIRE_COLOR);
87 xgate.route(g, p2, r2, 1, LOCAL_WIRE_COLOR);
89 xgate.draw(g, XGATE_COLOR);
90 ygate.draw(g, YGATE_COLOR);