From 480b62181dd3e7d9e598de5672e1aa471d9355f9 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Thu, 28 Apr 2022 07:29:39 +0200 Subject: netlists-memories: detect simple loop. Fix #2043 --- src/synth/netlists-memories.adb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/synth/netlists-memories.adb b/src/synth/netlists-memories.adb index 062a73a94..55bcf0ba4 100644 --- a/src/synth/netlists-memories.adb +++ b/src/synth/netlists-memories.adb @@ -1185,11 +1185,17 @@ package body Netlists.Memories is -- It is OK to have mux2, provided it is connected to -- a dyn_extract. declare + Mux_Out : constant Net := Get_Output (Pinst, 0); Sub_Status : Get_Next_Status; Sub_Res : Instance; begin - Get_Next_Non_Extract - (Get_Output (Pinst, 0), Sub_Status, Sub_Res); + if Mux_Out = O then + -- Avoid simple infinite recursion + Status := Status_None; + Res := No_Instance; + return; + end if; + Get_Next_Non_Extract (Mux_Out, Sub_Status, Sub_Res); -- Expect Dyn_Extract, so no next. if Sub_Status /= Status_None then Status := Status_Multiple; @@ -2392,7 +2398,8 @@ package body Netlists.Memories is Instance_Tables.Init (Mems, 16); - -- Extract memories (isignal/signal/const) from dyn gates. + -- Extract memories from dyn gates: + -- get the isignal/signal/const gate at the origin of the dyn gate. for I in Instance_Tables.First .. Instance_Tables.Last (Dyns) loop Inst := Dyns.Table (I); if not Get_Mark_Flag (Inst) then -- cgit v1.2.3