diff options
author | Tristan Gingold <tgingold@free.fr> | 2021-08-28 12:19:39 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2021-08-29 11:50:17 +0200 |
commit | 886fdeb52c4d37540e854dc2d57f8f95de09d4dc (patch) | |
tree | 2bed706cf4eedcba44bd7a3a35e6b3b9d723f82e | |
parent | 132fde15a4d4bffd31bff341dfeaf11317c82130 (diff) | |
download | ghdl-886fdeb52c4d37540e854dc2d57f8f95de09d4dc.tar.gz ghdl-886fdeb52c4d37540e854dc2d57f8f95de09d4dc.tar.bz2 ghdl-886fdeb52c4d37540e854dc2d57f8f95de09d4dc.zip |
synth: improve result of is_positive
-rw-r--r-- | src/synth/synth-environment.adb | 5 | ||||
-rw-r--r-- | src/synth/synth-values.adb | 7 | ||||
-rw-r--r-- | src/synth/synth-vhdl_expr.adb | 8 | ||||
-rw-r--r-- | src/synth/synth-vhdl_stmts.adb | 5 |
4 files changed, 15 insertions, 10 deletions
diff --git a/src/synth/synth-environment.adb b/src/synth/synth-environment.adb index 873e8d1e8..7b5eb5c50 100644 --- a/src/synth/synth-environment.adb +++ b/src/synth/synth-environment.adb @@ -1972,15 +1972,10 @@ package body Synth.Environment is end if; end Phi_Assign_Static; - -- Return the net driving WID when it is known to be possibly constant. - -- Return No_Net is not constant. function Is_Static_Wire (Wid : Wire_Id) return Boolean is Wire_Rec : Wire_Id_Record renames Wire_Id_Table.Table (Wid); begin - if Wire_Rec.Kind /= Wire_Variable then - return False; - end if; if Wire_Rec.Cur_Assign = No_Seq_Assign then return False; end if; diff --git a/src/synth/synth-values.adb b/src/synth/synth-values.adb index cf6c7aa3b..6f89876b6 100644 --- a/src/synth/synth-values.adb +++ b/src/synth/synth-values.adb @@ -52,7 +52,12 @@ package body Synth.Values is when Value_Net => return False; when Value_Wire => - return Is_Static_Wire (Val.W); + if Get_Kind (Val.W) = Wire_Variable then + return Is_Static_Wire (Val.W); + else + -- A signal does not have static values. + return False; + end if; when Value_File => return True; when Value_Const => diff --git a/src/synth/synth-vhdl_expr.adb b/src/synth/synth-vhdl_expr.adb index 4e6c2b33e..3db969c50 100644 --- a/src/synth/synth-vhdl_expr.adb +++ b/src/synth/synth-vhdl_expr.adb @@ -97,6 +97,7 @@ package body Synth.Vhdl_Expr is function Is_Positive (V : Valtyp) return Boolean is + use Synth.Vhdl_Environment.Env; N : Net; Inst : Instance; begin @@ -108,9 +109,10 @@ package body Synth.Vhdl_Expr is when Value_Net => N := V.Val.N; when Value_Wire => - if Synth.Vhdl_Environment.Env.Is_Static_Wire (V.Val.W) then - return Read_Discrete - (Synth.Vhdl_Environment.Env.Get_Static_Wire (V.Val.W)) >= 0; + if Get_Kind (V.Val.W) = Wire_Variable + and then Is_Static_Wire (V.Val.W) + then + return Read_Discrete (Get_Static_Wire (V.Val.W)) >= 0; else return False; end if; diff --git a/src/synth/synth-vhdl_stmts.adb b/src/synth/synth-vhdl_stmts.adb index bfa3db4be..89c96012a 100644 --- a/src/synth/synth-vhdl_stmts.adb +++ b/src/synth/synth-vhdl_stmts.adb @@ -1071,7 +1071,9 @@ package body Synth.Vhdl_Stmts is when Unknown => if Prev_Val = Null_Memtyp then -- First use of previous value. - if not Is_Static_Wire (Wid) then + if Get_Kind (Wid) /= Wire_Variable + or else not Is_Static_Wire (Wid) + then -- The previous value is not static. return Null_Memtyp; end if; @@ -2262,6 +2264,7 @@ package body Synth.Vhdl_Stmts is is M : Memtyp; begin + pragma Assert (Get_Kind (Wid) = Wire_Variable); if not Is_Static_Wire (Wid) then return False; end if; |