Merge branch 'master' of gitlab.com:SymbioticEDA/nextpnr

This commit is contained in:
David Shah 2018-06-07 12:59:41 +02:00
commit 9ebc879826
10 changed files with 857 additions and 849 deletions

View File

@ -47,12 +47,10 @@ DisableFormat: false
ExperimentalAutoDetectBinPacking: false ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories: IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/' - Regex: '<.*>'
Priority: 2
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1 Priority: 1
- Regex: '.*'
Priority: 2
IndentCaseLabels: false IndentCaseLabels: false
IndentWidth: 4 IndentWidth: 4
IndentWrappedFunctionNames: false IndentWrappedFunctionNames: false

View File

@ -18,4 +18,3 @@
*/ */
#include "design.h" #include "design.h"

View File

@ -20,26 +20,27 @@
#ifndef DESIGN_H #ifndef DESIGN_H
#define DESIGN_H #define DESIGN_H
#include <stdint.h>
#include <assert.h> #include <assert.h>
#include <vector> #include <stdint.h>
#include <string> #include <string>
#include <unordered_set>
#include <unordered_map> #include <unordered_map>
#include <unordered_set>
#include <vector>
// replace with proper IdString later // replace with proper IdString later
typedef std::string IdString; typedef std::string IdString;
// replace with haslib later // replace with haslib later
template<typename T> using pool = std::unordered_set<T>; template <typename T> using pool = std::unordered_set<T>;
template<typename T, typename U> using dict = std::unordered_map<T, U>; template <typename T, typename U> using dict = std::unordered_map<T, U>;
using std::vector; using std::vector;
struct GraphicElement struct GraphicElement
{ {
// This will control colour, and there should be separate // This will control colour, and there should be separate
// visibility controls in some cases also // visibility controls in some cases also
enum { enum
{
// Wires entirely inside tiles, e.g. between switchbox and bels // Wires entirely inside tiles, e.g. between switchbox and bels
G_LOCAL_WIRES, G_LOCAL_WIRES,
// Standard inter-tile routing // Standard inter-tile routing
@ -55,7 +56,8 @@ struct GraphicElement
G_TILE_MISC, G_TILE_MISC,
} style; } style;
enum { enum
{
G_LINE, G_LINE,
G_BOX, G_BOX,
G_CIRCLE, G_CIRCLE,
@ -116,12 +118,13 @@ struct Design
{ {
struct Chip chip; struct Chip chip;
Design(ChipArgs args) : chip(args) { Design(ChipArgs args) : chip(args)
{
// ... // ...
} }
dict<IdString, NetInfo*> nets; dict<IdString, NetInfo *> nets;
dict<IdString, CellInfo*> cells; dict<IdString, CellInfo *> cells;
}; };
#endif #endif

View File

@ -21,9 +21,11 @@
#include "design.h" #include "design.h"
#include "chip.h" #include "chip.h"
#include "pybindings.h"
#include "emb.h" #include "emb.h"
// include after design.h/chip.h
#include "pybindings.h"
// Required to determine concatenated module name (which differs for different archs) // Required to determine concatenated module name (which differs for different archs)
#define PASTER(x, y) x ## _ ## y #define PASTER(x, y) x ## _ ## y
#define EVALUATOR(x, y) PASTER(x,y) #define EVALUATOR(x, y) PASTER(x,y)

View File

@ -19,6 +19,4 @@
#include "chip.h" #include "chip.h"
Chip::Chip(ChipArgs) Chip::Chip(ChipArgs) {}
{
}

View File

@ -20,6 +20,8 @@
#include "design.h" #include "design.h"
#include "chip.h" #include "chip.h"
// include after design.h/chip.h
#include "pybindings.h" #include "pybindings.h"
void arch_wrap_python() { void arch_wrap_python() {

View File

@ -47,7 +47,9 @@ BelType belTypeFromId(IdString id)
IdString PortPinToId(PortPin type) IdString PortPinToId(PortPin type)
{ {
#define X(t) if (type == PIN_##t) return #t; #define X(t) \
if (type == PIN_##t) \
return #t;
X(IN_0) X(IN_0)
X(IN_1) X(IN_1)
@ -161,7 +163,9 @@ IdString PortPinToId(PortPin type)
PortPin PortPinFromId(IdString id) PortPin PortPinFromId(IdString id)
{ {
#define X(t) if (id == #t) return PIN_##t; #define X(t) \
if (id == #t) \
return PIN_##t;
X(IN_0) X(IN_0)
X(IN_1) X(IN_1)
@ -401,15 +405,17 @@ vector<GraphicElement> Chip::getBelGraphics(BelId bel) const
el.type = GraphicElement::G_BOX; el.type = GraphicElement::G_BOX;
el.x1 = chip_info.bel_data[bel.index].x + 0.1; el.x1 = chip_info.bel_data[bel.index].x + 0.1;
el.x2 = chip_info.bel_data[bel.index].x + 0.9; el.x2 = chip_info.bel_data[bel.index].x + 0.9;
el.y1 = chip_info.bel_data[bel.index].y + 0.10 + (chip_info.bel_data[bel.index].z) * (0.8/8); el.y1 = chip_info.bel_data[bel.index].y + 0.10 +
el.y2 = chip_info.bel_data[bel.index].y + 0.18 + (chip_info.bel_data[bel.index].z) * (0.8/8); (chip_info.bel_data[bel.index].z) * (0.8 / 8);
el.y2 = chip_info.bel_data[bel.index].y + 0.18 +
(chip_info.bel_data[bel.index].z) * (0.8 / 8);
el.z = 0; el.z = 0;
ret.push_back(el); ret.push_back(el);
} }
if (bel_type == TYPE_SB_IO) { 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) if (chip_info.bel_data[bel.index].x == 0 ||
{ chip_info.bel_data[bel.index].x == chip_info.width - 1) {
GraphicElement el; GraphicElement el;
el.type = GraphicElement::G_BOX; el.type = GraphicElement::G_BOX;
el.x1 = chip_info.bel_data[bel.index].x + 0.1; el.x1 = chip_info.bel_data[bel.index].x + 0.1;
@ -423,9 +429,7 @@ vector<GraphicElement> Chip::getBelGraphics(BelId bel) const
} }
el.z = 0; el.z = 0;
ret.push_back(el); ret.push_back(el);
} } else {
else
{
GraphicElement el; GraphicElement el;
el.type = GraphicElement::G_BOX; el.type = GraphicElement::G_BOX;
if (chip_info.bel_data[bel.index].z == 0) { if (chip_info.bel_data[bel.index].z == 0) {
@ -475,8 +479,7 @@ vector<GraphicElement> Chip::getFrameGraphics() const
vector<GraphicElement> ret; vector<GraphicElement> ret;
for (int x = 0; x <= chip_info.width; x++) for (int x = 0; x <= chip_info.width; x++)
for (int y = 0; y <= chip_info.height; y++) for (int y = 0; y <= chip_info.height; y++) {
{
GraphicElement el; GraphicElement el;
el.type = GraphicElement::G_LINE; el.type = GraphicElement::G_LINE;
el.x1 = x - 0.05, el.x2 = x + 0.05, el.y1 = y, el.y2 = y, el.z = 0; el.x1 = x - 0.05, el.x2 = x + 0.05, el.y1 = y, el.y2 = y, el.z = 0;

View File

@ -159,7 +159,6 @@ PortPin PortPinFromId(IdString id);
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
struct BelInfoPOD struct BelInfoPOD
{ {
const char *name; const char *name;
@ -213,9 +212,7 @@ struct BelId
{ {
int32_t index = -1; int32_t index = -1;
bool nil() const { bool nil() const { return index < 0; }
return index < 0;
}
bool operator==(const BelId &other) const { return index == other.index; } bool operator==(const BelId &other) const { return index == other.index; }
bool operator!=(const BelId &other) const { return index != other.index; } bool operator!=(const BelId &other) const { return index != other.index; }
@ -225,9 +222,7 @@ struct WireId
{ {
int32_t index = -1; int32_t index = -1;
bool nil() const { bool nil() const { return index < 0; }
return index < 0;
}
bool operator==(const WireId &other) const { return index == other.index; } bool operator==(const WireId &other) const { return index == other.index; }
bool operator!=(const WireId &other) const { return index != other.index; } bool operator!=(const WireId &other) const { return index != other.index; }
@ -237,9 +232,7 @@ struct PipId
{ {
int32_t index = -1; int32_t index = -1;
bool nil() const { bool nil() const { return index < 0; }
return index < 0;
}
bool operator==(const PipId &other) const { return index == other.index; } bool operator==(const PipId &other) const { return index == other.index; }
bool operator!=(const PipId &other) const { return index != other.index; } bool operator!=(const PipId &other) const { return index != other.index; }
@ -251,31 +244,30 @@ struct BelPin
PortPin pin; PortPin pin;
}; };
namespace std namespace std {
template <> struct hash<BelId>
{ {
template<> struct hash<BelId>
{
std::size_t operator()(const BelId &bel) const noexcept std::size_t operator()(const BelId &bel) const noexcept
{ {
return bel.index; return bel.index;
} }
}; };
template<> struct hash<WireId> template <> struct hash<WireId>
{ {
std::size_t operator()(const WireId &wire) const noexcept std::size_t operator()(const WireId &wire) const noexcept
{ {
return wire.index; return wire.index;
} }
}; };
template<> struct hash<PipId> template <> struct hash<PipId>
{ {
std::size_t operator()(const PipId &wire) const noexcept std::size_t operator()(const PipId &wire) const noexcept
{ {
return wire.index; return wire.index;
} }
}; };
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@ -285,9 +277,13 @@ struct BelIterator
int cursor; int cursor;
void operator++() { cursor++; } void operator++() { cursor++; }
bool operator!=(const BelIterator &other) const { return cursor != other.cursor; } bool operator!=(const BelIterator &other) const
{
return cursor != other.cursor;
}
BelId operator*() const { BelId operator*() const
{
BelId ret; BelId ret;
ret.index = cursor; ret.index = cursor;
return ret; return ret;
@ -308,9 +304,13 @@ struct BelPinIterator
BelPortPOD *ptr = nullptr; BelPortPOD *ptr = nullptr;
void operator++() { ptr++; } void operator++() { ptr++; }
bool operator!=(const BelPinIterator &other) const { return ptr != other.ptr; } bool operator!=(const BelPinIterator &other) const
{
return ptr != other.ptr;
}
BelPin operator*() const { BelPin operator*() const
{
BelPin ret; BelPin ret;
ret.bel.index = ptr->bel_index; ret.bel.index = ptr->bel_index;
ret.pin = ptr->port; ret.pin = ptr->port;
@ -332,9 +332,13 @@ struct WireIterator
int cursor = -1; int cursor = -1;
void operator++() { cursor++; } void operator++() { cursor++; }
bool operator!=(const WireIterator &other) const { return cursor != other.cursor; } bool operator!=(const WireIterator &other) const
{
return cursor != other.cursor;
}
WireId operator*() const { WireId operator*() const
{
WireId ret; WireId ret;
ret.index = cursor; ret.index = cursor;
return ret; return ret;
@ -355,9 +359,13 @@ struct AllPipIterator
int cursor = -1; int cursor = -1;
void operator++() { cursor++; } void operator++() { cursor++; }
bool operator!=(const AllPipIterator &other) const { return cursor != other.cursor; } bool operator!=(const AllPipIterator &other) const
{
return cursor != other.cursor;
}
PipId operator*() const { PipId operator*() const
{
PipId ret; PipId ret;
ret.index = cursor; ret.index = cursor;
return ret; return ret;
@ -378,9 +386,13 @@ struct PipIterator
int *cursor = nullptr; int *cursor = nullptr;
void operator++() { cursor++; } void operator++() { cursor++; }
bool operator!=(const PipIterator &other) const { return cursor != other.cursor; } bool operator!=(const PipIterator &other) const
{
return cursor != other.cursor;
}
PipId operator*() const { PipId operator*() const
{
PipId ret; PipId ret;
ret.index = *cursor; ret.index = *cursor;
return ret; return ret;
@ -398,7 +410,8 @@ struct PipRange
struct ChipArgs struct ChipArgs
{ {
enum { enum
{
NONE, NONE,
LP384, LP384,
LP1K, LP1K,
@ -429,17 +442,11 @@ struct Chip
return chip_info.bel_data[bel.index].name; return chip_info.bel_data[bel.index].name;
} }
void bindBel(BelId bel, IdString cell) void bindBel(BelId bel, IdString cell) {}
{
}
void unbindBel(BelId bel) void unbindBel(BelId bel) {}
{
}
bool checkBelAvail(BelId bel) const bool checkBelAvail(BelId bel) const {}
{
}
BelRange getBels() const BelRange getBels() const
{ {
@ -452,7 +459,7 @@ struct Chip
BelRange getBelsByType(BelType type) const BelRange getBelsByType(BelType type) const
{ {
BelRange range; BelRange range;
// FIXME // FIXME
#if 0 #if 0
if (type == "TYPE_A") { if (type == "TYPE_A") {
range.b.cursor = bels_type_a_begin; range.b.cursor = bels_type_a_begin;
@ -477,7 +484,8 @@ struct Chip
assert(!wire.nil()); assert(!wire.nil());
if (chip_info.wire_data[wire.index].bel_uphill.bel_index >= 0) { if (chip_info.wire_data[wire.index].bel_uphill.bel_index >= 0) {
ret.bel.index = chip_info.wire_data[wire.index].bel_uphill.bel_index; ret.bel.index =
chip_info.wire_data[wire.index].bel_uphill.bel_index;
ret.pin = chip_info.wire_data[wire.index].bel_uphill.port; ret.pin = chip_info.wire_data[wire.index].bel_uphill.port;
} }
@ -489,7 +497,8 @@ struct Chip
BelPinRange range; BelPinRange range;
assert(!wire.nil()); assert(!wire.nil());
range.b.ptr = chip_info.wire_data[wire.index].bels_downhill; range.b.ptr = chip_info.wire_data[wire.index].bels_downhill;
range.e.ptr = range.b.ptr + chip_info.wire_data[wire.index].num_bels_downhill; range.e.ptr =
range.b.ptr + chip_info.wire_data[wire.index].num_bels_downhill;
return range; return range;
} }
@ -503,17 +512,11 @@ struct Chip
return chip_info.wire_data[wire.index].name; return chip_info.wire_data[wire.index].name;
} }
void bindWire(WireId bel, IdString net) void bindWire(WireId bel, IdString net) {}
{
}
void unbindWire(WireId bel) void unbindWire(WireId bel) {}
{
}
bool checkWireAvail(WireId bel) const bool checkWireAvail(WireId bel) const {}
{
}
WireRange getWires() const WireRange getWires() const
{ {
@ -530,22 +533,18 @@ struct Chip
IdString getPipName(PipId pip) const IdString getPipName(PipId pip) const
{ {
assert(!pip.nil()); assert(!pip.nil());
std::string src_name = chip_info.wire_data[chip_info.pip_data[pip.index].src].name; std::string src_name =
std::string dst_name = chip_info.wire_data[chip_info.pip_data[pip.index].dst].name; chip_info.wire_data[chip_info.pip_data[pip.index].src].name;
std::string dst_name =
chip_info.wire_data[chip_info.pip_data[pip.index].dst].name;
return src_name + "->" + dst_name; return src_name + "->" + dst_name;
} }
void bindPip(PipId bel, IdString net) void bindPip(PipId bel, IdString net) {}
{
}
void unbindPip(PipId bel) void unbindPip(PipId bel) {}
{
}
bool checkPipAvail(PipId bel) const bool checkPipAvail(PipId bel) const {}
{
}
AllPipRange getPips() const AllPipRange getPips() const
{ {
@ -584,7 +583,8 @@ struct Chip
PipRange range; PipRange range;
assert(!wire.nil()); assert(!wire.nil());
range.b.cursor = chip_info.wire_data[wire.index].pips_downhill; range.b.cursor = chip_info.wire_data[wire.index].pips_downhill;
range.e.cursor = range.b.cursor + chip_info.wire_data[wire.index].num_downhill; range.e.cursor =
range.b.cursor + chip_info.wire_data[wire.index].num_downhill;
return range; return range;
} }
@ -593,7 +593,8 @@ struct Chip
PipRange range; PipRange range;
assert(!wire.nil()); assert(!wire.nil());
range.b.cursor = chip_info.wire_data[wire.index].pips_uphill; range.b.cursor = chip_info.wire_data[wire.index].pips_uphill;
range.e.cursor = range.b.cursor + chip_info.wire_data[wire.index].num_uphill; range.e.cursor =
range.b.cursor + chip_info.wire_data[wire.index].num_uphill;
return range; return range;
} }

View File

@ -20,6 +20,8 @@
#include "design.h" #include "design.h"
#include "chip.h" #include "chip.h"
// include after design.h/chip.h
#include "pybindings.h" #include "pybindings.h"
void arch_wrap_python() { void arch_wrap_python() {