From a86c4f2f5db2cefb4cb937b8bb9e02c9cb776167 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Thu, 26 Jul 2018 15:22:52 +0200 Subject: Improvements in bbasm Signed-off-by: Clifford Wolf --- ice40/chipdb.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ice40') diff --git a/ice40/chipdb.py b/ice40/chipdb.py index b5fee359..b6af8fcf 100644 --- a/ice40/chipdb.py +++ b/ice40/chipdb.py @@ -675,7 +675,8 @@ class BinaryBlobAssembler: print("ref %s %s" % (name, comment)) def s(self, s, comment): - print("str %s" % s) + assert "|" not in s + print("str |%s| %s" % (s, comment)) def u8(self, v, comment): if comment is None: -- cgit v1.2.3 From 7152ae1e3ddb540cafbfab38e0b69ea94d1ec3c2 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Thu, 26 Jul 2018 15:42:32 +0200 Subject: Add iCE40 pip gfx for carry_in mux Signed-off-by: Clifford Wolf --- ice40/gfx.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'ice40') diff --git a/ice40/gfx.cc b/ice40/gfx.cc index 1b01cbd8..0a583e8e 100644 --- a/ice40/gfx.cc +++ b/ice40/gfx.cc @@ -701,6 +701,17 @@ void gfxTilePip(std::vector &g, int x, int y, GfxTileWireId src, 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); + + if (src == TILE_WIRE_CARRY_IN && dst == TILE_WIRE_CARRY_IN_MUX) { + GraphicElement el; + el.type = GraphicElement::G_ARROW; + el.style = style; + el.x1 = x + logic_cell_x1 + 0.005 * 3; + el.x2 = el.x1; + el.y1 = y + 0.01; + el.y2 = y + 0.02; + g.push_back(el); + } } NEXTPNR_NAMESPACE_END -- cgit v1.2.3 From 6a59b8522cd13f4d4c4e0c0ac43a374da2d95615 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Thu, 26 Jul 2018 16:21:01 +0200 Subject: Move iCE40 switchbox gfx to UI groups Signed-off-by: Clifford Wolf --- ice40/arch.cc | 255 +++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 162 insertions(+), 93 deletions(-) (limited to 'ice40') diff --git a/ice40/arch.cc b/ice40/arch.cc index dedc59bc..55252f2c 100644 --- a/ice40/arch.cc +++ b/ice40/arch.cc @@ -440,11 +440,103 @@ GroupId Arch::getGroupByName(IdString name) const return GroupId(); } -IdString Arch::getGroupName(GroupId group) const { return IdString(); } +IdString Arch::getGroupName(GroupId group) const +{ + std::string suffix; + + switch (group.type) { + case GroupId::TYPE_FRAME: + suffix = "tile"; + break; + case GroupId::TYPE_MAIN_SW: + suffix = "main_sw"; + break; + case GroupId::TYPE_LOCAL_SW: + suffix = "local_sw"; + break; + case GroupId::TYPE_LC0_SW: + suffix = "lc0_sw"; + break; + case GroupId::TYPE_LC1_SW: + suffix = "lc1_sw"; + break; + case GroupId::TYPE_LC2_SW: + suffix = "lc2_sw"; + break; + case GroupId::TYPE_LC3_SW: + suffix = "lc3_sw"; + break; + case GroupId::TYPE_LC4_SW: + suffix = "lc4_sw"; + break; + case GroupId::TYPE_LC5_SW: + suffix = "lc5_sw"; + break; + case GroupId::TYPE_LC6_SW: + suffix = "lc6_sw"; + break; + case GroupId::TYPE_LC7_SW: + suffix = "lc7_sw"; + break; + default: + return IdString(); + } + + return id("X" + std::to_string(group.x) + "/Y" + std::to_string(group.y) + "/" + suffix); +} std::vector Arch::getGroups() const { std::vector ret; + + for (int y = 0; y < chip_info->height; y++) { + for (int x = 0; x < chip_info->width; x++) { + TileType type = chip_info->tile_grid[y * chip_info->width + x]; + if (type == TILE_NONE) + continue; + + GroupId group; + group.type = GroupId::TYPE_FRAME; + group.x = x; + group.y = y; + // ret.push_back(group); + + group.type = GroupId::TYPE_MAIN_SW; + ret.push_back(group); + + group.type = GroupId::TYPE_LOCAL_SW; + ret.push_back(group); + +#if 0 + if (type == TILE_LOGIC) + { + group.type = GroupId::TYPE_LC0_SW; + ret.push_back(group); + + group.type = GroupId::TYPE_LC1_SW; + ret.push_back(group); + + group.type = GroupId::TYPE_LC2_SW; + ret.push_back(group); + + group.type = GroupId::TYPE_LC3_SW; + ret.push_back(group); + + group.type = GroupId::TYPE_LC4_SW; + ret.push_back(group); + + group.type = GroupId::TYPE_LC5_SW; + ret.push_back(group); + + group.type = GroupId::TYPE_LC6_SW; + ret.push_back(group); + + group.type = GroupId::TYPE_LC7_SW; + ret.push_back(group); + } +#endif + } + } return ret; } @@ -552,15 +644,63 @@ std::vector Arch::getDecalGraphics(DecalId decal) const std::vector ret; if (decal.type == DecalId::TYPE_FRAME) { - for (int x = 0; x <= chip_info->width; x++) - for (int y = 0; y <= chip_info->height; y++) { - GraphicElement el; - el.type = GraphicElement::G_LINE; - el.x1 = x - 0.05, el.x2 = x + 0.05, el.y1 = y, el.y2 = y, el.z = 0; - ret.push_back(el); - el.x1 = x, el.x2 = x, el.y1 = y - 0.05, el.y2 = y + 0.05, el.z = 0; - ret.push_back(el); - } + /* nothing */ + } + + if (decal.type == DecalId::TYPE_GROUP) { + int type = (decal.index >> 16) & 255; + int x = (decal.index >> 8) & 255; + int y = decal.index & 255; + + if (type == GroupId::TYPE_FRAME) { + GraphicElement el; + el.type = GraphicElement::G_LINE; + el.style = GraphicElement::G_FRAME; + + el.x1 = x + 0.01, el.x2 = x + 0.02, el.y1 = y + 0.01, el.y2 = y + 0.01; + ret.push_back(el); + el.x1 = x + 0.01, el.x2 = x + 0.01, el.y1 = y + 0.01, el.y2 = y + 0.02; + ret.push_back(el); + + el.x1 = x + 0.99, el.x2 = x + 0.98, el.y1 = y + 0.01, el.y2 = y + 0.01; + ret.push_back(el); + el.x1 = x + 0.99, el.x2 = x + 0.99, el.y1 = y + 0.01, el.y2 = y + 0.02; + ret.push_back(el); + + el.x1 = x + 0.99, el.x2 = x + 0.98, el.y1 = y + 0.99, el.y2 = y + 0.99; + ret.push_back(el); + el.x1 = x + 0.99, el.x2 = x + 0.99, el.y1 = y + 0.99, el.y2 = y + 0.98; + ret.push_back(el); + + el.x1 = x + 0.01, el.x2 = x + 0.02, el.y1 = y + 0.99, el.y2 = y + 0.99; + ret.push_back(el); + el.x1 = x + 0.01, el.x2 = x + 0.01, el.y1 = y + 0.99, el.y2 = y + 0.98; + ret.push_back(el); + } + + if (type == GroupId::TYPE_MAIN_SW) { + GraphicElement el; + el.type = GraphicElement::G_BOX; + el.style = GraphicElement::G_FRAME; + + el.x1 = x + main_swbox_x1; + el.x2 = x + main_swbox_x2; + el.y1 = y + main_swbox_y1; + el.y2 = y + main_swbox_y2; + ret.push_back(el); + } + + if (type == GroupId::TYPE_LOCAL_SW) { + GraphicElement el; + el.type = GraphicElement::G_BOX; + el.style = GraphicElement::G_FRAME; + + el.x1 = x + local_swbox_x1; + el.x2 = x + local_swbox_x2; + el.y1 = y + local_swbox_y1; + el.y2 = y + local_swbox_y2; + ret.push_back(el); + } } if (decal.type == DecalId::TYPE_WIRE) { @@ -595,103 +735,32 @@ std::vector Arch::getDecalGraphics(DecalId decal) const (chip_info->bel_data[bel.index].z) * logic_cell_pitch; el.y2 = chip_info->bel_data[bel.index].y + logic_cell_y2 + (chip_info->bel_data[bel.index].z) * logic_cell_pitch; - el.z = 0; ret.push_back(el); - - if (chip_info->bel_data[bel.index].z == 0) { - int tx = chip_info->bel_data[bel.index].x; - int ty = chip_info->bel_data[bel.index].y; - - // 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; - main_sw.y2 = ty + main_swbox_y2; - ret.push_back(main_sw); - - // 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); - } } if (bel_type == TYPE_SB_IO) { - if (chip_info->bel_data[bel.index].x == 0 || chip_info->bel_data[bel.index].x == chip_info->width - 1) { - GraphicElement el; - el.type = GraphicElement::G_BOX; - el.x1 = chip_info->bel_data[bel.index].x + 0.1; - el.x2 = chip_info->bel_data[bel.index].x + 0.9; - if (chip_info->bel_data[bel.index].z == 0) { - el.y1 = chip_info->bel_data[bel.index].y + 0.10; - el.y2 = chip_info->bel_data[bel.index].y + 0.45; - } else { - el.y1 = chip_info->bel_data[bel.index].y + 0.55; - el.y2 = chip_info->bel_data[bel.index].y + 0.90; - } - el.z = 0; - ret.push_back(el); - } else { - GraphicElement el; - el.type = GraphicElement::G_BOX; - if (chip_info->bel_data[bel.index].z == 0) { - el.x1 = chip_info->bel_data[bel.index].x + 0.10; - el.x2 = chip_info->bel_data[bel.index].x + 0.45; - } else { - el.x1 = chip_info->bel_data[bel.index].x + 0.55; - el.x2 = chip_info->bel_data[bel.index].x + 0.90; - } - el.y1 = chip_info->bel_data[bel.index].y + 0.1; - el.y2 = chip_info->bel_data[bel.index].y + 0.9; - el.z = 0; - ret.push_back(el); - } + GraphicElement el; + el.type = GraphicElement::G_BOX; + el.style = decal.active ? 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 + + (4*chip_info->bel_data[bel.index].z) * logic_cell_pitch; + el.y2 = chip_info->bel_data[bel.index].y + logic_cell_y2 + + (4*chip_info->bel_data[bel.index].z + 3) * logic_cell_pitch; + ret.push_back(el); } if (bel_type == TYPE_ICESTORM_RAM) { for (int i = 0; i < 2; i++) { - int tx = chip_info->bel_data[bel.index].x; - int ty = chip_info->bel_data[bel.index].y + i; - GraphicElement el; el.type = GraphicElement::G_BOX; el.style = decal.active ? 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; - el.y2 = chip_info->bel_data[bel.index].y + logic_cell_y2 + 7 * logic_cell_pitch; - el.z = 0; + el.y1 = chip_info->bel_data[bel.index].y + logic_cell_y1 + i; + el.y2 = chip_info->bel_data[bel.index].y + logic_cell_y2 + i + 7 * logic_cell_pitch; ret.push_back(el); - - // 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; - main_sw.y2 = ty + main_swbox_y2; - ret.push_back(main_sw); - - // 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); } } } -- cgit v1.2.3 From 467e0926f920f23b7cb2241cf52dbcfe84646fed Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Thu, 26 Jul 2018 16:38:11 +0200 Subject: Add getWireType()/getPipType() API Signed-off-by: Clifford Wolf --- ice40/arch.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'ice40') diff --git a/ice40/arch.h b/ice40/arch.h index 123b408c..51cbe725 100644 --- a/ice40/arch.h +++ b/ice40/arch.h @@ -469,6 +469,8 @@ struct Arch : BaseCtx return id(chip_info->wire_data[wire.index].name.get()); } + IdString getWireType(WireId wire) const { return IdString(); } + uint32_t getWireChecksum(WireId wire) const { return wire.index; } void bindWire(WireId wire, IdString net, PlaceStrength strength) @@ -611,6 +613,8 @@ struct Arch : BaseCtx IdString getPipName(PipId pip) const; + IdString getPipType(PipId pip) const { return IdString(); } + uint32_t getPipChecksum(PipId pip) const { return pip.index; } WireId getPipSrcWire(PipId pip) const -- cgit v1.2.3 From 03f92948d1504c32049da065c0e73e01f96d8033 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Thu, 26 Jul 2018 17:14:56 +0200 Subject: clangformat and GraphicElement::style comments Signed-off-by: Clifford Wolf --- ice40/arch.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ice40') diff --git a/ice40/arch.cc b/ice40/arch.cc index 55252f2c..d08463d2 100644 --- a/ice40/arch.cc +++ b/ice40/arch.cc @@ -745,9 +745,9 @@ std::vector Arch::getDecalGraphics(DecalId decal) const 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 + - (4*chip_info->bel_data[bel.index].z) * logic_cell_pitch; + (4 * chip_info->bel_data[bel.index].z) * logic_cell_pitch; el.y2 = chip_info->bel_data[bel.index].y + logic_cell_y2 + - (4*chip_info->bel_data[bel.index].z + 3) * logic_cell_pitch; + (4 * chip_info->bel_data[bel.index].z + 3) * logic_cell_pitch; ret.push_back(el); } -- cgit v1.2.3 From c37d2baaf647fec35c28a8e639b0d4a74643537d Mon Sep 17 00:00:00 2001 From: Sergiusz Bazanski Date: Thu, 26 Jul 2018 16:39:19 +0100 Subject: common: rename GraphicElement::{style,type} enums, add _MAX members --- ice40/arch.cc | 28 ++++++++++++++-------------- ice40/gfx.cc | 6 +++--- ice40/main.cc | 4 ++-- 3 files changed, 19 insertions(+), 19 deletions(-) (limited to 'ice40') diff --git a/ice40/arch.cc b/ice40/arch.cc index d08463d2..3803f842 100644 --- a/ice40/arch.cc +++ b/ice40/arch.cc @@ -654,8 +654,8 @@ std::vector Arch::getDecalGraphics(DecalId decal) const if (type == GroupId::TYPE_FRAME) { GraphicElement el; - el.type = GraphicElement::G_LINE; - el.style = GraphicElement::G_FRAME; + el.type = GraphicElement::TYPE_LINE; + el.style = GraphicElement::STYLE_FRAME; el.x1 = x + 0.01, el.x2 = x + 0.02, el.y1 = y + 0.01, el.y2 = y + 0.01; ret.push_back(el); @@ -680,8 +680,8 @@ std::vector Arch::getDecalGraphics(DecalId decal) const if (type == GroupId::TYPE_MAIN_SW) { GraphicElement el; - el.type = GraphicElement::G_BOX; - el.style = GraphicElement::G_FRAME; + el.type = GraphicElement::TYPE_BOX; + el.style = GraphicElement::STYLE_FRAME; el.x1 = x + main_swbox_x1; el.x2 = x + main_swbox_x2; @@ -692,8 +692,8 @@ std::vector Arch::getDecalGraphics(DecalId decal) const if (type == GroupId::TYPE_LOCAL_SW) { GraphicElement el; - el.type = GraphicElement::G_BOX; - el.style = GraphicElement::G_FRAME; + el.type = GraphicElement::TYPE_BOX; + el.style = GraphicElement::STYLE_FRAME; el.x1 = x + local_swbox_x1; el.x2 = x + local_swbox_x2; @@ -707,7 +707,7 @@ std::vector Arch::getDecalGraphics(DecalId decal) const 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; + GraphicElement::style_t style = decal.active ? GraphicElement::STYLE_ACTIVE : GraphicElement::STYLE_INACTIVE; for (int i = 0; i < n; i++) gfxTileWire(ret, p[i].x, p[i].y, GfxTileWireId(p[i].index), style); @@ -715,7 +715,7 @@ std::vector Arch::getDecalGraphics(DecalId decal) const 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; + GraphicElement::style_t style = decal.active ? GraphicElement::STYLE_ACTIVE : GraphicElement::STYLE_HIDDEN; gfxTilePip(ret, p.x, p.y, GfxTileWireId(p.src_seg), GfxTileWireId(p.dst_seg), style); } @@ -727,8 +727,8 @@ std::vector Arch::getDecalGraphics(DecalId decal) const if (bel_type == TYPE_ICESTORM_LC) { GraphicElement el; - el.type = GraphicElement::G_BOX; - el.style = decal.active ? GraphicElement::G_ACTIVE : GraphicElement::G_INACTIVE; + el.type = GraphicElement::TYPE_BOX; + el.style = decal.active ? GraphicElement::STYLE_ACTIVE : GraphicElement::STYLE_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 + @@ -740,8 +740,8 @@ std::vector Arch::getDecalGraphics(DecalId decal) const if (bel_type == TYPE_SB_IO) { GraphicElement el; - el.type = GraphicElement::G_BOX; - el.style = decal.active ? GraphicElement::G_ACTIVE : GraphicElement::G_INACTIVE; + el.type = GraphicElement::TYPE_BOX; + el.style = decal.active ? GraphicElement::STYLE_ACTIVE : GraphicElement::STYLE_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 + @@ -754,8 +754,8 @@ std::vector Arch::getDecalGraphics(DecalId decal) const if (bel_type == TYPE_ICESTORM_RAM) { for (int i = 0; i < 2; i++) { GraphicElement el; - el.type = GraphicElement::G_BOX; - el.style = decal.active ? GraphicElement::G_ACTIVE : GraphicElement::G_INACTIVE; + el.type = GraphicElement::TYPE_BOX; + el.style = decal.active ? GraphicElement::STYLE_ACTIVE : GraphicElement::STYLE_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 + i; diff --git a/ice40/gfx.cc b/ice40/gfx.cc index 0a583e8e..0798862a 100644 --- a/ice40/gfx.cc +++ b/ice40/gfx.cc @@ -24,7 +24,7 @@ NEXTPNR_NAMESPACE_BEGIN void gfxTileWire(std::vector &g, int x, int y, GfxTileWireId id, GraphicElement::style_t style) { GraphicElement el; - el.type = GraphicElement::G_LINE; + el.type = GraphicElement::TYPE_LINE; el.style = style; // Horizontal Span-4 Wires @@ -647,7 +647,7 @@ void pipGfx(std::vector &g, int x, int y, float x1, float y1, fl float ty = 0.5 * (y1 + y2); GraphicElement el; - el.type = GraphicElement::G_ARROW; + el.type = GraphicElement::TYPE_ARROW; el.style = style; if (fabsf(x1 - swx1) < 0.001 && fabsf(x2 - swx1) < 0.001) { @@ -704,7 +704,7 @@ void gfxTilePip(std::vector &g, int x, int y, GfxTileWireId src, if (src == TILE_WIRE_CARRY_IN && dst == TILE_WIRE_CARRY_IN_MUX) { GraphicElement el; - el.type = GraphicElement::G_ARROW; + el.type = GraphicElement::TYPE_ARROW; el.style = style; el.x1 = x + logic_cell_x1 + 0.005 * 3; el.x2 = el.x1; diff --git a/ice40/main.cc b/ice40/main.cc index 6201831a..32815b26 100644 --- a/ice40/main.cc +++ b/ice40/main.cc @@ -52,13 +52,13 @@ void svg_dump_decal(const Context *ctx, const DecalXY &decal) const std::string style = "stroke=\"black\" stroke-width=\"0.1\" fill=\"none\""; for (auto &el : ctx->getDecalGraphics(decal.decal)) { - if (el.type == GraphicElement::G_BOX) { + if (el.type == GraphicElement::TYPE_BOX) { std::cout << "\n"; } - if (el.type == GraphicElement::G_LINE) { + if (el.type == GraphicElement::TYPE_LINE) { std::cout << "\n"; -- cgit v1.2.3