Add iCE40 Pip gfx
Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
parent
ecc4c3fa7b
commit
164bd28348
@ -333,17 +333,7 @@ PipId Arch::getPipByName(IdString name) const
|
|||||||
IdString Arch::getPipName(PipId pip) const
|
IdString Arch::getPipName(PipId pip) const
|
||||||
{
|
{
|
||||||
NPNR_ASSERT(pip != PipId());
|
NPNR_ASSERT(pip != PipId());
|
||||||
|
return id(chip_info->pip_data[pip.index].name.get());
|
||||||
int x = chip_info->pip_data[pip.index].x;
|
|
||||||
int y = chip_info->pip_data[pip.index].y;
|
|
||||||
|
|
||||||
std::string src_name = chip_info->wire_data[chip_info->pip_data[pip.index].src].name.get();
|
|
||||||
std::replace(src_name.begin(), src_name.end(), '/', '.');
|
|
||||||
|
|
||||||
std::string dst_name = chip_info->wire_data[chip_info->pip_data[pip.index].dst].name.get();
|
|
||||||
std::replace(dst_name.begin(), dst_name.end(), '/', '.');
|
|
||||||
|
|
||||||
return id("X" + std::to_string(x) + "/Y" + std::to_string(y) + "/" + src_name + ".->." + dst_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
@ -512,11 +502,8 @@ std::vector<GraphicElement> Arch::getDecalGraphics(DecalId decal) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (decal.type == DecalId::TYPE_WIRE) {
|
if (decal.type == DecalId::TYPE_WIRE) {
|
||||||
WireId wire;
|
int n = chip_info->wire_data[decal.index].num_segments;
|
||||||
wire.index = decal.index;
|
const WireSegmentPOD *p = chip_info->wire_data[decal.index].segments.get();
|
||||||
|
|
||||||
int n = chip_info->wire_data[wire.index].num_segments;
|
|
||||||
const WireSegmentPOD *p = chip_info->wire_data[wire.index].segments.get();
|
|
||||||
|
|
||||||
GraphicElement::style_t style = decal.active ? GraphicElement::G_ACTIVE : GraphicElement::G_INACTIVE;
|
GraphicElement::style_t style = decal.active ? GraphicElement::G_ACTIVE : GraphicElement::G_INACTIVE;
|
||||||
|
|
||||||
@ -524,6 +511,12 @@ std::vector<GraphicElement> Arch::getDecalGraphics(DecalId decal) const
|
|||||||
gfxTileWire(ret, p[i].x, p[i].y, GfxTileWireId(p[i].index), style);
|
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) {
|
if (decal.type == DecalId::TYPE_BEL) {
|
||||||
BelId bel;
|
BelId bel;
|
||||||
bel.index = decal.index;
|
bel.index = decal.index;
|
||||||
|
@ -63,9 +63,11 @@ NPNR_PACKED_STRUCT(struct BelPortPOD {
|
|||||||
});
|
});
|
||||||
|
|
||||||
NPNR_PACKED_STRUCT(struct PipInfoPOD {
|
NPNR_PACKED_STRUCT(struct PipInfoPOD {
|
||||||
|
RelPtr<char> name;
|
||||||
int32_t src, dst;
|
int32_t src, dst;
|
||||||
int32_t delay;
|
int32_t delay;
|
||||||
int8_t x, y;
|
int8_t x, y;
|
||||||
|
int16_t src_seg, dst_seg;
|
||||||
int16_t switch_mask;
|
int16_t switch_mask;
|
||||||
int32_t switch_index;
|
int32_t switch_index;
|
||||||
});
|
});
|
||||||
|
@ -390,9 +390,9 @@ with open(args.filename, "r") as f:
|
|||||||
wire_xy[mode[1]] = list()
|
wire_xy[mode[1]] = list()
|
||||||
wire_xy[mode[1]].append((int(line[0]), int(line[1])))
|
wire_xy[mode[1]].append((int(line[0]), int(line[1])))
|
||||||
if mode[1] not in wire_segments:
|
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:
|
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
|
continue
|
||||||
|
|
||||||
if mode[0] in ("buffer", "routing"):
|
if mode[0] in ("buffer", "routing"):
|
||||||
@ -1077,6 +1077,7 @@ for wire, info in enumerate(wireinfo):
|
|||||||
bba.r("wire_segments_%d" % wire, "segments")
|
bba.r("wire_segments_%d" % wire, "segments")
|
||||||
else:
|
else:
|
||||||
bba.u32(0, "segments")
|
bba.u32(0, "segments")
|
||||||
|
|
||||||
bba.u8(info["x"], "x")
|
bba.u8(info["x"], "x")
|
||||||
bba.u8(info["y"], "y")
|
bba.u8(info["y"], "y")
|
||||||
bba.u8(wiretypes[wire_type(info["name"])], "type")
|
bba.u8(wiretypes[wire_type(info["name"])], "type")
|
||||||
@ -1085,18 +1086,35 @@ for wire, info in enumerate(wireinfo):
|
|||||||
for wire in range(num_wires):
|
for wire in range(num_wires):
|
||||||
if len(wire_segments[wire]):
|
if len(wire_segments[wire]):
|
||||||
bba.l("wire_segments_%d" % wire, "WireSegmentPOD")
|
bba.l("wire_segments_%d" % wire, "WireSegmentPOD")
|
||||||
for seg in sorted(wire_segments[wire]):
|
for xy, seg in sorted(wire_segments[wire].items()):
|
||||||
bba.u8(seg[0], "x")
|
bba.u8(xy[0], "x")
|
||||||
bba.u8(seg[1], "y")
|
bba.u8(xy[1], "y")
|
||||||
bba.u16(seg[2], "index")
|
bba.u16(gfx_wire_ids["TILE_WIRE_" + seg.upper().replace("/", "_")], "index")
|
||||||
|
|
||||||
bba.l("pip_data_%s" % dev_name, "PipInfoPOD")
|
bba.l("pip_data_%s" % dev_name, "PipInfoPOD")
|
||||||
for info in pipinfo:
|
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["src"], "src")
|
||||||
bba.u32(info["dst"], "dst")
|
bba.u32(info["dst"], "dst")
|
||||||
bba.u32(info["delay"], "delay")
|
bba.u32(info["delay"], "delay")
|
||||||
bba.u8(info["x"], "x")
|
bba.u8(info["x"], "x")
|
||||||
bba.u8(info["y"], "y")
|
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.u16(info["switch_mask"], "switch_mask")
|
||||||
bba.u32(info["switch_index"], "switch_index")
|
bba.u32(info["switch_index"], "switch_index")
|
||||||
|
|
||||||
|
219
ice40/gfx.cc
219
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
|
NEXTPNR_NAMESPACE_END
|
||||||
|
@ -468,6 +468,7 @@ enum GfxTileWireId
|
|||||||
};
|
};
|
||||||
|
|
||||||
void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id, GraphicElement::style_t style);
|
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
|
NEXTPNR_NAMESPACE_END
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user