aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2014-06-27 05:10:13 +0200
committerTristan Gingold <tgingold@free.fr>2014-06-27 05:10:13 +0200
commit788ee650988ef93a947c6804c45dda54ed7d7c4f (patch)
tree6ae777e238be257900fdf2110b10da4a07b541c0
parent7fe7bdb1b5b0250c213526208a03445f58fba92d (diff)
downloadghdl-788ee650988ef93a947c6804c45dda54ed7d7c4f.tar.gz
ghdl-788ee650988ef93a947c6804c45dda54ed7d7c4f.tar.bz2
ghdl-788ee650988ef93a947c6804c45dda54ed7d7c4f.zip
simulate: fix nbr_objects, improve display of arrays.
-rw-r--r--simulate/annotations.adb44
-rw-r--r--simulate/debugger.adb2
-rw-r--r--simulate/execution.adb17
-rw-r--r--simulate/iir_values.adb51
4 files changed, 77 insertions, 37 deletions
diff --git a/simulate/annotations.adb b/simulate/annotations.adb
index 1b241d2ae..e4e921aca 100644
--- a/simulate/annotations.adb
+++ b/simulate/annotations.adb
@@ -697,9 +697,21 @@ package body Annotations is
El: Iir;
Max_Nbr_Objects : Object_Slot_Type;
Current_Nbr_Objects : Object_Slot_Type;
+
+ procedure Save_Nbr_Objects is
+ begin
+ -- Objects used by loop statements can be reused later by
+ -- other (ie following) loop statements.
+ -- Furthermore, this allow to correctly check elaboration
+ -- order.
+ Max_Nbr_Objects := Object_Slot_Type'Max
+ (Block_Info.Nbr_Objects, Max_Nbr_Objects);
+ Block_Info.Nbr_Objects := Current_Nbr_Objects;
+ end Save_Nbr_Objects;
begin
Current_Nbr_Objects := Block_Info.Nbr_Objects;
- Max_Nbr_Objects := Block_Info.Nbr_Objects;
+ Max_Nbr_Objects := Current_Nbr_Objects;
+
El := Stmt_Chain;
while El /= Null_Iir loop
case Get_Kind (El) is
@@ -725,31 +737,35 @@ package body Annotations is
declare
Clause: Iir := El;
begin
- while Clause /= Null_Iir loop
+ loop
Annotate_Sequential_Statement_Chain
(Block_Info, Get_Sequential_Statement_Chain (Clause));
Clause := Get_Else_Clause (Clause);
+ exit when Clause = Null_Iir;
+ Save_Nbr_Objects;
end loop;
end;
- when Iir_Kind_For_Loop_Statement =>
- Annotate_Declaration
- (Block_Info, Get_Iterator_Scheme (El));
- Annotate_Sequential_Statement_Chain
- (Block_Info, Get_Sequential_Statement_Chain (El));
-
when Iir_Kind_Case_Statement =>
declare
Assoc: Iir;
begin
Assoc := Get_Case_Statement_Alternative_Chain (El);
- while Assoc /= Null_Iir loop
+ loop
Annotate_Sequential_Statement_Chain
(Block_Info, Get_Associated (Assoc));
Assoc := Get_Chain (Assoc);
+ exit when Assoc = Null_Iir;
+ Save_Nbr_Objects;
end loop;
end;
+ when Iir_Kind_For_Loop_Statement =>
+ Annotate_Declaration
+ (Block_Info, Get_Iterator_Scheme (El));
+ Annotate_Sequential_Statement_Chain
+ (Block_Info, Get_Sequential_Statement_Chain (El));
+
when Iir_Kind_While_Loop_Statement =>
Annotate_Sequential_Statement_Chain
(Block_Info, Get_Sequential_Statement_Chain (El));
@@ -757,13 +773,9 @@ package body Annotations is
when others =>
Error_Kind ("annotate_sequential_statement_chain", El);
end case;
- -- Objects used by loop statements can be reused later by
- -- other (ie following) loop statements.
- -- Furthermore, this allow to correctly check elaboration
- -- order.
- Max_Nbr_Objects := Object_Slot_Type'Max
- (Block_Info.Nbr_Objects, Max_Nbr_Objects);
- Block_Info.Nbr_Objects := Current_Nbr_Objects;
+
+ Save_Nbr_Objects;
+
El := Get_Chain (El);
end loop;
Block_Info.Nbr_Objects := Max_Nbr_Objects;
diff --git a/simulate/debugger.adb b/simulate/debugger.adb
index b20c4e7db..0a65b9105 100644
--- a/simulate/debugger.adb
+++ b/simulate/debugger.adb
@@ -1320,7 +1320,7 @@ package body Debugger is
-- Add STD
Add_Name (Libraries.Std_Library, Std_Names.Name_Std, False);
- Use_All_Names (Std_Package.Std_Standard_Unit);
+ Use_All_Names (Std_Package.Standard_Package);
Foreach_Scopes (Node, Add_Decls_For'Access);
end Enter_Scope;
diff --git a/simulate/execution.adb b/simulate/execution.adb
index 3568e9d75..146660fd2 100644
--- a/simulate/execution.adb
+++ b/simulate/execution.adb
@@ -653,6 +653,13 @@ package body Execution is
raise Internal_Error;
end case;
+ when Iir_Predefined_Integer_Minimum =>
+ Eval_Right;
+ Result := Create_I64_Value (Ghdl_I64'Min (Left.I64, Right.I64));
+ when Iir_Predefined_Integer_Maximum =>
+ Eval_Right;
+ Result := Create_I64_Value (Ghdl_I64'Max (Left.I64, Right.I64));
+
when Iir_Predefined_Floating_Mul =>
Eval_Right;
Result := Create_F64_Value (Left.F64 * Right.F64);
@@ -687,6 +694,13 @@ package body Execution is
Eval_Right;
Result := Boolean_To_Lit (Left.F64 >= Right.F64);
+ when Iir_Predefined_Floating_Minimum =>
+ Eval_Right;
+ Result := Create_F64_Value (Ghdl_F64'Min (Left.F64, Right.F64));
+ when Iir_Predefined_Floating_Maximum =>
+ Eval_Right;
+ Result := Create_F64_Value (Ghdl_F64'Max (Left.F64, Right.F64));
+
when Iir_Predefined_Integer_Physical_Mul =>
Eval_Right;
Result := Create_I64_Value (Left.I64 * Right.I64);
@@ -793,8 +807,7 @@ package body Execution is
when others =>
Error_Msg ("execute_implicit_function: unimplemented " &
- Iir_Predefined_Functions'Image
- (Get_Implicit_Definition (Expr)));
+ Iir_Predefined_Functions'Image (Func));
raise Internal_Error;
end case;
return Result;
diff --git a/simulate/iir_values.adb b/simulate/iir_values.adb
index 5e42f37b2..1de8b8803 100644
--- a/simulate/iir_values.adb
+++ b/simulate/iir_values.adb
@@ -887,29 +887,33 @@ package body Iir_Values is
end case;
end Is_Indirect;
- procedure Disp_Iir_Value_Array
- (Value: Iir_Value_Literal_Acc; A_Type: Iir; Dim: Natural)
+ procedure Disp_Iir_Value_Array (Value: Iir_Value_Literal_Acc;
+ A_Type: Iir;
+ Dim: Iir_Index32;
+ Off : in out Iir_Index32)
is
use Ada.Text_IO;
type Last_Enum_Type is (None, Char, Identifier);
Last_Enum: Last_Enum_Type;
- Index_List: Iir_List;
El_Type: Iir;
Enum_List: Iir_List;
El: Name_Id;
+ El_Pos : Natural;
begin
- Index_List := Get_Index_Subtype_List (A_Type);
- if Dim = Get_Nbr_Elements (Index_List) then
+ if Dim = Value.Bounds.Nbr_Dims then
+ -- Last dimension
El_Type := Get_Base_Type (Get_Element_Subtype (A_Type));
+
+ -- Pretty print vectors of enumerated types
if Get_Kind (El_Type) = Iir_Kind_Enumeration_Type_Definition
and then not Is_Indirect (Value)
then
Last_Enum := None;
Enum_List := Get_Enumeration_Literal_List (El_Type);
- for I in Value.Val_Array.V'Range loop
- El := Get_Identifier
- (Get_Nth_Element (Enum_List,
- Ghdl_E32'Pos (Value.Val_Array.V (I).E32)));
+ for I in 1 .. Value.Bounds.D (Dim).Length loop
+ El_Pos := Ghdl_E32'Pos (Value.Val_Array.V (Off).E32);
+ Off := Off + 1;
+ El := Get_Identifier (Get_Nth_Element (Enum_List, El_Pos));
if Name_Table.Is_Character (El) then
case Last_Enum is
when None =>
@@ -942,21 +946,26 @@ package body Iir_Values is
when Char =>
Put ("""");
end case;
- return;
+ else
+ Put ("(");
+ for I in 1 .. Value.Bounds.D (Dim).Length loop
+ if I /= 1 then
+ Put (", ");
+ end if;
+ Disp_Iir_Value (Value.Val_Array.V (Off), El_Type);
+ Off := Off + 1;
+ end loop;
+ Put (")");
end if;
+ else
Put ("(");
- for I in Value.Val_Array.V'Range loop
+ for I in 1 .. Value.Bounds.D (Dim).Length loop
if I /= 1 then
Put (", ");
end if;
- Disp_Iir_Value (Value.Val_Array.V (I), El_Type);
+ Disp_Iir_Value_Array (Value, A_Type, Dim + 1, Off);
end loop;
Put (")");
- return;
- else
- Put ("(");
- Disp_Iir_Value_Array (Value, A_Type, Dim + 1);
- Put (")");
end if;
end Disp_Iir_Value_Array;
@@ -1017,7 +1026,13 @@ package body Iir_Values is
Put ("*acc*");
end if;
when Iir_Value_Array =>
- Disp_Iir_Value_Array (Value, A_Type, 1);
+ declare
+ Off : Iir_Index32;
+ begin
+ Off := 1;
+ Disp_Iir_Value_Array (Value, A_Type, 1, Off);
+ pragma Assert (Off = Value.Val_Array.Len + 1);
+ end;
when Iir_Value_File =>
raise Internal_Error;
when Iir_Value_Record =>