diff options
author | Tristan Gingold <tgingold@free.fr> | 2022-05-18 14:14:24 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2022-05-18 14:14:24 +0200 |
commit | 91162dc0553f088967d85633c6db0d78ab16f873 (patch) | |
tree | b5d9e4a2fb51beb16af20b1d47e81c0bb81d53bb /src | |
parent | 30f52be1c693f3a5b12de55656d04cba5f1ecd86 (diff) | |
download | ghdl-91162dc0553f088967d85633c6db0d78ab16f873.tar.gz ghdl-91162dc0553f088967d85633c6db0d78ab16f873.tar.bz2 ghdl-91162dc0553f088967d85633c6db0d78ab16f873.zip |
synth-vhdl_stmts: add comments about report statements
Diffstat (limited to 'src')
-rw-r--r-- | src/synth/synth-vhdl_stmts.adb | 56 |
1 files changed, 51 insertions, 5 deletions
diff --git a/src/synth/synth-vhdl_stmts.adb b/src/synth/synth-vhdl_stmts.adb index 53e7a2ee4..75080125f 100644 --- a/src/synth/synth-vhdl_stmts.adb +++ b/src/synth/synth-vhdl_stmts.adb @@ -2961,11 +2961,54 @@ package body Synth.Vhdl_Stmts is end if; end Synth_Static_Report; - procedure Synth_Static_Report_Statement (C : Seq_Context; Stmt : Node) is + procedure Synth_Static_Report_Statement (Inst : Synth_Instance_Acc; + Stmt : Node) is begin - Synth_Static_Report (C.Inst, Stmt); + Synth_Static_Report (Inst, Stmt); end Synth_Static_Report_Statement; + -- Return True if EXPR can be evaluated with static values. + -- Does not need to be fully accurate, used for report/assert messages. + function Is_Static_Expr (Inst : Synth_Instance_Acc; + Expr : Node) return Boolean is + begin + case Get_Kind (Expr) is + when Iir_Kinds_Dyadic_Operator => + return Is_Static_Expr (Inst, Get_Left (Expr)) + and then Is_Static_Expr (Inst, Get_Right (Expr)); + when Iir_Kind_Image_Attribute => + return Is_Static_Expr (Inst, Get_Parameter (Expr)); + when Iir_Kind_Instance_Name_Attribute + | Iir_Kinds_Literal + | Iir_Kind_Enumeration_Literal => + return True; + when Iir_Kind_Length_Array_Attribute => + -- Attributes on types can be evaluated. + return True; + when Iir_Kind_Simple_Name => + return Is_Static_Expr (Inst, Get_Named_Entity (Expr)); + when others => + Error_Kind ("is_static_expr", Expr); + return False; + end case; + end Is_Static_Expr; + + procedure Synth_Dynamic_Report_Statement (Inst : Synth_Instance_Acc; + Stmt : Node; + Is_Cond : Boolean) + is + Rep_Expr : constant Node := Get_Report_Expression (Stmt); + Sev_Expr : constant Node := Get_Severity_Expression (Stmt); + begin + if not Is_Cond + and then Is_Static_Expr (Inst, Rep_Expr) + and then (Sev_Expr = Null_Node + or else Is_Static_Expr (Inst, Sev_Expr)) + then + Synth_Static_Report (Inst, Stmt); + end if; + end Synth_Dynamic_Report_Statement; + procedure Execute_Assertion_Statement (Inst : Synth_Instance_Acc; Stmt : Node) is @@ -3082,10 +3125,13 @@ package body Synth.Vhdl_Stmts is when Iir_Kind_Procedure_Call_Statement => Synth_Procedure_Call (C.Inst, Stmt); when Iir_Kind_Report_Statement => - -- TODO: handle report statements from ieee library (at least - -- fixed pkg). They are known to be OK (tbc) and useful. if not Is_Dyn then - Synth_Static_Report_Statement (C, Stmt); + Synth_Static_Report_Statement (C.Inst, Stmt); + else + -- Not executed. + -- Depends on the execution path: the report statement may + -- be conditionally executed. + Synth_Dynamic_Report_Statement (C.Inst, Stmt, True); end if; when Iir_Kind_Assertion_Statement => if not Is_Dyn then |