aboutsummaryrefslogtreecommitdiffstats
path: root/ice40
diff options
context:
space:
mode:
authorEddie Hung <eddie.hung+gitlab@gmail.com>2018-07-17 14:19:43 +0000
committerEddie Hung <eddie.hung+gitlab@gmail.com>2018-07-17 14:19:43 +0000
commitdabc057da94207c1dfbb8d9679c639ff697bea14 (patch)
treed8d70b16f021d48fa053949d909fa206ce36927b /ice40
parent0bae7f5606b15591a23fb63da1c5ff6f93b40747 (diff)
parentf62f04e376f83d650ab1067cdf0f058151828b8a (diff)
downloadnextpnr-dabc057da94207c1dfbb8d9679c639ff697bea14.tar.gz
nextpnr-dabc057da94207c1dfbb8d9679c639ff697bea14.tar.bz2
nextpnr-dabc057da94207c1dfbb8d9679c639ff697bea14.zip
Merge branch 'master' into 'master'
Master See merge request eddiehung/nextpnr!2
Diffstat (limited to 'ice40')
-rw-r--r--ice40/arch.cc23
-rw-r--r--ice40/arch.h2
-rw-r--r--ice40/chipdb.py30
-rw-r--r--ice40/gfx.cc219
-rw-r--r--ice40/gfx.h1
-rw-r--r--ice40/place_legaliser.cc8
6 files changed, 265 insertions, 18 deletions
diff --git a/ice40/arch.cc b/ice40/arch.cc
index adc37dbd..69848aff 100644
--- a/ice40/arch.cc
+++ b/ice40/arch.cc
@@ -334,6 +334,7 @@ IdString Arch::getPipName(PipId pip) const
{
NPNR_ASSERT(pip != PipId());
+#if 1
int x = chip_info->pip_data[pip.index].x;
int y = chip_info->pip_data[pip.index].y;
@@ -344,6 +345,9 @@ IdString Arch::getPipName(PipId pip) const
std::replace(dst_name.begin(), dst_name.end(), '/', '.');
return id("X" + std::to_string(x) + "/Y" + std::to_string(y) + "/" + src_name + ".->." + dst_name);
+#else
+ return id(chip_info->pip_data[pip.index].name.get());
+#endif
}
// -----------------------------------------------------------------------
@@ -480,9 +484,9 @@ DecalXY Arch::getWireDecal(WireId wire) const
DecalXY Arch::getPipDecal(PipId pip) const
{
DecalXY decalxy;
- decalxy.decal.type = DecalId::TYPE_PIP;
- decalxy.decal.index = pip.index;
- decalxy.decal.active = pip_to_net.at(pip.index) != IdString();
+ // decalxy.decal.type = DecalId::TYPE_PIP;
+ // decalxy.decal.index = pip.index;
+ // decalxy.decal.active = pip_to_net.at(pip.index) != IdString();
return decalxy;
};
@@ -512,11 +516,8 @@ std::vector<GraphicElement> Arch::getDecalGraphics(DecalId decal) const
}
if (decal.type == DecalId::TYPE_WIRE) {
- WireId wire;
- wire.index = decal.index;
-
- int n = chip_info->wire_data[wire.index].num_segments;
- const WireSegmentPOD *p = chip_info->wire_data[wire.index].segments.get();
+ int n = chip_info->wire_data[decal.index].num_segments;
+ const WireSegmentPOD *p = chip_info->wire_data[decal.index].segments.get();
GraphicElement::style_t style = decal.active ? GraphicElement::G_ACTIVE : GraphicElement::G_INACTIVE;
@@ -524,6 +525,12 @@ std::vector<GraphicElement> Arch::getDecalGraphics(DecalId decal) const
gfxTileWire(ret, p[i].x, p[i].y, GfxTileWireId(p[i].index), style);
}
+ if (decal.type == DecalId::TYPE_PIP) {
+ const PipInfoPOD &p = chip_info->pip_data[decal.index];
+ GraphicElement::style_t style = decal.active ? GraphicElement::G_ACTIVE : GraphicElement::G_HIDDEN;
+ gfxTilePip(ret, p.x, p.y, GfxTileWireId(p.src_seg), GfxTileWireId(p.dst_seg), style);
+ }
+
if (decal.type == DecalId::TYPE_BEL) {
BelId bel;
bel.index = decal.index;
diff --git a/ice40/arch.h b/ice40/arch.h
index a02e0ced..5dab414b 100644
--- a/ice40/arch.h
+++ b/ice40/arch.h
@@ -63,9 +63,11 @@ NPNR_PACKED_STRUCT(struct BelPortPOD {
});
NPNR_PACKED_STRUCT(struct PipInfoPOD {
+ // RelPtr<char> name;
int32_t src, dst;
int32_t delay;
int8_t x, y;
+ int16_t src_seg, dst_seg;
int16_t switch_mask;
int32_t switch_index;
});
diff --git a/ice40/chipdb.py b/ice40/chipdb.py
index 51fe169c..698cd173 100644
--- a/ice40/chipdb.py
+++ b/ice40/chipdb.py
@@ -390,9 +390,9 @@ with open(args.filename, "r") as f:
wire_xy[mode[1]] = list()
wire_xy[mode[1]].append((int(line[0]), int(line[1])))
if mode[1] not in wire_segments:
- wire_segments[mode[1]] = set()
+ wire_segments[mode[1]] = dict()
if ("TILE_WIRE_" + wname[2].upper().replace("/", "_")) in gfx_wire_ids:
- wire_segments[mode[1]].add((wname[0], wname[1], gfx_wire_ids["TILE_WIRE_" + wname[2].upper().replace("/", "_")]))
+ wire_segments[mode[1]][(wname[0], wname[1])] = wname[2]
continue
if mode[0] in ("buffer", "routing"):
@@ -1077,6 +1077,7 @@ for wire, info in enumerate(wireinfo):
bba.r("wire_segments_%d" % wire, "segments")
else:
bba.u32(0, "segments")
+
bba.u8(info["x"], "x")
bba.u8(info["y"], "y")
bba.u8(wiretypes[wire_type(info["name"])], "type")
@@ -1085,18 +1086,35 @@ for wire, info in enumerate(wireinfo):
for wire in range(num_wires):
if len(wire_segments[wire]):
bba.l("wire_segments_%d" % wire, "WireSegmentPOD")
- for seg in sorted(wire_segments[wire]):
- bba.u8(seg[0], "x")
- bba.u8(seg[1], "y")
- bba.u16(seg[2], "index")
+ for xy, seg in sorted(wire_segments[wire].items()):
+ bba.u8(xy[0], "x")
+ bba.u8(xy[1], "y")
+ bba.u16(gfx_wire_ids["TILE_WIRE_" + seg.upper().replace("/", "_")], "index")
bba.l("pip_data_%s" % dev_name, "PipInfoPOD")
for info in pipinfo:
+ src_seg = -1
+ src_segname = wire_names_r[info["src"]]
+ if (info["x"], info["y"]) in wire_segments[info["src"]]:
+ src_segname = wire_segments[info["src"]][(info["x"], info["y"])]
+ src_seg = gfx_wire_ids["TILE_WIRE_" + src_segname.upper().replace("/", "_")]
+ src_segname = src_segname.replace("/", ".")
+
+ dst_seg = -1
+ dst_segname = wire_names_r[info["dst"]]
+ if (info["x"], info["y"]) in wire_segments[info["dst"]]:
+ dst_segname = wire_segments[info["dst"]][(info["x"], info["y"])]
+ dst_seg = gfx_wire_ids["TILE_WIRE_" + dst_segname.upper().replace("/", "_")]
+ dst_segname = dst_segname.replace("/", ".")
+
+ # bba.s("X%d/Y%d/%s->%s" % (info["x"], info["y"], src_segname, dst_segname), "name")
bba.u32(info["src"], "src")
bba.u32(info["dst"], "dst")
bba.u32(info["delay"], "delay")
bba.u8(info["x"], "x")
bba.u8(info["y"], "y")
+ bba.u16(src_seg, "src_seg")
+ bba.u16(dst_seg, "dst_seg")
bba.u16(info["switch_mask"], "switch_mask")
bba.u32(info["switch_index"], "switch_index")
diff --git a/ice40/gfx.cc b/ice40/gfx.cc
index 19aaed13..aa2fc9ce 100644
--- a/ice40/gfx.cc
+++ b/ice40/gfx.cc
@@ -485,4 +485,223 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id,
}
}
+static bool getWireXY_main(GfxTileWireId id, float &x, float &y)
+{
+ // Horizontal Span-4 Wires
+
+ if (id >= TILE_WIRE_SP4_H_L_36 && id <= TILE_WIRE_SP4_H_L_47) {
+ int idx = (id - TILE_WIRE_SP4_H_L_36) + 48;
+ x = main_swbox_x1 + 0.0025 * (idx + 35);
+ y = main_swbox_y2;
+ return true;
+ }
+
+ if (id >= TILE_WIRE_SP4_H_R_0 && id <= TILE_WIRE_SP4_H_R_47) {
+ int idx = id - TILE_WIRE_SP4_H_R_0;
+ x = main_swbox_x1 + 0.0025 * ((idx ^ 1) + 35);
+ y = main_swbox_y2;
+ return true;
+ }
+
+ // Vertical Span-4 Wires
+
+ if (id >= TILE_WIRE_SP4_V_T_36 && id <= TILE_WIRE_SP4_V_T_47) {
+ int idx = (id - TILE_WIRE_SP4_V_T_36) + 48;
+ y = 1.0 - (0.03 + 0.0025 * (270 - idx));
+ x = main_swbox_x1;
+ return true;
+ }
+
+ if (id >= TILE_WIRE_SP4_V_B_0 && id <= TILE_WIRE_SP4_V_B_47) {
+ int idx = id - TILE_WIRE_SP4_V_B_0;
+ y = 1.0 - (0.03 + 0.0025 * (270 - (idx ^ 1)));
+ x = main_swbox_x1;
+ return true;
+ }
+
+ // Horizontal Span-12 Wires
+
+ if (id >= TILE_WIRE_SP12_H_L_22 && id <= TILE_WIRE_SP12_H_L_23) {
+ int idx = (id - TILE_WIRE_SP12_H_L_22) + 24;
+ x = main_swbox_x1 + 0.0025 * (idx + 5);
+ y = main_swbox_y2;
+ return true;
+ }
+
+ if (id >= TILE_WIRE_SP12_H_R_0 && id <= TILE_WIRE_SP12_H_R_23) {
+ int idx = id - TILE_WIRE_SP12_H_R_0;
+ x = main_swbox_x1 + 0.0025 * ((idx ^ 1) + 5);
+ y = main_swbox_y2;
+ return true;
+ }
+
+ // Vertical Right Span-4
+
+ if (id >= TILE_WIRE_SP4_R_V_B_0 && id <= TILE_WIRE_SP4_R_V_B_47) {
+ int idx = id - TILE_WIRE_SP4_R_V_B_0;
+ y = 1.0 - (0.03 + 0.0025 * (145 - (idx ^ 1)));
+ x = main_swbox_x2;
+ return true;
+ }
+
+ // Vertical Span-12 Wires
+
+ if (id >= TILE_WIRE_SP12_V_T_22 && id <= TILE_WIRE_SP12_V_T_23) {
+ int idx = (id - TILE_WIRE_SP12_V_T_22) + 24;
+ y = 1.0 - (0.03 + 0.0025 * (300 - idx));
+ x = main_swbox_x1;
+ return true;
+ }
+
+ if (id >= TILE_WIRE_SP12_V_B_0 && id <= TILE_WIRE_SP12_V_B_23) {
+ int idx = id - TILE_WIRE_SP12_V_B_0;
+ y = 1.0 - (0.03 + 0.0025 * (300 - (idx ^ 1)));
+ x = main_swbox_x1;
+ return true;
+ }
+
+ // Global2Local
+
+ if (id >= TILE_WIRE_GLB2LOCAL_0 && id <= TILE_WIRE_GLB2LOCAL_3) {
+ int idx = id - TILE_WIRE_GLB2LOCAL_0;
+ x = main_swbox_x1 + 0.005 * (idx + 5);
+ y = main_swbox_y1;
+ return true;
+ }
+
+ // GlobalNets
+
+ if (id >= TILE_WIRE_GLB_NETWK_0 && id <= TILE_WIRE_GLB_NETWK_7) {
+ int idx = id - TILE_WIRE_GLB_NETWK_0;
+ x = main_swbox_x1;
+ y = main_swbox_y1 + 0.005 * (13 - idx);
+ return true;
+ }
+
+ // Neighbours
+
+ if (id >= TILE_WIRE_NEIGH_OP_BNL_0 && id <= TILE_WIRE_NEIGH_OP_TOP_7) {
+ int idx = id - TILE_WIRE_NEIGH_OP_BNL_0;
+ y = main_swbox_y2 - (0.0025 * (idx + 10) + 0.01 * (idx / 8));
+ x = main_swbox_x1;
+ return true;
+ }
+
+ // Local Tracks
+
+ if (id >= TILE_WIRE_LOCAL_G0_0 && id <= TILE_WIRE_LOCAL_G3_7) {
+ int idx = id - TILE_WIRE_LOCAL_G0_0;
+ float yoff = (local_swbox_y1 + local_swbox_y2) / 2 - 0.005 * 16 - 0.075;
+ x = main_swbox_x2;
+ y = yoff + 0.005 * idx + 0.05 * (idx / 8);
+ return true;
+ }
+
+ // LC Outputs
+
+ if (id >= TILE_WIRE_LUTFF_0_OUT && id <= TILE_WIRE_LUTFF_7_OUT) {
+ int idx = id - TILE_WIRE_LUTFF_0_OUT;
+ y = 1.0 - (0.03 + 0.0025 * (152 + idx));
+ x = main_swbox_x2;
+ return true;
+ }
+
+ // LC Control
+
+ if (id >= TILE_WIRE_LUTFF_GLOBAL_CEN && id <= TILE_WIRE_LUTFF_GLOBAL_S_R) {
+ int idx = id - TILE_WIRE_LUTFF_GLOBAL_CEN;
+ x = main_swbox_x2 - 0.005 * (idx + 5);
+ y = main_swbox_y1;
+ return true;
+ }
+
+ return false;
+}
+
+static bool getWireXY_local(GfxTileWireId id, float &x, float &y)
+{
+ if (id >= TILE_WIRE_LOCAL_G0_0 && id <= TILE_WIRE_LOCAL_G3_7) {
+ int idx = id - TILE_WIRE_LOCAL_G0_0;
+ float yoff = (local_swbox_y1 + local_swbox_y2) / 2 - 0.005 * 16 - 0.075;
+ x = local_swbox_x1;
+ y = yoff + 0.005 * idx + 0.05 * (idx / 8);
+ return true;
+ }
+
+ if (id >= TILE_WIRE_LUTFF_0_IN_0 && id <= TILE_WIRE_LUTFF_7_IN_3) {
+ int idx = id - TILE_WIRE_LUTFF_0_IN_0;
+ int z = idx / 4;
+ int input = idx % 4;
+ x = local_swbox_x2;
+ y = (logic_cell_y1 + logic_cell_y2) / 2 - 0.0075 + (0.005 * input) + z * logic_cell_pitch;
+ return true;
+ }
+
+ return false;
+}
+
+void pipGfx(std::vector<GraphicElement> &g, int x, int y,
+ float x1, float y1, float x2, float y2,
+ float swx1, float swy1, float swx2, float swy2,
+ GraphicElement::style_t style)
+{
+ float tx = 0.5 * (x1 + x2);
+ float ty = 0.5 * (y1 + y2);
+
+ GraphicElement el;
+ el.type = GraphicElement::G_LINE;
+ el.style = style;
+
+ if (fabsf(x1 - swx1) < 0.001 && fabsf(x2 - swx1) < 0.001) {
+ tx = x1 + 0.25 * fabsf(y1 - y2);
+ goto edge_pip;
+ }
+
+ if (fabsf(x1 - swx2) < 0.001 && fabsf(x2 - swx2) < 0.001) {
+ tx = x1 - 0.25 * fabsf(y1 - y2);
+ goto edge_pip;
+ }
+
+ if (fabsf(y1 - swy1) < 0.001 && fabsf(y2 - swy1) < 0.001) {
+ ty = y1 + 0.25 * fabsf(x1 - x2);
+ goto edge_pip;
+ }
+
+ if (fabsf(y1 - swy1) < 0.001 && fabsf(y2 - swy1) < 0.001) {
+ ty = y1 + 0.25 * fabsf(x1 - x2);
+ goto edge_pip;
+ }
+
+ el.x1 = x + x1;
+ el.y1 = y + y1;
+ el.x2 = x + x2;
+ el.y2 = y + y2;
+ g.push_back(el);
+ return;
+
+edge_pip:
+ el.x1 = x + x1;
+ el.y1 = y + y1;
+ el.x2 = x + tx;
+ el.y2 = y + ty;
+ g.push_back(el);
+
+ el.x1 = x + tx;
+ el.y1 = y + ty;
+ el.x2 = x + x2;
+ el.y2 = y + y2;
+ g.push_back(el);
+}
+
+void gfxTilePip(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId src, GfxTileWireId dst, GraphicElement::style_t style)
+{
+ float x1, y1, x2, y2;
+
+ if (getWireXY_main(src, x1, y1) && getWireXY_main(dst, x2, y2))
+ pipGfx(g, x, y, x1, y1, x2, y2, main_swbox_x1, main_swbox_y1, main_swbox_x2, main_swbox_y2, style);
+
+ if (getWireXY_local(src, x1, y1) && getWireXY_local(dst, x2, y2))
+ pipGfx(g, x, y, x1, y1, x2, y2, local_swbox_x1, local_swbox_y1, local_swbox_x2, local_swbox_y2, style);
+}
+
NEXTPNR_NAMESPACE_END
diff --git a/ice40/gfx.h b/ice40/gfx.h
index a65f7683..a1cbd65b 100644
--- a/ice40/gfx.h
+++ b/ice40/gfx.h
@@ -468,6 +468,7 @@ enum GfxTileWireId
};
void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id, GraphicElement::style_t style);
+void gfxTilePip(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId src, GfxTileWireId dst, GraphicElement::style_t style);
NEXTPNR_NAMESPACE_END
diff --git a/ice40/place_legaliser.cc b/ice40/place_legaliser.cc
index 559358c7..5fffb4fb 100644
--- a/ice40/place_legaliser.cc
+++ b/ice40/place_legaliser.cc
@@ -246,7 +246,7 @@ class PlacementLegaliser
std::tuple<int, int, int> find_closest_bel(float target_x, float target_y, CellChain &chain)
{
std::tuple<int, int, int> best_origin = std::make_tuple(-1, -1, -1);
- wirelen_t best_wirelength = std::numeric_limits<wirelen_t>::max();
+ wirelen_t best_metric = std::numeric_limits<wirelen_t>::max();
int width = ctx->chip_info->width, height = ctx->chip_info->height;
// Slow, should radiate outwards from target position - TODO
int chain_size = int(chain.cells.size());
@@ -260,11 +260,11 @@ class PlacementLegaliser
valid = false;
break;
} else {
- wirelen += get_cell_wirelength_at_bel(ctx, chain.cells.at(k), lb.first);
+ wirelen += get_cell_metric_at_bel(ctx, chain.cells.at(k), lb.first, MetricType::COST);
}
}
- if (valid && wirelen < best_wirelength) {
- best_wirelength = wirelen;
+ if (valid && wirelen < best_metric) {
+ best_metric = wirelen;
best_origin = std::make_tuple(x, y, 0);
}
}