2018-05-26 20:27:21 +08:00
|
|
|
/*
|
|
|
|
* nextpnr -- Next Generation Place and Route
|
|
|
|
*
|
2018-06-22 22:19:17 +08:00
|
|
|
* Copyright (C) 2018 Clifford Wolf <clifford@symbioticeda.com>
|
2018-07-24 05:13:10 +08:00
|
|
|
* Copyright (C) 2018 Serge Bazanski <q3k@symbioticeda.com>
|
2018-05-26 20:27:21 +08:00
|
|
|
*
|
|
|
|
* 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-13 20:53:44 +08:00
|
|
|
#include <algorithm>
|
2019-02-09 20:34:57 +08:00
|
|
|
#include <boost/iostreams/device/mapped_file.hpp>
|
2018-06-13 20:53:44 +08:00
|
|
|
#include <cmath>
|
2018-07-21 01:24:34 +08:00
|
|
|
#include "cells.h"
|
2018-07-13 04:04:13 +08:00
|
|
|
#include "gfx.h"
|
2018-06-10 00:19:20 +08:00
|
|
|
#include "log.h"
|
2018-06-12 02:12:57 +08:00
|
|
|
#include "nextpnr.h"
|
2018-07-12 00:15:08 +08:00
|
|
|
#include "placer1.h"
|
2019-01-11 00:42:29 +08:00
|
|
|
#include "placer_heap.h"
|
2018-07-12 00:04:09 +08:00
|
|
|
#include "router1.h"
|
2018-12-02 20:01:43 +08:00
|
|
|
#include "timing_opt.h"
|
2018-12-02 21:15:39 +08:00
|
|
|
#include "util.h"
|
2018-06-12 20:24:59 +08:00
|
|
|
NEXTPNR_NAMESPACE_BEGIN
|
|
|
|
|
2018-07-15 01:50:37 +08:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2018-06-19 18:08:37 +08:00
|
|
|
void IdString::initialize_arch(const BaseCtx *ctx)
|
2018-05-26 22:08:20 +08:00
|
|
|
{
|
2018-08-08 23:01:18 +08:00
|
|
|
#define X(t) initialize_add(ctx, #t, ID_##t);
|
|
|
|
#include "constids.inc"
|
2018-06-03 22:16:59 +08:00
|
|
|
#undef X
|
2018-05-26 22:08:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2018-06-23 21:28:09 +08:00
|
|
|
static const ChipInfoPOD *get_chip_info(const RelPtr<ChipInfoPOD> *ptr) { return ptr->get(); }
|
2018-06-23 02:19:29 +08:00
|
|
|
|
2018-07-04 18:06:03 +08:00
|
|
|
#if defined(_MSC_VER)
|
|
|
|
void load_chipdb();
|
|
|
|
#endif
|
|
|
|
|
2019-02-09 20:34:57 +08:00
|
|
|
#if defined(EXTERNAL_CHIPDB_ROOT)
|
|
|
|
const char *chipdb_blob_384 = nullptr;
|
|
|
|
const char *chipdb_blob_1k = nullptr;
|
|
|
|
const char *chipdb_blob_5k = nullptr;
|
2019-02-23 05:36:19 +08:00
|
|
|
const char *chipdb_blob_u4k = nullptr;
|
2019-02-09 20:34:57 +08:00
|
|
|
const char *chipdb_blob_8k = nullptr;
|
|
|
|
|
2019-03-19 22:23:43 +08:00
|
|
|
boost::iostreams::mapped_file_source blob_files[5];
|
2019-02-09 20:34:57 +08:00
|
|
|
|
|
|
|
const char *mmap_file(int index, const char *filename)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
blob_files[index].open(filename);
|
|
|
|
if (!blob_files[index].is_open())
|
|
|
|
log_error("Unable to read chipdb %s\n", filename);
|
|
|
|
return (const char *)blob_files[index].data();
|
|
|
|
} catch (...) {
|
|
|
|
log_error("Unable to read chipdb %s\n", filename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void load_chipdb()
|
|
|
|
{
|
|
|
|
chipdb_blob_384 = mmap_file(0, EXTERNAL_CHIPDB_ROOT "/ice40/chipdb-384.bin");
|
|
|
|
chipdb_blob_1k = mmap_file(1, EXTERNAL_CHIPDB_ROOT "/ice40/chipdb-1k.bin");
|
|
|
|
chipdb_blob_5k = mmap_file(2, EXTERNAL_CHIPDB_ROOT "/ice40/chipdb-5k.bin");
|
2019-03-19 22:23:43 +08:00
|
|
|
chipdb_blob_u4k = mmap_file(3, EXTERNAL_CHIPDB_ROOT "/ice40/chipdb-u4k.bin");
|
|
|
|
chipdb_blob_8k = mmap_file(4, EXTERNAL_CHIPDB_ROOT "/ice40/chipdb-8k.bin");
|
2019-02-09 20:34:57 +08:00
|
|
|
}
|
|
|
|
#endif
|
2018-06-18 19:35:25 +08:00
|
|
|
Arch::Arch(ArchArgs args) : args(args)
|
2018-05-26 20:27:21 +08:00
|
|
|
{
|
2019-02-09 20:34:57 +08:00
|
|
|
#if defined(_MSC_VER) || defined(EXTERNAL_CHIPDB_ROOT)
|
2018-07-04 18:06:03 +08:00
|
|
|
load_chipdb();
|
|
|
|
#endif
|
|
|
|
|
2018-06-07 18:26:02 +08:00
|
|
|
#ifdef ICE40_HX1K_ONLY
|
2018-06-18 19:35:25 +08:00
|
|
|
if (args.type == ArchArgs::HX1K) {
|
2018-07-30 22:21:03 +08:00
|
|
|
fast_part = true;
|
2018-06-23 21:28:09 +08:00
|
|
|
chip_info = get_chip_info(reinterpret_cast<const RelPtr<ChipInfoPOD> *>(chipdb_blob_1k));
|
2018-06-10 00:19:20 +08:00
|
|
|
} else {
|
|
|
|
log_error("Unsupported iCE40 chip type.\n");
|
2018-06-07 18:56:49 +08:00
|
|
|
}
|
2018-06-07 18:26:02 +08:00
|
|
|
#else
|
2018-06-18 19:35:25 +08:00
|
|
|
if (args.type == ArchArgs::LP384) {
|
2018-07-30 22:21:03 +08:00
|
|
|
fast_part = false;
|
2018-06-23 21:28:09 +08:00
|
|
|
chip_info = get_chip_info(reinterpret_cast<const RelPtr<ChipInfoPOD> *>(chipdb_blob_384));
|
2018-06-18 19:35:25 +08:00
|
|
|
} else if (args.type == ArchArgs::LP1K || args.type == ArchArgs::HX1K) {
|
2018-07-30 22:21:03 +08:00
|
|
|
fast_part = args.type == ArchArgs::HX1K;
|
2018-06-23 21:28:09 +08:00
|
|
|
chip_info = get_chip_info(reinterpret_cast<const RelPtr<ChipInfoPOD> *>(chipdb_blob_1k));
|
2018-06-18 19:35:25 +08:00
|
|
|
} else if (args.type == ArchArgs::UP5K) {
|
2018-07-30 22:21:03 +08:00
|
|
|
fast_part = false;
|
2018-06-23 21:28:09 +08:00
|
|
|
chip_info = get_chip_info(reinterpret_cast<const RelPtr<ChipInfoPOD> *>(chipdb_blob_5k));
|
2019-02-23 05:36:19 +08:00
|
|
|
} else if (args.type == ArchArgs::U4K) {
|
|
|
|
fast_part = false;
|
|
|
|
chip_info = get_chip_info(reinterpret_cast<const RelPtr<ChipInfoPOD> *>(chipdb_blob_u4k));
|
2018-06-18 19:35:25 +08:00
|
|
|
} else if (args.type == ArchArgs::LP8K || args.type == ArchArgs::HX8K) {
|
2018-07-30 22:21:03 +08:00
|
|
|
fast_part = args.type == ArchArgs::HX8K;
|
2018-06-23 21:28:09 +08:00
|
|
|
chip_info = get_chip_info(reinterpret_cast<const RelPtr<ChipInfoPOD> *>(chipdb_blob_8k));
|
2018-06-07 18:56:49 +08:00
|
|
|
} else {
|
2018-06-10 00:19:20 +08:00
|
|
|
log_error("Unsupported iCE40 chip type.\n");
|
2018-06-07 18:56:49 +08:00
|
|
|
}
|
2018-06-07 18:26:02 +08:00
|
|
|
#endif
|
2018-05-26 20:56:30 +08:00
|
|
|
|
2018-06-13 17:51:09 +08:00
|
|
|
package_info = nullptr;
|
2018-06-17 22:12:52 +08:00
|
|
|
for (int i = 0; i < chip_info->num_packages; i++) {
|
|
|
|
if (chip_info->packages_data[i].name.get() == args.package) {
|
|
|
|
package_info = &(chip_info->packages_data[i]);
|
2018-06-13 17:51:09 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (package_info == nullptr)
|
|
|
|
log_error("Unsupported package '%s'.\n", args.package.c_str());
|
|
|
|
|
2018-08-03 23:37:59 +08:00
|
|
|
bel_carry.resize(chip_info->num_bels);
|
2018-06-17 22:12:52 +08:00
|
|
|
bel_to_cell.resize(chip_info->num_bels);
|
|
|
|
wire_to_net.resize(chip_info->num_wires);
|
|
|
|
pip_to_net.resize(chip_info->num_pips);
|
|
|
|
switches_locked.resize(chip_info->num_switches);
|
2018-05-26 20:27:21 +08:00
|
|
|
}
|
|
|
|
|
2018-06-06 21:13:41 +08:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2018-07-31 23:01:38 +08:00
|
|
|
std::string Arch::getChipName() const
|
2018-06-11 00:25:23 +08:00
|
|
|
{
|
|
|
|
#ifdef ICE40_HX1K_ONLY
|
2018-06-18 19:35:25 +08:00
|
|
|
if (args.type == ArchArgs::HX1K) {
|
2018-06-11 00:25:23 +08:00
|
|
|
return "Lattice LP1K";
|
|
|
|
} else {
|
|
|
|
log_error("Unsupported iCE40 chip type.\n");
|
|
|
|
}
|
|
|
|
#else
|
2018-06-18 19:35:25 +08:00
|
|
|
if (args.type == ArchArgs::LP384) {
|
2018-06-11 00:25:23 +08:00
|
|
|
return "Lattice LP384";
|
2018-06-18 19:35:25 +08:00
|
|
|
} else if (args.type == ArchArgs::LP1K) {
|
2018-06-11 00:25:23 +08:00
|
|
|
return "Lattice LP1K";
|
2018-06-18 19:35:25 +08:00
|
|
|
} else if (args.type == ArchArgs::HX1K) {
|
2018-06-11 00:25:23 +08:00
|
|
|
return "Lattice HX1K";
|
2018-06-18 19:35:25 +08:00
|
|
|
} else if (args.type == ArchArgs::UP5K) {
|
2018-06-11 00:25:23 +08:00
|
|
|
return "Lattice UP5K";
|
2019-02-23 05:36:19 +08:00
|
|
|
} else if (args.type == ArchArgs::U4K) {
|
|
|
|
return "Lattice U4K";
|
2018-06-18 19:35:25 +08:00
|
|
|
} else if (args.type == ArchArgs::LP8K) {
|
2018-06-11 00:25:23 +08:00
|
|
|
return "Lattice LP8K";
|
2018-06-18 19:35:25 +08:00
|
|
|
} else if (args.type == ArchArgs::HX8K) {
|
2018-06-11 00:25:23 +08:00
|
|
|
return "Lattice HX8K";
|
|
|
|
} else {
|
|
|
|
log_error("Unknown chip\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2018-06-24 20:38:45 +08:00
|
|
|
IdString Arch::archArgsToId(ArchArgs args) const
|
|
|
|
{
|
|
|
|
if (args.type == ArchArgs::LP384)
|
|
|
|
return id("lp384");
|
|
|
|
if (args.type == ArchArgs::LP1K)
|
|
|
|
return id("lp1k");
|
|
|
|
if (args.type == ArchArgs::HX1K)
|
|
|
|
return id("hx1k");
|
|
|
|
if (args.type == ArchArgs::UP5K)
|
|
|
|
return id("up5k");
|
2019-02-23 05:36:19 +08:00
|
|
|
if (args.type == ArchArgs::U4K)
|
|
|
|
return id("u4k");
|
2018-06-24 20:38:45 +08:00
|
|
|
if (args.type == ArchArgs::LP8K)
|
|
|
|
return id("lp8k");
|
|
|
|
if (args.type == ArchArgs::HX8K)
|
|
|
|
return id("hx8k");
|
|
|
|
return IdString();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2018-07-15 01:52:56 +08:00
|
|
|
BelId Arch::getBelByName(IdString name) const
|
|
|
|
{
|
|
|
|
BelId ret;
|
|
|
|
|
|
|
|
if (bel_by_name.empty()) {
|
|
|
|
for (int i = 0; i < chip_info->num_bels; i++)
|
|
|
|
bel_by_name[id(chip_info->bel_data[i].name.get())] = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto it = bel_by_name.find(name);
|
|
|
|
if (it != bel_by_name.end())
|
|
|
|
ret.index = it->second;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-07-21 00:09:22 +08:00
|
|
|
BelId Arch::getBelByLocation(Loc loc) const
|
2018-07-20 23:33:57 +08:00
|
|
|
{
|
2018-07-21 00:09:22 +08:00
|
|
|
BelId bel;
|
|
|
|
|
2018-07-20 23:33:57 +08:00
|
|
|
if (bel_by_loc.empty()) {
|
2018-07-21 00:09:22 +08:00
|
|
|
for (int i = 0; i < chip_info->num_bels; i++) {
|
|
|
|
BelId b;
|
|
|
|
b.index = i;
|
|
|
|
bel_by_loc[getBelLocation(b)] = i;
|
|
|
|
}
|
2018-07-20 23:33:57 +08:00
|
|
|
}
|
|
|
|
|
2018-07-21 00:09:22 +08:00
|
|
|
auto it = bel_by_loc.find(loc);
|
2018-07-20 23:33:57 +08:00
|
|
|
if (it != bel_by_loc.end())
|
2018-07-21 00:09:22 +08:00
|
|
|
bel.index = it->second;
|
|
|
|
|
|
|
|
return bel;
|
2018-07-20 23:33:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
BelRange Arch::getBelsByTile(int x, int y) const
|
|
|
|
{
|
2018-08-07 08:35:23 +08:00
|
|
|
// In iCE40 chipdb bels at the same tile are consecutive and dense z ordinates
|
|
|
|
// are used
|
2018-07-20 23:33:57 +08:00
|
|
|
BelRange br;
|
2018-07-21 00:09:22 +08:00
|
|
|
|
2018-07-22 03:40:06 +08:00
|
|
|
br.b.cursor = Arch::getBelByLocation(Loc(x, y, 0)).index;
|
2018-07-20 23:33:57 +08:00
|
|
|
br.e.cursor = br.b.cursor;
|
|
|
|
|
|
|
|
if (br.e.cursor != -1) {
|
2018-07-22 06:50:49 +08:00
|
|
|
while (br.e.cursor < chip_info->num_bels && chip_info->bel_data[br.e.cursor].x == x &&
|
2018-07-20 23:33:57 +08:00
|
|
|
chip_info->bel_data[br.e.cursor].y == y)
|
|
|
|
br.e.cursor++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return br;
|
|
|
|
}
|
|
|
|
|
2018-08-08 23:01:18 +08:00
|
|
|
PortType Arch::getBelPinType(BelId bel, IdString pin) const
|
2018-07-22 17:56:51 +08:00
|
|
|
{
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
|
|
|
|
|
|
|
int num_bel_wires = chip_info->bel_data[bel.index].num_bel_wires;
|
|
|
|
const BelWirePOD *bel_wires = chip_info->bel_data[bel.index].bel_wires.get();
|
|
|
|
|
2018-07-31 17:55:25 +08:00
|
|
|
if (num_bel_wires < 7) {
|
|
|
|
for (int i = 0; i < num_bel_wires; i++) {
|
2018-08-08 23:01:18 +08:00
|
|
|
if (bel_wires[i].port == pin.index)
|
2018-07-31 17:55:25 +08:00
|
|
|
return PortType(bel_wires[i].type);
|
|
|
|
}
|
|
|
|
} else {
|
2018-08-01 11:57:36 +08:00
|
|
|
int b = 0, e = num_bel_wires - 1;
|
2018-07-31 17:55:25 +08:00
|
|
|
while (b <= e) {
|
2018-08-01 11:57:36 +08:00
|
|
|
int i = (b + e) / 2;
|
2018-08-08 23:01:18 +08:00
|
|
|
if (bel_wires[i].port == pin.index)
|
2018-07-31 17:55:25 +08:00
|
|
|
return PortType(bel_wires[i].type);
|
2018-08-08 23:01:18 +08:00
|
|
|
if (bel_wires[i].port > pin.index)
|
2018-08-01 11:57:36 +08:00
|
|
|
e = i - 1;
|
2018-07-31 17:55:25 +08:00
|
|
|
else
|
2018-08-01 11:57:36 +08:00
|
|
|
b = i + 1;
|
2018-07-31 17:55:25 +08:00
|
|
|
}
|
|
|
|
}
|
2018-07-22 17:56:51 +08:00
|
|
|
|
|
|
|
return PORT_INOUT;
|
|
|
|
}
|
|
|
|
|
2018-08-19 22:31:02 +08:00
|
|
|
std::vector<std::pair<IdString, std::string>> Arch::getBelAttrs(BelId bel) const
|
2018-08-18 20:14:27 +08:00
|
|
|
{
|
|
|
|
std::vector<std::pair<IdString, std::string>> ret;
|
2018-08-19 22:31:02 +08:00
|
|
|
|
|
|
|
ret.push_back(std::make_pair(id("INDEX"), stringf("%d", bel.index)));
|
|
|
|
|
2018-08-18 20:14:27 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-08-08 23:01:18 +08:00
|
|
|
WireId Arch::getBelPinWire(BelId bel, IdString pin) const
|
2018-07-15 01:50:34 +08:00
|
|
|
{
|
2018-07-15 01:52:56 +08:00
|
|
|
WireId ret;
|
2018-07-15 01:50:15 +08:00
|
|
|
|
2018-07-15 01:52:56 +08:00
|
|
|
NPNR_ASSERT(bel != BelId());
|
2018-07-15 01:50:15 +08:00
|
|
|
|
2018-07-15 01:52:56 +08:00
|
|
|
int num_bel_wires = chip_info->bel_data[bel.index].num_bel_wires;
|
|
|
|
const BelWirePOD *bel_wires = chip_info->bel_data[bel.index].bel_wires.get();
|
2018-07-15 01:50:15 +08:00
|
|
|
|
2018-07-31 17:55:25 +08:00
|
|
|
if (num_bel_wires < 7) {
|
|
|
|
for (int i = 0; i < num_bel_wires; i++) {
|
2018-08-08 23:01:18 +08:00
|
|
|
if (bel_wires[i].port == pin.index) {
|
2018-07-31 17:55:25 +08:00
|
|
|
ret.index = bel_wires[i].wire_index;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2018-08-01 11:57:36 +08:00
|
|
|
int b = 0, e = num_bel_wires - 1;
|
2018-07-31 17:55:25 +08:00
|
|
|
while (b <= e) {
|
2018-08-01 11:57:36 +08:00
|
|
|
int i = (b + e) / 2;
|
2018-08-08 23:01:18 +08:00
|
|
|
if (bel_wires[i].port == pin.index) {
|
2018-07-31 17:55:25 +08:00
|
|
|
ret.index = bel_wires[i].wire_index;
|
|
|
|
break;
|
|
|
|
}
|
2018-08-08 23:01:18 +08:00
|
|
|
if (bel_wires[i].port > pin.index)
|
2018-08-01 11:57:36 +08:00
|
|
|
e = i - 1;
|
2018-07-31 17:55:25 +08:00
|
|
|
else
|
2018-08-01 11:57:36 +08:00
|
|
|
b = i + 1;
|
2018-07-15 01:52:56 +08:00
|
|
|
}
|
2018-07-22 20:42:07 +08:00
|
|
|
}
|
2018-07-15 01:50:15 +08:00
|
|
|
|
2018-07-15 01:52:56 +08:00
|
|
|
return ret;
|
2018-07-15 01:50:34 +08:00
|
|
|
}
|
2018-07-15 01:50:15 +08:00
|
|
|
|
2018-08-08 23:01:18 +08:00
|
|
|
std::vector<IdString> Arch::getBelPins(BelId bel) const
|
2018-07-22 18:08:52 +08:00
|
|
|
{
|
2018-08-08 23:01:18 +08:00
|
|
|
std::vector<IdString> ret;
|
2018-07-22 18:08:52 +08:00
|
|
|
|
|
|
|
NPNR_ASSERT(bel != BelId());
|
|
|
|
|
|
|
|
int num_bel_wires = chip_info->bel_data[bel.index].num_bel_wires;
|
|
|
|
const BelWirePOD *bel_wires = chip_info->bel_data[bel.index].bel_wires.get();
|
|
|
|
|
|
|
|
for (int i = 0; i < num_bel_wires; i++)
|
2018-08-08 23:01:18 +08:00
|
|
|
ret.push_back(IdString(bel_wires[i].port));
|
2018-07-22 18:08:52 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-11-17 17:18:17 +08:00
|
|
|
bool Arch::isBelLocked(BelId bel) const
|
|
|
|
{
|
|
|
|
const BelConfigPOD *bel_config = nullptr;
|
|
|
|
for (int i = 0; i < chip_info->num_belcfgs; i++) {
|
|
|
|
if (chip_info->bel_config[i].bel_index == bel.index) {
|
|
|
|
bel_config = &chip_info->bel_config[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NPNR_ASSERT(bel_config != nullptr);
|
|
|
|
for (int i = 0; i < bel_config->num_entries; i++) {
|
|
|
|
if (strcmp("LOCKED", bel_config->entries[i].cbit_name.get()))
|
|
|
|
continue;
|
|
|
|
if ("LOCKED_" + archArgs().package == bel_config->entries[i].entry_name.get())
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-07-15 01:52:56 +08:00
|
|
|
// -----------------------------------------------------------------------
|
2018-07-15 01:50:15 +08:00
|
|
|
|
2018-07-15 01:50:34 +08:00
|
|
|
WireId Arch::getWireByName(IdString name) const
|
|
|
|
{
|
2018-07-15 01:52:56 +08:00
|
|
|
WireId ret;
|
2018-07-15 01:50:15 +08:00
|
|
|
|
2018-07-15 01:52:56 +08:00
|
|
|
if (wire_by_name.empty()) {
|
|
|
|
for (int i = 0; i < chip_info->num_wires; i++)
|
|
|
|
wire_by_name[id(chip_info->wire_data[i].name.get())] = i;
|
|
|
|
}
|
2018-07-15 01:50:15 +08:00
|
|
|
|
2018-07-15 01:52:56 +08:00
|
|
|
auto it = wire_by_name.find(name);
|
|
|
|
if (it != wire_by_name.end())
|
|
|
|
ret.index = it->second;
|
2018-07-15 01:50:15 +08:00
|
|
|
|
2018-07-15 01:52:56 +08:00
|
|
|
return ret;
|
2018-07-15 01:50:34 +08:00
|
|
|
}
|
2018-07-15 01:50:15 +08:00
|
|
|
|
2018-08-04 03:11:12 +08:00
|
|
|
IdString Arch::getWireType(WireId wire) const
|
|
|
|
{
|
|
|
|
NPNR_ASSERT(wire != WireId());
|
2018-08-05 20:18:34 +08:00
|
|
|
switch (chip_info->wire_data[wire.index].type) {
|
|
|
|
case WireInfoPOD::WIRE_TYPE_NONE:
|
|
|
|
return IdString();
|
|
|
|
case WireInfoPOD::WIRE_TYPE_GLB2LOCAL:
|
|
|
|
return id("GLB2LOCAL");
|
|
|
|
case WireInfoPOD::WIRE_TYPE_GLB_NETWK:
|
|
|
|
return id("GLB_NETWK");
|
|
|
|
case WireInfoPOD::WIRE_TYPE_LOCAL:
|
|
|
|
return id("LOCAL");
|
|
|
|
case WireInfoPOD::WIRE_TYPE_LUTFF_IN:
|
|
|
|
return id("LUTFF_IN");
|
|
|
|
case WireInfoPOD::WIRE_TYPE_LUTFF_IN_LUT:
|
|
|
|
return id("LUTFF_IN_LUT");
|
|
|
|
case WireInfoPOD::WIRE_TYPE_LUTFF_LOUT:
|
|
|
|
return id("LUTFF_LOUT");
|
|
|
|
case WireInfoPOD::WIRE_TYPE_LUTFF_OUT:
|
|
|
|
return id("LUTFF_OUT");
|
|
|
|
case WireInfoPOD::WIRE_TYPE_LUTFF_COUT:
|
|
|
|
return id("LUTFF_COUT");
|
|
|
|
case WireInfoPOD::WIRE_TYPE_LUTFF_GLOBAL:
|
|
|
|
return id("LUTFF_GLOBAL");
|
|
|
|
case WireInfoPOD::WIRE_TYPE_CARRY_IN_MUX:
|
|
|
|
return id("CARRY_IN_MUX");
|
|
|
|
case WireInfoPOD::WIRE_TYPE_SP4_V:
|
|
|
|
return id("SP4_V");
|
|
|
|
case WireInfoPOD::WIRE_TYPE_SP4_H:
|
|
|
|
return id("SP4_H");
|
|
|
|
case WireInfoPOD::WIRE_TYPE_SP12_V:
|
|
|
|
return id("SP12_V");
|
|
|
|
case WireInfoPOD::WIRE_TYPE_SP12_H:
|
|
|
|
return id("SP12_H");
|
2018-08-04 03:11:12 +08:00
|
|
|
}
|
|
|
|
return IdString();
|
|
|
|
}
|
|
|
|
|
2018-08-18 20:14:27 +08:00
|
|
|
std::vector<std::pair<IdString, std::string>> Arch::getWireAttrs(WireId wire) const
|
|
|
|
{
|
|
|
|
std::vector<std::pair<IdString, std::string>> ret;
|
|
|
|
auto &wi = chip_info->wire_data[wire.index];
|
|
|
|
|
2018-08-19 22:31:02 +08:00
|
|
|
ret.push_back(std::make_pair(id("INDEX"), stringf("%d", wire.index)));
|
2018-08-18 22:20:33 +08:00
|
|
|
|
2018-08-18 20:14:27 +08:00
|
|
|
ret.push_back(std::make_pair(id("GRID_X"), stringf("%d", wi.x)));
|
|
|
|
ret.push_back(std::make_pair(id("GRID_Y"), stringf("%d", wi.y)));
|
|
|
|
ret.push_back(std::make_pair(id("GRID_Z"), stringf("%d", wi.z)));
|
|
|
|
|
2018-08-18 22:20:33 +08:00
|
|
|
#if 0
|
2018-08-18 20:14:27 +08:00
|
|
|
for (int i = 0; i < wi.num_segments; i++) {
|
|
|
|
auto &si = wi.segments[i];
|
|
|
|
ret.push_back(std::make_pair(id(stringf("segment[%d]", i)),
|
|
|
|
stringf("X%d/Y%d/%s", si.x, si.y, chip_info->tile_wire_names[si.index].get())));
|
|
|
|
}
|
2018-08-18 22:20:33 +08:00
|
|
|
#endif
|
2018-08-18 20:14:27 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-07-15 01:52:56 +08:00
|
|
|
// -----------------------------------------------------------------------
|
2018-07-15 01:50:15 +08:00
|
|
|
|
2018-07-15 01:52:56 +08:00
|
|
|
PipId Arch::getPipByName(IdString name) const
|
2018-07-15 01:50:34 +08:00
|
|
|
{
|
2018-07-15 01:52:56 +08:00
|
|
|
PipId ret;
|
2018-07-15 01:50:15 +08:00
|
|
|
|
2018-07-15 01:52:56 +08:00
|
|
|
if (pip_by_name.empty()) {
|
|
|
|
for (int i = 0; i < chip_info->num_pips; i++) {
|
|
|
|
PipId pip;
|
|
|
|
pip.index = i;
|
|
|
|
pip_by_name[getPipName(pip)] = i;
|
|
|
|
}
|
|
|
|
}
|
2018-07-15 01:50:15 +08:00
|
|
|
|
2018-07-15 01:52:56 +08:00
|
|
|
auto it = pip_by_name.find(name);
|
|
|
|
if (it != pip_by_name.end())
|
|
|
|
ret.index = it->second;
|
2018-07-15 01:50:15 +08:00
|
|
|
|
2018-07-15 01:52:56 +08:00
|
|
|
return ret;
|
2018-07-15 01:50:34 +08:00
|
|
|
}
|
2018-07-15 01:50:15 +08:00
|
|
|
|
2018-06-18 19:35:25 +08:00
|
|
|
IdString Arch::getPipName(PipId pip) const
|
2018-06-13 20:53:44 +08:00
|
|
|
{
|
2018-07-04 18:15:23 +08:00
|
|
|
NPNR_ASSERT(pip != PipId());
|
2018-07-16 03:41:34 +08:00
|
|
|
|
|
|
|
#if 1
|
|
|
|
int x = chip_info->pip_data[pip.index].x;
|
|
|
|
int y = chip_info->pip_data[pip.index].y;
|
|
|
|
|
|
|
|
std::string src_name = chip_info->wire_data[chip_info->pip_data[pip.index].src].name.get();
|
|
|
|
std::replace(src_name.begin(), src_name.end(), '/', '.');
|
|
|
|
|
|
|
|
std::string dst_name = chip_info->wire_data[chip_info->pip_data[pip.index].dst].name.get();
|
|
|
|
std::replace(dst_name.begin(), dst_name.end(), '/', '.');
|
|
|
|
|
|
|
|
return id("X" + std::to_string(x) + "/Y" + std::to_string(y) + "/" + src_name + ".->." + dst_name);
|
|
|
|
#else
|
2018-07-16 02:29:32 +08:00
|
|
|
return id(chip_info->pip_data[pip.index].name.get());
|
2018-07-16 03:41:34 +08:00
|
|
|
#endif
|
2018-06-13 20:53:44 +08:00
|
|
|
}
|
|
|
|
|
2018-08-18 20:14:27 +08:00
|
|
|
IdString Arch::getPipType(PipId pip) const { return IdString(); }
|
|
|
|
|
2018-08-19 22:31:02 +08:00
|
|
|
std::vector<std::pair<IdString, std::string>> Arch::getPipAttrs(PipId pip) const
|
2018-08-18 20:14:27 +08:00
|
|
|
{
|
|
|
|
std::vector<std::pair<IdString, std::string>> ret;
|
2018-08-19 22:31:02 +08:00
|
|
|
|
|
|
|
ret.push_back(std::make_pair(id("INDEX"), stringf("%d", pip.index)));
|
|
|
|
|
2018-08-18 20:14:27 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-06-06 21:13:41 +08:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2018-06-18 19:35:25 +08:00
|
|
|
BelId Arch::getPackagePinBel(const std::string &pin) const
|
2018-06-13 18:30:15 +08:00
|
|
|
{
|
|
|
|
for (int i = 0; i < package_info->num_pins; i++) {
|
2018-06-17 19:32:38 +08:00
|
|
|
if (package_info->pins[i].name.get() == pin) {
|
2018-06-13 18:30:15 +08:00
|
|
|
BelId id;
|
|
|
|
id.index = package_info->pins[i].bel_index;
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return BelId();
|
|
|
|
}
|
|
|
|
|
2018-06-18 19:35:25 +08:00
|
|
|
std::string Arch::getBelPackagePin(BelId bel) const
|
2018-06-16 03:29:02 +08:00
|
|
|
{
|
|
|
|
for (int i = 0; i < package_info->num_pins; i++) {
|
|
|
|
if (package_info->pins[i].bel_index == bel.index) {
|
2018-06-17 19:32:38 +08:00
|
|
|
return std::string(package_info->pins[i].name.get());
|
2018-06-16 03:29:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
2018-07-12 23:22:29 +08:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
GroupId Arch::getGroupByName(IdString name) const
|
|
|
|
{
|
|
|
|
for (auto g : getGroups())
|
|
|
|
if (getGroupName(g) == name)
|
|
|
|
return g;
|
|
|
|
return GroupId();
|
|
|
|
}
|
|
|
|
|
2018-07-26 22:21:01 +08:00
|
|
|
IdString Arch::getGroupName(GroupId group) const
|
|
|
|
{
|
|
|
|
std::string suffix;
|
|
|
|
|
|
|
|
switch (group.type) {
|
|
|
|
case GroupId::TYPE_FRAME:
|
|
|
|
suffix = "tile";
|
|
|
|
break;
|
|
|
|
case GroupId::TYPE_MAIN_SW:
|
|
|
|
suffix = "main_sw";
|
|
|
|
break;
|
|
|
|
case GroupId::TYPE_LOCAL_SW:
|
|
|
|
suffix = "local_sw";
|
|
|
|
break;
|
|
|
|
case GroupId::TYPE_LC0_SW:
|
|
|
|
suffix = "lc0_sw";
|
|
|
|
break;
|
|
|
|
case GroupId::TYPE_LC1_SW:
|
|
|
|
suffix = "lc1_sw";
|
|
|
|
break;
|
|
|
|
case GroupId::TYPE_LC2_SW:
|
|
|
|
suffix = "lc2_sw";
|
|
|
|
break;
|
|
|
|
case GroupId::TYPE_LC3_SW:
|
|
|
|
suffix = "lc3_sw";
|
|
|
|
break;
|
|
|
|
case GroupId::TYPE_LC4_SW:
|
|
|
|
suffix = "lc4_sw";
|
|
|
|
break;
|
|
|
|
case GroupId::TYPE_LC5_SW:
|
|
|
|
suffix = "lc5_sw";
|
|
|
|
break;
|
|
|
|
case GroupId::TYPE_LC6_SW:
|
|
|
|
suffix = "lc6_sw";
|
|
|
|
break;
|
|
|
|
case GroupId::TYPE_LC7_SW:
|
|
|
|
suffix = "lc7_sw";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return IdString();
|
|
|
|
}
|
|
|
|
|
|
|
|
return id("X" + std::to_string(group.x) + "/Y" + std::to_string(group.y) + "/" + suffix);
|
|
|
|
}
|
2018-07-12 23:22:29 +08:00
|
|
|
|
|
|
|
std::vector<GroupId> Arch::getGroups() const
|
|
|
|
{
|
|
|
|
std::vector<GroupId> ret;
|
2018-07-26 22:21:01 +08:00
|
|
|
|
|
|
|
for (int y = 0; y < chip_info->height; y++) {
|
|
|
|
for (int x = 0; x < chip_info->width; x++) {
|
|
|
|
TileType type = chip_info->tile_grid[y * chip_info->width + x];
|
|
|
|
if (type == TILE_NONE)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
GroupId group;
|
|
|
|
group.type = GroupId::TYPE_FRAME;
|
|
|
|
group.x = x;
|
|
|
|
group.y = y;
|
|
|
|
// ret.push_back(group);
|
|
|
|
|
|
|
|
group.type = GroupId::TYPE_MAIN_SW;
|
|
|
|
ret.push_back(group);
|
|
|
|
|
|
|
|
group.type = GroupId::TYPE_LOCAL_SW;
|
|
|
|
ret.push_back(group);
|
|
|
|
|
2018-08-05 20:18:34 +08:00
|
|
|
if (type == TILE_LOGIC) {
|
2018-07-26 22:21:01 +08:00
|
|
|
group.type = GroupId::TYPE_LC0_SW;
|
|
|
|
ret.push_back(group);
|
|
|
|
|
|
|
|
group.type = GroupId::TYPE_LC1_SW;
|
|
|
|
ret.push_back(group);
|
|
|
|
|
|
|
|
group.type = GroupId::TYPE_LC2_SW;
|
|
|
|
ret.push_back(group);
|
|
|
|
|
|
|
|
group.type = GroupId::TYPE_LC3_SW;
|
|
|
|
ret.push_back(group);
|
|
|
|
|
|
|
|
group.type = GroupId::TYPE_LC4_SW;
|
|
|
|
ret.push_back(group);
|
|
|
|
|
|
|
|
group.type = GroupId::TYPE_LC5_SW;
|
|
|
|
ret.push_back(group);
|
|
|
|
|
|
|
|
group.type = GroupId::TYPE_LC6_SW;
|
|
|
|
ret.push_back(group);
|
|
|
|
|
|
|
|
group.type = GroupId::TYPE_LC7_SW;
|
|
|
|
ret.push_back(group);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-07-12 23:22:29 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<BelId> Arch::getGroupBels(GroupId group) const
|
|
|
|
{
|
|
|
|
std::vector<BelId> ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<WireId> Arch::getGroupWires(GroupId group) const
|
|
|
|
{
|
|
|
|
std::vector<WireId> ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<PipId> Arch::getGroupPips(GroupId group) const
|
|
|
|
{
|
|
|
|
std::vector<PipId> ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<GroupId> Arch::getGroupGroups(GroupId group) const
|
|
|
|
{
|
|
|
|
std::vector<GroupId> ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-06-13 18:30:15 +08:00
|
|
|
// -----------------------------------------------------------------------
|
2018-06-06 21:13:41 +08:00
|
|
|
|
2018-08-06 13:31:59 +08:00
|
|
|
bool Arch::getBudgetOverride(const NetInfo *net_info, const PortRef &sink, delay_t &budget) const
|
2018-07-27 12:37:19 +08:00
|
|
|
{
|
2018-07-29 05:11:43 +08:00
|
|
|
const auto &driver = net_info->driver;
|
2019-01-30 02:43:14 +08:00
|
|
|
if (driver.port == id_COUT) {
|
|
|
|
NPNR_ASSERT(sink.port == id_CIN || sink.port == id_I3);
|
|
|
|
NPNR_ASSERT(driver.cell->constr_abs_z);
|
|
|
|
bool cin = sink.port == id_CIN;
|
|
|
|
bool same_y = driver.cell->constr_z < 7;
|
|
|
|
if (cin && same_y)
|
2018-08-06 13:31:59 +08:00
|
|
|
budget = 0;
|
2018-11-14 04:51:46 +08:00
|
|
|
else {
|
2018-08-07 08:35:23 +08:00
|
|
|
switch (args.type) {
|
2018-08-07 03:22:13 +08:00
|
|
|
#ifndef ICE40_HX1K_ONLY
|
|
|
|
case ArchArgs::HX8K:
|
|
|
|
#endif
|
|
|
|
case ArchArgs::HX1K:
|
2019-01-30 02:43:14 +08:00
|
|
|
budget = cin ? 190 : (same_y ? 260 : 560);
|
2018-08-07 08:35:23 +08:00
|
|
|
break;
|
2018-08-07 03:22:13 +08:00
|
|
|
#ifndef ICE40_HX1K_ONLY
|
|
|
|
case ArchArgs::LP384:
|
|
|
|
case ArchArgs::LP1K:
|
|
|
|
case ArchArgs::LP8K:
|
2019-01-30 02:43:14 +08:00
|
|
|
budget = cin ? 290 : (same_y ? 380 : 670);
|
2018-08-07 08:35:23 +08:00
|
|
|
break;
|
2018-08-07 03:22:13 +08:00
|
|
|
case ArchArgs::UP5K:
|
2019-02-23 05:36:19 +08:00
|
|
|
case ArchArgs::U4K:
|
2019-01-30 02:43:14 +08:00
|
|
|
budget = cin ? 560 : (same_y ? 660 : 1220);
|
2018-08-07 08:35:23 +08:00
|
|
|
break;
|
2018-08-07 03:22:13 +08:00
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
log_error("Unsupported iCE40 chip type.\n");
|
2018-08-07 08:35:23 +08:00
|
|
|
}
|
2018-11-14 04:51:46 +08:00
|
|
|
}
|
2018-08-06 13:31:59 +08:00
|
|
|
return true;
|
2018-07-27 13:30:15 +08:00
|
|
|
}
|
2018-08-06 13:31:59 +08:00
|
|
|
return false;
|
2018-07-27 12:37:19 +08:00
|
|
|
}
|
|
|
|
|
2018-06-13 18:37:23 +08:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2018-12-02 21:15:39 +08:00
|
|
|
bool Arch::place()
|
|
|
|
{
|
2019-01-11 00:42:29 +08:00
|
|
|
// if (!placer1(getCtx(), Placer1Cfg(getCtx())))
|
|
|
|
// return false;
|
|
|
|
if (!placer_heap(getCtx()))
|
2018-12-02 20:01:43 +08:00
|
|
|
return false;
|
2018-12-06 19:00:16 +08:00
|
|
|
if (bool_or_default(settings, id("opt_timing"), false)) {
|
2018-12-02 22:08:11 +08:00
|
|
|
TimingOptCfg tocfg(getCtx());
|
|
|
|
tocfg.cellTypes.insert(id_ICESTORM_LC);
|
|
|
|
return timing_opt(getCtx(), tocfg);
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
2018-12-02 20:01:43 +08:00
|
|
|
}
|
2018-07-12 00:15:08 +08:00
|
|
|
|
2018-08-10 00:39:10 +08:00
|
|
|
bool Arch::route() { return router1(getCtx(), Router1Cfg(getCtx())); }
|
2018-07-12 00:04:09 +08:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2018-07-11 20:03:23 +08:00
|
|
|
DecalXY Arch::getBelDecal(BelId bel) const
|
|
|
|
{
|
|
|
|
DecalXY decalxy;
|
2018-07-12 23:22:29 +08:00
|
|
|
decalxy.decal.type = DecalId::TYPE_BEL;
|
|
|
|
decalxy.decal.index = bel.index;
|
2018-08-05 21:25:42 +08:00
|
|
|
decalxy.decal.active = bel_to_cell.at(bel.index) != nullptr;
|
2018-07-11 20:03:23 +08:00
|
|
|
return decalxy;
|
|
|
|
}
|
2018-06-13 18:48:58 +08:00
|
|
|
|
2018-07-11 20:03:23 +08:00
|
|
|
DecalXY Arch::getWireDecal(WireId wire) const
|
|
|
|
{
|
|
|
|
DecalXY decalxy;
|
2018-07-13 03:05:09 +08:00
|
|
|
decalxy.decal.type = DecalId::TYPE_WIRE;
|
|
|
|
decalxy.decal.index = wire.index;
|
2018-08-05 21:25:42 +08:00
|
|
|
decalxy.decal.active = wire_to_net.at(wire.index) != nullptr;
|
2018-07-11 20:03:23 +08:00
|
|
|
return decalxy;
|
2018-06-13 18:48:58 +08:00
|
|
|
}
|
|
|
|
|
2018-07-11 20:03:23 +08:00
|
|
|
DecalXY Arch::getPipDecal(PipId pip) const
|
|
|
|
{
|
|
|
|
DecalXY decalxy;
|
2018-07-21 01:35:42 +08:00
|
|
|
decalxy.decal.type = DecalId::TYPE_PIP;
|
|
|
|
decalxy.decal.index = pip.index;
|
2018-08-05 21:25:42 +08:00
|
|
|
decalxy.decal.active = pip_to_net.at(pip.index) != nullptr;
|
2018-07-11 20:03:23 +08:00
|
|
|
return decalxy;
|
|
|
|
};
|
|
|
|
|
2018-07-12 23:22:29 +08:00
|
|
|
DecalXY Arch::getGroupDecal(GroupId group) const
|
|
|
|
{
|
|
|
|
DecalXY decalxy;
|
2018-07-13 20:29:03 +08:00
|
|
|
decalxy.decal.type = DecalId::TYPE_GROUP;
|
|
|
|
decalxy.decal.index = (group.type << 16) | (group.x << 8) | (group.y);
|
|
|
|
decalxy.decal.active = true;
|
2018-07-12 23:22:29 +08:00
|
|
|
return decalxy;
|
|
|
|
};
|
|
|
|
|
2018-07-15 01:50:50 +08:00
|
|
|
std::vector<GraphicElement> Arch::getDecalGraphics(DecalId decal) const
|
2018-06-06 21:13:41 +08:00
|
|
|
{
|
2018-06-12 01:56:33 +08:00
|
|
|
std::vector<GraphicElement> ret;
|
2018-06-07 18:56:49 +08:00
|
|
|
|
2018-07-26 22:21:01 +08:00
|
|
|
if (decal.type == DecalId::TYPE_GROUP) {
|
|
|
|
int type = (decal.index >> 16) & 255;
|
|
|
|
int x = (decal.index >> 8) & 255;
|
|
|
|
int y = decal.index & 255;
|
|
|
|
|
|
|
|
if (type == GroupId::TYPE_FRAME) {
|
|
|
|
GraphicElement el;
|
2018-07-26 23:39:19 +08:00
|
|
|
el.type = GraphicElement::TYPE_LINE;
|
|
|
|
el.style = GraphicElement::STYLE_FRAME;
|
2018-07-26 22:21:01 +08:00
|
|
|
|
|
|
|
el.x1 = x + 0.01, el.x2 = x + 0.02, el.y1 = y + 0.01, el.y2 = y + 0.01;
|
|
|
|
ret.push_back(el);
|
|
|
|
el.x1 = x + 0.01, el.x2 = x + 0.01, el.y1 = y + 0.01, el.y2 = y + 0.02;
|
|
|
|
ret.push_back(el);
|
|
|
|
|
|
|
|
el.x1 = x + 0.99, el.x2 = x + 0.98, el.y1 = y + 0.01, el.y2 = y + 0.01;
|
|
|
|
ret.push_back(el);
|
|
|
|
el.x1 = x + 0.99, el.x2 = x + 0.99, el.y1 = y + 0.01, el.y2 = y + 0.02;
|
|
|
|
ret.push_back(el);
|
|
|
|
|
|
|
|
el.x1 = x + 0.99, el.x2 = x + 0.98, el.y1 = y + 0.99, el.y2 = y + 0.99;
|
|
|
|
ret.push_back(el);
|
|
|
|
el.x1 = x + 0.99, el.x2 = x + 0.99, el.y1 = y + 0.99, el.y2 = y + 0.98;
|
|
|
|
ret.push_back(el);
|
|
|
|
|
|
|
|
el.x1 = x + 0.01, el.x2 = x + 0.02, el.y1 = y + 0.99, el.y2 = y + 0.99;
|
|
|
|
ret.push_back(el);
|
|
|
|
el.x1 = x + 0.01, el.x2 = x + 0.01, el.y1 = y + 0.99, el.y2 = y + 0.98;
|
|
|
|
ret.push_back(el);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == GroupId::TYPE_MAIN_SW) {
|
|
|
|
GraphicElement el;
|
2018-07-26 23:39:19 +08:00
|
|
|
el.type = GraphicElement::TYPE_BOX;
|
|
|
|
el.style = GraphicElement::STYLE_FRAME;
|
2018-07-26 22:21:01 +08:00
|
|
|
|
|
|
|
el.x1 = x + main_swbox_x1;
|
|
|
|
el.x2 = x + main_swbox_x2;
|
|
|
|
el.y1 = y + main_swbox_y1;
|
|
|
|
el.y2 = y + main_swbox_y2;
|
|
|
|
ret.push_back(el);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == GroupId::TYPE_LOCAL_SW) {
|
|
|
|
GraphicElement el;
|
2018-07-26 23:39:19 +08:00
|
|
|
el.type = GraphicElement::TYPE_BOX;
|
|
|
|
el.style = GraphicElement::STYLE_FRAME;
|
2018-07-26 22:21:01 +08:00
|
|
|
|
|
|
|
el.x1 = x + local_swbox_x1;
|
|
|
|
el.x2 = x + local_swbox_x2;
|
|
|
|
el.y1 = y + local_swbox_y1;
|
|
|
|
el.y2 = y + local_swbox_y2;
|
|
|
|
ret.push_back(el);
|
|
|
|
}
|
2018-08-03 23:37:59 +08:00
|
|
|
|
|
|
|
if (GroupId::TYPE_LC0_SW <= type && type <= GroupId::TYPE_LC7_SW) {
|
|
|
|
GraphicElement el;
|
|
|
|
el.type = GraphicElement::TYPE_BOX;
|
|
|
|
el.style = GraphicElement::STYLE_FRAME;
|
|
|
|
|
|
|
|
el.x1 = x + lut_swbox_x1;
|
|
|
|
el.x2 = x + lut_swbox_x2;
|
|
|
|
el.y1 = y + logic_cell_y1 + logic_cell_pitch * (type - GroupId::TYPE_LC0_SW);
|
|
|
|
el.y2 = y + logic_cell_y2 + logic_cell_pitch * (type - GroupId::TYPE_LC0_SW);
|
|
|
|
ret.push_back(el);
|
|
|
|
}
|
2018-06-07 18:56:49 +08:00
|
|
|
}
|
|
|
|
|
2018-07-13 04:04:13 +08:00
|
|
|
if (decal.type == DecalId::TYPE_WIRE) {
|
2018-07-16 02:29:32 +08:00
|
|
|
int n = chip_info->wire_data[decal.index].num_segments;
|
|
|
|
const WireSegmentPOD *p = chip_info->wire_data[decal.index].segments.get();
|
2018-07-13 03:05:09 +08:00
|
|
|
|
2018-07-26 23:39:19 +08:00
|
|
|
GraphicElement::style_t style = decal.active ? GraphicElement::STYLE_ACTIVE : GraphicElement::STYLE_INACTIVE;
|
2018-07-13 03:05:09 +08:00
|
|
|
|
|
|
|
for (int i = 0; i < n; i++)
|
2018-08-19 22:53:34 +08:00
|
|
|
gfxTileWire(ret, p[i].x, p[i].y, chip_info->width, chip_info->height, GfxTileWireId(p[i].index), style);
|
2018-08-20 00:43:38 +08:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (ret.empty()) {
|
|
|
|
WireId wire;
|
|
|
|
wire.index = decal.index;
|
|
|
|
log_warning("No gfx decal for wire %s (%d).\n", getWireName(wire).c_str(getCtx()), decal.index);
|
|
|
|
}
|
|
|
|
#endif
|
2018-07-13 03:05:09 +08:00
|
|
|
}
|
|
|
|
|
2018-07-16 02:29:32 +08:00
|
|
|
if (decal.type == DecalId::TYPE_PIP) {
|
|
|
|
const PipInfoPOD &p = chip_info->pip_data[decal.index];
|
2018-07-26 23:39:19 +08:00
|
|
|
GraphicElement::style_t style = decal.active ? GraphicElement::STYLE_ACTIVE : GraphicElement::STYLE_HIDDEN;
|
2018-07-16 02:29:32 +08:00
|
|
|
gfxTilePip(ret, p.x, p.y, GfxTileWireId(p.src_seg), GfxTileWireId(p.dst_seg), style);
|
2018-08-20 00:43:38 +08:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (ret.empty()) {
|
|
|
|
PipId pip;
|
|
|
|
pip.index = decal.index;
|
|
|
|
log_warning("No gfx decal for pip %s (%d).\n", getPipName(pip).c_str(getCtx()), decal.index);
|
|
|
|
}
|
|
|
|
#endif
|
2018-07-16 02:29:32 +08:00
|
|
|
}
|
|
|
|
|
2018-07-13 04:04:13 +08:00
|
|
|
if (decal.type == DecalId::TYPE_BEL) {
|
2018-07-11 20:03:23 +08:00
|
|
|
BelId bel;
|
2018-07-12 23:22:29 +08:00
|
|
|
bel.index = decal.index;
|
2018-07-11 20:03:23 +08:00
|
|
|
|
2018-07-15 01:50:50 +08:00
|
|
|
auto bel_type = getBelType(bel);
|
2018-07-11 20:03:23 +08:00
|
|
|
|
2018-08-08 23:01:18 +08:00
|
|
|
if (bel_type == id_ICESTORM_LC) {
|
2018-06-07 18:56:49 +08:00
|
|
|
GraphicElement el;
|
2018-07-26 23:39:19 +08:00
|
|
|
el.type = GraphicElement::TYPE_BOX;
|
|
|
|
el.style = decal.active ? GraphicElement::STYLE_ACTIVE : GraphicElement::STYLE_INACTIVE;
|
2018-07-11 20:03:23 +08:00
|
|
|
el.x1 = chip_info->bel_data[bel.index].x + logic_cell_x1;
|
|
|
|
el.x2 = chip_info->bel_data[bel.index].x + logic_cell_x2;
|
2018-07-13 04:04:13 +08:00
|
|
|
el.y1 = chip_info->bel_data[bel.index].y + logic_cell_y1 +
|
|
|
|
(chip_info->bel_data[bel.index].z) * logic_cell_pitch;
|
|
|
|
el.y2 = chip_info->bel_data[bel.index].y + logic_cell_y2 +
|
|
|
|
(chip_info->bel_data[bel.index].z) * logic_cell_pitch;
|
2018-06-07 18:56:49 +08:00
|
|
|
ret.push_back(el);
|
2018-07-11 20:03:23 +08:00
|
|
|
}
|
|
|
|
|
2018-08-08 23:01:18 +08:00
|
|
|
if (bel_type == id_SB_IO) {
|
2018-07-26 22:21:01 +08:00
|
|
|
GraphicElement el;
|
2018-07-26 23:39:19 +08:00
|
|
|
el.type = GraphicElement::TYPE_BOX;
|
|
|
|
el.style = decal.active ? GraphicElement::STYLE_ACTIVE : GraphicElement::STYLE_INACTIVE;
|
2018-08-18 22:20:33 +08:00
|
|
|
el.x1 = chip_info->bel_data[bel.index].x + lut_swbox_x1;
|
2018-07-26 22:21:01 +08:00
|
|
|
el.x2 = chip_info->bel_data[bel.index].x + logic_cell_x2;
|
|
|
|
el.y1 = chip_info->bel_data[bel.index].y + logic_cell_y1 +
|
2018-07-26 23:14:56 +08:00
|
|
|
(4 * chip_info->bel_data[bel.index].z) * logic_cell_pitch;
|
2018-07-26 22:21:01 +08:00
|
|
|
el.y2 = chip_info->bel_data[bel.index].y + logic_cell_y2 +
|
2018-07-26 23:14:56 +08:00
|
|
|
(4 * chip_info->bel_data[bel.index].z + 3) * logic_cell_pitch;
|
2018-07-26 22:21:01 +08:00
|
|
|
ret.push_back(el);
|
2018-07-11 20:03:23 +08:00
|
|
|
}
|
|
|
|
|
2018-08-08 23:01:18 +08:00
|
|
|
if (bel_type == id_ICESTORM_RAM) {
|
2018-07-18 18:12:05 +08:00
|
|
|
for (int i = 0; i < 2; i++) {
|
2018-07-13 22:22:28 +08:00
|
|
|
GraphicElement el;
|
2018-07-26 23:39:19 +08:00
|
|
|
el.type = GraphicElement::TYPE_BOX;
|
|
|
|
el.style = decal.active ? GraphicElement::STYLE_ACTIVE : GraphicElement::STYLE_INACTIVE;
|
2018-08-18 22:20:33 +08:00
|
|
|
el.x1 = chip_info->bel_data[bel.index].x + lut_swbox_x1;
|
2018-07-13 22:22:28 +08:00
|
|
|
el.x2 = chip_info->bel_data[bel.index].x + logic_cell_x2;
|
2018-07-26 22:21:01 +08:00
|
|
|
el.y1 = chip_info->bel_data[bel.index].y + logic_cell_y1 + i;
|
|
|
|
el.y2 = chip_info->bel_data[bel.index].y + logic_cell_y2 + i + 7 * logic_cell_pitch;
|
2018-07-13 22:22:28 +08:00
|
|
|
ret.push_back(el);
|
|
|
|
}
|
2018-06-07 18:56:49 +08:00
|
|
|
}
|
2018-08-20 00:43:38 +08:00
|
|
|
|
|
|
|
if (bel_type == id_SB_GB) {
|
|
|
|
GraphicElement el;
|
|
|
|
el.type = GraphicElement::TYPE_BOX;
|
|
|
|
el.style = decal.active ? GraphicElement::STYLE_ACTIVE : GraphicElement::STYLE_INACTIVE;
|
|
|
|
el.x1 = chip_info->bel_data[bel.index].x + local_swbox_x1 + 0.05;
|
|
|
|
el.x2 = chip_info->bel_data[bel.index].x + logic_cell_x2 - 0.05;
|
|
|
|
el.y1 = chip_info->bel_data[bel.index].y + main_swbox_y2 - 0.05;
|
|
|
|
el.y2 = chip_info->bel_data[bel.index].y + main_swbox_y2 - 0.10;
|
|
|
|
ret.push_back(el);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bel_type == id_ICESTORM_PLL || bel_type == id_SB_WARMBOOT) {
|
|
|
|
GraphicElement el;
|
|
|
|
el.type = GraphicElement::TYPE_BOX;
|
|
|
|
el.style = decal.active ? GraphicElement::STYLE_ACTIVE : GraphicElement::STYLE_INACTIVE;
|
|
|
|
el.x1 = chip_info->bel_data[bel.index].x + local_swbox_x1 + 0.05;
|
|
|
|
el.x2 = chip_info->bel_data[bel.index].x + logic_cell_x2 - 0.05;
|
|
|
|
el.y1 = chip_info->bel_data[bel.index].y + main_swbox_y2;
|
|
|
|
el.y2 = chip_info->bel_data[bel.index].y + main_swbox_y2 + 0.05;
|
|
|
|
ret.push_back(el);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (ret.empty()) {
|
|
|
|
BelId bel;
|
|
|
|
bel.index = decal.index;
|
|
|
|
log_warning("No gfx decal for bel %s (%d).\n", getBelName(bel).c_str(getCtx()), decal.index);
|
|
|
|
}
|
|
|
|
#endif
|
2018-06-07 18:56:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2018-06-06 21:13:41 +08:00
|
|
|
}
|
|
|
|
|
2018-06-20 17:44:28 +08:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2018-07-30 22:59:30 +08:00
|
|
|
bool Arch::getCellDelay(const CellInfo *cell, IdString fromPort, IdString toPort, DelayInfo &delay) const
|
2019-01-21 19:58:49 +08:00
|
|
|
{
|
|
|
|
if (cell->type == id_ICESTORM_LC && cell->lcInfo.dffEnable) {
|
|
|
|
if (toPort == id_O)
|
|
|
|
return false;
|
|
|
|
} else if (cell->type == id_ICESTORM_RAM || cell->type == id_ICESTORM_SPRAM) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return getCellDelayInternal(cell, fromPort, toPort, delay);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Arch::getCellDelayInternal(const CellInfo *cell, IdString fromPort, IdString toPort, DelayInfo &delay) const
|
2018-06-20 17:44:28 +08:00
|
|
|
{
|
2018-08-02 22:02:43 +08:00
|
|
|
for (int i = 0; i < chip_info->num_timing_cells; i++) {
|
|
|
|
const auto &tc = chip_info->cell_timing[i];
|
2018-08-08 23:01:18 +08:00
|
|
|
if (tc.type == cell->type.index) {
|
2018-08-02 22:02:43 +08:00
|
|
|
for (int j = 0; j < tc.num_paths; j++) {
|
|
|
|
const auto &path = tc.path_delays[j];
|
2018-08-08 23:01:18 +08:00
|
|
|
if (path.from_port == fromPort.index && path.to_port == toPort.index) {
|
2018-08-02 22:02:43 +08:00
|
|
|
if (fast_part)
|
|
|
|
delay.delay = path.fast_delay;
|
|
|
|
else
|
|
|
|
delay.delay = path.slow_delay;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2018-06-20 19:01:22 +08:00
|
|
|
}
|
|
|
|
}
|
2018-06-20 18:21:56 +08:00
|
|
|
return false;
|
2018-06-20 17:44:28 +08:00
|
|
|
}
|
|
|
|
|
2018-08-08 20:37:59 +08:00
|
|
|
// Get the port class, also setting clockPort to associated clock if applicable
|
2018-11-02 21:35:59 +08:00
|
|
|
TimingPortClass Arch::getPortTimingClass(const CellInfo *cell, IdString port, int &clockInfoCount) const
|
2018-08-08 20:37:59 +08:00
|
|
|
{
|
2018-11-02 21:35:59 +08:00
|
|
|
clockInfoCount = 0;
|
2018-08-09 01:35:13 +08:00
|
|
|
if (cell->type == id_ICESTORM_LC) {
|
|
|
|
if (port == id_CLK)
|
2018-08-08 20:37:59 +08:00
|
|
|
return TMG_CLOCK_INPUT;
|
2018-08-09 01:35:13 +08:00
|
|
|
if (port == id_CIN)
|
2018-08-08 20:37:59 +08:00
|
|
|
return TMG_COMB_INPUT;
|
2018-08-09 01:35:13 +08:00
|
|
|
if (port == id_COUT || port == id_LO)
|
2018-08-08 20:37:59 +08:00
|
|
|
return TMG_COMB_OUTPUT;
|
2018-09-16 06:16:21 +08:00
|
|
|
if (port == id_O) {
|
|
|
|
// LCs with no inputs are constant drivers
|
|
|
|
if (cell->lcInfo.inputCount == 0)
|
|
|
|
return TMG_IGNORE;
|
|
|
|
if (cell->lcInfo.dffEnable) {
|
2018-11-02 21:35:59 +08:00
|
|
|
clockInfoCount = 1;
|
2018-08-08 20:37:59 +08:00
|
|
|
return TMG_REGISTER_OUTPUT;
|
2018-11-02 21:35:59 +08:00
|
|
|
} else
|
2018-08-08 20:37:59 +08:00
|
|
|
return TMG_COMB_OUTPUT;
|
2018-11-02 21:35:59 +08:00
|
|
|
} else {
|
2018-09-16 06:16:21 +08:00
|
|
|
if (cell->lcInfo.dffEnable) {
|
2018-11-02 21:35:59 +08:00
|
|
|
clockInfoCount = 1;
|
2018-09-16 06:16:21 +08:00
|
|
|
return TMG_REGISTER_INPUT;
|
2018-11-02 21:35:59 +08:00
|
|
|
} else
|
2018-08-08 20:37:59 +08:00
|
|
|
return TMG_COMB_INPUT;
|
|
|
|
}
|
2018-08-08 23:17:16 +08:00
|
|
|
} else if (cell->type == id_ICESTORM_RAM) {
|
2018-08-08 21:00:39 +08:00
|
|
|
|
2018-08-09 01:35:13 +08:00
|
|
|
if (port == id_RCLK || port == id_WCLK)
|
2018-08-08 21:00:39 +08:00
|
|
|
return TMG_CLOCK_INPUT;
|
|
|
|
|
2018-11-02 21:35:59 +08:00
|
|
|
clockInfoCount = 1;
|
2018-06-20 17:44:28 +08:00
|
|
|
|
2018-08-08 21:00:39 +08:00
|
|
|
if (cell->ports.at(port).type == PORT_OUT)
|
|
|
|
return TMG_REGISTER_OUTPUT;
|
|
|
|
else
|
|
|
|
return TMG_REGISTER_INPUT;
|
2018-08-09 01:35:13 +08:00
|
|
|
} else if (cell->type == id_ICESTORM_DSP || cell->type == id_ICESTORM_SPRAM) {
|
2018-11-03 22:09:27 +08:00
|
|
|
if (port == id_CLK || port == id_CLOCK)
|
2018-08-08 20:37:59 +08:00
|
|
|
return TMG_CLOCK_INPUT;
|
2018-11-02 21:35:59 +08:00
|
|
|
else {
|
|
|
|
clockInfoCount = 1;
|
|
|
|
if (cell->ports.at(port).type == PORT_OUT)
|
|
|
|
return TMG_REGISTER_OUTPUT;
|
|
|
|
else
|
|
|
|
return TMG_REGISTER_INPUT;
|
|
|
|
}
|
2018-08-09 01:35:13 +08:00
|
|
|
} else if (cell->type == id_SB_IO) {
|
2019-01-08 01:18:40 +08:00
|
|
|
if (port == id_INPUT_CLK || port == id_OUTPUT_CLK)
|
|
|
|
return TMG_CLOCK_INPUT;
|
|
|
|
if (port == id_CLOCK_ENABLE) {
|
|
|
|
clockInfoCount = 2;
|
|
|
|
return TMG_REGISTER_INPUT;
|
|
|
|
}
|
|
|
|
if ((port == id_D_IN_0 && !(cell->ioInfo.pintype & 0x1)) || port == id_D_IN_1) {
|
|
|
|
clockInfoCount = 1;
|
|
|
|
return TMG_REGISTER_OUTPUT;
|
|
|
|
} else if (port == id_D_IN_0) {
|
2018-08-08 20:37:59 +08:00
|
|
|
return TMG_STARTPOINT;
|
2019-01-08 01:18:40 +08:00
|
|
|
}
|
|
|
|
if (port == id_D_OUT_0 || port == id_D_OUT_1) {
|
|
|
|
if ((cell->ioInfo.pintype & 0xC) == 0x8) {
|
|
|
|
return TMG_ENDPOINT;
|
|
|
|
} else {
|
|
|
|
clockInfoCount = 1;
|
|
|
|
return TMG_REGISTER_INPUT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (port == id_OUTPUT_ENABLE) {
|
|
|
|
if ((cell->ioInfo.pintype & 0x18) == 0x18) {
|
|
|
|
return TMG_REGISTER_INPUT;
|
|
|
|
} else {
|
|
|
|
return TMG_ENDPOINT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-08 20:37:59 +08:00
|
|
|
return TMG_IGNORE;
|
2018-08-09 01:35:13 +08:00
|
|
|
} else if (cell->type == id_ICESTORM_PLL) {
|
2019-01-21 19:58:49 +08:00
|
|
|
if (port == id_PLLOUT_A || port == id_PLLOUT_B || port == id_PLLOUT_A_GLOBAL || port == id_PLLOUT_B_GLOBAL)
|
2018-08-08 20:37:59 +08:00
|
|
|
return TMG_GEN_CLOCK;
|
|
|
|
return TMG_IGNORE;
|
2018-08-09 01:35:13 +08:00
|
|
|
} else if (cell->type == id_ICESTORM_LFOSC) {
|
|
|
|
if (port == id_CLKLF)
|
2018-08-08 20:37:59 +08:00
|
|
|
return TMG_GEN_CLOCK;
|
|
|
|
return TMG_IGNORE;
|
2018-08-09 01:35:13 +08:00
|
|
|
} else if (cell->type == id_ICESTORM_HFOSC) {
|
|
|
|
if (port == id_CLKHF)
|
2018-08-08 20:37:59 +08:00
|
|
|
return TMG_GEN_CLOCK;
|
|
|
|
return TMG_IGNORE;
|
2018-08-09 01:35:13 +08:00
|
|
|
} else if (cell->type == id_SB_GB) {
|
|
|
|
if (port == id_GLOBAL_BUFFER_OUTPUT)
|
2019-02-20 17:43:12 +08:00
|
|
|
return cell->gbInfo.forPadIn ? TMG_GEN_CLOCK : TMG_COMB_OUTPUT;
|
2018-08-08 22:34:41 +08:00
|
|
|
return TMG_COMB_INPUT;
|
2018-08-09 01:35:13 +08:00
|
|
|
} else if (cell->type == id_SB_WARMBOOT) {
|
2018-08-09 00:07:34 +08:00
|
|
|
return TMG_ENDPOINT;
|
2018-11-18 01:02:31 +08:00
|
|
|
} else if (cell->type == id_SB_RGBA_DRV) {
|
|
|
|
if (port == id_RGB0 || port == id_RGB1 || port == id_RGB2)
|
|
|
|
return TMG_IGNORE;
|
|
|
|
return TMG_ENDPOINT;
|
2018-12-02 09:27:04 +08:00
|
|
|
} else if (cell->type == id_SB_LEDDA_IP) {
|
|
|
|
if (port == id_CLK || port == id_CLOCK)
|
|
|
|
return TMG_CLOCK_INPUT;
|
|
|
|
return TMG_IGNORE;
|
2018-06-20 19:01:22 +08:00
|
|
|
}
|
2018-11-30 03:26:23 +08:00
|
|
|
log_error("cell type '%s' is unsupported (instantiated as '%s')\n", cell->type.c_str(this), cell->name.c_str(this));
|
2018-06-20 17:44:28 +08:00
|
|
|
}
|
|
|
|
|
2018-11-02 21:35:59 +08:00
|
|
|
TimingClockingInfo Arch::getPortClockingInfo(const CellInfo *cell, IdString port, int index) const
|
|
|
|
{
|
|
|
|
TimingClockingInfo info;
|
|
|
|
if (cell->type == id_ICESTORM_LC) {
|
|
|
|
info.clock_port = id_CLK;
|
2018-11-03 00:56:53 +08:00
|
|
|
info.edge = cell->lcInfo.negClk ? FALLING_EDGE : RISING_EDGE;
|
2018-11-02 21:35:59 +08:00
|
|
|
if (port == id_O) {
|
2019-01-21 19:58:49 +08:00
|
|
|
bool has_clktoq = getCellDelayInternal(cell, id_CLK, id_O, info.clockToQ);
|
2018-11-02 21:35:59 +08:00
|
|
|
NPNR_ASSERT(has_clktoq);
|
|
|
|
} else {
|
2019-01-21 19:58:49 +08:00
|
|
|
if (port == id_I0 || port == id_I1 || port == id_I2 || port == id_I3) {
|
|
|
|
DelayInfo dlut;
|
|
|
|
bool has_ld = getCellDelayInternal(cell, port, id_O, dlut);
|
|
|
|
NPNR_ASSERT(has_ld);
|
|
|
|
if (args.type == ArchArgs::LP1K || args.type == ArchArgs::LP8K || args.type == ArchArgs::LP384) {
|
|
|
|
info.setup.delay = 30 + dlut.delay;
|
2019-02-23 05:36:19 +08:00
|
|
|
} else if (args.type == ArchArgs::UP5K || args.type == ArchArgs::U4K) { // XXX verify u4k
|
2019-01-21 19:58:49 +08:00
|
|
|
info.setup.delay = dlut.delay - 50;
|
|
|
|
} else {
|
|
|
|
info.setup.delay = 20 + dlut.delay;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
info.setup.delay = 100;
|
|
|
|
}
|
2018-11-02 21:35:59 +08:00
|
|
|
info.hold.delay = 0;
|
|
|
|
}
|
|
|
|
} else if (cell->type == id_ICESTORM_RAM) {
|
|
|
|
if (port.str(this)[0] == 'R') {
|
|
|
|
info.clock_port = id_RCLK;
|
2018-11-03 00:56:53 +08:00
|
|
|
info.edge = bool_or_default(cell->params, id("NEG_CLK_R")) ? FALLING_EDGE : RISING_EDGE;
|
2018-11-02 21:35:59 +08:00
|
|
|
} else {
|
|
|
|
info.clock_port = id_WCLK;
|
2018-11-03 00:56:53 +08:00
|
|
|
info.edge = bool_or_default(cell->params, id("NEG_CLK_W")) ? FALLING_EDGE : RISING_EDGE;
|
2018-11-02 21:35:59 +08:00
|
|
|
}
|
|
|
|
if (cell->ports.at(port).type == PORT_OUT) {
|
2019-01-21 19:58:49 +08:00
|
|
|
bool has_clktoq = getCellDelayInternal(cell, info.clock_port, port, info.clockToQ);
|
2018-11-02 21:35:59 +08:00
|
|
|
NPNR_ASSERT(has_clktoq);
|
|
|
|
} else {
|
|
|
|
info.setup.delay = 100;
|
|
|
|
info.hold.delay = 0;
|
|
|
|
}
|
2019-01-08 01:18:40 +08:00
|
|
|
} else if (cell->type == id_SB_IO) {
|
|
|
|
delay_t io_setup = 80, io_clktoq = 140;
|
|
|
|
if (args.type == ArchArgs::LP1K || args.type == ArchArgs::LP8K || args.type == ArchArgs::LP384) {
|
|
|
|
io_setup = 115;
|
|
|
|
io_clktoq = 210;
|
2019-02-23 05:36:19 +08:00
|
|
|
} else if (args.type == ArchArgs::UP5K || args.type == ArchArgs::U4K) {
|
2019-01-08 01:18:40 +08:00
|
|
|
io_setup = 205;
|
|
|
|
io_clktoq = 1005;
|
|
|
|
}
|
|
|
|
if (port == id_CLOCK_ENABLE) {
|
|
|
|
info.clock_port = (index == 1) ? id_OUTPUT_CLK : id_INPUT_CLK;
|
|
|
|
info.edge = cell->ioInfo.negtrig ? FALLING_EDGE : RISING_EDGE;
|
|
|
|
info.setup.delay = io_setup;
|
|
|
|
info.hold.delay = 0;
|
|
|
|
} else if (port == id_D_OUT_0 || port == id_OUTPUT_ENABLE) {
|
|
|
|
info.clock_port = id_OUTPUT_CLK;
|
|
|
|
info.edge = cell->ioInfo.negtrig ? FALLING_EDGE : RISING_EDGE;
|
|
|
|
info.setup.delay = io_setup;
|
|
|
|
info.hold.delay = 0;
|
|
|
|
} else if (port == id_D_OUT_1) {
|
|
|
|
info.clock_port = id_OUTPUT_CLK;
|
|
|
|
info.edge = cell->ioInfo.negtrig ? RISING_EDGE : FALLING_EDGE;
|
|
|
|
info.setup.delay = io_setup;
|
|
|
|
info.hold.delay = 0;
|
|
|
|
} else if (port == id_D_IN_0) {
|
|
|
|
info.clock_port = id_INPUT_CLK;
|
|
|
|
info.edge = cell->ioInfo.negtrig ? FALLING_EDGE : RISING_EDGE;
|
|
|
|
info.clockToQ.delay = io_clktoq;
|
|
|
|
} else if (port == id_D_IN_1) {
|
|
|
|
info.clock_port = id_INPUT_CLK;
|
|
|
|
info.edge = cell->ioInfo.negtrig ? RISING_EDGE : FALLING_EDGE;
|
|
|
|
info.clockToQ.delay = io_clktoq;
|
|
|
|
} else {
|
|
|
|
NPNR_ASSERT_FALSE("no clock data for IO cell port");
|
|
|
|
}
|
2018-11-02 21:35:59 +08:00
|
|
|
} else if (cell->type == id_ICESTORM_DSP || cell->type == id_ICESTORM_SPRAM) {
|
2018-11-03 22:09:27 +08:00
|
|
|
info.clock_port = cell->type == id_ICESTORM_SPRAM ? id_CLOCK : id_CLK;
|
2018-11-03 00:56:53 +08:00
|
|
|
info.edge = RISING_EDGE;
|
2018-11-02 21:35:59 +08:00
|
|
|
if (cell->ports.at(port).type == PORT_OUT) {
|
2019-01-21 19:58:49 +08:00
|
|
|
bool has_clktoq = getCellDelayInternal(cell, info.clock_port, port, info.clockToQ);
|
2018-11-02 21:35:59 +08:00
|
|
|
if (!has_clktoq)
|
|
|
|
info.clockToQ.delay = 100;
|
|
|
|
} else {
|
|
|
|
info.setup.delay = 100;
|
|
|
|
info.hold.delay = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
NPNR_ASSERT_FALSE("unhandled cell type in getPortClockingInfo");
|
|
|
|
}
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
2018-06-23 18:09:01 +08:00
|
|
|
bool Arch::isGlobalNet(const NetInfo *net) const
|
|
|
|
{
|
|
|
|
if (net == nullptr)
|
|
|
|
return false;
|
2018-08-08 23:17:16 +08:00
|
|
|
return net->driver.cell != nullptr && net->driver.port == id_GLOBAL_BUFFER_OUTPUT;
|
2018-06-23 18:09:01 +08:00
|
|
|
}
|
|
|
|
|
2018-07-18 18:21:02 +08:00
|
|
|
// Assign arch arg info
|
2018-07-18 20:34:32 +08:00
|
|
|
void Arch::assignArchInfo()
|
2018-07-18 18:21:02 +08:00
|
|
|
{
|
|
|
|
for (auto &net : getCtx()->nets) {
|
|
|
|
NetInfo *ni = net.second.get();
|
|
|
|
if (isGlobalNet(ni))
|
|
|
|
ni->is_global = true;
|
2018-07-20 17:36:32 +08:00
|
|
|
ni->is_enable = false;
|
|
|
|
ni->is_reset = false;
|
|
|
|
for (auto usr : ni->users) {
|
|
|
|
if (is_enable_port(this, usr))
|
|
|
|
ni->is_enable = true;
|
|
|
|
if (is_reset_port(this, usr))
|
|
|
|
ni->is_reset = true;
|
|
|
|
}
|
2018-07-18 18:21:02 +08:00
|
|
|
}
|
|
|
|
for (auto &cell : getCtx()->cells) {
|
|
|
|
CellInfo *ci = cell.second.get();
|
2018-07-18 20:34:32 +08:00
|
|
|
assignCellInfo(ci);
|
2018-07-18 18:51:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-18 20:34:32 +08:00
|
|
|
void Arch::assignCellInfo(CellInfo *cell)
|
2018-07-18 18:51:07 +08:00
|
|
|
{
|
2018-08-08 23:01:18 +08:00
|
|
|
if (cell->type == id_ICESTORM_LC) {
|
2018-08-08 23:17:16 +08:00
|
|
|
cell->lcInfo.dffEnable = bool_or_default(cell->params, id_DFF_ENABLE);
|
|
|
|
cell->lcInfo.carryEnable = bool_or_default(cell->params, id_CARRY_ENABLE);
|
|
|
|
cell->lcInfo.negClk = bool_or_default(cell->params, id_NEG_CLK);
|
|
|
|
cell->lcInfo.clk = get_net_or_empty(cell, id_CLK);
|
|
|
|
cell->lcInfo.cen = get_net_or_empty(cell, id_CEN);
|
|
|
|
cell->lcInfo.sr = get_net_or_empty(cell, id_SR);
|
2018-07-18 18:51:07 +08:00
|
|
|
cell->lcInfo.inputCount = 0;
|
2018-08-08 23:17:16 +08:00
|
|
|
if (get_net_or_empty(cell, id_I0))
|
2018-07-18 18:51:07 +08:00
|
|
|
cell->lcInfo.inputCount++;
|
2018-08-08 23:17:16 +08:00
|
|
|
if (get_net_or_empty(cell, id_I1))
|
2018-07-18 18:51:07 +08:00
|
|
|
cell->lcInfo.inputCount++;
|
2018-08-08 23:17:16 +08:00
|
|
|
if (get_net_or_empty(cell, id_I2))
|
2018-07-18 18:51:07 +08:00
|
|
|
cell->lcInfo.inputCount++;
|
2018-08-08 23:17:16 +08:00
|
|
|
if (get_net_or_empty(cell, id_I3))
|
2018-07-18 18:51:07 +08:00
|
|
|
cell->lcInfo.inputCount++;
|
2018-09-24 22:14:28 +08:00
|
|
|
} else if (cell->type == id_SB_IO) {
|
|
|
|
cell->ioInfo.lvds = str_or_default(cell->params, id_IO_STANDARD, "SB_LVCMOS") == "SB_LVDS_INPUT";
|
2018-11-17 20:04:14 +08:00
|
|
|
cell->ioInfo.global = bool_or_default(cell->attrs, this->id("GLOBAL"));
|
2019-01-08 01:18:40 +08:00
|
|
|
cell->ioInfo.pintype = int_or_default(cell->attrs, this->id("PIN_TYPE"));
|
|
|
|
cell->ioInfo.negtrig = bool_or_default(cell->attrs, this->id("NEG_TRIGGER"));
|
|
|
|
|
2018-11-19 08:57:47 +08:00
|
|
|
} else if (cell->type == id_SB_GB) {
|
|
|
|
cell->gbInfo.forPadIn = bool_or_default(cell->attrs, this->id("FOR_PAD_IN"));
|
2018-07-18 18:21:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-12 20:24:59 +08:00
|
|
|
NEXTPNR_NAMESPACE_END
|