2020-12-30 22:59:55 +08:00
|
|
|
/*
|
|
|
|
* nextpnr -- Next Generation Place and Route
|
|
|
|
*
|
2021-06-09 20:09:08 +08:00
|
|
|
* Copyright (C) 2018 Claire Xenia Wolf <claire@yosyshq.com>
|
2020-12-30 22:59:55 +08:00
|
|
|
* Copyright (C) 2020 Pepijn de Vos <pepijn@symbioticeda.com>
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-03-13 05:09:44 +08:00
|
|
|
#ifndef GOWIN_ARCH_H
|
|
|
|
#define GOWIN_ARCH_H
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "base_arch.h"
|
|
|
|
#include "idstring.h"
|
|
|
|
#include "nextpnr_namespaces.h"
|
|
|
|
#include "nextpnr_types.h"
|
2020-12-30 22:59:55 +08:00
|
|
|
|
2022-07-04 08:32:39 +08:00
|
|
|
#include "globals.h"
|
|
|
|
|
2020-12-30 22:59:55 +08:00
|
|
|
NEXTPNR_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
template <typename T> struct RelPtr
|
|
|
|
{
|
|
|
|
int32_t offset;
|
|
|
|
|
|
|
|
// void set(const T *ptr) {
|
|
|
|
// offset = reinterpret_cast<const char*>(ptr) -
|
|
|
|
// reinterpret_cast<const char*>(this);
|
|
|
|
// }
|
|
|
|
|
|
|
|
const T *get() const { return reinterpret_cast<const T *>(reinterpret_cast<const char *>(this) + offset); }
|
|
|
|
|
2020-12-31 00:49:55 +08:00
|
|
|
T *get_mut() const
|
|
|
|
{
|
|
|
|
return const_cast<T *>(reinterpret_cast<const T *>(reinterpret_cast<const char *>(this) + offset));
|
|
|
|
}
|
2020-12-30 22:59:55 +08:00
|
|
|
|
2021-03-13 05:09:44 +08:00
|
|
|
const T &operator[](std::size_t index) const { return get()[index]; }
|
2020-12-30 22:59:55 +08:00
|
|
|
|
|
|
|
const T &operator*() const { return *(get()); }
|
|
|
|
|
|
|
|
const T *operator->() const { return get(); }
|
|
|
|
|
|
|
|
RelPtr(const RelPtr &) = delete;
|
|
|
|
RelPtr &operator=(const RelPtr &) = delete;
|
|
|
|
};
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct PairPOD {
|
|
|
|
uint16_t dest_id;
|
|
|
|
uint16_t src_id;
|
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct BelsPOD {
|
|
|
|
uint16_t type_id;
|
|
|
|
uint16_t num_ports;
|
|
|
|
RelPtr<PairPOD> ports;
|
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct TilePOD /*TidePOD*/ {
|
|
|
|
uint32_t num_bels;
|
|
|
|
RelPtr<BelsPOD> bels;
|
|
|
|
uint32_t num_pips;
|
|
|
|
RelPtr<PairPOD> pips;
|
|
|
|
uint32_t num_clock_pips;
|
|
|
|
RelPtr<PairPOD> clock_pips;
|
|
|
|
uint32_t num_aliases;
|
|
|
|
RelPtr<PairPOD> aliases;
|
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct GlobalAliasPOD {
|
|
|
|
uint16_t dest_row;
|
|
|
|
uint16_t dest_col;
|
|
|
|
uint16_t dest_id;
|
|
|
|
uint16_t src_row;
|
|
|
|
uint16_t src_col;
|
|
|
|
uint16_t src_id;
|
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct TimingPOD {
|
|
|
|
uint32_t name_id;
|
|
|
|
// input, output
|
|
|
|
uint32_t ff;
|
|
|
|
uint32_t fr;
|
|
|
|
uint32_t rf;
|
|
|
|
uint32_t rr;
|
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct TimingGroupPOD {
|
|
|
|
uint32_t name_id;
|
|
|
|
uint32_t num_timings;
|
|
|
|
RelPtr<TimingPOD> timings;
|
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct TimingGroupsPOD {
|
|
|
|
TimingGroupPOD lut;
|
|
|
|
TimingGroupPOD alu;
|
|
|
|
TimingGroupPOD sram;
|
|
|
|
TimingGroupPOD dff;
|
2020-12-31 00:49:55 +08:00
|
|
|
// TimingGroupPOD dl;
|
|
|
|
// TimingGroupPOD iddroddr;
|
|
|
|
// TimingGroupPOD pll;
|
|
|
|
// TimingGroupPOD dll;
|
2020-12-30 22:59:55 +08:00
|
|
|
TimingGroupPOD bram;
|
2020-12-31 00:49:55 +08:00
|
|
|
// TimingGroupPOD dsp;
|
2020-12-30 22:59:55 +08:00
|
|
|
TimingGroupPOD fanout;
|
|
|
|
TimingGroupPOD glbsrc;
|
|
|
|
TimingGroupPOD hclk;
|
|
|
|
TimingGroupPOD iodelay;
|
2020-12-31 00:49:55 +08:00
|
|
|
// TimingGroupPOD io;
|
|
|
|
// TimingGroupPOD iregoreg;
|
|
|
|
TimingGroupPOD wire;
|
2020-12-30 22:59:55 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct TimingClassPOD {
|
|
|
|
uint32_t name_id;
|
|
|
|
uint32_t num_groups;
|
|
|
|
RelPtr<TimingGroupsPOD> groups;
|
|
|
|
});
|
|
|
|
|
2021-11-04 16:55:00 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct PartnumberPOD {
|
|
|
|
uint32_t name_id;
|
|
|
|
uint32_t package_id;
|
|
|
|
uint32_t device_id;
|
2021-11-05 15:02:45 +08:00
|
|
|
uint32_t speed_id;
|
2021-11-04 16:55:00 +08:00
|
|
|
});
|
|
|
|
|
2022-11-25 18:49:26 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct PinPOD {
|
|
|
|
uint16_t index_id;
|
|
|
|
uint16_t loc_id;
|
|
|
|
uint32_t num_cfgs;
|
|
|
|
RelPtr<uint32_t> cfgs;
|
|
|
|
});
|
|
|
|
|
2020-12-30 22:59:55 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct PackagePOD {
|
|
|
|
uint32_t name_id;
|
|
|
|
uint32_t num_pins;
|
2022-11-25 18:49:26 +08:00
|
|
|
RelPtr<PinPOD> pins;
|
2020-12-30 22:59:55 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct VariantPOD {
|
|
|
|
uint32_t name_id;
|
|
|
|
uint32_t num_packages;
|
|
|
|
RelPtr<PackagePOD> packages;
|
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct DatabasePOD {
|
|
|
|
RelPtr<char> family;
|
|
|
|
uint32_t version;
|
|
|
|
uint16_t rows;
|
|
|
|
uint16_t cols;
|
|
|
|
RelPtr<RelPtr<TilePOD>> grid;
|
|
|
|
uint32_t num_aliases;
|
|
|
|
RelPtr<GlobalAliasPOD> aliases;
|
|
|
|
uint32_t num_speeds;
|
|
|
|
RelPtr<TimingClassPOD> speeds;
|
2021-11-04 16:55:00 +08:00
|
|
|
uint32_t num_partnumbers;
|
|
|
|
RelPtr<PartnumberPOD> partnumber_packages;
|
2020-12-30 22:59:55 +08:00
|
|
|
uint32_t num_variants;
|
|
|
|
RelPtr<VariantPOD> variants;
|
|
|
|
uint16_t num_constids;
|
|
|
|
uint16_t num_ids;
|
|
|
|
RelPtr<RelPtr<char>> id_strs;
|
|
|
|
});
|
|
|
|
|
|
|
|
struct ArchArgs
|
|
|
|
{
|
|
|
|
std::string family;
|
2021-11-04 16:55:00 +08:00
|
|
|
std::string partnumber;
|
2020-12-30 22:59:55 +08:00
|
|
|
// y = mx + c relationship between distance and delay for interconnect
|
|
|
|
// delay estimates
|
|
|
|
double delayScale = 0.4, delayOffset = 0.4;
|
2022-01-29 12:45:17 +08:00
|
|
|
bool gui;
|
2020-12-30 22:59:55 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct WireInfo;
|
|
|
|
|
|
|
|
struct PipInfo
|
|
|
|
{
|
|
|
|
IdString name, type;
|
|
|
|
std::map<IdString, std::string> attrs;
|
|
|
|
NetInfo *bound_net;
|
|
|
|
WireId srcWire, dstWire;
|
2021-02-19 18:39:57 +08:00
|
|
|
DelayQuad delay;
|
2022-01-29 12:45:17 +08:00
|
|
|
DecalXY decalxy_active, decalxy_inactive;
|
2020-12-30 22:59:55 +08:00
|
|
|
Loc loc;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct WireInfo
|
|
|
|
{
|
|
|
|
IdString name, type;
|
|
|
|
std::map<IdString, std::string> attrs;
|
|
|
|
NetInfo *bound_net;
|
|
|
|
std::vector<PipId> downhill, uphill;
|
|
|
|
BelPin uphill_bel_pin;
|
|
|
|
std::vector<BelPin> downhill_bel_pins;
|
|
|
|
std::vector<BelPin> bel_pins;
|
2022-01-29 12:45:17 +08:00
|
|
|
DecalXY decalxy_active, decalxy_inactive;
|
2020-12-30 22:59:55 +08:00
|
|
|
int x, y;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PinInfo
|
|
|
|
{
|
|
|
|
IdString name;
|
|
|
|
WireId wire;
|
|
|
|
PortType type;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BelInfo
|
|
|
|
{
|
|
|
|
IdString name, type;
|
|
|
|
std::map<IdString, std::string> attrs;
|
|
|
|
CellInfo *bound_cell;
|
2021-06-02 17:01:36 +08:00
|
|
|
dict<IdString, PinInfo> pins;
|
2022-12-04 13:06:44 +08:00
|
|
|
std::vector<IdString> pin_cfgs;
|
2022-01-29 12:45:17 +08:00
|
|
|
DecalXY decalxy_active, decalxy_inactive;
|
2020-12-30 22:59:55 +08:00
|
|
|
int x, y, z;
|
|
|
|
bool gb;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GroupInfo
|
|
|
|
{
|
|
|
|
IdString name;
|
|
|
|
std::vector<BelId> bels;
|
|
|
|
std::vector<WireId> wires;
|
|
|
|
std::vector<PipId> pips;
|
|
|
|
std::vector<GroupId> groups;
|
|
|
|
DecalXY decalxy;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CellDelayKey
|
|
|
|
{
|
|
|
|
IdString from, to;
|
|
|
|
inline bool operator==(const CellDelayKey &other) const { return from == other.from && to == other.to; }
|
2021-06-02 17:01:36 +08:00
|
|
|
unsigned int hash() const { return mkhash(from.hash(), to.hash()); }
|
2020-12-30 22:59:55 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CellTiming
|
|
|
|
{
|
2021-06-02 17:01:36 +08:00
|
|
|
dict<IdString, TimingPortClass> portClasses;
|
|
|
|
dict<CellDelayKey, DelayQuad> combDelays;
|
|
|
|
dict<IdString, std::vector<TimingClockingInfo>> clockingInfo;
|
2020-12-30 22:59:55 +08:00
|
|
|
};
|
|
|
|
|
2021-02-17 23:58:00 +08:00
|
|
|
struct ArchRanges : BaseArchRanges
|
2021-02-05 21:46:56 +08:00
|
|
|
{
|
2021-02-08 18:29:50 +08:00
|
|
|
using ArchArgsT = ArchArgs;
|
2021-02-05 21:46:56 +08:00
|
|
|
// Bels
|
2021-02-08 18:29:50 +08:00
|
|
|
using AllBelsRangeT = const std::vector<BelId> &;
|
|
|
|
using TileBelsRangeT = const std::vector<BelId> &;
|
|
|
|
using BelAttrsRangeT = const std::map<IdString, std::string> &;
|
|
|
|
using BelPinsRangeT = std::vector<IdString>;
|
2021-02-10 19:54:54 +08:00
|
|
|
using CellBelPinRangeT = std::array<IdString, 1>;
|
2021-02-05 21:46:56 +08:00
|
|
|
// Wires
|
2021-02-08 18:29:50 +08:00
|
|
|
using AllWiresRangeT = const std::vector<WireId> &;
|
|
|
|
using DownhillPipRangeT = const std::vector<PipId> &;
|
|
|
|
using UphillPipRangeT = const std::vector<PipId> &;
|
|
|
|
using WireBelPinRangeT = const std::vector<BelPin> &;
|
|
|
|
using WireAttrsRangeT = const std::map<IdString, std::string> &;
|
2021-02-05 21:46:56 +08:00
|
|
|
// Pips
|
2021-02-08 18:29:50 +08:00
|
|
|
using AllPipsRangeT = const std::vector<PipId> &;
|
|
|
|
using PipAttrsRangeT = const std::map<IdString, std::string> &;
|
2021-02-05 21:46:56 +08:00
|
|
|
// Groups
|
2021-02-08 18:29:50 +08:00
|
|
|
using AllGroupsRangeT = std::vector<GroupId>;
|
|
|
|
using GroupBelsRangeT = const std::vector<BelId> &;
|
|
|
|
using GroupWiresRangeT = const std::vector<WireId> &;
|
|
|
|
using GroupPipsRangeT = const std::vector<PipId> &;
|
|
|
|
using GroupGroupsRangeT = const std::vector<GroupId> &;
|
2021-02-05 21:46:56 +08:00
|
|
|
};
|
|
|
|
|
2023-01-30 16:59:09 +08:00
|
|
|
enum class PLL // fixed PLL locations
|
|
|
|
{
|
|
|
|
left,
|
|
|
|
right
|
|
|
|
};
|
|
|
|
|
2021-02-05 21:46:56 +08:00
|
|
|
struct Arch : BaseArch<ArchRanges>
|
2020-12-30 22:59:55 +08:00
|
|
|
{
|
|
|
|
std::string family;
|
|
|
|
std::string device;
|
|
|
|
const PackagePOD *package;
|
|
|
|
const TimingGroupsPOD *speed;
|
|
|
|
|
2021-06-02 17:01:36 +08:00
|
|
|
dict<IdString, WireInfo> wires;
|
|
|
|
dict<IdString, PipInfo> pips;
|
|
|
|
dict<IdString, BelInfo> bels;
|
|
|
|
dict<GroupId, GroupInfo> groups;
|
2020-12-30 22:59:55 +08:00
|
|
|
|
|
|
|
// These functions include useful errors if not found
|
|
|
|
WireInfo &wire_info(IdString wire);
|
2022-03-15 09:02:37 +08:00
|
|
|
PipInfo &pip_info(IdString pip);
|
|
|
|
BelInfo &bel_info(IdString bel);
|
2022-06-23 09:42:58 +08:00
|
|
|
NetInfo &net_info(IdString net);
|
2020-12-30 22:59:55 +08:00
|
|
|
|
|
|
|
std::vector<IdString> bel_ids, wire_ids, pip_ids;
|
|
|
|
|
2021-06-02 17:01:36 +08:00
|
|
|
dict<Loc, BelId> bel_by_loc;
|
2020-12-30 22:59:55 +08:00
|
|
|
std::vector<std::vector<std::vector<BelId>>> bels_by_tile;
|
|
|
|
|
2021-06-02 17:01:36 +08:00
|
|
|
dict<DecalId, std::vector<GraphicElement>> decal_graphics;
|
2020-12-30 22:59:55 +08:00
|
|
|
|
2021-12-26 10:05:35 +08:00
|
|
|
int gridDimX = 0, gridDimY = 0;
|
2020-12-30 22:59:55 +08:00
|
|
|
std::vector<std::vector<int>> tileBelDimZ;
|
|
|
|
std::vector<std::vector<int>> tilePipDimZ;
|
|
|
|
|
2021-06-02 17:01:36 +08:00
|
|
|
dict<IdString, CellTiming> cellTiming;
|
2020-12-30 22:59:55 +08:00
|
|
|
|
|
|
|
void addWire(IdString name, IdString type, int x, int y);
|
2021-02-19 18:39:57 +08:00
|
|
|
void addPip(IdString name, IdString type, IdString srcWire, IdString dstWire, DelayQuad delay, Loc loc);
|
2020-12-30 22:59:55 +08:00
|
|
|
|
|
|
|
void addBel(IdString name, IdString type, Loc loc, bool gb);
|
|
|
|
void addBelInput(IdString bel, IdString name, IdString wire);
|
|
|
|
void addBelOutput(IdString bel, IdString name, IdString wire);
|
|
|
|
void addBelInout(IdString bel, IdString name, IdString wire);
|
|
|
|
|
2022-01-29 12:45:17 +08:00
|
|
|
void addGroup(IdString name);
|
2020-12-30 22:59:55 +08:00
|
|
|
void addGroupBel(IdString group, IdString bel);
|
|
|
|
void addGroupWire(IdString group, IdString wire);
|
|
|
|
void addGroupPip(IdString group, IdString pip);
|
|
|
|
void addGroupGroup(IdString group, IdString grp);
|
|
|
|
|
|
|
|
void addDecalGraphic(DecalId decal, const GraphicElement &graphic);
|
2022-01-29 12:45:17 +08:00
|
|
|
void setWireDecal(WireId wire, DecalXY active, DecalXY inactive);
|
|
|
|
void setPipDecal(PipId pip, DecalXY active, DecalXY inactive);
|
|
|
|
void setBelDecal(BelId bel, DecalXY active, DecalXY inactive);
|
|
|
|
void setDefaultDecals(void);
|
2020-12-30 22:59:55 +08:00
|
|
|
void setGroupDecal(GroupId group, DecalXY decalxy);
|
2022-01-29 12:45:17 +08:00
|
|
|
std::vector<GraphicElement> getDecalGraphics(DecalId decal) const override;
|
|
|
|
DecalXY getBelDecal(BelId bel) const override;
|
|
|
|
DecalXY getGroupDecal(GroupId grp) const override;
|
|
|
|
DecalXY getPipDecal(PipId pip) const override;
|
|
|
|
DecalXY getWireDecal(WireId pip) const override;
|
2020-12-30 22:59:55 +08:00
|
|
|
|
|
|
|
void setWireAttr(IdString wire, IdString key, const std::string &value);
|
|
|
|
void setPipAttr(IdString pip, IdString key, const std::string &value);
|
|
|
|
void setBelAttr(IdString bel, IdString key, const std::string &value);
|
|
|
|
|
|
|
|
void setDelayScaling(double scale, double offset);
|
|
|
|
|
|
|
|
void addCellTimingClock(IdString cell, IdString port);
|
2022-07-05 18:02:12 +08:00
|
|
|
void addCellTimingClass(IdString cell, IdString port, TimingPortClass cls);
|
2021-02-19 18:39:57 +08:00
|
|
|
void addCellTimingDelay(IdString cell, IdString fromPort, IdString toPort, DelayQuad delay);
|
|
|
|
void addCellTimingSetupHold(IdString cell, IdString port, IdString clock, DelayPair setup, DelayPair hold);
|
|
|
|
void addCellTimingClockToOut(IdString cell, IdString port, IdString clock, DelayQuad clktoq);
|
2020-12-30 22:59:55 +08:00
|
|
|
|
2020-12-31 00:49:55 +08:00
|
|
|
IdString wireToGlobal(int &row, int &col, const DatabasePOD *db, IdString &wire);
|
2021-02-19 18:39:57 +08:00
|
|
|
DelayQuad getWireTypeDelay(IdString wire);
|
2020-12-30 22:59:55 +08:00
|
|
|
void read_cst(std::istream &in);
|
2021-10-07 16:38:33 +08:00
|
|
|
void addMuxBels(const DatabasePOD *db, int row, int col);
|
2020-12-30 22:59:55 +08:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
|
|
|
// Common Arch API. Every arch must provide the following methods.
|
|
|
|
|
|
|
|
ArchArgs args;
|
|
|
|
Arch(ArchArgs args);
|
|
|
|
|
2021-02-05 21:46:56 +08:00
|
|
|
std::string getChipName() const override { return device; }
|
2020-12-30 22:59:55 +08:00
|
|
|
|
2021-02-06 02:41:35 +08:00
|
|
|
ArchArgs archArgs() const override { return args; }
|
2022-02-17 01:09:54 +08:00
|
|
|
IdString archArgsToId(ArchArgs args) const override { return id_none; }
|
2020-12-30 22:59:55 +08:00
|
|
|
|
2021-02-05 21:46:56 +08:00
|
|
|
int getGridDimX() const override { return gridDimX; }
|
|
|
|
int getGridDimY() const override { return gridDimY; }
|
2021-02-25 19:21:39 +08:00
|
|
|
int getTileBelDimZ(int x, int y) const override { return tileBelDimZ[x][y]; }
|
|
|
|
int getTilePipDimZ(int x, int y) const override { return tilePipDimZ[x][y]; }
|
|
|
|
char getNameDelimiter() const override
|
2021-02-01 20:03:16 +08:00
|
|
|
{
|
|
|
|
return ' '; /* use a non-existent delimiter as we aren't using IdStringLists yet */
|
|
|
|
}
|
2020-12-30 22:59:55 +08:00
|
|
|
|
2021-02-05 21:46:56 +08:00
|
|
|
BelId getBelByName(IdStringList name) const override;
|
|
|
|
IdStringList getBelName(BelId bel) const override;
|
|
|
|
Loc getBelLocation(BelId bel) const override;
|
|
|
|
BelId getBelByLocation(Loc loc) const override;
|
|
|
|
const std::vector<BelId> &getBelsByTile(int x, int y) const override;
|
|
|
|
bool getBelGlobalBuf(BelId bel) const override;
|
|
|
|
void bindBel(BelId bel, CellInfo *cell, PlaceStrength strength) override;
|
|
|
|
void unbindBel(BelId bel) override;
|
|
|
|
bool checkBelAvail(BelId bel) const override;
|
|
|
|
CellInfo *getBoundBelCell(BelId bel) const override;
|
|
|
|
CellInfo *getConflictingBelCell(BelId bel) const override;
|
|
|
|
const std::vector<BelId> &getBels() const override;
|
|
|
|
IdString getBelType(BelId bel) const override;
|
|
|
|
const std::map<IdString, std::string> &getBelAttrs(BelId bel) const override;
|
|
|
|
WireId getBelPinWire(BelId bel, IdString pin) const override;
|
|
|
|
PortType getBelPinType(BelId bel, IdString pin) const override;
|
|
|
|
std::vector<IdString> getBelPins(BelId bel) const override;
|
2021-02-24 05:49:01 +08:00
|
|
|
std::array<IdString, 1> getBelPinsForCellPin(const CellInfo *cell_info, IdString pin) const override;
|
2023-03-22 15:15:17 +08:00
|
|
|
// Placement validity checks
|
|
|
|
virtual bool isValidBelForCellType(IdString cell_type, BelId bel) const override
|
|
|
|
{
|
|
|
|
return cell_type == id_DUMMY_CELL || cell_type == this->getBelType(bel);
|
|
|
|
}
|
2021-02-05 21:46:56 +08:00
|
|
|
|
|
|
|
WireId getWireByName(IdStringList name) const override;
|
|
|
|
IdStringList getWireName(WireId wire) const override;
|
|
|
|
IdString getWireType(WireId wire) const override;
|
|
|
|
const std::map<IdString, std::string> &getWireAttrs(WireId wire) const override;
|
|
|
|
void bindWire(WireId wire, NetInfo *net, PlaceStrength strength) override;
|
|
|
|
void unbindWire(WireId wire) override;
|
|
|
|
bool checkWireAvail(WireId wire) const override;
|
|
|
|
NetInfo *getBoundWireNet(WireId wire) const override;
|
|
|
|
WireId getConflictingWireWire(WireId wire) const override { return wire; }
|
|
|
|
NetInfo *getConflictingWireNet(WireId wire) const override;
|
2021-02-19 18:39:57 +08:00
|
|
|
DelayQuad getWireDelay(WireId wire) const override { return DelayQuad(0); }
|
2021-02-05 21:46:56 +08:00
|
|
|
const std::vector<WireId> &getWires() const override;
|
|
|
|
const std::vector<BelPin> &getWireBelPins(WireId wire) const override;
|
|
|
|
|
|
|
|
PipId getPipByName(IdStringList name) const override;
|
|
|
|
IdStringList getPipName(PipId pip) const override;
|
|
|
|
IdString getPipType(PipId pip) const override;
|
|
|
|
const std::map<IdString, std::string> &getPipAttrs(PipId pip) const override;
|
|
|
|
void bindPip(PipId pip, NetInfo *net, PlaceStrength strength) override;
|
|
|
|
void unbindPip(PipId pip) override;
|
|
|
|
bool checkPipAvail(PipId pip) const override;
|
|
|
|
NetInfo *getBoundPipNet(PipId pip) const override;
|
|
|
|
WireId getConflictingPipWire(PipId pip) const override;
|
|
|
|
NetInfo *getConflictingPipNet(PipId pip) const override;
|
|
|
|
const std::vector<PipId> &getPips() const override;
|
|
|
|
Loc getPipLocation(PipId pip) const override;
|
|
|
|
WireId getPipSrcWire(PipId pip) const override;
|
|
|
|
WireId getPipDstWire(PipId pip) const override;
|
2021-02-19 18:39:57 +08:00
|
|
|
DelayQuad getPipDelay(PipId pip) const override;
|
2021-02-05 21:46:56 +08:00
|
|
|
const std::vector<PipId> &getPipsDownhill(WireId wire) const override;
|
|
|
|
const std::vector<PipId> &getPipsUphill(WireId wire) const override;
|
|
|
|
|
|
|
|
GroupId getGroupByName(IdStringList name) const override;
|
|
|
|
IdStringList getGroupName(GroupId group) const override;
|
|
|
|
std::vector<GroupId> getGroups() const override;
|
|
|
|
const std::vector<BelId> &getGroupBels(GroupId group) const override;
|
|
|
|
const std::vector<WireId> &getGroupWires(GroupId group) const override;
|
|
|
|
const std::vector<PipId> &getGroupPips(GroupId group) const override;
|
|
|
|
const std::vector<GroupId> &getGroupGroups(GroupId group) const override;
|
|
|
|
|
|
|
|
delay_t estimateDelay(WireId src, WireId dst) const override;
|
2021-12-20 00:41:34 +08:00
|
|
|
delay_t predictDelay(BelId src_bel, IdString src_pin, BelId dst_bel, IdString dst_pin) const override;
|
2021-02-05 21:46:56 +08:00
|
|
|
delay_t getDelayEpsilon() const override { return 0.01; }
|
|
|
|
delay_t getRipupDelayPenalty() const override { return 0.4; }
|
|
|
|
float getDelayNS(delay_t v) const override { return v; }
|
|
|
|
|
2021-02-19 18:39:57 +08:00
|
|
|
delay_t getDelayFromNS(float ns) const override { return ns; }
|
2020-12-30 22:59:55 +08:00
|
|
|
|
2021-02-05 21:46:56 +08:00
|
|
|
uint32_t getDelayChecksum(delay_t v) const override { return 0; }
|
2020-12-30 22:59:55 +08:00
|
|
|
|
2022-12-07 17:00:53 +08:00
|
|
|
BoundingBox getRouteBoundingBox(WireId src, WireId dst) const override;
|
2020-12-30 22:59:55 +08:00
|
|
|
|
2021-02-05 21:46:56 +08:00
|
|
|
bool pack() override;
|
|
|
|
bool place() override;
|
|
|
|
bool route() override;
|
2020-12-30 22:59:55 +08:00
|
|
|
|
2021-02-25 19:21:39 +08:00
|
|
|
bool getCellDelay(const CellInfo *cell, IdString fromPort, IdString toPort, DelayQuad &delay) const override;
|
2020-12-30 22:59:55 +08:00
|
|
|
// Get the port class, also setting clockInfoCount to the number of TimingClockingInfos associated with a port
|
2021-02-25 19:21:39 +08:00
|
|
|
TimingPortClass getPortTimingClass(const CellInfo *cell, IdString port, int &clockInfoCount) const override;
|
2020-12-30 22:59:55 +08:00
|
|
|
// Get the TimingClockingInfo of a port
|
2021-02-25 19:21:39 +08:00
|
|
|
TimingClockingInfo getPortClockingInfo(const CellInfo *cell, IdString port, int index) const override;
|
2020-12-30 22:59:55 +08:00
|
|
|
|
2022-12-07 17:27:58 +08:00
|
|
|
bool isBelLocationValid(BelId bel, bool explain_invalid = false) const override;
|
2020-12-30 22:59:55 +08:00
|
|
|
|
|
|
|
static const std::string defaultPlacer;
|
|
|
|
static const std::vector<std::string> availablePlacers;
|
|
|
|
static const std::string defaultRouter;
|
|
|
|
static const std::vector<std::string> availableRouters;
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------
|
|
|
|
// Internal usage
|
2021-02-25 19:21:39 +08:00
|
|
|
void assignArchInfo() override;
|
2020-12-30 22:59:55 +08:00
|
|
|
bool cellsCompatible(const CellInfo **cells, int count) const;
|
2022-01-29 12:45:17 +08:00
|
|
|
bool haveBelType(int x, int y, IdString bel_type);
|
2022-05-27 20:44:21 +08:00
|
|
|
bool allocate_longwire(NetInfo *ni, int lw_idx = -1);
|
|
|
|
void fix_longwire_bels();
|
2022-07-04 08:32:39 +08:00
|
|
|
void pre_pack(Context *ctx);
|
|
|
|
void post_pack(Context *ctx);
|
2022-12-04 13:06:44 +08:00
|
|
|
void pre_route(Context *ctx);
|
|
|
|
void post_route(Context *ctx);
|
2022-07-04 08:32:39 +08:00
|
|
|
void auto_longwires();
|
2023-01-18 17:18:02 +08:00
|
|
|
void add_pllvr_ports(DatabasePOD const *db, BelsPOD const *bel, IdString belname, int row, int col);
|
2023-01-26 18:26:05 +08:00
|
|
|
void add_rpll_ports(DatabasePOD const *db, BelsPOD const *bel, IdString belname, int row, int col);
|
2022-12-04 13:06:44 +08:00
|
|
|
void fix_pll_nets(Context *ctx);
|
2022-12-30 09:55:39 +08:00
|
|
|
bool is_GCLKT_iob(const CellInfo *cell);
|
2023-01-30 16:59:09 +08:00
|
|
|
void bind_pll_to_bel(CellInfo *ci, PLL loc);
|
2022-07-04 08:32:39 +08:00
|
|
|
|
2023-03-22 15:15:17 +08:00
|
|
|
void mark_used_hclk(Context *ctx);
|
|
|
|
IdString apply_local_aliases(int row, int col, const DatabasePOD *db, IdString &wire);
|
|
|
|
|
2023-04-18 18:10:36 +08:00
|
|
|
WireId get_make_port_wire(const DatabasePOD *db, const BelsPOD *bel, int row, int col, IdString port);
|
|
|
|
|
2022-07-04 08:32:39 +08:00
|
|
|
GowinGlobalRouter globals_router;
|
|
|
|
void mark_gowin_globals(Context *ctx);
|
|
|
|
void route_gowin_globals(Context *ctx);
|
2022-05-27 20:44:21 +08:00
|
|
|
|
2021-11-07 07:05:34 +08:00
|
|
|
// chip db version
|
2022-11-25 18:49:26 +08:00
|
|
|
unsigned int const chipdb_version = 2;
|
2021-01-29 11:24:00 +08:00
|
|
|
|
|
|
|
std::vector<IdString> cell_types;
|
2021-08-31 05:36:11 +08:00
|
|
|
|
2022-01-29 12:45:17 +08:00
|
|
|
// clock spines cache
|
|
|
|
// spine_id : [wire_id, wire_id, ...]
|
|
|
|
dict<IdString, std::vector<IdString>> clockSpinesCache;
|
|
|
|
void updateClockSpinesCache(IdString spine_id, IdString wire_id);
|
|
|
|
void fixClockSpineDecals(void);
|
|
|
|
|
2022-03-26 18:56:30 +08:00
|
|
|
// XXX GW1N-9C DDR quirk
|
|
|
|
bool ddr_has_extra_inputs = false;
|
2022-04-03 08:05:27 +08:00
|
|
|
// XXX GW1NR-9 iobuf quirk
|
|
|
|
bool gw1n9_quirk = false;
|
2022-03-26 18:56:30 +08:00
|
|
|
|
2022-05-27 20:44:21 +08:00
|
|
|
// 8 Long wires
|
|
|
|
uint8_t avail_longwires = 0xff;
|
|
|
|
|
2021-08-31 05:36:11 +08:00
|
|
|
// Permissible combinations of modes in a single slice
|
|
|
|
std::map<const IdString, IdString> dff_comp_mode;
|
2023-01-18 17:18:02 +08:00
|
|
|
|
|
|
|
// max global clock wires
|
|
|
|
int max_clock;
|
2020-12-30 22:59:55 +08:00
|
|
|
};
|
|
|
|
|
2022-03-15 09:02:37 +08:00
|
|
|
// Bels Z range
|
|
|
|
namespace BelZ {
|
|
|
|
enum
|
|
|
|
{
|
2023-04-12 11:42:16 +08:00
|
|
|
ioba_z = 0, // IOBA
|
|
|
|
iobb_z = 1, // IOBB
|
2023-03-22 15:15:17 +08:00
|
|
|
mux_0_z = 10, // start Z for the MUX2LUT5 bels
|
|
|
|
lutram_0_z = 30, // start Z for the LUTRAM bels
|
|
|
|
vcc_0_z = 277, // virtual VCC bel Z
|
|
|
|
gnd_0_z = 278, // virtual VSS bel Z
|
|
|
|
osc_z = 280, // Z for the oscillator bels
|
|
|
|
bufs_0_z = 281, // Z for long wire buffer bel
|
|
|
|
pll_z = 289, // PLL
|
|
|
|
pllvr_z = 290, // PLLVR
|
|
|
|
iologic_z = 291, // IOLOGIC
|
2023-04-12 11:42:16 +08:00
|
|
|
oser16_z = 293, // OSER16
|
|
|
|
ides16_z = 294, // IDES16
|
|
|
|
free_z = 295 // Must be the last, one can use z starting from this value, adjust accordingly.
|
2022-03-15 09:02:37 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-12-30 22:59:55 +08:00
|
|
|
NEXTPNR_NAMESPACE_END
|
2021-03-13 05:09:44 +08:00
|
|
|
|
|
|
|
#endif /* GOWIN_ARCH_H */
|