aboutsummaryrefslogtreecommitdiffstats
path: root/ice40
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2018-07-12 21:05:09 +0200
committerClifford Wolf <clifford@clifford.at>2018-07-12 21:05:09 +0200
commit4f87ea0eb6ae8a4f8fbf9890c8101cd530d4c5da (patch)
tree9f9db2bb2a5b0be9a381d8a06d49d1dbe13ee536 /ice40
parent13e7cd868111300577c36a3fd45ba698ce926160 (diff)
downloadnextpnr-4f87ea0eb6ae8a4f8fbf9890c8101cd530d4c5da.tar.gz
nextpnr-4f87ea0eb6ae8a4f8fbf9890c8101cd530d4c5da.tar.bz2
nextpnr-4f87ea0eb6ae8a4f8fbf9890c8101cd530d4c5da.zip
Improve iCE40 wire database and gfx
Signed-off-by: Clifford Wolf <clifford@clifford.at>
Diffstat (limited to 'ice40')
-rw-r--r--ice40/arch.cc24
-rw-r--r--ice40/arch.h8
-rw-r--r--ice40/chipdb.py35
-rw-r--r--ice40/family.cmake6
-rw-r--r--ice40/gfx.cc47
-rw-r--r--ice40/gfx.h2
6 files changed, 72 insertions, 50 deletions
diff --git a/ice40/arch.cc b/ice40/arch.cc
index 26c3b003..8650aeff 100644
--- a/ice40/arch.cc
+++ b/ice40/arch.cc
@@ -478,6 +478,8 @@ DecalXY Arch::getBelDecal(BelId bel) const
DecalXY Arch::getWireDecal(WireId wire) const
{
DecalXY decalxy;
+ decalxy.decal.type = DecalId::TYPE_WIRE;
+ decalxy.decal.index = wire.index;
return decalxy;
}
@@ -510,6 +512,21 @@ 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();
+
+ GraphicElement::style_t style = wire_to_net.at(wire.index) != IdString() ?
+ GraphicElement::G_ACTIVE : GraphicElement::G_INACTIVE;
+
+ for (int i = 0; i < n; i++)
+ gfxTileWire(ret, p[i].x, p[i].y, GfxTileWireId(p[i].index), style);
+ }
+
if (decal.type == DecalId::TYPE_BEL)
{
BelId bel;
@@ -520,6 +537,7 @@ std::vector<GraphicElement> Arch::getDecalGraphics(DecalId decal) const
if (bel_type == TYPE_ICESTORM_LC) {
GraphicElement el;
el.type = GraphicElement::G_BOX;
+ el.style = bel_to_cell.at(bel.index) != IdString() ? GraphicElement::G_ACTIVE : GraphicElement::G_INACTIVE;
el.x1 = chip_info->bel_data[bel.index].x + logic_cell_x1;
el.x2 = chip_info->bel_data[bel.index].x + logic_cell_x2;
el.y1 = chip_info->bel_data[bel.index].y + logic_cell_y1 + (chip_info->bel_data[bel.index].z) * logic_cell_pitch;
@@ -534,6 +552,7 @@ std::vector<GraphicElement> Arch::getDecalGraphics(DecalId decal) const
// Main switchbox
GraphicElement main_sw;
main_sw.type = GraphicElement::G_BOX;
+ main_sw.style = GraphicElement::G_FRAME;
main_sw.x1 = tx + main_swbox_x1;
main_sw.x2 = tx + main_swbox_x2;
main_sw.y1 = ty + main_swbox_y1;
@@ -543,16 +562,13 @@ std::vector<GraphicElement> Arch::getDecalGraphics(DecalId decal) const
// Local tracks to LUT input switchbox
GraphicElement local_sw;
local_sw.type = GraphicElement::G_BOX;
+ local_sw.style = GraphicElement::G_FRAME;
local_sw.x1 = tx + local_swbox_x1;
local_sw.x2 = tx + local_swbox_x2;
local_sw.y1 = ty + local_swbox_y1;
local_sw.y2 = ty + local_swbox_y2;
local_sw.z = 0;
ret.push_back(local_sw);
-
- // All the wires
- for (int i = TILE_WIRE_GLB2LOCAL_0; i <= TILE_WIRE_SP12_H_L_23; i++)
- gfxTileWire(ret, tx, ty, GfxTileWireId(i));
}
}
diff --git a/ice40/arch.h b/ice40/arch.h
index 96d0d209..04de5178 100644
--- a/ice40/arch.h
+++ b/ice40/arch.h
@@ -70,6 +70,11 @@ NPNR_PACKED_STRUCT(struct PipInfoPOD {
int32_t switch_index;
});
+NPNR_PACKED_STRUCT(struct WireSegmentPOD {
+ int8_t x, y;
+ int16_t index;
+});
+
NPNR_PACKED_STRUCT(struct WireInfoPOD {
RelPtr<char> name;
int32_t num_uphill, num_downhill;
@@ -79,6 +84,9 @@ NPNR_PACKED_STRUCT(struct WireInfoPOD {
BelPortPOD bel_uphill;
RelPtr<BelPortPOD> bels_downhill;
+ int32_t num_segments;
+ RelPtr<WireSegmentPOD> segments;
+
int8_t x, y;
WireType type;
int8_t padding_0;
diff --git a/ice40/chipdb.py b/ice40/chipdb.py
index 2a918ed9..00194deb 100644
--- a/ice40/chipdb.py
+++ b/ice40/chipdb.py
@@ -11,6 +11,7 @@ group.add_argument("-b", "--binary", action="store_true")
group.add_argument("-c", "--c_file", action="store_true")
parser.add_argument("filename", type=str, help="chipdb input filename")
parser.add_argument("-p", "--portspins", type=str, help="path to portpins.inc")
+parser.add_argument("-g", "--gfxh", type=str, help="path to gfx.h")
args = parser.parse_args()
endianness = "le"
@@ -54,6 +55,9 @@ beltypes = dict()
tiletypes = dict()
wiretypes = dict()
+gfx_wire_ids = dict()
+wire_segments = dict()
+
with open(args.portspins) as f:
for line in f:
line = line.replace("(", " ")
@@ -66,6 +70,18 @@ with open(args.portspins) as f:
idx = len(portpins) + 1
portpins[line[1]] = idx
+with open(args.gfxh) as f:
+ state = 0
+ for line in f:
+ if state == 0 and line.startswith("enum GfxTileWireId "):
+ state = 1
+ elif state == 1 and line.startswith("};"):
+ state = 0
+ elif state == 1:
+ idx = len(gfx_wire_ids)
+ name = line.strip().rstrip(",")
+ gfx_wire_ids[name] = idx
+
beltypes["ICESTORM_LC"] = 1
beltypes["ICESTORM_RAM"] = 2
beltypes["SB_IO"] = 3
@@ -371,6 +387,10 @@ with open(args.filename, "r") as f:
if mode[1] not in wire_xy:
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()
+ if ("TILE_WIRE_" + wname[2].upper()) in gfx_wire_ids:
+ wire_segments[mode[1]].add((wname[0], wname[1], gfx_wire_ids["TILE_WIRE_" + wname[2].upper()]))
continue
if mode[0] in ("buffer", "routing"):
@@ -1040,7 +1060,7 @@ for t in range(num_tile_types):
tileinfo.append(ti)
bba.l("wire_data_%s" % dev_name, "WireInfoPOD")
-for info in wireinfo:
+for wire, info in enumerate(wireinfo):
bba.s(info["name"], "name")
bba.u32(info["num_uphill"], "num_uphill")
bba.u32(info["num_downhill"], "num_downhill")
@@ -1050,11 +1070,24 @@ for info in wireinfo:
bba.u32(info["uphill_bel"], "bel_uphill.bel_index")
bba.u32(info["uphill_pin"], "bel_uphill.port")
bba.r(info["list_bels_downhill"], "bels_downhill")
+ bba.u32(len(wire_segments[wire]), "num_segments")
+ if len(wire_segments[wire]):
+ 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")
bba.u8(0, "padding")
+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")
+
bba.l("pip_data_%s" % dev_name, "PipInfoPOD")
for info in pipinfo:
bba.u32(info["src"], "src")
diff --git a/ice40/family.cmake b/ice40/family.cmake
index e6cefecb..9af06f82 100644
--- a/ice40/family.cmake
+++ b/ice40/family.cmake
@@ -21,8 +21,9 @@ if (MSVC)
set(DEV_TXT_DB ${ICEBOX_ROOT}/chipdb-${dev}.txt)
set(DEV_CC_DB ${CMAKE_CURRENT_SOURCE_DIR}/ice40/chipdbs/chipdb-${dev}.bin)
set(DEV_PORTS_INC ${CMAKE_CURRENT_SOURCE_DIR}/ice40/portpins.inc)
+ set(DEV_GFXH ${CMAKE_CURRENT_SOURCE_DIR}/ice40/gfx.h)
add_custom_command(OUTPUT ${DEV_CC_DB}
- COMMAND ${PYTHON_EXECUTABLE} ${DB_PY} -b -p ${DEV_PORTS_INC} ${DEV_TXT_DB} > ${DEV_CC_DB}
+ COMMAND ${PYTHON_EXECUTABLE} ${DB_PY} -b -p ${DEV_PORTS_INC} -g ${DEV_GFXH} ${DEV_TXT_DB} > ${DEV_CC_DB}
DEPENDS ${DEV_TXT_DB} ${DB_PY}
)
target_sources(ice40_chipdb PRIVATE ${DEV_CC_DB})
@@ -37,8 +38,9 @@ else()
set(DEV_TXT_DB ${ICEBOX_ROOT}/chipdb-${dev}.txt)
set(DEV_CC_DB ${CMAKE_CURRENT_SOURCE_DIR}/ice40/chipdbs/chipdb-${dev}.cc)
set(DEV_PORTS_INC ${CMAKE_CURRENT_SOURCE_DIR}/ice40/portpins.inc)
+ set(DEV_GFXH ${CMAKE_CURRENT_SOURCE_DIR}/ice40/gfx.h)
add_custom_command(OUTPUT ${DEV_CC_DB}
- COMMAND ${PYTHON_EXECUTABLE} ${DB_PY} -c -p ${DEV_PORTS_INC} ${DEV_TXT_DB} > ${DEV_CC_DB}.new
+ COMMAND ${PYTHON_EXECUTABLE} ${DB_PY} -c -p ${DEV_PORTS_INC} -g ${DEV_GFXH} ${DEV_TXT_DB} > ${DEV_CC_DB}.new
COMMAND mv ${DEV_CC_DB}.new ${DEV_CC_DB}
DEPENDS ${DEV_TXT_DB} ${DB_PY}
)
diff --git a/ice40/gfx.cc b/ice40/gfx.cc
index 64bb66ec..d6935b7d 100644
--- a/ice40/gfx.cc
+++ b/ice40/gfx.cc
@@ -21,15 +21,16 @@
NEXTPNR_NAMESPACE_BEGIN
-void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id)
+void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id, GraphicElement::style_t style)
{
+ GraphicElement el;
+ el.type = GraphicElement::G_LINE;
+ el.style = style;
+
// 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;
- GraphicElement el;
- el.type = GraphicElement::G_LINE;
-
float y1 = y + 1.0 - (0.03 + 0.0025 * (60 - idx));
el.x1 = x + 0.0;
@@ -47,8 +48,6 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id)
if (id >= TILE_WIRE_SP4_H_R_0 && id <= TILE_WIRE_SP4_H_R_47) {
int idx = id - TILE_WIRE_SP4_H_R_0;
- GraphicElement el;
- el.type = GraphicElement::G_LINE;
float y1 = y + 1.0 - (0.03 + 0.0025 * (60 - idx));
float y2 = y + 1.0 - (0.03 + 0.0025 * (60 - (idx ^ 1)));
@@ -91,8 +90,6 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id)
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;
- GraphicElement el;
- el.type = GraphicElement::G_LINE;
float x1 = x + 0.03 + 0.0025 * (60 - idx);
@@ -111,8 +108,6 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id)
if (id >= TILE_WIRE_SP4_V_B_0 && id <= TILE_WIRE_SP4_V_B_47) {
int idx = id - TILE_WIRE_SP4_V_B_0;
- GraphicElement el;
- el.type = GraphicElement::G_LINE;
float x1 = x + 0.03 + 0.0025 * (60 - (idx ^ 1));
float x2 = x + 0.03 + 0.0025 * (60 - idx);
@@ -161,8 +156,6 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id)
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;
- GraphicElement el;
- el.type = GraphicElement::G_LINE;
float y1 = y + 1.0 - (0.03 + 0.0025 * (90 - idx));
@@ -181,8 +174,6 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id)
if (id >= TILE_WIRE_SP12_H_R_0 && id <= TILE_WIRE_SP12_H_R_23) {
int idx = id - TILE_WIRE_SP12_H_R_0;
- GraphicElement el;
- el.type = GraphicElement::G_LINE;
float y1 = y + 1.0 - (0.03 + 0.0025 * (90 - (idx ^ 1)));
float y2 = y + 1.0 - (0.03 + 0.0025 * (90 - idx));
@@ -225,8 +216,6 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id)
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;
- GraphicElement el;
- el.type = GraphicElement::G_LINE;
float y1 = y + 1.0 - (0.03 + 0.0025 * (145 - idx));
@@ -241,8 +230,6 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id)
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;
- GraphicElement el;
- el.type = GraphicElement::G_LINE;
float x1 = x + 0.03 + 0.0025 * (90 - idx);
@@ -261,8 +248,6 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id)
if (id >= TILE_WIRE_SP12_V_B_0 && id <= TILE_WIRE_SP12_V_B_23) {
int idx = id - TILE_WIRE_SP12_V_B_0;
- GraphicElement el;
- el.type = GraphicElement::G_LINE;
float x1 = x + 0.03 + 0.0025 * (90 - idx);
float x2 = x + 0.03 + 0.0025 * (90 - (idx ^ 1));
@@ -305,8 +290,6 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id)
if (id >= TILE_WIRE_GLB2LOCAL_0 && id <= TILE_WIRE_GLB2LOCAL_3) {
int idx = id - TILE_WIRE_GLB2LOCAL_0;
- GraphicElement el;
- el.type = GraphicElement::G_LINE;
el.x1 = x + main_swbox_x1 + 0.005 * (idx + 5);
el.x2 = el.x1;
el.y1 = y + main_swbox_y1;
@@ -318,8 +301,6 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id)
if (id >= TILE_WIRE_GLB_NETWK_0 && id <= TILE_WIRE_GLB_NETWK_7) {
int idx = id - TILE_WIRE_GLB_NETWK_0;
- GraphicElement el;
- el.type = GraphicElement::G_LINE;
el.x1 = x + main_swbox_x1 - 0.05;
el.x2 = x + main_swbox_x1;
el.y1 = y + main_swbox_y1 + 0.005 * (13 - idx);
@@ -331,8 +312,6 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id)
if (id >= TILE_WIRE_NEIGH_OP_BNL_0 && id <= TILE_WIRE_NEIGH_OP_TOP_7) {
int idx = id - TILE_WIRE_NEIGH_OP_BNL_0;
- GraphicElement el;
- el.type = GraphicElement::G_LINE;
el.y1 = y + main_swbox_y2 - (0.0025 * (idx + 10) + 0.01 * (idx / 8));
el.y2 = el.y1;
el.x1 = x + main_swbox_x1 - 0.05;
@@ -344,8 +323,6 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id)
if (id >= TILE_WIRE_LOCAL_G0_0 && id <= TILE_WIRE_LOCAL_G3_7) {
int idx = id - TILE_WIRE_LOCAL_G0_0;
- GraphicElement el;
- el.type = GraphicElement::G_LINE;
el.x1 = x + main_swbox_x2;
el.x2 = x + local_swbox_x1;
float yoff = y + (local_swbox_y1 + local_swbox_y2) / 2 - 0.005 * 16 - 0.075;
@@ -360,8 +337,6 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id)
int idx = id - TILE_WIRE_LUTFF_0_IN_0;
int z = idx / 4;
int input = idx % 4;
- GraphicElement el;
- el.type = GraphicElement::G_LINE;
el.x1 = x + local_swbox_x2;
el.x2 = x + logic_cell_x1;
el.y1 = y + (logic_cell_y1 + logic_cell_y2) / 2 - 0.0075 + (0.005 * input) + z * logic_cell_pitch;
@@ -376,8 +351,6 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id)
float y1 = y + 1.0 - (0.03 + 0.0025 * (152 + idx));
- GraphicElement el;
- el.type = GraphicElement::G_LINE;
el.y1 = y1;
el.y2 = y1;
el.x1 = x + main_swbox_x2;
@@ -398,8 +371,6 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id)
if (id >= TILE_WIRE_LUTFF_GLOBAL_CEN && id <= TILE_WIRE_LUTFF_GLOBAL_S_R) {
int idx = id - TILE_WIRE_LUTFF_GLOBAL_CEN;
- GraphicElement el;
- el.type = GraphicElement::G_LINE;
el.x1 = x + main_swbox_x2 - 0.005 * (idx + 5);
el.x2 = el.x1;
@@ -426,8 +397,6 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id)
if (id >= TILE_WIRE_LUTFF_0_LOUT && id <= TILE_WIRE_LUTFF_6_LOUT) {
int idx = id - TILE_WIRE_LUTFF_0_LOUT;
- GraphicElement el;
- el.type = GraphicElement::G_LINE;
el.x1 = x + logic_cell_x1 + 0.005 * 5;
el.x2 = el.x1;
el.y1 = y + logic_cell_y2 + idx * logic_cell_pitch;
@@ -439,8 +408,6 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id)
if (id >= TILE_WIRE_LUTFF_0_COUT && id <= TILE_WIRE_LUTFF_7_COUT) {
int idx = id - TILE_WIRE_LUTFF_0_COUT;
- GraphicElement el;
- el.type = GraphicElement::G_LINE;
el.x1 = x + logic_cell_x1 + 0.005 * 3;
el.x2 = el.x1;
el.y1 = y + logic_cell_y2 + idx * logic_cell_pitch;
@@ -449,8 +416,6 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id)
}
if (id == TILE_WIRE_CARRY_IN) {
- GraphicElement el;
- el.type = GraphicElement::G_LINE;
el.x1 = x + logic_cell_x1 + 0.005 * 3;
el.x2 = el.x1;
el.y1 = y;
@@ -459,8 +424,6 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id)
}
if (id == TILE_WIRE_CARRY_IN_MUX) {
- GraphicElement el;
- el.type = GraphicElement::G_LINE;
el.x1 = x + logic_cell_x1 + 0.005 * 3;
el.x2 = el.x1;
el.y1 = y + 0.02;
diff --git a/ice40/gfx.h b/ice40/gfx.h
index b0009b59..aa07c2fa 100644
--- a/ice40/gfx.h
+++ b/ice40/gfx.h
@@ -466,7 +466,7 @@ enum GfxTileWireId {
TILE_WIRE_SP12_H_L_23
};
-void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id);
+void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id, GraphicElement::style_t style);
NEXTPNR_NAMESPACE_END