diff options
Diffstat (limited to 'ice40')
| -rw-r--r-- | ice40/arch.cc | 267 | ||||
| -rw-r--r-- | ice40/arch.h | 4 | ||||
| -rw-r--r-- | ice40/chipdb.py | 3 | ||||
| -rw-r--r-- | ice40/gfx.cc | 15 | ||||
| -rw-r--r-- | ice40/main.cc | 4 | 
5 files changed, 189 insertions, 104 deletions
diff --git a/ice40/arch.cc b/ice40/arch.cc index dedc59bc..3803f842 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<GroupId> Arch::getGroups() const  {      std::vector<GroupId> 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,22 +644,70 @@ std::vector<GraphicElement> Arch::getDecalGraphics(DecalId decal) const      std::vector<GraphicElement> 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::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); +            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::TYPE_BOX; +            el.style = GraphicElement::STYLE_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::TYPE_BOX; +            el.style = GraphicElement::STYLE_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) {          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); @@ -575,7 +715,7 @@ std::vector<GraphicElement> 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);      } @@ -587,111 +727,40 @@ std::vector<GraphicElement> 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 +                      (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::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 + +                    (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.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; -                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);              }          }      } 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 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: diff --git a/ice40/gfx.cc b/ice40/gfx.cc index 1b01cbd8..0798862a 100644 --- a/ice40/gfx.cc +++ b/ice40/gfx.cc @@ -24,7 +24,7 @@ NEXTPNR_NAMESPACE_BEGIN  void gfxTileWire(std::vector<GraphicElement> &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<GraphicElement> &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) { @@ -701,6 +701,17 @@ void gfxTilePip(std::vector<GraphicElement> &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::TYPE_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 diff --git a/ice40/main.cc b/ice40/main.cc index 2560387b..865eea9e 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 << "<rect x=\"" << (offset + scale * (decal.x + el.x1)) << "\" y=\""                        << (offset + scale * (decal.y + el.y1)) << "\" height=\"" << (scale * (el.y2 - el.y1))                        << "\" width=\"" << (scale * (el.x2 - el.x1)) << "\" " << style << "/>\n";          } -        if (el.type == GraphicElement::G_LINE) { +        if (el.type == GraphicElement::TYPE_LINE) {              std::cout << "<line x1=\"" << (offset + scale * (decal.x + el.x1)) << "\" y1=\""                        << (offset + scale * (decal.y + el.y1)) << "\" x2=\"" << (offset + scale * (decal.x + el.x2))                        << "\" y2=\"" << (offset + scale * (decal.y + el.y2)) << "\" " << style << "/>\n";  | 
