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 DRIVEN_WIRE_COLOR = 0x00ff0000;
12 public static final int LOCAL_WIRE_COLOR = 0x000FF000;
13 public static final int XGATE_COLOR = 0x00800000;
14 public static final int YGATE_COLOR = 0x00000080;
16 private static final int LOCAL_ROUTING_CHANNEL_WIDTH = 7;
18 public boolean val = false;
19 public final Fpslic.Cell fpslicCell;
20 private GuiGate xgate = new GuiGate(this);
21 private GuiGate ygate = new GuiGate(this);
25 public GuiCell(Fpslic.Cell fpslicCell) {
26 this.fpslicCell = fpslicCell;
30 * The graphics context argument must already be translated such
31 * that the space allocated to this cell is from (-1,-1) to (1,1)
33 public void draw(G g, R r, boolean selected) {
38 drawGlobalRouting(g, r);
39 if (fpslicCell.relevant()) {
40 xgate.disabled = !fpslicCell.xlut_relevant();
41 ygate.disabled = !fpslicCell.ylut_relevant();
46 private void drawGlobalRouting(G g, R r) {
47 for(int i=1; i<6; i++) {
48 g.color(fpslicCell.out(L0 + i-1) && fpslicCell.vx(L0+i-1)
51 g.line(r.corner(SW).translate(2*i,0), r.corner(NW).translate(2*i,0));
52 g.color(fpslicCell.out(L0 + i-1) && fpslicCell.hx(L0+i-1)
55 g.line(r.corner(SW).translate(0,2*i), r.corner(SE).translate(0,2*i));
60 private void drawBody(G g, R r) {
61 if (xgate.disabled && ygate.disabled) return;
64 r.plus(12+LOCAL_ROUTING_CHANNEL_WIDTH,
65 12+LOCAL_ROUTING_CHANNEL_WIDTH,
66 -(4+LOCAL_ROUTING_CHANNEL_WIDTH),
67 -(4+LOCAL_ROUTING_CHANNEL_WIDTH));
69 double factor = gateArea.width()/2;
70 xgate.r = xgate.disabled || ygate.disabled ? gateArea : gateArea.plus(factor, 0, 0, -factor);
71 ygate.r = xgate.disabled || ygate.disabled ? gateArea : gateArea.plus(0, 0, -factor, -factor);
73 P xip = r.corner(fpslicCell.xi());
74 P yip = r.corner(fpslicCell.yi());
75 R xring = gateArea.plus(-4, -4, 4, 4);
76 R yring = gateArea.plus(-6, -6, 6, 6);
77 xgate.rotation(fpslicCell.yi());
78 ygate.rotation(fpslicCell.yi());
79 if (xip != null) xgate.route(g, xip, xring, 0, XGATE_COLOR);
80 if (yip != null) xgate.route(g, yip, yring, 2, YGATE_COLOR);
81 if (xip != null) ygate.route(g, xip, xring, 2, XGATE_COLOR);
82 if (yip != null) ygate.route(g, yip, yring, 0, YGATE_COLOR);
88 private void drawWin(G g, R r) {
89 int layer = fpslicCell.wi() - L0;
90 P wip = r.corner(SW).translate(2*(layer+1), 2*(layer+1));
91 R wring = r.plus(2*(layer+1), 2*(layer+1), -2*(layer+1), -2*(layer+1));
92 ygate.route(g, wip, wring, 1, LOCAL_WIRE_COLOR);
93 xgate.route(g, wip, wring, 1, LOCAL_WIRE_COLOR);
96 private void drawGates(G g) {
97 xgate.draw(g, XGATE_COLOR, val ? XGATE_COLOR : 0xffffff);
98 ygate.draw(g, YGATE_COLOR, val ? YGATE_COLOR : 0xffffff);