diff options
author | Tristan Gingold <tgingold@free.fr> | 2021-03-29 21:23:30 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2021-03-29 21:25:07 +0200 |
commit | fb5bbea118c7cfa6d5793c8d463ffc4448d3a84f (patch) | |
tree | de9e9222fe00a9de57890d05697d189cb7aa0324 /src/synth | |
parent | 9f58adc16cb9306b5bf45cfaa5c7167bc52a56f8 (diff) | |
download | ghdl-fb5bbea118c7cfa6d5793c8d463ffc4448d3a84f.tar.gz ghdl-fb5bbea118c7cfa6d5793c8d463ffc4448d3a84f.tar.bz2 ghdl-fb5bbea118c7cfa6d5793c8d463ffc4448d3a84f.zip |
netlists-disp_vhdl: do not display edge net when not needed. Fix #1703
Diffstat (limited to 'src/synth')
-rw-r--r-- | src/synth/netlists-disp_vhdl.adb | 54 | ||||
-rw-r--r-- | src/synth/netlists-utils.adb | 19 | ||||
-rw-r--r-- | src/synth/netlists-utils.ads | 1 |
3 files changed, 49 insertions, 25 deletions
diff --git a/src/synth/netlists-disp_vhdl.adb b/src/synth/netlists-disp_vhdl.adb index 77fa364a1..ce25ca15b 100644 --- a/src/synth/netlists-disp_vhdl.adb +++ b/src/synth/netlists-disp_vhdl.adb @@ -29,6 +29,7 @@ with Netlists.Dump; use Netlists.Dump; package body Netlists.Disp_Vhdl is Flag_Merge_Lit : constant Boolean := True; + Flag_Merge_Edge : constant Boolean := True; procedure Put_Type (W : Width) is begin @@ -478,6 +479,37 @@ package body Netlists.Disp_Vhdl is return False; end Need_Signal; + -- Return TRUE if edge INST (posedge or negedge) is used outside clock + -- inputs. + function Need_Edge (Inst : Instance) return Boolean + is + I : Input; + Parent : Instance; + begin + I := Get_First_Sink (Get_Output (Inst, 0)); + while I /= No_Input loop + Parent := Get_Input_Parent (I); + case Get_Id (Parent) is + when Id_Dff + | Id_Adff + | Id_Idff + | Id_Iadff => + if I /= Get_Input (Parent, 0) then + return True; + end if; + when Id_Mem_Rd_Sync + | Id_Mem_Wr_Sync => + if I /= Get_Input (Parent, 2) then + return True; + end if; + when others => + return True; + end case; + I := Get_Next_Sink (I); + end loop; + return False; + end Need_Edge; + type Conv_Type is (Conv_None, Conv_Slv, Conv_Unsigned, Conv_Signed, Conv_Edge, Conv_Clock); @@ -492,7 +524,7 @@ package body Netlists.Disp_Vhdl is Net_Inst := Get_Net_Parent (N); if Flag_Merge_Lit - and then Is_Const_Module (Get_Id (Net_Inst)) + and then Get_Id (Net_Inst) in Constant_Module_Id and then not Need_Name (Inst) then case Conv is @@ -1334,6 +1366,9 @@ package body Netlists.Disp_Vhdl is and then Id in Constant_Module_Id and then Id < Id_User_None and then not Need_Signal (Inst)) + and then not (Flag_Merge_Edge + and then Id in Edge_Module_Id + and then not Need_Edge (Inst)) then if Locations.Get_Location (Inst) = No_Location then case Get_Id (Inst) is @@ -1406,11 +1441,18 @@ package body Netlists.Disp_Vhdl is end; for Inst of Instances (M) loop - if not (Flag_Merge_Lit - and then Is_Const_Module (Get_Id (Inst))) - then - Disp_Instance_Inline (Inst); - end if; + case Get_Id (Inst) is + when Constant_Module_Id => + if not Flag_Merge_Lit then + Disp_Instance_Inline (Inst); + end if; + when Edge_Module_Id => + if (not Flag_Merge_Edge) or else Need_Edge (Inst) then + Disp_Instance_Inline (Inst); + end if; + when others => + Disp_Instance_Inline (Inst); + end case; end loop; end Disp_Architecture_Statements; diff --git a/src/synth/netlists-utils.adb b/src/synth/netlists-utils.adb index a22a97707..236602fac 100644 --- a/src/synth/netlists-utils.adb +++ b/src/synth/netlists-utils.adb @@ -123,29 +123,12 @@ package body Netlists.Utils is return Get_Param_Desc (M, I).Typ; end Get_Param_Type; - function Is_Const_Module (Id : Module_Id) return Boolean is - begin - case Id is - when Id_Const_UB32 - | Id_Const_SB32 - | Id_Const_UL32 - | Id_Const_X - | Id_Const_Z - | Id_Const_0 - | Id_Const_Bit - | Id_Const_Log => - return True; - when others => - return False; - end case; - end Is_Const_Module; - function Is_Const_Net (N : Net) return Boolean is begin if Get_Width (N) = 0 then return True; end if; - return Is_Const_Module (Get_Id (Get_Net_Parent (N))); + return Get_Id (Get_Net_Parent (N)) in Constant_Module_Id; end Is_Const_Net; function Get_Net_Uns64 (N : Net) return Uns64 diff --git a/src/synth/netlists-utils.ads b/src/synth/netlists-utils.ads index 5e5fac591..7ef000685 100644 --- a/src/synth/netlists-utils.ads +++ b/src/synth/netlists-utils.ads @@ -59,7 +59,6 @@ package Netlists.Utils is return Instance; -- Return True iff ID describe a constant. - function Is_Const_Module (Id : Module_Id) return Boolean; function Is_Const_Net (N : Net) return Boolean; -- Assuming that N is a const net, return the value (for small values). |