diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-09-18 07:07:27 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-09-18 18:45:25 +0200 |
commit | 1b8c3d64e07584ffcd60f2d13634e6285e3cc7ef (patch) | |
tree | 1d9f47c3896738ec3e4450b796b71d210fe5eada /src/synth | |
parent | 48396102d53ed1c10a750a14ff75364d5c533e10 (diff) | |
download | ghdl-1b8c3d64e07584ffcd60f2d13634e6285e3cc7ef.tar.gz ghdl-1b8c3d64e07584ffcd60f2d13634e6285e3cc7ef.tar.bz2 ghdl-1b8c3d64e07584ffcd60f2d13634e6285e3cc7ef.zip |
synth: improve locations tracking.
Diffstat (limited to 'src/synth')
-rw-r--r-- | src/synth/netlists-locations.adb | 25 | ||||
-rw-r--r-- | src/synth/netlists-locations.ads | 5 | ||||
-rw-r--r-- | src/synth/synth-environment.adb | 12 | ||||
-rw-r--r-- | src/synth/synth-environment.ads | 3 | ||||
-rw-r--r-- | src/synth/synth-inference.adb | 3 | ||||
-rw-r--r-- | src/synth/synth-source.adb | 31 | ||||
-rw-r--r-- | src/synth/synth-source.ads | 5 | ||||
-rw-r--r-- | src/synth/synth-stmts.adb | 7 |
8 files changed, 84 insertions, 7 deletions
diff --git a/src/synth/netlists-locations.adb b/src/synth/netlists-locations.adb index c754d2855..ecc1d42fd 100644 --- a/src/synth/netlists-locations.adb +++ b/src/synth/netlists-locations.adb @@ -64,6 +64,31 @@ package body Netlists.Locations is return No_Location; end if; end Get_Location; + + procedure Copy_Location1 (Dest : Net; Src : Instance) is + begin + Set_Location (Get_Parent (Dest), Get_Location (Src)); + end Copy_Location1; + + procedure Copy_Location1 (Dest : Net; Src : Net) is + begin + Set_Location (Get_Parent (Dest), Get_Location (Get_Parent (Src))); + end Copy_Location1; + + procedure Copy_Location (Dest : Net; Src : Net) is + begin + if Flag_Locations then + Copy_Location1 (Dest, Src); + end if; + end Copy_Location; + + procedure Copy_Location (Dest : Net; Src : Instance) is + begin + if Flag_Locations then + Copy_Location1 (Dest, Src); + end if; + end Copy_Location; + begin Loc_Table.Append (No_Location); end Netlists.Locations; diff --git a/src/synth/netlists-locations.ads b/src/synth/netlists-locations.ads index 9bc7d55f1..1990a8b67 100644 --- a/src/synth/netlists-locations.ads +++ b/src/synth/netlists-locations.ads @@ -28,4 +28,9 @@ package Netlists.Locations is -- Get the previously saved location for INST. -- Return Null_Location if no location set or locations are disabled. function Get_Location (Inst : Instance) return Location_Type; + + -- Utilities. + procedure Copy_Location (Dest : Net; Src : Net); + procedure Copy_Location (Dest : Net; Src : Instance); + pragma Inline (Copy_Location); end Netlists.Locations; diff --git a/src/synth/synth-environment.adb b/src/synth/synth-environment.adb index 33a38db0c..53c5e1493 100644 --- a/src/synth/synth-environment.adb +++ b/src/synth/synth-environment.adb @@ -21,8 +21,11 @@ with Netlists.Builders; use Netlists.Builders; with Netlists.Concats; with Errorout; use Errorout; + with Synth.Inference; with Synth.Errors; use Synth.Errors; +with Synth.Source; use Synth.Source; + with Vhdl.Nodes; with Vhdl.Errors; use Vhdl.Errors; @@ -790,7 +793,8 @@ package body Synth.Environment is W : Wire_Id; Sel : Net; F_Asgns : Partial_Assign; - T_Asgns : Partial_Assign) + T_Asgns : Partial_Assign; + Stmt : Source.Syn_Src) is P : Partial_Assign_Array (0 .. 1); N : Net_Array (0 .. 1); @@ -821,6 +825,7 @@ package body Synth.Environment is -- Build mux. Res := Netlists.Builders.Build_Mux2 (Ctxt, Sel, N (0), N (1)); + Set_Location (Res, Stmt); -- Keep the result in a list. Pasgn := New_Partial_Assign (Res, Off); @@ -838,7 +843,8 @@ package body Synth.Environment is -- Add muxes for two lists T and F of assignments. procedure Merge_Phis (Ctxt : Builders.Context_Acc; Sel : Net; - T, F : Phi_Type) + T, F : Phi_Type; + Stmt : Source.Syn_Src) is T_Asgns : Seq_Assign; F_Asgns : Seq_Assign; @@ -877,7 +883,7 @@ package body Synth.Environment is T_Asgns := Get_Assign_Chain (T_Asgns); F_Asgns := Get_Assign_Chain (F_Asgns); end if; - Merge_Assigns (Ctxt, W, Sel, Fp, Tp); + Merge_Assigns (Ctxt, W, Sel, Fp, Tp, Stmt); end loop; end Merge_Phis; diff --git a/src/synth/synth-environment.ads b/src/synth/synth-environment.ads index fff66e01d..71388c610 100644 --- a/src/synth/synth-environment.ads +++ b/src/synth/synth-environment.ads @@ -105,7 +105,8 @@ package Synth.Environment is -- those from T or from F. procedure Merge_Phis (Ctxt : Builders.Context_Acc; Sel : Net; - T, F : Phi_Type); + T, F : Phi_Type; + Stmt : Source.Syn_Src); -- Sort all seq assign of P by wire id. Used to more easily merge them. function Sort_Phi (P : Phi_Type) return Seq_Assign; diff --git a/src/synth/synth-inference.adb b/src/synth/synth-inference.adb index 376a48840..afb47c965 100644 --- a/src/synth/synth-inference.adb +++ b/src/synth/synth-inference.adb @@ -23,6 +23,7 @@ with Dyn_Interning; with Netlists.Utils; use Netlists.Utils; with Netlists.Gates; use Netlists.Gates; with Netlists.Gates_Ports; use Netlists.Gates_Ports; +with Netlists.Locations; use Netlists.Locations; with Synth.Flags; @@ -239,6 +240,7 @@ package body Synth.Inference is -- for it. if Enable /= No_Net then Data := Build_Mux2 (Ctxt, Enable, Prev_Val, Data); + Copy_Location (Data, Enable); end if; -- If the signal declaration has an initial value, get it. @@ -324,6 +326,7 @@ package body Synth.Inference is Rst => Rst, Rst_Val => Rst_Val); end if; end if; + Copy_Location (Res, Last_Mux); -- The output of the mux may be read later in the process, -- like this: diff --git a/src/synth/synth-source.adb b/src/synth/synth-source.adb new file mode 100644 index 000000000..d160da1f2 --- /dev/null +++ b/src/synth/synth-source.adb @@ -0,0 +1,31 @@ +-- Source/origin of synthesis. +-- Copyright (C) 2019 Tristan Gingold +-- +-- This file is part of GHDL. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +-- MA 02110-1301, USA. + +with Netlists; use Netlists; +with Netlists.Locations; use Netlists.Locations; + +package body Synth.Source is + procedure Set_Location (N : Net; Src : Syn_Src) is + begin + if Flag_Locations then + Set_Location (Get_Parent (N), Get_Location (Src)); + end if; + end Set_Location; +end Synth.Source; diff --git a/src/synth/synth-source.ads b/src/synth/synth-source.ads index 2dd081e84..1a2db0209 100644 --- a/src/synth/synth-source.ads +++ b/src/synth/synth-source.ads @@ -18,9 +18,14 @@ -- Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, -- MA 02110-1301, USA. +with Netlists; + with Vhdl.Nodes; use Vhdl.Nodes; package Synth.Source is subtype Syn_Src is Iir; No_Syn_Src : constant Syn_Src := Null_Iir; + + procedure Set_Location (N : Netlists.Net; Src : Syn_Src); + pragma Inline (Set_Location); end Synth.Source; diff --git a/src/synth/synth-stmts.adb b/src/synth/synth-stmts.adb index 647cd0184..2abfc6bf9 100644 --- a/src/synth/synth-stmts.adb +++ b/src/synth/synth-stmts.adb @@ -460,7 +460,8 @@ package body Synth.Stmts is Pop_Phi (Phi_False); En_F := C.T_En; - Merge_Phis (Build_Context, Get_Net (Cond_Val), Phi_True, Phi_False); + Merge_Phis (Build_Context, + Get_Net (Cond_Val), Phi_True, Phi_False, Stmt); if En_T = En_F then C.T_En := En_T; else @@ -1372,7 +1373,7 @@ package body Synth.Stmts is Pop_Phi (Phi_F); Merge_Phis (Build_Context, Get_Current_Value (Build_Context, C.W_Ret), - Phi_F, Phi_T); + Phi_F, Phi_T, Stmt); end if; if C.T_En = False then return; @@ -1412,7 +1413,7 @@ package body Synth.Stmts is Pop_Phi (Phi_False); Merge_Phis (Build_Context, Get_Net (Cond_Val), - Phi_True, Phi_False); + Phi_True, Phi_False, Stmt); end Synth_Process_Sequential_Statements; procedure Synth_Process_Statement |