From 960bb65b1579ccadb8f00fa32f685c4a71967539 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Wed, 23 May 2018 11:35:49 +0200 Subject: Import apidraft.h Signed-off-by: Clifford Wolf --- apidraft.h | 134 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 apidraft.h (limited to 'apidraft.h') diff --git a/apidraft.h b/apidraft.h new file mode 100644 index 00000000..f6e5a44b --- /dev/null +++ b/apidraft.h @@ -0,0 +1,134 @@ +#include +#include + +// replace with proper IdString later +typedef std::string IdString; + +// ------------------------------------------------------- +// Arch-specific declarations + +#ifdef ARCH_ICE40 +struct ObjId +{ + uint8_t tile_x = 0, tile_y = 0; + uint16_t index = 0; + + bool nil() const { + return !tile_x && !tile_y && !index; + } +} __attribute__((packed)); + +struct ObjIterator +{ + // ... + ObjId operator*() const; +}; + +struct ObjRange +{ + ObjIterator begin(); + ObjIterator end(); +}; + +struct BelPin +{ + ObjId bel; + IdString pin; +}; + +struct BelPinIterator +{ + // ... + BelPin operator*() const; +}; + +struct BelPinRange +{ + BelPinIterator begin(); + BelPinIterator end(); +}; + +struct GuiLine +{ + float x1, y1, x2, y2; +}; + +struct Chip +{ + Chip(std::string cfg); + + ObjId getObjByName(IdString name) const; + IdString getObjName(ObjId obj) const; + IdString getBelType(ObjId obj) const; + ObjRange getBelsByType(IdString type) const; + + void getObjPosition(ObjId obj, float &x, float &y) const; + vector getGuiLines(ObjId obj) const; + + ObjRange getWires() const; + ObjRange getWiresUphillWire(ObjId wire) const; + ObjRange getWiresDownhillWire(ObjId wire) const; + ObjRange getWiresBidirWire(ObjId wire) const; + ObjRange getWireAliases(ObjId wire) const; + + ObjId getWireBelPin(ObjId bel, IdString pin) const; + BelPin getBelPinUphillWire(ObjId wire) const; + BelPinRange getBelPinsDownhillWire(ObjId wire) const; +}; +#endif + +// ------------------------------------------------------- +// Generic declarations + +struct PortRef +{ + IdString cell_name; + IdString port_name; +}; + +struct NetInfo +{ + IdString name; + PortRef driver; + vector users; + dict attrs; + + // wire objid -> signal delay + dict wires; +}; + +enum PortType +{ + PORT_IN = 0, + PORT_OUT = 1, + PORT_INOUT = 2 +}; + +struct PortInfo +{ + IdString name, net; + PortType type; +}; + +struct CellInfo +{ + IdString name, type; + dict ports; + dict attrs, params; + + ObjId bel; + // port_name -> pin_name + dict pins; +}; + +struct Design +{ + struct Chip; + + Design(std::string chipCfg) : Chip(chipCfg) { + // ... + } + + dict nets; + dict cells; +}; -- cgit v1.2.3