Merge pull request #881 from uis246/regex

Tidy gowin modification regex
This commit is contained in:
gatecat 2021-12-18 21:38:52 +00:00 committed by GitHub
commit 4a3847765c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,7 +54,7 @@ po::options_description GowinCommandHandler::getArchOptions()
std::unique_ptr<Context> GowinCommandHandler::createContext(dict<std::string, Property> &values) 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?).*"); std::regex devicere = std::regex("GW1N(S?)[A-Z]*-(LV|UV|UX)([0-9])(C?).*");
std::smatch match; std::smatch match;
std::string device = vm["device"].as<std::string>(); std::string device = vm["device"].as<std::string>();
if (!std::regex_match(device, match, devicere)) { if (!std::regex_match(device, match, devicere)) {
@ -65,11 +65,7 @@ std::unique_ptr<Context> GowinCommandHandler::createContext(dict<std::string, Pr
// GW1N and GW1NR variants share the same database. // GW1N and GW1NR variants share the same database.
// Most Gowin devices are a System in Package with some SDRAM wirebonded to a GPIO bank. // 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. // However, it appears that the S series with embedded ARM core are unique silicon.
if (match[1].str().length() && match[1].str()[0] == 'S') { snprintf(buf, 36, "GW1N%s-%s", match[1].str().c_str(), match[3].str().c_str());
snprintf(buf, 36, "GW1NS-%s", match[3].str().c_str());
} else {
snprintf(buf, 36, "GW1N-%s", match[3].str().c_str());
}
chipArgs.family = buf; chipArgs.family = buf;
chipArgs.partnumber = match[0]; chipArgs.partnumber = match[0];
return std::unique_ptr<Context>(new Context(chipArgs)); return std::unique_ptr<Context>(new Context(chipArgs));