Merge pull request #859 from yrabbit/gowin-packages
gowin: Add partnumbers and packages to the chipdb
This commit is contained in:
commit
b7207b0885
@ -65,4 +65,4 @@ RUN set -e -x ;\
|
||||
PATH=$PATH:$HOME/.cargo/bin cargo install --path prjoxide
|
||||
|
||||
RUN set -e -x ;\
|
||||
pip3 install apycula==0.0.1a9
|
||||
pip3 install apycula==0.0.1a12
|
||||
|
@ -670,13 +670,16 @@ void Arch::addMuxBels(const DatabasePOD *db, int row, int col)
|
||||
Arch::Arch(ArchArgs args) : args(args)
|
||||
{
|
||||
family = args.family;
|
||||
device = args.device;
|
||||
|
||||
// Load database
|
||||
std::string chipdb = stringf("gowin/chipdb-%s.bin", family.c_str());
|
||||
auto db = reinterpret_cast<const DatabasePOD *>(get_chipdb(chipdb));
|
||||
if (db == nullptr)
|
||||
if (db == nullptr) {
|
||||
log_error("Failed to load chipdb '%s'\n", chipdb.c_str());
|
||||
}
|
||||
if (db->version != chipdb_version) {
|
||||
log_error("Incorrect chipdb version %u is used. Version %u is required\n", db->version, chipdb_version);
|
||||
}
|
||||
if (db->family.get() != family) {
|
||||
log_error("Database is for family '%s' but provided device is family '%s'.\n", db->family.get(),
|
||||
family.c_str());
|
||||
@ -685,37 +688,58 @@ Arch::Arch(ArchArgs args) : args(args)
|
||||
for (size_t i = 0; i < db->num_ids; i++) {
|
||||
IdString::initialize_add(this, db->id_strs[i].get(), uint32_t(i) + db->num_constids);
|
||||
}
|
||||
|
||||
// setup package
|
||||
IdString package_name;
|
||||
IdString device_id;
|
||||
IdString speed_id;
|
||||
for (unsigned int i = 0; i < db->num_partnumbers; i++) {
|
||||
auto partnumber = &db->partnumber_packages[i];
|
||||
// std::cout << IdString(partnumber->name_id).str(this) << IdString(partnumber->package_id).str(this) <<
|
||||
// std::endl;
|
||||
if (IdString(partnumber->name_id) == id(args.partnumber)) {
|
||||
package_name = IdString(partnumber->package_id);
|
||||
device_id = IdString(partnumber->device_id);
|
||||
speed_id = IdString(partnumber->speed_id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (package_name == IdString()) {
|
||||
log_error("Unsuported partnumber '%s'.\n", args.partnumber.c_str());
|
||||
}
|
||||
|
||||
// setup timing info
|
||||
speed = nullptr;
|
||||
for (unsigned int i = 0; i < db->num_speeds; i++) {
|
||||
const TimingClassPOD *tc = &db->speeds[i];
|
||||
// std::cout << IdString(tc->name_id).str(this) << std::endl;
|
||||
if (IdString(tc->name_id) == id(args.speed)) {
|
||||
if (IdString(tc->name_id) == speed_id) {
|
||||
speed = tc->groups.get();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (speed == nullptr) {
|
||||
log_error("Unsuported speed grade '%s'.\n", args.speed.c_str());
|
||||
log_error("Unsuported speed grade '%s'.\n", speed_id.c_str(this));
|
||||
}
|
||||
|
||||
const VariantPOD *variant = nullptr;
|
||||
for (unsigned int i = 0; i < db->num_variants; i++) {
|
||||
auto var = &db->variants[i];
|
||||
// std::cout << IdString(var->name_id).str(this) << std::endl;
|
||||
if (IdString(var->name_id) == id(args.device)) {
|
||||
if (IdString(var->name_id) == device_id) {
|
||||
variant = var;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (variant == nullptr) {
|
||||
log_error("Unsuported device grade '%s'.\n", args.device.c_str());
|
||||
log_error("Unsuported device grade '%s'.\n", device_id.c_str(this));
|
||||
}
|
||||
|
||||
package = nullptr;
|
||||
for (unsigned int i = 0; i < variant->num_packages; i++) {
|
||||
auto pkg = &variant->packages[i];
|
||||
// std::cout << IdString(pkg->name_id).str(this) << std::endl;
|
||||
if (IdString(pkg->name_id) == id(args.package)) {
|
||||
if (IdString(pkg->name_id) == package_name) {
|
||||
package = pkg;
|
||||
break;
|
||||
}
|
||||
@ -724,9 +748,15 @@ Arch::Arch(ArchArgs args) : args(args)
|
||||
// std::cout << IdString(pin.src_id).str(this) << " " << IdString(pin.dest_id).str(this) << std::endl;
|
||||
// }
|
||||
}
|
||||
|
||||
if (package == nullptr) {
|
||||
log_error("Unsuported package '%s'.\n", args.package.c_str());
|
||||
log_error("Unsuported package '%s'.\n", package_name.c_str(this));
|
||||
}
|
||||
|
||||
//
|
||||
log_info("Series:%s Device:%s Package:%s Speed:%s\n", family.c_str(), device_id.c_str(this),
|
||||
package_name.c_str(this), speed_id.c_str(this));
|
||||
|
||||
// setup db
|
||||
char buf[32];
|
||||
// The reverse order of the enumeration simplifies the creation
|
||||
|
15
gowin/arch.h
15
gowin/arch.h
@ -131,6 +131,13 @@ NPNR_PACKED_STRUCT(struct TimingClassPOD {
|
||||
RelPtr<TimingGroupsPOD> groups;
|
||||
});
|
||||
|
||||
NPNR_PACKED_STRUCT(struct PartnumberPOD {
|
||||
uint32_t name_id;
|
||||
uint32_t package_id;
|
||||
uint32_t device_id;
|
||||
uint32_t speed_id;
|
||||
});
|
||||
|
||||
NPNR_PACKED_STRUCT(struct PackagePOD {
|
||||
uint32_t name_id;
|
||||
uint32_t num_pins;
|
||||
@ -153,6 +160,8 @@ NPNR_PACKED_STRUCT(struct DatabasePOD {
|
||||
RelPtr<GlobalAliasPOD> aliases;
|
||||
uint32_t num_speeds;
|
||||
RelPtr<TimingClassPOD> speeds;
|
||||
uint32_t num_partnumbers;
|
||||
RelPtr<PartnumberPOD> partnumber_packages;
|
||||
uint32_t num_variants;
|
||||
RelPtr<VariantPOD> variants;
|
||||
uint16_t num_constids;
|
||||
@ -162,10 +171,8 @@ NPNR_PACKED_STRUCT(struct DatabasePOD {
|
||||
|
||||
struct ArchArgs
|
||||
{
|
||||
std::string device;
|
||||
std::string family;
|
||||
std::string speed;
|
||||
std::string package;
|
||||
std::string partnumber;
|
||||
// y = mx + c relationship between distance and delay for interconnect
|
||||
// delay estimates
|
||||
double delayScale = 0.4, delayOffset = 0.4;
|
||||
@ -447,6 +454,8 @@ struct Arch : BaseArch<ArchRanges>
|
||||
bool cellsCompatible(const CellInfo **cells, int count) const;
|
||||
// start Z for the MUX2LUT5 bels
|
||||
int const mux_0_z = 10;
|
||||
// chip db version
|
||||
unsigned int const chipdb_version = 1;
|
||||
|
||||
std::vector<IdString> cell_types;
|
||||
|
||||
|
@ -54,7 +54,7 @@ po::options_description GowinCommandHandler::getArchOptions()
|
||||
|
||||
std::unique_ptr<Context> GowinCommandHandler::createContext(dict<std::string, Property> &values)
|
||||
{
|
||||
std::regex devicere = std::regex("GW1N([A-Z]*)-(LV|UV|UX)([0-9])(C?)([A-Z]{2}[0-9]+)(C[0-9]/I[0-9])");
|
||||
std::regex devicere = std::regex("GW1N([A-Z]*)-(LV|UV|UX)([0-9])(C?).*");
|
||||
std::smatch match;
|
||||
std::string device = vm["device"].as<std::string>();
|
||||
if (!std::regex_match(device, match, devicere)) {
|
||||
@ -62,8 +62,6 @@ std::unique_ptr<Context> GowinCommandHandler::createContext(dict<std::string, Pr
|
||||
}
|
||||
ArchArgs chipArgs;
|
||||
char buf[36];
|
||||
snprintf(buf, 36, "GW1N%s-%s%s", match[1].str().c_str(), match[3].str().c_str(), match[4].str().c_str());
|
||||
chipArgs.device = buf;
|
||||
// GW1N and GW1NR variants share the same database.
|
||||
// Most Gowin devices are a System in Package with some SDRAM wirebonded to a GPIO bank.
|
||||
// However, it appears that the S series with embedded ARM core are unique silicon.
|
||||
@ -73,8 +71,7 @@ std::unique_ptr<Context> GowinCommandHandler::createContext(dict<std::string, Pr
|
||||
snprintf(buf, 36, "GW1N-%s", match[3].str().c_str());
|
||||
}
|
||||
chipArgs.family = buf;
|
||||
chipArgs.package = match[5];
|
||||
chipArgs.speed = match[6];
|
||||
chipArgs.partnumber = match[0];
|
||||
return std::unique_ptr<Context>(new Context(chipArgs));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user