gowin: Add partnumbers and packages to the chipdb
Instead of parsing the partnumber with a regular expression, a simple table is used. This is done because the structure of the partnumber changes as new features appear (e.g., ES instead of C6/I5) This commit does not yet disable the very first regular expression check. Signed-off-by: YRabbit <rabbit@yrabbit.cyou>
This commit is contained in:
parent
06d58e6eed
commit
0e8a2999bd
@ -698,24 +698,38 @@ Arch::Arch(ArchArgs args) : args(args)
|
||||
if (speed == nullptr) {
|
||||
log_error("Unsuported speed grade '%s'.\n", args.speed.c_str());
|
||||
}
|
||||
|
||||
IdString package_name;
|
||||
IdString device_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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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,8 +738,9 @@ 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));
|
||||
}
|
||||
// setup db
|
||||
char buf[32];
|
||||
|
10
gowin/arch.h
10
gowin/arch.h
@ -131,6 +131,12 @@ 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;
|
||||
});
|
||||
|
||||
NPNR_PACKED_STRUCT(struct PackagePOD {
|
||||
uint32_t name_id;
|
||||
uint32_t num_pins;
|
||||
@ -153,6 +159,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;
|
||||
@ -165,7 +173,7 @@ 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;
|
||||
|
@ -73,7 +73,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.partnumber = match[0];
|
||||
chipArgs.speed = match[6];
|
||||
return std::unique_ptr<Context>(new Context(chipArgs));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user