diff options
author | Tristan Gingold <tgingold@free.fr> | 2017-12-06 20:29:37 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2017-12-06 20:35:49 +0100 |
commit | 09fa83fe0838776a4113deff34afd65fb28a6ab7 (patch) | |
tree | ec53506b032160a9566ea6d7fa283401b0def1d4 /src/vhdl | |
parent | a18c9e2cbbe205729adc11236c8cee1cce0d9fc2 (diff) | |
download | ghdl-09fa83fe0838776a4113deff34afd65fb28a6ab7.tar.gz ghdl-09fa83fe0838776a4113deff34afd65fb28a6ab7.tar.bz2 ghdl-09fa83fe0838776a4113deff34afd65fb28a6ab7.zip |
simul: fix execution of actual expression.
Diffstat (limited to 'src/vhdl')
-rw-r--r-- | src/vhdl/simulate/simul-elaboration.adb | 7 | ||||
-rw-r--r-- | src/vhdl/simulate/simul-execution.adb | 40 | ||||
-rw-r--r-- | src/vhdl/simulate/simul-execution.ads | 6 |
3 files changed, 40 insertions, 13 deletions
diff --git a/src/vhdl/simulate/simul-elaboration.adb b/src/vhdl/simulate/simul-elaboration.adb index 400cd3b85..58764d301 100644 --- a/src/vhdl/simulate/simul-elaboration.adb +++ b/src/vhdl/simulate/simul-elaboration.adb @@ -1149,7 +1149,8 @@ package body Simul.Elaboration is end if; when Iir_Kind_Association_Element_By_Expression => Value := Get_Actual (Assoc); - Val := Execute_Expression (Local_Instance, Value); + Val := Execute_Association_Expression + (Local_Instance, Value, Target_Instance); when Iir_Kind_Association_Element_By_Individual => Val := Create_Value_For_Type (Local_Instance, Get_Actual_Type (Assoc), Init_Value_Any); @@ -1324,8 +1325,8 @@ package body Simul.Elaboration is Actual_Expr := null; else -- Association with an expression - Init_Expr := Execute_Expression - (Actual_Instance, Actual); + Init_Expr := Execute_Association_Expression + (Actual_Instance, Actual, Formal_Instance); Implicit_Array_Conversion (Formal_Instance, Init_Expr, Get_Type (Formal), Actual); Init_Expr := Unshare (Init_Expr, Global_Pool'Access); diff --git a/src/vhdl/simulate/simul-execution.adb b/src/vhdl/simulate/simul-execution.adb index 0e698d7c5..538655906 100644 --- a/src/vhdl/simulate/simul-execution.adb +++ b/src/vhdl/simulate/simul-execution.adb @@ -1774,8 +1774,8 @@ package body Simul.Execution is end String_To_Enumeration_Array_1; -- Create a literal for a string or a bit_string - function String_To_Enumeration_Array (Block: Block_Instance_Acc; Str: Iir) - return Iir_Value_Literal_Acc + function Execute_String_Literal (Str: Iir; Block_Type : Block_Instance_Acc) + return Iir_Value_Literal_Acc is Array_Type: constant Iir := Get_Type (Str); Index_Types : constant Iir_Flist := Get_Index_Subtype_List (Array_Type); @@ -1797,7 +1797,7 @@ package body Simul.Execution is Res.Val_Array.Len); else Res.Bounds.D (1) := - Execute_Bounds (Block, Get_Nth_Element (Index_Types, 0)); + Execute_Bounds (Block_Type, Get_Nth_Element (Index_Types, 0)); end if; -- The range may not be statically constant. @@ -1806,7 +1806,7 @@ package body Simul.Execution is end if; return Res; - end String_To_Enumeration_Array; + end Execute_String_Literal; -- Fill LENGTH elements of RES, starting at ORIG by steps of STEP. -- Use expressions from (BLOCK, AGGREGATE) to fill the elements. @@ -2032,6 +2032,7 @@ package body Simul.Execution is function Execute_Aggregate (Block: Block_Instance_Acc; Aggregate: Iir; + Block_Type : Block_Instance_Acc; Aggregate_Type: Iir) return Iir_Value_Literal_Acc is begin @@ -2042,19 +2043,38 @@ package body Simul.Execution is Res : Iir_Value_Literal_Acc; begin Res := Create_Array_Bounds_From_Type - (Block, Aggregate_Type, True); + (Block_Type, Aggregate_Type, True); Fill_Array_Aggregate (Block, Aggregate, Res); return Res; end; when Iir_Kind_Record_Type_Definition | Iir_Kind_Record_Subtype_Definition => - return Execute_Record_Aggregate - (Block, Aggregate, Aggregate_Type); + return Execute_Record_Aggregate (Block, Aggregate, Aggregate_Type); when others => Error_Kind ("execute_aggregate", Aggregate_Type); end case; end Execute_Aggregate; + function Execute_Association_Expression + (Actual_Instance : Block_Instance_Acc; + Actual : Iir; + Formal_Instance : Block_Instance_Acc) + return Iir_Value_Literal_Acc + is + begin + case Get_Kind (Actual) is + when Iir_Kind_String_Literal8 => + return Execute_String_Literal (Actual, Formal_Instance); + when Iir_Kind_Aggregate => + return Execute_Aggregate + (Actual_Instance, Actual, Formal_Instance, Get_Type (Actual)); + when others => + null; + end case; + return Execute_Expression (Actual_Instance, Actual); + end Execute_Association_Expression; + + function Execute_Simple_Aggregate (Block: Block_Instance_Acc; Aggr : Iir) return Iir_Value_Literal_Acc is @@ -2472,7 +2492,7 @@ package body Simul.Execution is if Get_Kind (Expr) = Iir_Kind_Aggregate and then not Is_Fully_Constrained_Type (Get_Type (Expr)) then - return Execute_Aggregate (Block, Expr, Expr_Type); + return Execute_Aggregate (Block, Expr, Block, Expr_Type); else Res := Execute_Expression (Block, Expr); Implicit_Array_Conversion (Block, Res, Expr_Type, Expr); @@ -2922,7 +2942,7 @@ package body Simul.Execution is return Execute_Expression (Block, Get_Named_Entity (Expr)); when Iir_Kind_Aggregate => - return Execute_Aggregate (Block, Expr, Get_Type (Expr)); + return Execute_Aggregate (Block, Expr, Block, Get_Type (Expr)); when Iir_Kind_Simple_Aggregate => return Execute_Simple_Aggregate (Block, Expr); @@ -3013,7 +3033,7 @@ package body Simul.Execution is (Ghdl_I64 (Evaluation.Get_Physical_Value (Expr))); when Iir_Kind_String_Literal8 => - return String_To_Enumeration_Array (Block, Expr); + return Execute_String_Literal (Expr, Block); when Iir_Kind_Null_Literal => return Null_Lit; diff --git a/src/vhdl/simulate/simul-execution.ads b/src/vhdl/simulate/simul-execution.ads index 7037f2d27..b8ef5e7d2 100644 --- a/src/vhdl/simulate/simul-execution.ads +++ b/src/vhdl/simulate/simul-execution.ads @@ -81,6 +81,12 @@ package Simul.Execution is Res : out Iir_Value_Literal_Acc; Is_Sig : out Boolean); + function Execute_Association_Expression + (Actual_Instance : Block_Instance_Acc; + Actual : Iir; + Formal_Instance : Block_Instance_Acc) + return Iir_Value_Literal_Acc; + -- Return the initial value (default value) of signal name EXPR. To be -- used only during (non-dynamic) elaboration. function Execute_Signal_Init_Value (Block : Block_Instance_Acc; Expr : Iir) |