diff --git a/fpga/lib/ips/bram.cpp b/fpga/lib/ips/bram.cpp index 11dda7f67..003e7083f 100644 --- a/fpga/lib/ips/bram.cpp +++ b/fpga/lib/ips/bram.cpp @@ -9,7 +9,7 @@ static BramFactory factory; bool BramFactory::configureJson(IpCore& ip, json_t* json_ip) { - auto& bram = reinterpret_cast(ip); + auto& bram = dynamic_cast(ip); if(json_unpack(json_ip, "{ s: i }", "size", &bram.size) != 0) { getLogger()->error("Cannot parse 'size'"); diff --git a/fpga/lib/ips/pcie.cpp b/fpga/lib/ips/pcie.cpp index d8294469e..ea5675b7d 100644 --- a/fpga/lib/ips/pcie.cpp +++ b/fpga/lib/ips/pcie.cpp @@ -125,7 +125,7 @@ bool AxiPciExpressBridgeFactory::configureJson(IpCore& ip, json_t* json_ip) { auto logger = getLogger(); - auto& pcie = reinterpret_cast(ip); + auto& pcie = dynamic_cast(ip); for(auto barType : std::list{"axi_bars", "pcie_bars"}) { json_t* json_bars = json_object_get(json_ip, barType.c_str()); diff --git a/fpga/lib/ips/switch.cpp b/fpga/lib/ips/switch.cpp index bb0ba0cbc..a06ebbc72 100644 --- a/fpga/lib/ips/switch.cpp +++ b/fpga/lib/ips/switch.cpp @@ -143,7 +143,7 @@ AxiStreamSwitchFactory::configureJson(IpCore& ip, json_t* json_ip) auto logger = getLogger(); - auto& axiSwitch = reinterpret_cast(ip); + auto& axiSwitch = dynamic_cast(ip); if(json_unpack(json_ip, "{ s: i }", "num_ports", &axiSwitch.num_ports) != 0) { logger->error("Cannot parse 'num_ports'"); diff --git a/fpga/tests/dma.cpp b/fpga/tests/dma.cpp index e7c462b26..aa43f12a2 100644 --- a/fpga/tests/dma.cpp +++ b/fpga/tests/dma.cpp @@ -24,7 +24,7 @@ Test(fpga, dma, .description = "DMA") logger->info("Testing {}", *ip); - auto dma = reinterpret_cast(*ip); + auto dma = dynamic_cast(*ip); if(not dma.loopbackPossible()) { logger->info("Loopback test not possible for {}", *ip); diff --git a/fpga/tests/fifo.cpp b/fpga/tests/fifo.cpp index 17cfd3dde..515a5fdac 100644 --- a/fpga/tests/fifo.cpp +++ b/fpga/tests/fifo.cpp @@ -47,7 +47,7 @@ Test(fpga, fifo, .description = "FIFO") logger->info("Testing {}", *ip); - auto fifo = reinterpret_cast(*ip); + auto fifo = dynamic_cast(*ip); if(not fifo.connectLoopback()) { continue; diff --git a/fpga/tests/gpu.cpp b/fpga/tests/gpu.cpp index bdc3aba92..489f86b8c 100644 --- a/fpga/tests/gpu.cpp +++ b/fpga/tests/gpu.cpp @@ -40,7 +40,7 @@ Test(fpga, gpu_dma, .description = "GPU DMA tests") logger->info("Testing {}", *ip); - auto bram = reinterpret_cast(ip.get()); + auto bram = dynamic_cast(ip.get()); cr_assert_not_null(bram, "Couldn't find BRAM"); count++; diff --git a/fpga/tests/timer.cpp b/fpga/tests/timer.cpp index 66cc71d41..2eb0cfba5 100644 --- a/fpga/tests/timer.cpp +++ b/fpga/tests/timer.cpp @@ -46,7 +46,7 @@ Test(fpga, timer, .description = "Timer Counter") count++; - auto timer = reinterpret_cast(*ip); + auto timer = dynamic_cast(*ip); logger->info("Test simple waiting"); timer.start(timer.getFrequency() / 10);