diff --git a/gowin/CMakeLists.txt b/gowin/CMakeLists.txt index ab6f4ee4..92ff1c08 100644 --- a/gowin/CMakeLists.txt +++ b/gowin/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.5) project(chipdb-gowin NONE) -set(ALL_GOWIN_DEVICES GW1N-1 GW1NZ-1 GW1N-4 GW1N-9 GW1N-9C GW1NS-2 GW1NS-4) +set(ALL_GOWIN_DEVICES GW1N-1 GW1NZ-1 GW1N-4 GW1N-9 GW1N-9C GW1NS-2 GW1NS-4 GW2A-18) set(GOWIN_DEVICES ${ALL_GOWIN_DEVICES} CACHE STRING "Include support for these Gowin devices (available: ${ALL_GOWIN_DEVICES})") message(STATUS "Enabled Gowin devices: ${GOWIN_DEVICES}") diff --git a/gowin/main.cc b/gowin/main.cc index ccf4d190..15b1914d 100644 --- a/gowin/main.cc +++ b/gowin/main.cc @@ -66,7 +66,9 @@ std::unique_ptr GowinCommandHandler::createContext(dict(); - if (!std::regex_match(device, match, devicere)) { + bool GW2 = device == "GW2A-LV18PG256C8/I7"; + + if (!GW2 && !std::regex_match(device, match, devicere)) { log_error("Invalid device %s\n", device.c_str()); } ArchArgs chipArgs; @@ -74,14 +76,22 @@ std::unique_ptr GowinCommandHandler::createContext(dict(); } else { - char buf[36]; - // 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. - snprintf(buf, 36, "GW1N%s-%s", match[1].str().c_str(), match[3].str().c_str()); - chipArgs.family = buf; + if (!GW2) { + char buf[36]; + // 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. + snprintf(buf, 36, "GW1N%s-%s", match[1].str().c_str(), match[3].str().c_str()); + chipArgs.family = buf; + } else { + chipArgs.family = "GW2A-18"; + } + } + if (!GW2) { + chipArgs.partnumber = match[0]; + } else { + chipArgs.partnumber = device; } - chipArgs.partnumber = match[0]; auto ctx = std::unique_ptr(new Context(chipArgs)); // routing options @@ -93,6 +103,10 @@ std::unique_ptr GowinCommandHandler::createContext(dictsettings[ctx->id("arch.enable-auto-longwires")] = 1; } + // XXX disable clock lines for now + if (GW2) { + ctx->settings[ctx->id("arch.enable-globals")] = 0; + } return ctx; }