aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/simulate
diff options
context:
space:
mode:
Diffstat (limited to 'src/vhdl/simulate')
-rw-r--r--src/vhdl/simulate/simul-annotations.adb53
-rw-r--r--src/vhdl/simulate/simul-environments.ads13
2 files changed, 49 insertions, 17 deletions
diff --git a/src/vhdl/simulate/simul-annotations.adb b/src/vhdl/simulate/simul-annotations.adb
index f807f12b7..53e1fb0f7 100644
--- a/src/vhdl/simulate/simul-annotations.adb
+++ b/src/vhdl/simulate/simul-annotations.adb
@@ -18,10 +18,12 @@
with Tables;
with Simple_IO;
+with Types; use Types;
+with Mutils; use Mutils;
with Vhdl.Std_Package;
with Vhdl.Errors; use Vhdl.Errors;
with Vhdl.Utils; use Vhdl.Utils;
-with Types; use Types;
+with Vhdl.Ieee.Std_Logic_1164;
package body Simul.Annotations is
procedure Annotate_Declaration_List
@@ -91,6 +93,8 @@ package body Simul.Annotations is
| Kind_Frame
| Kind_Protected
| Kind_Package
+ | Kind_Bit_Type
+ | Kind_Enum_Type
| Kind_Scalar_Type
| Kind_File_Type
| Kind_Extra =>
@@ -277,22 +281,36 @@ package body Simul.Annotations is
case Get_Kind (Def) is
when Iir_Kind_Enumeration_Type_Definition =>
declare
- Mode : Iir_Value_Kind;
+ Info : Sim_Info_Acc;
+ Nbr_Enums : Natural;
begin
if Def = Vhdl.Std_Package.Boolean_Type_Definition
or else Def = Vhdl.Std_Package.Bit_Type_Definition
then
- Mode := Iir_Value_B1;
- elsif (Get_Nbr_Elements (Get_Enumeration_Literal_List (Def))
- <= 256)
+ Info := new Sim_Info_Type'(Kind => Kind_Bit_Type,
+ Ref => Def,
+ Scalar_Mode => Iir_Value_B1,
+ Width => 1);
+ elsif Def = Vhdl.Ieee.Std_Logic_1164.Std_Ulogic_Type
+ or else Def = Vhdl.Ieee.Std_Logic_1164.Std_Logic_Type
then
- Mode := Iir_Value_E8;
+ Info := new Sim_Info_Type'(Kind => Kind_Bit_Type,
+ Ref => Def,
+ Scalar_Mode => Iir_Value_E8,
+ Width => 1);
else
- Mode := Iir_Value_E32;
+ Nbr_Enums := Get_Nbr_Elements
+ (Get_Enumeration_Literal_List (Def));
+ Info := new Sim_Info_Type'
+ (Kind => Kind_Enum_Type,
+ Ref => Def,
+ Scalar_Mode => Iir_Value_E8,
+ Width => Uns32 (Clog2 (Uns64 (Nbr_Enums))));
+ if Nbr_Enums > 256 then
+ Info.Scalar_Mode := Iir_Value_E32;
+ end if;
end if;
- Set_Info (Def, new Sim_Info_Type'(Kind => Kind_Scalar_Type,
- Ref => Def,
- Scalar_Mode => Mode));
+ Set_Info (Def, Info);
Annotate_Range_Expression
(Block_Info, Get_Range_Constraint (Def));
end;
@@ -327,19 +345,22 @@ package body Simul.Annotations is
Set_Info (Def,
new Sim_Info_Type'(Kind => Kind_Scalar_Type,
Ref => Def,
- Scalar_Mode => Iir_Value_I64));
+ Scalar_Mode => Iir_Value_I64,
+ Width => 0));
when Iir_Kind_Floating_Type_Definition =>
Set_Info (Def,
new Sim_Info_Type'(Kind => Kind_Scalar_Type,
Ref => Def,
- Scalar_Mode => Iir_Value_F64));
+ Scalar_Mode => Iir_Value_F64,
+ Width => 0));
when Iir_Kind_Physical_Type_Definition =>
Set_Info (Def,
new Sim_Info_Type'(Kind => Kind_Scalar_Type,
Ref => Def,
- Scalar_Mode => Iir_Value_I64));
+ Scalar_Mode => Iir_Value_I64,
+ Width => 0));
when Iir_Kind_Array_Type_Definition =>
El := Get_Element_Subtype (Def);
@@ -1225,6 +1246,8 @@ package body Simul.Annotations is
| Kind_PSL =>
Put_Line ("-- slot:" & Object_Slot_Type'Image (Info.Slot));
when Kind_Scalar_Type
+ | Kind_Bit_Type
+ | Kind_Enum_Type
| Kind_File_Type
| Kind_Extra =>
null;
@@ -1265,6 +1288,10 @@ package body Simul.Annotations is
when Kind_Scalar_Type =>
Put_Line ("scalar type: "
& Iir_Value_Kind'Image (Info.Scalar_Mode));
+ when Kind_Bit_Type =>
+ Put_Line ("bit type");
+ when Kind_Enum_Type =>
+ Put_Line ("enum type");
when Kind_File_Type =>
Put ("file type: ");
if Info.File_Signature = null then
diff --git a/src/vhdl/simulate/simul-environments.ads b/src/vhdl/simulate/simul-environments.ads
index ec3a5f9e3..68109eb78 100644
--- a/src/vhdl/simulate/simul-environments.ads
+++ b/src/vhdl/simulate/simul-environments.ads
@@ -229,13 +229,15 @@ package Simul.Environments is
-- The annotation depends on the kind of the node.
type Sim_Info_Kind is
- (Kind_Block, Kind_Process, Kind_Frame, Kind_Protected, Kind_Package,
- Kind_Scalar_Type, Kind_File_Type,
+ (
+ Kind_Block, Kind_Process, Kind_Frame, Kind_Protected, Kind_Package,
+ Kind_Bit_Type, Kind_Enum_Type, Kind_Scalar_Type, Kind_File_Type,
Kind_Object, Kind_Signal,
Kind_File,
Kind_Terminal, Kind_Quantity,
Kind_PSL,
- Kind_Extra);
+ Kind_Extra
+ );
type Instance_Slot_Type is new Integer;
Invalid_Instance_Slot : constant Instance_Slot_Type := -1;
@@ -285,8 +287,11 @@ package Simul.Environments is
-- Variable index in the block.
Slot: Object_Slot_Type;
- when Kind_Scalar_Type =>
+ when Kind_Scalar_Type
+ | Kind_Bit_Type
+ | Kind_Enum_Type =>
Scalar_Mode : Iir_Value_Kind;
+ Width : Uns32;
when Kind_File_Type =>
File_Signature : String_Acc;