aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/evaluation.adb
diff options
context:
space:
mode:
Diffstat (limited to 'src/vhdl/evaluation.adb')
-rw-r--r--src/vhdl/evaluation.adb38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/vhdl/evaluation.adb b/src/vhdl/evaluation.adb
index 08610882a..8f93d379d 100644
--- a/src/vhdl/evaluation.adb
+++ b/src/vhdl/evaluation.adb
@@ -16,6 +16,7 @@
-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-- 02111-1307, USA.
with Ada.Unchecked_Deallocation;
+with Scanner;
with Errorout; use Errorout;
with Name_Table; use Name_Table;
with Str_Table;
@@ -1980,6 +1981,43 @@ package body Evaluation is
return Build_Physical (Get_Physical_Value (Val), Expr);
end Eval_Physical_Literal;
+ function Eval_Value_Attribute
+ (Value : String; Atype : Iir; Orig : Iir) return Iir
+ is
+ Base_Type : constant Iir := Get_Base_Type (Atype);
+ First, Last : Positive;
+ begin
+ -- LRM93 14.1 Predefined attributes.
+ -- Leading and trailing whitespace are ignored.
+ First := Value'First;
+ Last := Value'Last;
+ while First <= Last loop
+ exit when not Scanner.Is_Whitespace (Value (First));
+ First := First + 1;
+ end loop;
+ while Last >= First loop
+ exit when not Scanner.Is_Whitespace (Value (Last));
+ Last := Last - 1;
+ end loop;
+
+ declare
+ Value1 : String renames Value (First .. Last);
+ begin
+ case Get_Kind (Base_Type) is
+ when Iir_Kind_Integer_Type_Definition =>
+ return Build_Discrete (Iir_Int64'Value (Value1), Orig);
+ when Iir_Kind_Enumeration_Type_Definition =>
+ return Build_Enumeration_Value (Value1, Base_Type, Orig);
+ when Iir_Kind_Floating_Type_Definition =>
+ return Build_Floating (Iir_Fp64'value (Value1), Orig);
+ when Iir_Kind_Physical_Type_Definition =>
+ return Build_Physical_Value (Value1, Base_Type, Orig);
+ when others =>
+ Error_Kind ("eval_value_attribute", Base_Type);
+ end case;
+ end;
+ end Eval_Value_Attribute;
+
function Eval_Static_Expr (Expr: Iir) return Iir
is
Res : Iir;