示例#1
0
  /**
   * Create switch assembly code for to route one item from
   *
   * <pre>fire</pre>
   *
   * to the dests.
   *
   * <pre>previous</pre>
   *
   * is a hashmap from ComputeNode -> ComputeNode that maps a node to its previous hop,
   *
   * <pre>next</pre>
   *
   * is similiar...
   */
  protected void asm(
      ComputeNode fire,
      HashMap<ComputeNode, ComputeNode> previous,
      HashMap<ComputeNode, HashSet> next) {
    assert fire != null;
    // System.out.println("asm: " + fire);
    // generate the sends
    if (!switchSchedules.containsKey(fire)) switchSchedules.put(fire, new StringBuffer());
    StringBuffer buf = switchSchedules.get(fire);
    Iterator it = next.get(fire).iterator();
    buf.append("route ");
    while (it.hasNext()) {
      ComputeNode dest = (ComputeNode) it.next();
      buf.append("$csto->" + "$c" + rawChip.getDirection(fire, dest) + "o,");
    }
    // erase the trailing ,
    buf.setCharAt(buf.length() - 1, '\n');

    // generate all the other
    Iterator<ComputeNode> tiles = next.keySet().iterator();
    while (tiles.hasNext()) {
      ComputeNode tile = tiles.next();
      assert tile != null;
      if (tile == fire) continue;
      if (!switchSchedules.containsKey(tile)) switchSchedules.put(tile, new StringBuffer());
      buf = switchSchedules.get(tile);
      ComputeNode prevTile = previous.get(tile);
      buf.append("route ");
      Iterator nexts = next.get(tile).iterator();
      while (nexts.hasNext()) {
        ComputeNode nextTile = (ComputeNode) nexts.next();
        if (!nextTile.equals(tile))
          buf.append(
              "$c"
                  + rawChip.getDirection(tile, prevTile)
                  + "i->$c"
                  + rawChip.getDirection(tile, nextTile)
                  + "o,");
        else
          buf.append(
              "$c"
                  + rawChip.getDirection(tile, prevTile)
                  + "i->$c"
                  + rawChip.getDirection(tile, nextTile)
                  + "i,");
      }
      buf.setCharAt(buf.length() - 1, '\n');
    }
  }
示例#2
0
 protected void setLocationAndCodeStore() {
   location = backEndBits.getLayout().getComputeNode(inputNode);
   assert location != null;
   codeStore = location.getComputeCode();
 }