From e2cd4d8f005ac7eba676eb8574359e15a4cd8013 Mon Sep 17 00:00:00 2001 From: IgnoreWarnings Date: Tue, 4 Jun 2024 12:22:43 +0000 Subject: [PATCH] fix test --- fpga/src/platform.cpp | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/fpga/src/platform.cpp b/fpga/src/platform.cpp index e4362f6ac..03519bf83 100644 --- a/fpga/src/platform.cpp +++ b/fpga/src/platform.cpp @@ -13,9 +13,36 @@ int main() { logging.setLevel(spdlog::level::trace); - const std::string config = "/home/root/codebase/node/etc/examples/nodes/miob.conf"; - const std::string name = "zcu106"; - auto card = fpga::setupFpgaCard(config, name); + std::string configFilePath = "/home/root/codebase/node/etc/fpga/miob/fpgas.json"; + auto configDir = std::filesystem::path(configFilePath).parent_path(); + std::vector modules {"vfio"}; + auto vfioContainer = std::make_shared(modules); + + // Parse FPGA configuration + FILE* f = fopen(configFilePath.c_str(), "r"); + if (!f) + throw RuntimeError("Cannot open config file: {}", configFilePath); + + json_t* json = json_loadf(f, 0, nullptr); + if (!json) { + fclose(f); + throw RuntimeError("Cannot parse JSON config"); + } + + fclose(f); + + json_t* fpgas = json_object_get(json, "fpgas"); + if (fpgas == nullptr) { + exit(1); + } + + json_t* fpga = json_object_get(fpgas, "zcu106"); + if (fpga == nullptr) { + exit(1); + } + + // Create all FPGA card instances using the corresponding plugin + auto card = PlatformCardFactory::make(fpga, "zcu106", vfioContainer, configDir); auto axi_switch = std::dynamic_pointer_cast( card->lookupIp(fpga::Vlnv("xilinx.com:ip:axis_switch:")));