aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/simulate
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-04-20 07:49:03 +0200
committerTristan Gingold <tgingold@free.fr>2020-04-20 12:19:48 +0200
commitcb72a1834f160d95d026b7e466886fd95fd82146 (patch)
tree87cd0fff5a8ce03b05b8e6a0a0129b60de90fe61 /src/vhdl/simulate
parentb6d42a577f4ee5f2084a165b0cdf66cadcc878a1 (diff)
downloadghdl-cb72a1834f160d95d026b7e466886fd95fd82146.tar.gz
ghdl-cb72a1834f160d95d026b7e466886fd95fd82146.tar.bz2
ghdl-cb72a1834f160d95d026b7e466886fd95fd82146.zip
types: introduce Direction_Type, which replaces Iir_Direction.
Global renaming.
Diffstat (limited to 'src/vhdl/simulate')
-rw-r--r--src/vhdl/simulate/simul-environments.adb41
-rw-r--r--src/vhdl/simulate/simul-environments.ads9
-rw-r--r--src/vhdl/simulate/simul-execution.adb82
-rw-r--r--src/vhdl/simulate/simul-grt_interface.adb6
4 files changed, 70 insertions, 68 deletions
diff --git a/src/vhdl/simulate/simul-environments.adb b/src/vhdl/simulate/simul-environments.adb
index 356383bba..221e812d7 100644
--- a/src/vhdl/simulate/simul-environments.adb
+++ b/src/vhdl/simulate/simul-environments.adb
@@ -19,7 +19,7 @@
with System;
with Ada.Unchecked_Conversion;
with GNAT.Debug_Utilities;
-with Types; use Types;
+
with Simple_IO;
with Name_Table;
with Simul.Debugger; use Simul.Debugger;
@@ -207,9 +207,9 @@ package body Simul.Environments is
begin
Cmp := Compare_Value (Arange.Left, Arange.Right);
case Arange.Dir is
- when Iir_To =>
+ when Dir_To =>
return Cmp = Greater;
- when Iir_Downto =>
+ when Dir_Downto =>
return Cmp = Less;
end case;
end Is_Null_Range;
@@ -462,22 +462,20 @@ package body Simul.Environments is
(Kind => Iir_Value_Access, Val_Access => Val)));
end Create_Access_Value;
- function Create_Range_Value
- (Left, Right : Iir_Value_Literal_Acc;
- Dir : Iir_Direction;
- Length : Iir_Index32)
- return Iir_Value_Literal_Acc
+ function Create_Range_Value (Left, Right : Iir_Value_Literal_Acc;
+ Dir : Direction_Type;
+ Length : Iir_Index32)
+ return Iir_Value_Literal_Acc
is
subtype Range_Value is Iir_Value_Literal (Iir_Value_Range);
function Alloc is new Alloc_On_Pool_Addr (Range_Value);
begin
- return To_Iir_Value_Literal_Acc
- (Alloc (Current_Pool,
- (Kind => Iir_Value_Range,
- Left => Left,
- Right => Right,
- Dir => Dir,
- Length => Length)));
+ return To_Iir_Value_Literal_Acc (Alloc (Current_Pool,
+ (Kind => Iir_Value_Range,
+ Left => Left,
+ Right => Right,
+ Dir => Dir,
+ Length => Length)));
end Create_Range_Value;
function Create_File_Value (Val : Grt.Files.Ghdl_File_Index)
@@ -492,19 +490,18 @@ package body Simul.Environments is
end Create_File_Value;
-- Create a range_value of life LIFE.
- function Create_Range_Value
- (Left, Right : Iir_Value_Literal_Acc;
- Dir : Iir_Direction)
- return Iir_Value_Literal_Acc
+ function Create_Range_Value (Left, Right : Iir_Value_Literal_Acc;
+ Dir : Direction_Type)
+ return Iir_Value_Literal_Acc
is
Low, High : Iir_Value_Literal_Acc;
Len : Iir_Index32;
begin
case Dir is
- when Iir_To =>
+ when Dir_To =>
Low := Left;
High := Right;
- when Iir_Downto =>
+ when Dir_Downto =>
Low := Right;
High := Left;
end case;
@@ -891,7 +888,7 @@ package body Simul.Environments is
Put_Line ("range:");
Put_Indent (Indent);
Put (" direction: ");
- Put (Iir_Direction'Image (Value.Dir));
+ Put (Direction_Type'Image (Value.Dir));
Put (", length:");
Put_Line (Iir_Index32'Image (Value.Length));
if Value.Left /= null then
diff --git a/src/vhdl/simulate/simul-environments.ads b/src/vhdl/simulate/simul-environments.ads
index dd0ca8b55..1d07d6bbc 100644
--- a/src/vhdl/simulate/simul-environments.ads
+++ b/src/vhdl/simulate/simul-environments.ads
@@ -17,6 +17,9 @@
-- 02111-1307, USA.
with Ada.Unchecked_Deallocation;
+
+with Types; use Types;
+
with Vhdl.Nodes; use Vhdl.Nodes;
with Vhdl.Annotations; use Vhdl.Annotations;
with Grt.Types; use Grt.Types;
@@ -201,7 +204,7 @@ package Simul.Environments is
when Iir_Value_Instance =>
Instance : Block_Instance_Acc;
when Iir_Value_Range =>
- Dir: Iir_Direction;
+ Dir: Direction_Type;
Length : Iir_Index32;
Left: Iir_Value_Literal_Acc;
Right: Iir_Value_Literal_Acc;
@@ -338,14 +341,14 @@ package Simul.Environments is
-- Create a range_value of life LIFE.
function Create_Range_Value
(Left, Right : Iir_Value_Literal_Acc;
- Dir : Iir_Direction;
+ Dir : Direction_Type;
Length : Iir_Index32)
return Iir_Value_Literal_Acc;
-- Create a range_value (compute the length)
function Create_Range_Value
(Left, Right : Iir_Value_Literal_Acc;
- Dir : Iir_Direction)
+ Dir : Direction_Type)
return Iir_Value_Literal_Acc;
-- Return true if the value of LEFT and RIGHT are equal.
diff --git a/src/vhdl/simulate/simul-execution.adb b/src/vhdl/simulate/simul-execution.adb
index a70d920c7..977921df3 100644
--- a/src/vhdl/simulate/simul-execution.adb
+++ b/src/vhdl/simulate/simul-execution.adb
@@ -160,9 +160,9 @@ package body Simul.Execution is
R : Ghdl_E32;
begin
case Bounds.Dir is
- when Iir_To =>
+ when Dir_To =>
R := Bounds.Left.E32 + Ghdl_E32 (Len - 1);
- when Iir_Downto =>
+ when Dir_Downto =>
R := Bounds.Left.E32 - Ghdl_E32 (Len - 1);
end case;
Bounds.Right := Create_E32_Value (R);
@@ -172,9 +172,9 @@ package body Simul.Execution is
R : Ghdl_I64;
begin
case Bounds.Dir is
- when Iir_To =>
+ when Dir_To =>
R := Bounds.Left.I64 + Ghdl_I64 (Len - 1);
- when Iir_Downto =>
+ when Dir_Downto =>
R := Bounds.Left.I64 - Ghdl_I64 (Len - 1);
end case;
Bounds.Right := Create_I64_Value (R);
@@ -205,9 +205,9 @@ package body Simul.Execution is
case Res.Left.Kind is
when Iir_Value_I64 =>
case Index_Bounds.Dir is
- when Iir_To =>
+ when Dir_To =>
Res.Left := Create_I64_Value (Res.Right.I64 + 1);
- when Iir_Downto =>
+ when Dir_Downto =>
Res.Left := Create_I64_Value (Res.Right.I64 - 1);
end case;
when others =>
@@ -222,7 +222,7 @@ package body Simul.Execution is
function Execute_High_Limit (Bounds : Iir_Value_Literal_Acc)
return Iir_Value_Literal_Acc is
begin
- if Bounds.Dir = Iir_To then
+ if Bounds.Dir = Dir_To then
return Bounds.Right;
else
return Bounds.Left;
@@ -232,7 +232,7 @@ package body Simul.Execution is
function Execute_Low_Limit (Bounds : Iir_Value_Literal_Acc)
return Iir_Value_Literal_Acc is
begin
- if Bounds.Dir = Iir_To then
+ if Bounds.Dir = Dir_To then
return Bounds.Left;
else
return Bounds.Right;
@@ -282,7 +282,7 @@ package body Simul.Execution is
Res.Bounds.D (1) := Create_Range_Value
(Create_I64_Value (1),
Create_I64_Value (Str'Length),
- Iir_To);
+ Dir_To);
for I in Str'Range loop
Res.Val_Array.V (1 + Iir_Index32 (I - Str'First)) :=
Create_E8_Value (Character'Pos (Str (I)));
@@ -1646,14 +1646,14 @@ package body Simul.Execution is
case Iir_Value_Discrete (Index.Kind) is
when Iir_Value_B1 =>
case Bounds.Dir is
- when Iir_To =>
+ when Dir_To =>
if Index.B1 >= Left_Pos.B1 and then
Index.B1 <= Right_Pos.B1
then
-- to
return Ghdl_B1'Pos (Index.B1) - Ghdl_B1'Pos (Left_Pos.B1);
end if;
- when Iir_Downto =>
+ when Dir_Downto =>
if Index.B1 <= Left_Pos.B1 and then
Index.B1 >= Right_Pos.B1
then
@@ -1663,14 +1663,14 @@ package body Simul.Execution is
end case;
when Iir_Value_E8 =>
case Bounds.Dir is
- when Iir_To =>
+ when Dir_To =>
if Index.E8 >= Left_Pos.E8 and then
Index.E8 <= Right_Pos.E8
then
-- to
return Iir_Index32 (Index.E8 - Left_Pos.E8);
end if;
- when Iir_Downto =>
+ when Dir_Downto =>
if Index.E8 <= Left_Pos.E8 and then
Index.E8 >= Right_Pos.E8
then
@@ -1680,14 +1680,14 @@ package body Simul.Execution is
end case;
when Iir_Value_E32 =>
case Bounds.Dir is
- when Iir_To =>
+ when Dir_To =>
if Index.E32 >= Left_Pos.E32 and then
Index.E32 <= Right_Pos.E32
then
-- to
return Iir_Index32 (Index.E32 - Left_Pos.E32);
end if;
- when Iir_Downto =>
+ when Dir_Downto =>
if Index.E32 <= Left_Pos.E32 and then
Index.E32 >= Right_Pos.E32
then
@@ -1697,14 +1697,14 @@ package body Simul.Execution is
end case;
when Iir_Value_I64 =>
case Bounds.Dir is
- when Iir_To =>
+ when Dir_To =>
if Index.I64 >= Left_Pos.I64 and then
Index.I64 <= Right_Pos.I64
then
-- to
return Iir_Index32 (Index.I64 - Left_Pos.I64);
end if;
- when Iir_Downto =>
+ when Dir_Downto =>
if Index.I64 <= Left_Pos.I64 and then
Index.I64 >= Right_Pos.I64
then
@@ -1809,7 +1809,7 @@ package body Simul.Execution is
Res.Bounds.D (1) :=
Create_Range_Value (Create_I64_Value (1),
Create_I64_Value (Ghdl_I64 (Res.Val_Array.Len)),
- Iir_To,
+ Dir_To,
Res.Val_Array.Len);
else
Res.Bounds.D (1) :=
@@ -1912,7 +1912,7 @@ package body Simul.Execution is
if Is_Null_Range (A_Range) then
return;
end if;
- if A_Range.Dir = Iir_To then
+ if A_Range.Dir = Dir_To then
High := A_Range.Right;
Low := A_Range.Left;
else
@@ -2331,12 +2331,12 @@ package body Simul.Execution is
when Iir_Kind_Reverse_Range_Array_Attribute =>
Bound := Execute_Indexes (Block, Prefix);
case Bound.Dir is
- when Iir_To =>
+ when Dir_To =>
Bound := Create_Range_Value
- (Bound.Right, Bound.Left, Iir_Downto, Bound.Length);
- when Iir_Downto =>
+ (Bound.Right, Bound.Left, Dir_Downto, Bound.Length);
+ when Dir_Downto =>
Bound := Create_Range_Value
- (Bound.Right, Bound.Left, Iir_To, Bound.Length);
+ (Bound.Right, Bound.Left, Dir_To, Bound.Length);
end case;
when Iir_Kind_Floating_Type_Definition
@@ -2616,8 +2616,8 @@ package body Simul.Execution is
-- discrete range does not belong to the index range of the
-- prefixing array, unless the slice is a null slice.
Index_Order := Compare_Value (Srange.Left, Srange.Right);
- if (Srange.Dir = Iir_To and Index_Order = Greater)
- or (Srange.Dir = Iir_Downto and Index_Order = Less)
+ if (Srange.Dir = Dir_To and Index_Order = Greater)
+ or (Srange.Dir = Dir_Downto and Index_Order = Less)
then
-- Null slice.
Low := 1;
@@ -3128,7 +3128,7 @@ package body Simul.Execution is
when Iir_Kind_Ascending_Array_Attribute =>
Res := Execute_Indexes (Block, Expr);
- return Boolean_To_Lit (Res.Dir = Iir_To);
+ return Boolean_To_Lit (Res.Dir = Dir_To);
when Iir_Kind_Event_Attribute =>
Res := Execute_Name (Block, Get_Prefix (Expr), True);
@@ -3228,9 +3228,9 @@ package body Simul.Execution is
Bound := Execute_Bounds
(Block, Get_Type (Get_Prefix (Expr)));
case Bound.Dir is
- when Iir_To =>
+ when Dir_To =>
Res := Execute_Dec (Res, Expr);
- when Iir_Downto =>
+ when Dir_Downto =>
Res := Execute_Inc (Res, Expr);
end case;
Check_Constraints (Block, Res, Get_Type (Expr), Expr);
@@ -3245,9 +3245,9 @@ package body Simul.Execution is
Bound := Execute_Bounds
(Block, Get_Type (Get_Prefix (Expr)));
case Bound.Dir is
- when Iir_Downto =>
+ when Dir_Downto =>
Res := Execute_Dec (Res, Expr);
- when Iir_To =>
+ when Dir_To =>
Res := Execute_Inc (Res, Expr);
end case;
Check_Constraints (Block, Res, Get_Type (Expr), Expr);
@@ -3985,7 +3985,7 @@ package body Simul.Execution is
| Iir_Kind_Physical_Subtype_Definition
| Iir_Kind_Enumeration_Type_Definition =>
Bound := Execute_Bounds (Instance, Def);
- if Bound.Dir = Iir_To then
+ if Bound.Dir = Dir_To then
High := Bound.Right;
Low := Bound.Left;
else
@@ -4373,10 +4373,10 @@ package body Simul.Execution is
Max, Min : Iir_Value_Literal_Acc;
begin
case Bounds.Dir is
- when Iir_To =>
+ when Dir_To =>
Min := Bounds.Left;
Max := Bounds.Right;
- when Iir_Downto =>
+ when Dir_Downto =>
Min := Bounds.Right;
Max := Bounds.Left;
end case;
@@ -4402,30 +4402,30 @@ package body Simul.Execution is
case Iir_Value_Discrete (Val.Kind) is
when Iir_Value_E8 =>
case Bounds.Dir is
- when Iir_To =>
+ when Dir_To =>
Val.E8 := Val.E8 + 1;
- when Iir_Downto =>
+ when Dir_Downto =>
Val.E8 := Val.E8 - 1;
end case;
when Iir_Value_E32 =>
case Bounds.Dir is
- when Iir_To =>
+ when Dir_To =>
Val.E32 := Val.E32 + 1;
- when Iir_Downto =>
+ when Dir_Downto =>
Val.E32 := Val.E32 - 1;
end case;
when Iir_Value_B1 =>
case Bounds.Dir is
- when Iir_To =>
+ when Dir_To =>
Val.B1 := True;
- when Iir_Downto =>
+ when Dir_Downto =>
Val.B1 := False;
end case;
when Iir_Value_I64 =>
case Bounds.Dir is
- when Iir_To =>
+ when Dir_To =>
Val.I64 := Val.I64 + 1;
- when Iir_Downto =>
+ when Dir_Downto =>
Val.I64 := Val.I64 - 1;
end case;
end case;
diff --git a/src/vhdl/simulate/simul-grt_interface.adb b/src/vhdl/simulate/simul-grt_interface.adb
index e485d7d18..32e6f7b54 100644
--- a/src/vhdl/simulate/simul-grt_interface.adb
+++ b/src/vhdl/simulate/simul-grt_interface.adb
@@ -16,11 +16,13 @@
-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-- 02111-1307, USA.
+with Types; use Types;
+
with Vhdl.Nodes; use Vhdl.Nodes;
package body Simul.Grt_Interface is
- To_Dir : constant array (Iir_Direction) of Ghdl_Dir_Type :=
- (Iir_To => Dir_To, Iir_Downto => Dir_Downto);
+ To_Dir : constant array (Direction_Type) of Ghdl_Dir_Type :=
+ (Dir_To => Dir_To, Dir_Downto => Dir_Downto);
function Build_Bound (Arr : Iir_Value_Literal_Acc) return Std_String_Bound
is