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;
15 private static final int LOCAL_ROUTING_CHANNEL_WIDTH = 7;
17 private final Fpslic.Cell fpslicCell;
18 private GuiGate xgate = new GuiGate();
19 private GuiGate ygate = new GuiGate();
21 public GuiCell(Fpslic.Cell fpslicCell) {
22 this.fpslicCell = fpslicCell;
26 * The graphics context argument must already be translated such
27 * that the space allocated to this cell is from (-1,-1) to (1,1)
29 public void draw(G g, R r, boolean selected) {
34 drawGlobalRouting(g, r);
35 if (fpslicCell.relevant()) {
36 xgate.disabled = !fpslicCell.xlut_relevant();
37 ygate.disabled = !fpslicCell.ylut_relevant();
42 private void drawGlobalRouting(G g, R r) {
43 g.color(GLOBAL_WIRE_COLOR);
44 for(int i=1; i<6; i++) {
45 g.line(r.minx() + 2*i, r.miny(),
46 r.minx() + 2*i, r.maxy());
47 g.line(r.minx(), r.miny() + 2*i,
48 r.maxx(), r.miny() + 2*i);
52 private void drawBody(G g, R r) {
53 if (xgate.disabled && ygate.disabled) return;
58 r.plus(12+LOCAL_ROUTING_CHANNEL_WIDTH,
59 12+LOCAL_ROUTING_CHANNEL_WIDTH,
60 -(4+LOCAL_ROUTING_CHANNEL_WIDTH),
61 -(4+LOCAL_ROUTING_CHANNEL_WIDTH));
63 double factor = gateArea.width()/2;
64 xgate.r = xgate.disabled || ygate.disabled ? gateArea : gateArea.plus(factor, 0, 0, -factor);
65 ygate.r = xgate.disabled || ygate.disabled ? gateArea : gateArea.plus(0, 0, -factor, -factor);
67 P xip = r.corner(fpslicCell.xi());
68 P yip = r.corner(fpslicCell.yi());
69 R xring = gateArea.plus(-4, -4, 4, 4);
70 R yring = gateArea.plus(-6, -6, 6, 6);
71 xgate.rotation(fpslicCell.yi());
72 ygate.rotation(fpslicCell.yi());
73 if (xip != null) xgate.route(g, xip, xring, 0, XGATE_COLOR);
74 if (yip != null) xgate.route(g, yip, yring, 2, YGATE_COLOR);
75 if (xip != null) ygate.route(g, xip, xring, 2, XGATE_COLOR);
76 if (yip != null) ygate.route(g, yip, yring, 0, YGATE_COLOR);
82 private void drawWin(G g, R r) {
83 int layer = fpslicCell.wi() - L0;
84 P wip = r.corner(SW).translate(2*(layer+1), 2*(layer+1));
85 R wring = r.plus(2*(layer+1), 2*(layer+1), -2*(layer+1), -2*(layer+1));
86 ygate.route(g, wip, wring, 1, LOCAL_WIRE_COLOR);
87 xgate.route(g, wip, wring, 1, LOCAL_WIRE_COLOR);
90 private void drawGates(G g) {
91 xgate.draw(g, XGATE_COLOR);
92 ygate.draw(g, YGATE_COLOR);