diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-11-13 18:59:05 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-11-13 18:59:05 +0100 |
commit | e8426164f027c019865e8df796a778989a3f9101 (patch) | |
tree | 02a4b1f15476ed792e352d28ef013c11b768ca92 | |
parent | 76dd45bb8abac08540068c69f0cc9492cf032a1b (diff) | |
download | ghdl-e8426164f027c019865e8df796a778989a3f9101.tar.gz ghdl-e8426164f027c019865e8df796a778989a3f9101.tar.bz2 ghdl-e8426164f027c019865e8df796a778989a3f9101.zip |
synth-expr: handle static values in
-rw-r--r-- | src/synth/synth-expr.adb | 7 | ||||
-rw-r--r-- | src/synth/synth-insts.adb | 3 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb index b30aa94ce..701724aa1 100644 --- a/src/synth/synth-expr.adb +++ b/src/synth/synth-expr.adb @@ -1573,6 +1573,13 @@ package body Synth.Expr is Right := Synth_Expression_With_Type (Syn_Inst, Right_Expr, Typ); Strip_Const (Right); + -- Return a static value if both operands are static. + -- Note: we know the value of left if it is not constant. + if Is_Const_Val (Left) and then Is_Const_Val (Right) then + Val := Get_Const_Discrete (Right); + return Create_Value_Discrete (Val, Boolean_Type); + end if; + N := Build_Dyadic (Build_Context, Id, Get_Net (Left), Get_Net (Right)); Set_Location (N, Expr); diff --git a/src/synth/synth-insts.adb b/src/synth/synth-insts.adb index 411ddcd38..3665e8954 100644 --- a/src/synth/synth-insts.adb +++ b/src/synth/synth-insts.adb @@ -556,6 +556,8 @@ package body Synth.Insts is Val := Synth_Subtype_Conversion (Val, Inter_Type, True, Assoc); + pragma Assert (Is_Const (Val)); + Create_Object (Sub_Inst, Inter, Val); Next_Association_Interface (Assoc, Assoc_Inter); @@ -980,6 +982,7 @@ package body Synth.Insts is Inter_Type := Get_Value_Type (Syn_Inst, Get_Type (Inter)); Val := Synth_Expression_With_Type (Syn_Inst, Get_Default_Value (Inter), Inter_Type); + pragma Assert (Is_Const (Val)); Create_Object (Syn_Inst, Inter, Val); end; Inter := Get_Chain (Inter); |