2018-05-26 16:47:35 +08:00
|
|
|
/*
|
2018-05-26 17:17:50 +08:00
|
|
|
* nextpnr -- Next Generation Place and Route
|
2018-05-26 16:47:35 +08:00
|
|
|
*
|
|
|
|
* Copyright (C) 2018 Clifford Wolf <clifford@clifford.at>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-06-12 02:12:57 +08:00
|
|
|
#ifndef NEXTPNR_H
|
2018-06-18 20:12:39 +08:00
|
|
|
#error Include "arch.h" via "nextpnr.h" only.
|
2018-06-12 02:12:57 +08:00
|
|
|
#endif
|
|
|
|
|
2018-06-19 18:08:37 +08:00
|
|
|
#ifdef NEXTPNR_ARCH_TOP
|
|
|
|
|
2018-06-12 20:24:59 +08:00
|
|
|
NEXTPNR_NAMESPACE_BEGIN
|
|
|
|
|
2018-06-16 21:23:04 +08:00
|
|
|
typedef float delay_t;
|
|
|
|
|
2018-05-30 02:04:29 +08:00
|
|
|
struct DelayInfo
|
|
|
|
{
|
2018-06-16 21:23:04 +08:00
|
|
|
delay_t delay = 0;
|
2018-05-30 02:04:29 +08:00
|
|
|
|
2018-06-16 21:23:04 +08:00
|
|
|
delay_t raiseDelay() const { return delay; }
|
2018-06-20 17:44:28 +08:00
|
|
|
|
2018-06-16 21:23:04 +08:00
|
|
|
delay_t fallDelay() const { return delay; }
|
2018-06-20 17:44:28 +08:00
|
|
|
|
2018-06-16 21:23:04 +08:00
|
|
|
delay_t avgDelay() const { return delay; }
|
2018-06-10 00:19:20 +08:00
|
|
|
|
|
|
|
DelayInfo operator+(const DelayInfo &other) const
|
|
|
|
{
|
|
|
|
DelayInfo ret;
|
|
|
|
ret.delay = this->delay + other.delay;
|
|
|
|
return ret;
|
|
|
|
}
|
2018-05-30 02:04:29 +08:00
|
|
|
};
|
|
|
|
|
2018-05-26 22:08:20 +08:00
|
|
|
typedef IdString BelType;
|
|
|
|
typedef IdString PortPin;
|
|
|
|
|
2018-06-06 21:30:23 +08:00
|
|
|
typedef IdString BelId;
|
|
|
|
typedef IdString WireId;
|
|
|
|
typedef IdString PipId;
|
2018-05-23 17:35:49 +08:00
|
|
|
|
|
|
|
struct BelPin
|
|
|
|
{
|
2018-06-07 18:56:49 +08:00
|
|
|
BelId bel;
|
|
|
|
PortPin pin;
|
2018-05-23 17:35:49 +08:00
|
|
|
};
|
|
|
|
|
2018-06-19 18:08:37 +08:00
|
|
|
NEXTPNR_NAMESPACE_END
|
|
|
|
|
|
|
|
#endif // NEXTPNR_ARCH_TOP
|
|
|
|
|
|
|
|
#ifdef NEXTPNR_ARCH_BOTTOM
|
|
|
|
|
|
|
|
NEXTPNR_NAMESPACE_BEGIN
|
|
|
|
|
2018-06-18 19:35:25 +08:00
|
|
|
struct ArchArgs
|
2018-05-26 16:36:33 +08:00
|
|
|
{
|
|
|
|
};
|
|
|
|
|
2018-06-19 18:08:37 +08:00
|
|
|
struct Arch : BaseCtx
|
2018-05-23 17:35:49 +08:00
|
|
|
{
|
2018-06-18 19:35:25 +08:00
|
|
|
Arch(ArchArgs args);
|
2018-06-07 18:56:49 +08:00
|
|
|
|
2018-06-11 00:25:23 +08:00
|
|
|
std::string getChipName();
|
|
|
|
|
2018-06-18 21:53:18 +08:00
|
|
|
virtual IdString id(const std::string &s) const { abort(); }
|
|
|
|
virtual IdString id(const char *s) const { abort(); }
|
|
|
|
|
2018-06-18 22:08:19 +08:00
|
|
|
IdString belTypeToId(BelType type) const { return type; }
|
|
|
|
IdString portPinToId(PortPin type) const { return type; }
|
|
|
|
|
|
|
|
BelType belTypeFromId(IdString id) const { return id; }
|
|
|
|
PortPin portPinFromId(IdString id) const { return id; }
|
|
|
|
|
2018-06-07 18:56:49 +08:00
|
|
|
BelId getBelByName(IdString name) const;
|
|
|
|
IdString getBelName(BelId bel) const;
|
|
|
|
void bindBel(BelId bel, IdString cell);
|
|
|
|
void unbindBel(BelId bel);
|
|
|
|
bool checkBelAvail(BelId bel) const;
|
2018-06-12 01:56:33 +08:00
|
|
|
IdString getBelCell(BelId bel, bool conflicting = false) const;
|
|
|
|
const std::vector<BelId> &getBels() const;
|
|
|
|
const std::vector<BelId> &getBelsByType(BelType type) const;
|
2018-06-07 18:56:49 +08:00
|
|
|
BelType getBelType(BelId bel) const;
|
|
|
|
WireId getWireBelPin(BelId bel, PortPin pin) const;
|
|
|
|
BelPin getBelPinUphill(WireId wire) const;
|
2018-06-12 01:56:33 +08:00
|
|
|
const std::vector<BelPin> &getBelPinsDownhill(WireId wire) const;
|
2018-06-07 18:56:49 +08:00
|
|
|
|
|
|
|
WireId getWireByName(IdString name) const;
|
|
|
|
IdString getWireName(WireId wire) const;
|
2018-06-10 00:19:20 +08:00
|
|
|
void bindWire(WireId wire, IdString net);
|
|
|
|
void unbindWire(WireId wire);
|
|
|
|
bool checkWireAvail(WireId wire) const;
|
2018-06-12 01:56:33 +08:00
|
|
|
IdString getWireNet(WireId wire, bool conflicting = false) const;
|
|
|
|
const std::vector<WireId> &getWires() const;
|
2018-06-07 18:56:49 +08:00
|
|
|
|
|
|
|
PipId getPipByName(IdString name) const;
|
|
|
|
IdString getPipName(PipId pip) const;
|
2018-06-10 00:19:20 +08:00
|
|
|
void bindPip(PipId pip, IdString net);
|
|
|
|
void unbindPip(PipId pip);
|
|
|
|
bool checkPipAvail(PipId pip) const;
|
2018-06-12 01:56:33 +08:00
|
|
|
IdString getPipNet(PipId pip, bool conflicting = false) const;
|
|
|
|
const std::vector<PipId> &getPips() const;
|
2018-06-07 18:56:49 +08:00
|
|
|
WireId getPipSrcWire(PipId pip) const;
|
|
|
|
WireId getPipDstWire(PipId pip) const;
|
|
|
|
DelayInfo getPipDelay(PipId pip) const;
|
2018-06-12 01:56:33 +08:00
|
|
|
const std::vector<PipId> &getPipsDownhill(WireId wire) const;
|
|
|
|
const std::vector<PipId> &getPipsUphill(WireId wire) const;
|
|
|
|
const std::vector<PipId> &getWireAliases(WireId wire) const;
|
2018-06-07 18:56:49 +08:00
|
|
|
|
2018-06-16 21:23:04 +08:00
|
|
|
bool estimatePosition(BelId bel, int &x, int &y) const;
|
|
|
|
delay_t estimateDelay(WireId src, WireId dst) const;
|
2018-06-12 01:46:03 +08:00
|
|
|
|
2018-06-13 18:48:58 +08:00
|
|
|
std::vector<GraphicElement> getFrameGraphics() const;
|
2018-06-12 01:56:33 +08:00
|
|
|
std::vector<GraphicElement> getBelGraphics(BelId bel) const;
|
|
|
|
std::vector<GraphicElement> getWireGraphics(WireId wire) const;
|
|
|
|
std::vector<GraphicElement> getPipGraphics(PipId pip) const;
|
2018-06-13 18:48:58 +08:00
|
|
|
|
|
|
|
bool allGraphicsReload = false;
|
|
|
|
bool frameGraphicsReload = false;
|
|
|
|
std::unordered_set<BelId> belGraphicsReload;
|
|
|
|
std::unordered_set<WireId> wireGraphicsReload;
|
|
|
|
std::unordered_set<PipId> pipGraphicsReload;
|
2018-06-20 17:44:28 +08:00
|
|
|
|
|
|
|
delay_t getCellDelay(const CellInfo *cell, IdString fromPort,
|
|
|
|
IdString toPort) const;
|
|
|
|
IdString getPortClock(const CellInfo *cell, IdString port) const;
|
|
|
|
bool isClockPort(const CellInfo *cell, IdString port) const;
|
2018-05-23 17:35:49 +08:00
|
|
|
};
|
|
|
|
|
2018-06-12 20:24:59 +08:00
|
|
|
NEXTPNR_NAMESPACE_END
|
|
|
|
|
2018-06-19 18:08:37 +08:00
|
|
|
#endif // NEXTPNR_ARCH_BOTTOM
|