diff options
Diffstat (limited to 'src/synth')
-rw-r--r-- | src/synth/netlists-inference.adb | 7 | ||||
-rw-r--r-- | src/synth/netlists-inference.ads | 6 | ||||
-rw-r--r-- | src/synth/synth-environment.adb | 6 |
3 files changed, 16 insertions, 3 deletions
diff --git a/src/synth/netlists-inference.adb b/src/synth/netlists-inference.adb index 66aabf2bc..b0a660ec5 100644 --- a/src/synth/netlists-inference.adb +++ b/src/synth/netlists-inference.adb @@ -795,7 +795,8 @@ package body Netlists.Inference is Val : Net; Off : Uns32; Prev_Val : Net; - Stmt : Synth.Source.Syn_Src) return Net + Stmt : Synth.Source.Syn_Src; + Last_Use : Boolean) return Net is pragma Assert (Val /= No_Net); pragma Assert (Prev_Val /= No_Net); @@ -817,6 +818,10 @@ package body Netlists.Inference is -- No logical loop or self assignment. return Val; end if; + if Last_Use and then Has_One_Connection (Prev_Val) then + -- Value is not used, to be removed. Do not try to infere anything. + return Val; + end if; -- So there is a logical loop. Sel := Get_Mux2_Sel (Last_Mux); diff --git a/src/synth/netlists-inference.ads b/src/synth/netlists-inference.ads index b034ec301..291b135bd 100644 --- a/src/synth/netlists-inference.ads +++ b/src/synth/netlists-inference.ads @@ -32,9 +32,13 @@ package Netlists.Inference is -- To be called when there is an assignment to a signal/output of VAL and -- the previous value is PREV_VAL (an Id_Signal or Id_Output). -- If there is a loop, infere a dff or a latch or emit an error. + -- LAST_USE is true iff PREV_VAL won't be reused anywhere else. So, if + -- PREV_VAL is only used in VAL, this is a closed logic that could be + -- ignored. function Infere (Ctxt : Context_Acc; Val : Net; Off : Uns32; Prev_Val : Net; - Stmt : Synth.Source.Syn_Src) return Net; + Stmt : Synth.Source.Syn_Src; + Last_Use : Boolean) return Net; end Netlists.Inference; diff --git a/src/synth/synth-environment.adb b/src/synth/synth-environment.adb index ec11d4ba2..0f5e3b607 100644 --- a/src/synth/synth-environment.adb +++ b/src/synth/synth-environment.adb @@ -365,8 +365,12 @@ package body Synth.Environment is if Synth.Flags.Flag_Debug_Noinference then Res := Pa.Value; else + -- Note: lifetime is currently based on the kind of the + -- wire (variable -> not reused beyond this process). + -- This is OK for vhdl but not general. Res := Inference.Infere - (Ctxt, Pa.Value, Pa.Offset, Outport, Stmt); + (Ctxt, Pa.Value, Pa.Offset, Outport, Stmt, + Wire_Rec.Kind = Wire_Variable); end if; Add_Conc_Assign (Wid, Res, Pa.Offset, Stmt); |