1 package edu.berkeley.slipway.mpar;
2 import com.atmel.fpslic.*;
4 import byucc.edif.tools.merge.*;
8 import edu.berkeley.slipway.*;
9 import edu.berkeley.abits.*;
10 import com.atmel.fpslic.*;
11 import static com.atmel.fpslic.FpslicConstants.*;
12 import static edu.berkeley.slipway.mpar.PhysicalDevice.*;
13 import static edu.berkeley.slipway.mpar.NetList.*;
15 public class Placement {
17 public final NetList netlist;
18 public final PhysicalDevice pd;
20 public HashMap<PhysicalDevice.PhysicalCell, NetList.Node> cellToNode =
21 new HashMap<PhysicalDevice.PhysicalCell, NetList.Node>();
22 public HashMap<NetList.Node, PhysicalDevice.PhysicalCell> nodeToCell =
23 new HashMap<NetList.Node, PhysicalDevice.PhysicalCell>();
25 public Placement(NetList netlist, PhysicalDevice pd) {
26 this.netlist = netlist;
30 public void unplace(PhysicalDevice.PhysicalCell pc) {
31 NetList.Node n = cellToNode.get(pc);
32 if (n != null) unplace(n);
34 public void unplace(NetList.Node n) {
35 PhysicalDevice.PhysicalCell pc = nodeToCell.get(n);
36 cellToNode.remove(pc);
39 public void place(NetList.Node n, PhysicalDevice.PhysicalCell pc) {
44 cellToNode.put(pc, n);
45 nodeToCell.put(n, pc);
48 public void setPlacement() {
49 for(PhysicalDevice.PhysicalCell pc : cellToNode.keySet()) {
50 NetList.Node node = cellToNode.get(pc);
55 public boolean isPlaced(NetList.Node n) { return nodeToCell.get(n) != null; }
56 public boolean isPlaced(PhysicalDevice.PhysicalCell pc) { return cellToNode.get(pc) != null; }
58 public PhysicalDevice.PhysicalCell nodeToCell(NetList.Node n) { return nodeToCell.get(n); }
59 public NetList.Node cellToNode(PhysicalDevice.PhysicalCell pc) { return cellToNode.get(pc); }
61 public void random(Random rand) {
62 for(NetList.Node n : netlist.nodes) {
64 PhysicalDevice.PhysicalCell pc = pd.randomCell(rand);
65 if (isPlaced(pc)) continue;