Rename Chip to Arch and ChipArgs to ArchArgs

Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
Clifford Wolf 2018-06-18 13:35:25 +02:00
parent 2f5e9542c2
commit ad18cdb087
14 changed files with 158 additions and 159 deletions

View File

@ -72,9 +72,9 @@ struct CellInfo
struct Design struct Design
{ {
struct Chip chip; struct Arch chip;
Design(ChipArgs args) : chip(args) Design(ArchArgs args) : chip(args)
{ {
// ... // ...
} }

View File

@ -35,7 +35,7 @@ void IdString::initialize()
void IdString::initialize_add(const char *s, int idx) void IdString::initialize_add(const char *s, int idx)
{ {
assert(database_str_to_idx->count(s) == 0); assert(database_str_to_idx->count(s) == 0);
assert(database_idx_to_str->size() == idx); assert(int(database_idx_to_str->size()) == idx);
auto insert_rc = database_str_to_idx->insert({s, idx}); auto insert_rc = database_str_to_idx->insert({s, idx});
database_idx_to_str->push_back(&insert_rc.first->first); database_idx_to_str->push_back(&insert_rc.first->first);
} }

View File

@ -78,7 +78,7 @@ static void place_initial(Design *design, CellInfo *cell, rnd_state &rnd)
BelId best_bel = BelId(); BelId best_bel = BelId();
float best_score = std::numeric_limits<float>::infinity(), float best_score = std::numeric_limits<float>::infinity(),
best_ripup_score = std::numeric_limits<float>::infinity(); best_ripup_score = std::numeric_limits<float>::infinity();
Chip &chip = design->chip; Arch &chip = design->chip;
CellInfo *ripup_target = nullptr; CellInfo *ripup_target = nullptr;
BelId ripup_bel = BelId(); BelId ripup_bel = BelId();
if (cell->bel != BelId()) { if (cell->bel != BelId()) {
@ -141,7 +141,7 @@ struct SAState
}; };
// Get the total estimated wirelength for a net // Get the total estimated wirelength for a net
static float get_wirelength(Chip *chip, NetInfo *net) static float get_wirelength(Arch *chip, NetInfo *net)
{ {
float wirelength = 0; float wirelength = 0;
int driver_x = 0, driver_y = 0; int driver_x = 0, driver_y = 0;
@ -181,7 +181,7 @@ static bool try_swap_position(Design *design, CellInfo *cell, BelId newBel,
static std::vector<std::pair<NetInfo *, float>> new_lengths; static std::vector<std::pair<NetInfo *, float>> new_lengths;
new_lengths.clear(); new_lengths.clear();
update.clear(); update.clear();
Chip &chip = design->chip; Arch &chip = design->chip;
BelId oldBel = cell->bel; BelId oldBel = cell->bel;
IdString other = chip.getBelCell(newBel, true); IdString other = chip.getBelCell(newBel, true);
CellInfo *other_cell = nullptr; CellInfo *other_cell = nullptr;
@ -264,7 +264,7 @@ swap_fail:
BelId random_bel_for_cell(Design *design, CellInfo *cell, SAState &state, BelId random_bel_for_cell(Design *design, CellInfo *cell, SAState &state,
rnd_state &rnd) rnd_state &rnd)
{ {
Chip &chip = design->chip; Arch &chip = design->chip;
BelType targetType = belTypeFromId(cell->type); BelType targetType = belTypeFromId(cell->type);
int x = 0, y = 0; int x = 0, y = 0;
chip.estimatePosition(cell->bel, x, y); chip.estimatePosition(cell->bel, x, y);

View File

@ -57,7 +57,7 @@ void parse_json_shim(std::string filename, Design &d)
} }
// Create a new Chip and load design from json file // Create a new Chip and load design from json file
Design load_design_shim(std::string filename, ChipArgs args) Design load_design_shim(std::string filename, ArchArgs args)
{ {
Design d(args); Design d(args);
parse_json_shim(filename, d); parse_json_shim(filename, d);

View File

@ -22,48 +22,48 @@
NEXTPNR_NAMESPACE_BEGIN NEXTPNR_NAMESPACE_BEGIN
Chip::Chip(ChipArgs) {} Arch::Arch(ArchArgs) {}
std::string Chip::getChipName() { return "Dummy"; } std::string Arch::getChipName() { return "Dummy"; }
void IdString::initialize_chip() {} void IdString::initialize_chip() {}
// --------------------------------------------------------------- // ---------------------------------------------------------------
BelId Chip::getBelByName(IdString name) const { return BelId(); } BelId Arch::getBelByName(IdString name) const { return BelId(); }
IdString Chip::getBelName(BelId bel) const { return IdString(); } IdString Arch::getBelName(BelId bel) const { return IdString(); }
void Chip::bindBel(BelId bel, IdString cell) {} void Arch::bindBel(BelId bel, IdString cell) {}
void Chip::unbindBel(BelId bel) {} void Arch::unbindBel(BelId bel) {}
bool Chip::checkBelAvail(BelId bel) const { return false; } bool Arch::checkBelAvail(BelId bel) const { return false; }
IdString Chip::getBelCell(BelId bel, bool conflicting) const IdString Arch::getBelCell(BelId bel, bool conflicting) const
{ {
return IdString(); return IdString();
} }
const std::vector<BelId> &Chip::getBels() const const std::vector<BelId> &Arch::getBels() const
{ {
static std::vector<BelId> ret; static std::vector<BelId> ret;
return ret; return ret;
} }
const std::vector<BelId> &Chip::getBelsByType(BelType type) const const std::vector<BelId> &Arch::getBelsByType(BelType type) const
{ {
static std::vector<BelId> ret; static std::vector<BelId> ret;
return ret; return ret;
} }
BelType Chip::getBelType(BelId bel) const { return BelType(); } BelType Arch::getBelType(BelId bel) const { return BelType(); }
WireId Chip::getWireBelPin(BelId bel, PortPin pin) const { return WireId(); } WireId Arch::getWireBelPin(BelId bel, PortPin pin) const { return WireId(); }
BelPin Chip::getBelPinUphill(WireId wire) const { return BelPin(); } BelPin Arch::getBelPinUphill(WireId wire) const { return BelPin(); }
const std::vector<BelPin> &Chip::getBelPinsDownhill(WireId wire) const const std::vector<BelPin> &Arch::getBelPinsDownhill(WireId wire) const
{ {
static std::vector<BelPin> ret; static std::vector<BelPin> ret;
return ret; return ret;
@ -71,22 +71,22 @@ const std::vector<BelPin> &Chip::getBelPinsDownhill(WireId wire) const
// --------------------------------------------------------------- // ---------------------------------------------------------------
WireId Chip::getWireByName(IdString name) const { return WireId(); } WireId Arch::getWireByName(IdString name) const { return WireId(); }
IdString Chip::getWireName(WireId wire) const { return IdString(); } IdString Arch::getWireName(WireId wire) const { return IdString(); }
void Chip::bindWire(WireId wire, IdString net) {} void Arch::bindWire(WireId wire, IdString net) {}
void Chip::unbindWire(WireId wire) {} void Arch::unbindWire(WireId wire) {}
bool Chip::checkWireAvail(WireId wire) const { return false; } bool Arch::checkWireAvail(WireId wire) const { return false; }
IdString Chip::getWireNet(WireId wire, bool conflicting) const IdString Arch::getWireNet(WireId wire, bool conflicting) const
{ {
return IdString(); return IdString();
} }
const std::vector<WireId> &Chip::getWires() const const std::vector<WireId> &Arch::getWires() const
{ {
static std::vector<WireId> ret; static std::vector<WireId> ret;
return ret; return ret;
@ -94,46 +94,46 @@ const std::vector<WireId> &Chip::getWires() const
// --------------------------------------------------------------- // ---------------------------------------------------------------
PipId Chip::getPipByName(IdString name) const { return PipId(); } PipId Arch::getPipByName(IdString name) const { return PipId(); }
IdString Chip::getPipName(PipId pip) const { return IdString(); } IdString Arch::getPipName(PipId pip) const { return IdString(); }
void Chip::bindPip(PipId pip, IdString net) {} void Arch::bindPip(PipId pip, IdString net) {}
void Chip::unbindPip(PipId pip) {} void Arch::unbindPip(PipId pip) {}
bool Chip::checkPipAvail(PipId pip) const { return false; } bool Arch::checkPipAvail(PipId pip) const { return false; }
IdString Chip::getPipNet(PipId pip, bool conflicting) const IdString Arch::getPipNet(PipId pip, bool conflicting) const
{ {
return IdString(); return IdString();
} }
const std::vector<PipId> &Chip::getPips() const const std::vector<PipId> &Arch::getPips() const
{ {
static std::vector<PipId> ret; static std::vector<PipId> ret;
return ret; return ret;
} }
WireId Chip::getPipSrcWire(PipId pip) const { return WireId(); } WireId Arch::getPipSrcWire(PipId pip) const { return WireId(); }
WireId Chip::getPipDstWire(PipId pip) const { return WireId(); } WireId Arch::getPipDstWire(PipId pip) const { return WireId(); }
DelayInfo Chip::getPipDelay(PipId pip) const { return DelayInfo(); } DelayInfo Arch::getPipDelay(PipId pip) const { return DelayInfo(); }
const std::vector<PipId> &Chip::getPipsDownhill(WireId wire) const const std::vector<PipId> &Arch::getPipsDownhill(WireId wire) const
{ {
static std::vector<PipId> ret; static std::vector<PipId> ret;
return ret; return ret;
} }
const std::vector<PipId> &Chip::getPipsUphill(WireId wire) const const std::vector<PipId> &Arch::getPipsUphill(WireId wire) const
{ {
static std::vector<PipId> ret; static std::vector<PipId> ret;
return ret; return ret;
} }
const std::vector<PipId> &Chip::getWireAliases(WireId wire) const const std::vector<PipId> &Arch::getWireAliases(WireId wire) const
{ {
static std::vector<PipId> ret; static std::vector<PipId> ret;
return ret; return ret;
@ -141,36 +141,36 @@ const std::vector<PipId> &Chip::getWireAliases(WireId wire) const
// --------------------------------------------------------------- // ---------------------------------------------------------------
bool Chip::estimatePosition(BelId bel, int &x, int &y) const bool Arch::estimatePosition(BelId bel, int &x, int &y) const
{ {
x = 0.0; x = 0.0;
y = 0.0; y = 0.0;
return false; return false;
} }
delay_t Chip::estimateDelay(WireId src, WireId dst) const { return 0.0; } delay_t Arch::estimateDelay(WireId src, WireId dst) const { return 0.0; }
// --------------------------------------------------------------- // ---------------------------------------------------------------
std::vector<GraphicElement> Chip::getFrameGraphics() const std::vector<GraphicElement> Arch::getFrameGraphics() const
{ {
static std::vector<GraphicElement> ret; static std::vector<GraphicElement> ret;
return ret; return ret;
} }
std::vector<GraphicElement> Chip::getBelGraphics(BelId bel) const std::vector<GraphicElement> Arch::getBelGraphics(BelId bel) const
{ {
static std::vector<GraphicElement> ret; static std::vector<GraphicElement> ret;
return ret; return ret;
} }
std::vector<GraphicElement> Chip::getWireGraphics(WireId wire) const std::vector<GraphicElement> Arch::getWireGraphics(WireId wire) const
{ {
static std::vector<GraphicElement> ret; static std::vector<GraphicElement> ret;
return ret; return ret;
} }
std::vector<GraphicElement> Chip::getPipGraphics(PipId pip) const std::vector<GraphicElement> Arch::getPipGraphics(PipId pip) const
{ {
static std::vector<GraphicElement> ret; static std::vector<GraphicElement> ret;
return ret; return ret;

View File

@ -63,15 +63,13 @@ struct BelPin
PortPin pin; PortPin pin;
}; };
struct ChipArgs struct ArchArgs
{ {
}; };
std::string getChipName(ChipArgs id); struct Arch
struct Chip
{ {
Chip(ChipArgs args); Arch(ArchArgs args);
std::string getChipName(); std::string getChipName();

View File

@ -27,7 +27,7 @@ USING_NEXTPNR_NAMESPACE
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
Design design(ChipArgs{}); Design design(ArchArgs{});
QApplication a(argc, argv); QApplication a(argc, argv);
MainWindow w(&design); MainWindow w(&design);

View File

@ -23,6 +23,6 @@
NEXTPNR_NAMESPACE_BEGIN NEXTPNR_NAMESPACE_BEGIN
void arch_wrap_python() { class_<ChipArgs>("ChipArgs"); } void arch_wrap_python() { class_<ArchArgs>("ArchArgs"); }
NEXTPNR_NAMESPACE_END NEXTPNR_NAMESPACE_END

View File

@ -90,7 +90,7 @@ static bool logicCellsCompatible(const std::vector<const CellInfo *> &cells)
bool isBelLocationValid(Design *design, BelId bel) bool isBelLocationValid(Design *design, BelId bel)
{ {
const Chip &chip = design->chip; const Arch &chip = design->chip;
if (chip.getBelType(bel) == TYPE_ICESTORM_LC) { if (chip.getBelType(bel) == TYPE_ICESTORM_LC) {
std::vector<const CellInfo *> cells; std::vector<const CellInfo *> cells;
for (auto bel_other : chip.getBelsAtSameTile(bel)) { for (auto bel_other : chip.getBelsAtSameTile(bel)) {
@ -112,7 +112,7 @@ bool isBelLocationValid(Design *design, BelId bel)
bool isValidBelForCell(Design *design, CellInfo *cell, BelId bel) bool isValidBelForCell(Design *design, CellInfo *cell, BelId bel)
{ {
const Chip &chip = design->chip; const Arch &chip = design->chip;
if (cell->type == "ICESTORM_LC") { if (cell->type == "ICESTORM_LC") {
assert(chip.getBelType(bel) == TYPE_ICESTORM_LC); assert(chip.getBelType(bel) == TYPE_ICESTORM_LC);

View File

@ -23,7 +23,7 @@
NEXTPNR_NAMESPACE_BEGIN NEXTPNR_NAMESPACE_BEGIN
inline TileType tile_at(const Chip &chip, int x, int y) inline TileType tile_at(const Arch &chip, int x, int y)
{ {
return chip.chip_info->tile_grid[y * chip.chip_info->width + x]; return chip.chip_info->tile_grid[y * chip.chip_info->width + x];
} }
@ -97,7 +97,7 @@ char get_hexdigit(int i) { return std::string("0123456789ABCDEF").at(i); }
void write_asc(const Design &design, std::ostream &out) void write_asc(const Design &design, std::ostream &out)
{ {
const Chip &chip = design.chip; const Arch &chip = design.chip;
// [y][x][row][col] // [y][x][row][col]
const ChipInfoPOD &ci = *chip.chip_info; const ChipInfoPOD &ci = *chip.chip_info;
const BitstreamInfoPOD &bi = *ci.bits_info; const BitstreamInfoPOD &bi = *ci.bits_info;
@ -115,18 +115,18 @@ void write_asc(const Design &design, std::ostream &out)
out << ".comment from next-pnr" << std::endl; out << ".comment from next-pnr" << std::endl;
switch (chip.args.type) { switch (chip.args.type) {
case ChipArgs::LP384: case ArchArgs::LP384:
out << ".device 384" << std::endl; out << ".device 384" << std::endl;
break; break;
case ChipArgs::HX1K: case ArchArgs::HX1K:
case ChipArgs::LP1K: case ArchArgs::LP1K:
out << ".device 1k" << std::endl; out << ".device 1k" << std::endl;
break; break;
case ChipArgs::HX8K: case ArchArgs::HX8K:
case ChipArgs::LP8K: case ArchArgs::LP8K:
out << ".device 8k" << std::endl; out << ".device 8k" << std::endl;
break; break;
case ChipArgs::UP5K: case ArchArgs::UP5K:
out << ".device 5k" << std::endl; out << ".device 5k" << std::endl;
break; break;
default: default:
@ -213,8 +213,8 @@ void write_asc(const Design &design, std::ostream &out)
input_en = true; input_en = true;
} }
if (chip.args.type == ChipArgs::LP1K || if (chip.args.type == ArchArgs::LP1K ||
chip.args.type == ChipArgs::HX1K) { chip.args.type == ArchArgs::HX1K) {
set_config(ti, config.at(iey).at(iex), set_config(ti, config.at(iey).at(iex),
"IoCtrl.IE_" + std::to_string(iez), !input_en); "IoCtrl.IE_" + std::to_string(iez), !input_en);
set_config(ti, config.at(iey).at(iex), set_config(ti, config.at(iey).at(iex),
@ -232,8 +232,8 @@ void write_asc(const Design &design, std::ostream &out)
int x = beli.x, y = beli.y; int x = beli.x, y = beli.y;
const TileInfoPOD &ti_ramt = bi.tiles_nonrouting[TILE_RAMT]; const TileInfoPOD &ti_ramt = bi.tiles_nonrouting[TILE_RAMT];
const TileInfoPOD &ti_ramb = bi.tiles_nonrouting[TILE_RAMB]; const TileInfoPOD &ti_ramb = bi.tiles_nonrouting[TILE_RAMB];
if (!(chip.args.type == ChipArgs::LP1K || if (!(chip.args.type == ArchArgs::LP1K ||
chip.args.type == ChipArgs::HX1K)) { chip.args.type == ArchArgs::HX1K)) {
set_config(ti_ramb, config.at(y).at(x), "RamConfig.PowerUp", set_config(ti_ramb, config.at(y).at(x), "RamConfig.PowerUp",
true); true);
} }
@ -268,8 +268,8 @@ void write_asc(const Design &design, std::ostream &out)
int iex, iey, iez; int iex, iey, iez;
std::tie(iex, iey, iez) = ieren; std::tie(iex, iey, iez) = ieren;
if (iez != -1) { if (iez != -1) {
if (chip.args.type == ChipArgs::LP1K || if (chip.args.type == ArchArgs::LP1K ||
chip.args.type == ChipArgs::HX1K) { chip.args.type == ArchArgs::HX1K) {
set_config(ti, config.at(iey).at(iex), set_config(ti, config.at(iey).at(iex),
"IoCtrl.IE_" + std::to_string(iez), true); "IoCtrl.IE_" + std::to_string(iez), true);
set_config(ti, config.at(iey).at(iex), set_config(ti, config.at(iey).at(iex),
@ -281,8 +281,8 @@ void write_asc(const Design &design, std::ostream &out)
const BelInfoPOD &beli = ci.bel_data[bel.index]; const BelInfoPOD &beli = ci.bel_data[bel.index];
int x = beli.x, y = beli.y; int x = beli.x, y = beli.y;
const TileInfoPOD &ti = bi.tiles_nonrouting[TILE_RAMB]; const TileInfoPOD &ti = bi.tiles_nonrouting[TILE_RAMB];
if ((chip.args.type == ChipArgs::LP1K || if ((chip.args.type == ArchArgs::LP1K ||
chip.args.type == ChipArgs::HX1K)) { chip.args.type == ArchArgs::HX1K)) {
set_config(ti, config.at(y).at(x), "RamConfig.PowerUp", true); set_config(ti, config.at(y).at(x), "RamConfig.PowerUp", true);
} }
} }
@ -296,17 +296,17 @@ void write_asc(const Design &design, std::ostream &out)
// set all ColBufCtrl bits (FIXME) // set all ColBufCtrl bits (FIXME)
bool setColBufCtrl = true; bool setColBufCtrl = true;
if (chip.args.type == ChipArgs::LP1K || if (chip.args.type == ArchArgs::LP1K ||
chip.args.type == ChipArgs::HX1K) { chip.args.type == ArchArgs::HX1K) {
if (tile == TILE_RAMB || tile == TILE_RAMT) { if (tile == TILE_RAMB || tile == TILE_RAMT) {
setColBufCtrl = (y == 3 || y == 5 || y == 11 || y == 13); setColBufCtrl = (y == 3 || y == 5 || y == 11 || y == 13);
} else { } else {
setColBufCtrl = (y == 4 || y == 5 || y == 12 || y == 13); setColBufCtrl = (y == 4 || y == 5 || y == 12 || y == 13);
} }
} else if (chip.args.type == ChipArgs::LP8K || } else if (chip.args.type == ArchArgs::LP8K ||
chip.args.type == ChipArgs::HX8K) { chip.args.type == ArchArgs::HX8K) {
setColBufCtrl = (y == 8 || y == 9 || y == 24 || y == 25); setColBufCtrl = (y == 8 || y == 9 || y == 24 || y == 25);
} else if (chip.args.type == ChipArgs::UP5K) { } else if (chip.args.type == ArchArgs::UP5K) {
if (tile == TILE_LOGIC) { if (tile == TILE_LOGIC) {
setColBufCtrl = (y == 4 || y == 5 || y == 14 || y == 15 || setColBufCtrl = (y == 4 || y == 5 || y == 14 || y == 15 ||
y == 26 || y == 27); y == 26 || y == 27);

View File

@ -78,10 +78,10 @@ PortPin portPinFromId(IdString id)
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
Chip::Chip(ChipArgs args) : args(args) Arch::Arch(ArchArgs args) : args(args)
{ {
#ifdef ICE40_HX1K_ONLY #ifdef ICE40_HX1K_ONLY
if (args.type == ChipArgs::HX1K) { if (args.type == ArchArgs::HX1K) {
chip_info = chip_info =
reinterpret_cast<const RelPtr<ChipInfoPOD> *>(chipdb_blob_1k) reinterpret_cast<const RelPtr<ChipInfoPOD> *>(chipdb_blob_1k)
->get(); ->get();
@ -89,19 +89,19 @@ Chip::Chip(ChipArgs args) : args(args)
log_error("Unsupported iCE40 chip type.\n"); log_error("Unsupported iCE40 chip type.\n");
} }
#else #else
if (args.type == ChipArgs::LP384) { if (args.type == ArchArgs::LP384) {
chip_info = chip_info =
reinterpret_cast<const RelPtr<ChipInfoPOD> *>(chipdb_blob_384) reinterpret_cast<const RelPtr<ChipInfoPOD> *>(chipdb_blob_384)
->get(); ->get();
} else if (args.type == ChipArgs::LP1K || args.type == ChipArgs::HX1K) { } else if (args.type == ArchArgs::LP1K || args.type == ArchArgs::HX1K) {
chip_info = chip_info =
reinterpret_cast<const RelPtr<ChipInfoPOD> *>(chipdb_blob_1k) reinterpret_cast<const RelPtr<ChipInfoPOD> *>(chipdb_blob_1k)
->get(); ->get();
} else if (args.type == ChipArgs::UP5K) { } else if (args.type == ArchArgs::UP5K) {
chip_info = chip_info =
reinterpret_cast<const RelPtr<ChipInfoPOD> *>(chipdb_blob_5k) reinterpret_cast<const RelPtr<ChipInfoPOD> *>(chipdb_blob_5k)
->get(); ->get();
} else if (args.type == ChipArgs::LP8K || args.type == ChipArgs::HX8K) { } else if (args.type == ArchArgs::LP8K || args.type == ArchArgs::HX8K) {
chip_info = chip_info =
reinterpret_cast<const RelPtr<ChipInfoPOD> *>(chipdb_blob_8k) reinterpret_cast<const RelPtr<ChipInfoPOD> *>(chipdb_blob_8k)
->get(); ->get();
@ -128,26 +128,26 @@ Chip::Chip(ChipArgs args) : args(args)
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
std::string Chip::getChipName() std::string Arch::getChipName()
{ {
#ifdef ICE40_HX1K_ONLY #ifdef ICE40_HX1K_ONLY
if (args.type == ChipArgs::HX1K) { if (args.type == ArchArgs::HX1K) {
return "Lattice LP1K"; return "Lattice LP1K";
} else { } else {
log_error("Unsupported iCE40 chip type.\n"); log_error("Unsupported iCE40 chip type.\n");
} }
#else #else
if (args.type == ChipArgs::LP384) { if (args.type == ArchArgs::LP384) {
return "Lattice LP384"; return "Lattice LP384";
} else if (args.type == ChipArgs::LP1K) { } else if (args.type == ArchArgs::LP1K) {
return "Lattice LP1K"; return "Lattice LP1K";
} else if (args.type == ChipArgs::HX1K) { } else if (args.type == ArchArgs::HX1K) {
return "Lattice HX1K"; return "Lattice HX1K";
} else if (args.type == ChipArgs::UP5K) { } else if (args.type == ArchArgs::UP5K) {
return "Lattice UP5K"; return "Lattice UP5K";
} else if (args.type == ChipArgs::LP8K) { } else if (args.type == ArchArgs::LP8K) {
return "Lattice LP8K"; return "Lattice LP8K";
} else if (args.type == ChipArgs::HX8K) { } else if (args.type == ArchArgs::HX8K) {
return "Lattice HX8K"; return "Lattice HX8K";
} else { } else {
log_error("Unknown chip\n"); log_error("Unknown chip\n");
@ -157,7 +157,7 @@ std::string Chip::getChipName()
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
BelId Chip::getBelByName(IdString name) const BelId Arch::getBelByName(IdString name) const
{ {
BelId ret; BelId ret;
@ -173,7 +173,7 @@ BelId Chip::getBelByName(IdString name) const
return ret; return ret;
} }
BelRange Chip::getBelsAtSameTile(BelId bel) const BelRange Arch::getBelsAtSameTile(BelId bel) const
{ {
BelRange br; BelRange br;
assert(bel != BelId()); assert(bel != BelId());
@ -193,7 +193,7 @@ BelRange Chip::getBelsAtSameTile(BelId bel) const
return br; return br;
} }
WireId Chip::getWireBelPin(BelId bel, PortPin pin) const WireId Arch::getWireBelPin(BelId bel, PortPin pin) const
{ {
WireId ret; WireId ret;
@ -214,7 +214,7 @@ WireId Chip::getWireBelPin(BelId bel, PortPin pin) const
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
WireId Chip::getWireByName(IdString name) const WireId Arch::getWireByName(IdString name) const
{ {
WireId ret; WireId ret;
@ -232,7 +232,7 @@ WireId Chip::getWireByName(IdString name) const
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
PipId Chip::getPipByName(IdString name) const PipId Arch::getPipByName(IdString name) const
{ {
PipId ret; PipId ret;
@ -251,7 +251,7 @@ PipId Chip::getPipByName(IdString name) const
return ret; return ret;
} }
IdString Chip::getPipName(PipId pip) const IdString Arch::getPipName(PipId pip) const
{ {
assert(pip != PipId()); assert(pip != PipId());
@ -272,7 +272,7 @@ IdString Chip::getPipName(PipId pip) const
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
BelId Chip::getPackagePinBel(const std::string &pin) const BelId Arch::getPackagePinBel(const std::string &pin) const
{ {
for (int i = 0; i < package_info->num_pins; i++) { for (int i = 0; i < package_info->num_pins; i++) {
if (package_info->pins[i].name.get() == pin) { if (package_info->pins[i].name.get() == pin) {
@ -284,7 +284,7 @@ BelId Chip::getPackagePinBel(const std::string &pin) const
return BelId(); return BelId();
} }
std::string Chip::getBelPackagePin(BelId bel) const std::string Arch::getBelPackagePin(BelId bel) const
{ {
for (int i = 0; i < package_info->num_pins; i++) { for (int i = 0; i < package_info->num_pins; i++) {
if (package_info->pins[i].bel_index == bel.index) { if (package_info->pins[i].bel_index == bel.index) {
@ -295,7 +295,7 @@ std::string Chip::getBelPackagePin(BelId bel) const
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
bool Chip::estimatePosition(BelId bel, int &x, int &y) const bool Arch::estimatePosition(BelId bel, int &x, int &y) const
{ {
assert(bel != BelId()); assert(bel != BelId());
x = chip_info->bel_data[bel.index].x; x = chip_info->bel_data[bel.index].x;
@ -304,7 +304,7 @@ bool Chip::estimatePosition(BelId bel, int &x, int &y) const
return chip_info->bel_data[bel.index].type != TYPE_SB_GB; return chip_info->bel_data[bel.index].type != TYPE_SB_GB;
} }
delay_t Chip::estimateDelay(WireId src, WireId dst) const delay_t Arch::estimateDelay(WireId src, WireId dst) const
{ {
assert(src != WireId()); assert(src != WireId());
delay_t x1 = chip_info->wire_data[src.index].x; delay_t x1 = chip_info->wire_data[src.index].x;
@ -319,7 +319,7 @@ delay_t Chip::estimateDelay(WireId src, WireId dst) const
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
std::vector<GraphicElement> Chip::getFrameGraphics() const std::vector<GraphicElement> Arch::getFrameGraphics() const
{ {
std::vector<GraphicElement> ret; std::vector<GraphicElement> ret;
@ -336,7 +336,7 @@ std::vector<GraphicElement> Chip::getFrameGraphics() const
return ret; return ret;
} }
std::vector<GraphicElement> Chip::getBelGraphics(BelId bel) const std::vector<GraphicElement> Arch::getBelGraphics(BelId bel) const
{ {
std::vector<GraphicElement> ret; std::vector<GraphicElement> ret;
@ -402,14 +402,14 @@ std::vector<GraphicElement> Chip::getBelGraphics(BelId bel) const
return ret; return ret;
} }
std::vector<GraphicElement> Chip::getWireGraphics(WireId wire) const std::vector<GraphicElement> Arch::getWireGraphics(WireId wire) const
{ {
std::vector<GraphicElement> ret; std::vector<GraphicElement> ret;
// FIXME // FIXME
return ret; return ret;
} }
std::vector<GraphicElement> Chip::getPipGraphics(PipId pip) const std::vector<GraphicElement> Arch::getPipGraphics(PipId pip) const
{ {
std::vector<GraphicElement> ret; std::vector<GraphicElement> ret;
// FIXME // FIXME

View File

@ -443,7 +443,7 @@ struct PipRange
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
struct ChipArgs struct ArchArgs
{ {
enum enum
{ {
@ -458,7 +458,7 @@ struct ChipArgs
std::string package; std::string package;
}; };
struct Chip struct Arch
{ {
const ChipInfoPOD *chip_info; const ChipInfoPOD *chip_info;
const PackageInfoPOD *package_info; const PackageInfoPOD *package_info;
@ -471,13 +471,14 @@ struct Chip
std::vector<IdString> wire_to_net; std::vector<IdString> wire_to_net;
std::vector<IdString> pip_to_net; std::vector<IdString> pip_to_net;
std::vector<IdString> switches_locked; std::vector<IdString> switches_locked;
Chip(ChipArgs args);
ChipArgs args; ArchArgs args;
// ------------------------------------------------- Arch(ArchArgs args);
std::string getChipName(); std::string getChipName();
// -------------------------------------------------
BelId getBelByName(IdString name) const; BelId getBelByName(IdString name) const;
IdString getBelName(BelId bel) const IdString getBelName(BelId bel) const
@ -641,7 +642,7 @@ struct Chip
bool checkPipAvail(PipId pip) const bool checkPipAvail(PipId pip) const
{ {
assert(pip != PipId()); assert(pip != PipId());
if (args.type == ChipArgs::UP5K) { if (args.type == ArchArgs::UP5K) {
int x = chip_info->pip_data[pip.index].x; int x = chip_info->pip_data[pip.index].x;
if (x == 0 || x == (chip_info->width - 1)) if (x == 0 || x == (chip_info->width - 1))
return false; return false;

View File

@ -134,56 +134,56 @@ int main(int argc, char *argv[])
verbose = true; verbose = true;
} }
ChipArgs chipArgs; ArchArgs chipArgs;
if (vm.count("lp384")) { if (vm.count("lp384")) {
if (chipArgs.type != ChipArgs::NONE) if (chipArgs.type != ArchArgs::NONE)
goto help; goto help;
chipArgs.type = ChipArgs::LP384; chipArgs.type = ArchArgs::LP384;
chipArgs.package = "qn32"; chipArgs.package = "qn32";
} }
if (vm.count("lp1k")) { if (vm.count("lp1k")) {
if (chipArgs.type != ChipArgs::NONE) if (chipArgs.type != ArchArgs::NONE)
goto help; goto help;
chipArgs.type = ChipArgs::LP1K; chipArgs.type = ArchArgs::LP1K;
chipArgs.package = "tq144"; chipArgs.package = "tq144";
} }
if (vm.count("lp8k")) { if (vm.count("lp8k")) {
if (chipArgs.type != ChipArgs::NONE) if (chipArgs.type != ArchArgs::NONE)
goto help; goto help;
chipArgs.type = ChipArgs::LP8K; chipArgs.type = ArchArgs::LP8K;
chipArgs.package = "ct256"; chipArgs.package = "ct256";
} }
if (vm.count("hx1k")) { if (vm.count("hx1k")) {
if (chipArgs.type != ChipArgs::NONE) if (chipArgs.type != ArchArgs::NONE)
goto help; goto help;
chipArgs.type = ChipArgs::HX1K; chipArgs.type = ArchArgs::HX1K;
chipArgs.package = "tq144"; chipArgs.package = "tq144";
} }
if (vm.count("hx8k")) { if (vm.count("hx8k")) {
if (chipArgs.type != ChipArgs::NONE) if (chipArgs.type != ArchArgs::NONE)
goto help; goto help;
chipArgs.type = ChipArgs::HX8K; chipArgs.type = ArchArgs::HX8K;
chipArgs.package = "ct256"; chipArgs.package = "ct256";
} }
if (vm.count("up5k")) { if (vm.count("up5k")) {
if (chipArgs.type != ChipArgs::NONE) if (chipArgs.type != ArchArgs::NONE)
goto help; goto help;
chipArgs.type = ChipArgs::UP5K; chipArgs.type = ArchArgs::UP5K;
chipArgs.package = "sg48"; chipArgs.package = "sg48";
} }
if (chipArgs.type == ChipArgs::NONE) { if (chipArgs.type == ArchArgs::NONE) {
chipArgs.type = ChipArgs::HX1K; chipArgs.type = ArchArgs::HX1K;
chipArgs.package = "tq144"; chipArgs.package = "tq144";
} }
#ifdef ICE40_HX1K_ONLY #ifdef ICE40_HX1K_ONLY
if (chipArgs.type != ChipArgs::HX1K) { if (chipArgs.type != ArchArgs::HX1K) {
std::cout << "This version of nextpnr-ice40 is built with HX1K-support " std::cout << "This version of nextpnr-ice40 is built with HX1K-support "
"only.\n"; "only.\n";
return 1; return 1;

View File

@ -25,16 +25,16 @@ NEXTPNR_NAMESPACE_BEGIN
void arch_wrap_python() void arch_wrap_python()
{ {
class_<ChipArgs>("ChipArgs").def_readwrite("type", &ChipArgs::type); class_<ArchArgs>("ArchArgs").def_readwrite("type", &ArchArgs::type);
enum_<decltype(std::declval<ChipArgs>().type)>("iCE40Type") enum_<decltype(std::declval<ArchArgs>().type)>("iCE40Type")
.value("NONE", ChipArgs::NONE) .value("NONE", ArchArgs::NONE)
.value("LP384", ChipArgs::LP384) .value("LP384", ArchArgs::LP384)
.value("LP1K", ChipArgs::LP1K) .value("LP1K", ArchArgs::LP1K)
.value("LP8K", ChipArgs::LP8K) .value("LP8K", ArchArgs::LP8K)
.value("HX1K", ChipArgs::HX1K) .value("HX1K", ArchArgs::HX1K)
.value("HX8K", ChipArgs::HX8K) .value("HX8K", ArchArgs::HX8K)
.value("UP5K", ChipArgs::UP5K) .value("UP5K", ArchArgs::UP5K)
.export_values(); .export_values();
class_<BelId>("BelId").def_readwrite("index", &BelId::index); class_<BelId>("BelId").def_readwrite("index", &BelId::index);
@ -53,28 +53,28 @@ void arch_wrap_python()
; ;
#undef X #undef X
class_<Chip>("Chip", init<ChipArgs>()) class_<Arch>("Arch", init<ArchArgs>())
.def("getBelByName", &Chip::getBelByName) .def("getBelByName", &Arch::getBelByName)
.def("getWireByName", &Chip::getWireByName) .def("getWireByName", &Arch::getWireByName)
.def("getBelName", &Chip::getBelName) .def("getBelName", &Arch::getBelName)
.def("getWireName", &Chip::getWireName) .def("getWireName", &Arch::getWireName)
.def("getBels", &Chip::getBels) .def("getBels", &Arch::getBels)
.def("getBelType", &Chip::getBelType) .def("getBelType", &Arch::getBelType)
.def("getWireBelPin", &Chip::getWireBelPin) .def("getWireBelPin", &Arch::getWireBelPin)
.def("getBelPinUphill", &Chip::getBelPinUphill) .def("getBelPinUphill", &Arch::getBelPinUphill)
.def("getBelPinsDownhill", &Chip::getBelPinsDownhill) .def("getBelPinsDownhill", &Arch::getBelPinsDownhill)
.def("getWires", &Chip::getWires) .def("getWires", &Arch::getWires)
.def("getPipByName", &Chip::getPipByName) .def("getPipByName", &Arch::getPipByName)
.def("getPipName", &Chip::getPipName) .def("getPipName", &Arch::getPipName)
.def("getPips", &Chip::getPips) .def("getPips", &Arch::getPips)
.def("getPipSrcWire", &Chip::getPipSrcWire) .def("getPipSrcWire", &Arch::getPipSrcWire)
.def("getPipDstWire", &Chip::getPipDstWire) .def("getPipDstWire", &Arch::getPipDstWire)
.def("getPipDelay", &Chip::getPipDelay) .def("getPipDelay", &Arch::getPipDelay)
.def("getPipsDownhill", &Chip::getPipsDownhill) .def("getPipsDownhill", &Arch::getPipsDownhill)
.def("getPipsUphill", &Chip::getPipsUphill) .def("getPipsUphill", &Arch::getPipsUphill)
.def("getWireAliases", &Chip::getWireAliases) .def("getWireAliases", &Arch::getWireAliases)
.def("estimatePosition", &Chip::estimatePosition) .def("estimatePosition", &Arch::estimatePosition)
.def("estimateDelay", &Chip::estimateDelay); .def("estimateDelay", &Arch::estimateDelay);
WRAP_RANGE(Bel); WRAP_RANGE(Bel);
WRAP_RANGE(BelPin); WRAP_RANGE(BelPin);