diff options
author | Serge Bazanski <serge@bazanski.pl> | 2018-07-15 21:57:42 +0100 |
---|---|---|
committer | Serge Bazanski <serge@bazanski.pl> | 2018-07-15 21:57:42 +0100 |
commit | f3c6c76fff90d89dd65af2c02124c098dab63892 (patch) | |
tree | 48aad4eb072d9972a5a1c298c9fde7922038d74d /ice40 | |
parent | 91db413c60c965b6b7cc095f53c8d03a1658566e (diff) | |
parent | 5531546d6bcf188c27449b6256108c6c722b5b5b (diff) | |
download | nextpnr-f3c6c76fff90d89dd65af2c02124c098dab63892.tar.gz nextpnr-f3c6c76fff90d89dd65af2c02124c098dab63892.tar.bz2 nextpnr-f3c6c76fff90d89dd65af2c02124c098dab63892.zip |
Merge branch 'master' of gitlab.com:SymbioticEDA/nextpnr into q3k/lock-2-electric-boogaloo
Diffstat (limited to 'ice40')
-rw-r--r-- | ice40/arch.cc | 23 | ||||
-rw-r--r-- | ice40/arch.h | 2 | ||||
-rw-r--r-- | ice40/chipdb.py | 30 | ||||
-rw-r--r-- | ice40/gfx.cc | 219 | ||||
-rw-r--r-- | ice40/gfx.h | 1 |
5 files changed, 261 insertions, 14 deletions
diff --git a/ice40/arch.cc b/ice40/arch.cc index c9cda40d..08e32ae6 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 |