diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-12-31 08:22:30 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-12-31 09:34:34 +0100 |
commit | 8a60406d94e89804a5a52afb95bdac4c3bdd7f40 (patch) | |
tree | 6ffa80d954978fd005542b46dc20296d8b63cfba /src | |
parent | 10b0ac263ed7c59c438c1cb82faef51370cbd67e (diff) | |
download | ghdl-8a60406d94e89804a5a52afb95bdac4c3bdd7f40.tar.gz ghdl-8a60406d94e89804a5a52afb95bdac4c3bdd7f40.tar.bz2 ghdl-8a60406d94e89804a5a52afb95bdac4c3bdd7f40.zip |
ams-vhdl: handle zoh, ltf and ztf attributes.
Diffstat (limited to 'src')
-rw-r--r-- | src/std_names.adb | 6 | ||||
-rw-r--r-- | src/std_names.ads | 6 | ||||
-rw-r--r-- | src/vhdl/vhdl-elocations.adb | 3 | ||||
-rw-r--r-- | src/vhdl/vhdl-elocations.ads | 3 | ||||
-rw-r--r-- | src/vhdl/vhdl-errors.adb | 6 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes.adb | 37 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes.ads | 25 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes_meta.adb | 148 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes_meta.ads | 4 | ||||
-rw-r--r-- | src/vhdl/vhdl-prints.adb | 15 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_expr.adb | 3 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_names.adb | 135 | ||||
-rw-r--r-- | src/vhdl/vhdl-utils.adb | 30 | ||||
-rw-r--r-- | src/vhdl/vhdl-utils.ads | 8 |
14 files changed, 358 insertions, 71 deletions
diff --git a/src/std_names.adb b/src/std_names.adb index 7f6e20242..8c97e5f27 100644 --- a/src/std_names.adb +++ b/src/std_names.adb @@ -430,9 +430,9 @@ package body Std_Names is Def ("dot", Name_Dot); Def ("integ", Name_Integ); Def ("above", Name_Above); - Def ("zoh", Name_ZOH); - Def ("ltf", Name_LTF); - Def ("ztf", Name_ZTF); + Def ("zoh", Name_Zoh); + Def ("ltf", Name_Ltf); + Def ("ztf", Name_Ztf); Def ("ramp", Name_Ramp); Def ("slew", Name_Slew); diff --git a/src/std_names.ads b/src/std_names.ads index 544f7ed7b..f9cc961a0 100644 --- a/src/std_names.ads +++ b/src/std_names.ads @@ -500,9 +500,9 @@ package Std_Names is Name_Dot : constant Name_Id := Name_First_AMS_Attribute + 001; Name_Integ : constant Name_Id := Name_First_AMS_Attribute + 002; Name_Above : constant Name_Id := Name_First_AMS_Attribute + 003; - Name_ZOH : constant Name_Id := Name_First_AMS_Attribute + 004; - Name_LTF : constant Name_Id := Name_First_AMS_Attribute + 005; - Name_ZTF : constant Name_Id := Name_First_AMS_Attribute + 006; + Name_Zoh : constant Name_Id := Name_First_AMS_Attribute + 004; + Name_Ltf : constant Name_Id := Name_First_AMS_Attribute + 005; + Name_Ztf : constant Name_Id := Name_First_AMS_Attribute + 006; Name_Ramp : constant Name_Id := Name_First_AMS_Attribute + 007; Name_Slew : constant Name_Id := Name_First_AMS_Attribute + 008; Name_Last_AMS_Attribute : constant Name_Id := Name_Slew; diff --git a/src/vhdl/vhdl-elocations.adb b/src/vhdl/vhdl-elocations.adb index f74fd6037..f6e1ac80e 100644 --- a/src/vhdl/vhdl-elocations.adb +++ b/src/vhdl/vhdl-elocations.adb @@ -412,6 +412,9 @@ package body Vhdl.Elocations is | Iir_Kind_Signal_Slew_Attribute | Iir_Kind_Quantity_Slew_Attribute | Iir_Kind_Ramp_Attribute + | Iir_Kind_Zoh_Attribute + | Iir_Kind_Ltf_Attribute + | Iir_Kind_Ztf_Attribute | Iir_Kind_Dot_Attribute | Iir_Kind_Integ_Attribute | Iir_Kind_Above_Attribute diff --git a/src/vhdl/vhdl-elocations.ads b/src/vhdl/vhdl-elocations.ads index 2a185341c..daeda35ae 100644 --- a/src/vhdl/vhdl-elocations.ads +++ b/src/vhdl/vhdl-elocations.ads @@ -644,6 +644,9 @@ package Vhdl.Elocations is -- Iir_Kind_Signal_Slew_Attribute (None) -- Iir_Kind_Quantity_Slew_Attribute (None) + -- Iir_Kind_Zoh_Attribute (None) + -- Iir_Kind_Ltf_Attribute (None) + -- Iir_Kind_Ztf_Attribute (None) -- Iir_Kind_Dot_Attribute (None) -- Iir_Kind_Integ_Attribute (None) diff --git a/src/vhdl/vhdl-errors.adb b/src/vhdl/vhdl-errors.adb index 02dc0df5d..63e3bb02b 100644 --- a/src/vhdl/vhdl-errors.adb +++ b/src/vhdl/vhdl-errors.adb @@ -688,6 +688,12 @@ package body Vhdl.Errors is when Iir_Kind_Signal_Slew_Attribute | Iir_Kind_Quantity_Slew_Attribute => return "'slew attribute"; + when Iir_Kind_Zoh_Attribute => + return "'zoh attribute"; + when Iir_Kind_Ltf_Attribute => + return "'ltf attribute"; + when Iir_Kind_Ztf_Attribute => + return "'ztf attribute"; when Iir_Kind_Ramp_Attribute => return "'ramp attribute"; when Iir_Kind_Dot_Attribute => diff --git a/src/vhdl/vhdl-nodes.adb b/src/vhdl/vhdl-nodes.adb index 84b94196d..50d7fe2cf 100644 --- a/src/vhdl/vhdl-nodes.adb +++ b/src/vhdl/vhdl-nodes.adb @@ -1274,7 +1274,10 @@ package body Vhdl.Nodes is | Iir_Kind_Wait_Statement | Iir_Kind_Signal_Slew_Attribute | Iir_Kind_Quantity_Slew_Attribute - | Iir_Kind_Ramp_Attribute => + | Iir_Kind_Ramp_Attribute + | Iir_Kind_Zoh_Attribute + | Iir_Kind_Ltf_Attribute + | Iir_Kind_Ztf_Attribute => return Format_Medium; end case; end Get_Format; @@ -5960,6 +5963,38 @@ package body Vhdl.Nodes is Set_Field6 (Target, Param); end Set_Parameter_2; + function Get_Parameter_3 (Target : Iir) return Iir is + begin + pragma Assert (Target /= Null_Iir); + pragma Assert (Has_Parameter_3 (Get_Kind (Target)), + "no field Parameter_3"); + return Get_Field7 (Target); + end Get_Parameter_3; + + procedure Set_Parameter_3 (Target : Iir; Param : Iir) is + begin + pragma Assert (Target /= Null_Iir); + pragma Assert (Has_Parameter_3 (Get_Kind (Target)), + "no field Parameter_3"); + Set_Field7 (Target, Param); + end Set_Parameter_3; + + function Get_Parameter_4 (Target : Iir) return Iir is + begin + pragma Assert (Target /= Null_Iir); + pragma Assert (Has_Parameter_4 (Get_Kind (Target)), + "no field Parameter_4"); + return Get_Field8 (Target); + end Get_Parameter_4; + + procedure Set_Parameter_4 (Target : Iir; Param : Iir) is + begin + pragma Assert (Target /= Null_Iir); + pragma Assert (Has_Parameter_4 (Get_Kind (Target)), + "no field Parameter_4"); + Set_Field8 (Target, Param); + end Set_Parameter_4; + function Get_Attr_Chain (Attr : Iir) return Iir is begin pragma Assert (Attr /= Null_Iir); diff --git a/src/vhdl/vhdl-nodes.ads b/src/vhdl/vhdl-nodes.ads index cb51e8920..217f6a562 100644 --- a/src/vhdl/vhdl-nodes.ads +++ b/src/vhdl/vhdl-nodes.ads @@ -4475,6 +4475,9 @@ package Vhdl.Nodes is -- Iir_Kind_Ramp_Attribute (Medium) -- Iir_Kind_Signal_Slew_Attribute (Medium) -- Iir_Kind_Quantity_Slew_Attribute (Medium) + -- Iir_Kind_Zoh_Attribute (Medium) + -- Iir_Kind_Ltf_Attribute (Medium) + -- Iir_Kind_Ztf_Attribute (Medium) -- -- Get/Set_Prefix (Field0) -- @@ -4486,6 +4489,12 @@ package Vhdl.Nodes is -- -- Get/Set_Parameter_2 (Field6) -- + -- Only for Iir_Kind_Ztf_Attribute: + -- Get/Set_Parameter_3 (Field7) + -- + -- Only for Iir_Kind_Ztf_Attribute: + -- Get/Set_Parameter_4 (Field8) + -- -- Get/Set_Base_Name (Field5) -- -- Get/Set_Name_Staticness (State2) @@ -4991,6 +5000,9 @@ package Vhdl.Nodes is Iir_Kind_Signal_Slew_Attribute, Iir_Kind_Quantity_Slew_Attribute, Iir_Kind_Ramp_Attribute, + Iir_Kind_Zoh_Attribute, + Iir_Kind_Ltf_Attribute, + Iir_Kind_Ztf_Attribute, Iir_Kind_Dot_Attribute, Iir_Kind_Integ_Attribute, Iir_Kind_Above_Attribute, @@ -6205,6 +6217,9 @@ package Vhdl.Nodes is --Iir_Kind_Signal_Slew_Attribute --Iir_Kind_Quantity_Slew_Attribute --Iir_Kind_Ramp_Attribute + --Iir_Kind_Zoh_Attribute + --Iir_Kind_Ltf_Attribute + --Iir_Kind_Ztf_Attribute --Iir_Kind_Dot_Attribute --Iir_Kind_Integ_Attribute --Iir_Kind_Above_Attribute @@ -8265,6 +8280,16 @@ package Vhdl.Nodes is function Get_Parameter_2 (Target : Iir) return Iir; procedure Set_Parameter_2 (Target : Iir; Param : Iir); + -- Third parameter of an attribute (for AMS VHDL). + -- Field: Field7 + function Get_Parameter_3 (Target : Iir) return Iir; + procedure Set_Parameter_3 (Target : Iir; Param : Iir); + + -- Fourth parameter of an attribute (for AMS VHDL). + -- Field: Field8 + function Get_Parameter_4 (Target : Iir) return Iir; + procedure Set_Parameter_4 (Target : Iir; Param : Iir); + -- Field: Field2 Forward_Ref function Get_Attr_Chain (Attr : Iir) return Iir; procedure Set_Attr_Chain (Attr : Iir; Chain : Iir); diff --git a/src/vhdl/vhdl-nodes_meta.adb b/src/vhdl/vhdl-nodes_meta.adb index ed955d05c..48029e8c9 100644 --- a/src/vhdl/vhdl-nodes_meta.adb +++ b/src/vhdl/vhdl-nodes_meta.adb @@ -305,6 +305,8 @@ package body Vhdl.Nodes_Meta is Field_Index_Subtype => Type_Iir, Field_Parameter => Type_Iir, Field_Parameter_2 => Type_Iir, + Field_Parameter_3 => Type_Iir, + Field_Parameter_4 => Type_Iir, Field_Attr_Chain => Type_Iir, Field_Signal_Attribute_Declaration => Type_Iir, Field_Actual_Type => Type_Iir, @@ -957,6 +959,10 @@ package body Vhdl.Nodes_Meta is return "parameter"; when Field_Parameter_2 => return "parameter_2"; + when Field_Parameter_3 => + return "parameter_3"; + when Field_Parameter_4 => + return "parameter_4"; when Field_Attr_Chain => return "attr_chain"; when Field_Signal_Attribute_Declaration => @@ -1653,6 +1659,12 @@ package body Vhdl.Nodes_Meta is return "quantity_slew_attribute"; when Iir_Kind_Ramp_Attribute => return "ramp_attribute"; + when Iir_Kind_Zoh_Attribute => + return "zoh_attribute"; + when Iir_Kind_Ltf_Attribute => + return "ltf_attribute"; + when Iir_Kind_Ztf_Attribute => + return "ztf_attribute"; when Iir_Kind_Dot_Attribute => return "dot_attribute"; when Iir_Kind_Integ_Attribute => @@ -2287,6 +2299,10 @@ package body Vhdl.Nodes_Meta is return Attr_None; when Field_Parameter_2 => return Attr_None; + when Field_Parameter_3 => + return Attr_None; + when Field_Parameter_4 => + return Attr_None; when Field_Attr_Chain => return Attr_Forward_Ref; when Field_Signal_Attribute_Declaration => @@ -4798,6 +4814,35 @@ package body Vhdl.Nodes_Meta is Field_Parameter, Field_Parameter_2, Field_Base_Name, + -- Iir_Kind_Zoh_Attribute + Field_Expr_Staticness, + Field_Name_Staticness, + Field_Prefix, + Field_Type, + Field_Attr_Chain, + Field_Parameter, + Field_Parameter_2, + Field_Base_Name, + -- Iir_Kind_Ltf_Attribute + Field_Expr_Staticness, + Field_Name_Staticness, + Field_Prefix, + Field_Type, + Field_Attr_Chain, + Field_Parameter, + Field_Parameter_2, + Field_Base_Name, + -- Iir_Kind_Ztf_Attribute + Field_Expr_Staticness, + Field_Name_Staticness, + Field_Prefix, + Field_Type, + Field_Attr_Chain, + Field_Parameter, + Field_Parameter_2, + Field_Parameter_3, + Field_Parameter_4, + Field_Base_Name, -- Iir_Kind_Dot_Attribute Field_Expr_Staticness, Field_Name_Staticness, @@ -5273,34 +5318,37 @@ package body Vhdl.Nodes_Meta is Iir_Kind_Signal_Slew_Attribute => 2074, Iir_Kind_Quantity_Slew_Attribute => 2082, Iir_Kind_Ramp_Attribute => 2090, - Iir_Kind_Dot_Attribute => 2097, - Iir_Kind_Integ_Attribute => 2104, - Iir_Kind_Above_Attribute => 2112, - Iir_Kind_Delayed_Attribute => 2121, - Iir_Kind_Stable_Attribute => 2130, - Iir_Kind_Quiet_Attribute => 2139, - Iir_Kind_Transaction_Attribute => 2148, - Iir_Kind_Event_Attribute => 2152, - Iir_Kind_Active_Attribute => 2156, - Iir_Kind_Last_Event_Attribute => 2160, - Iir_Kind_Last_Active_Attribute => 2164, - Iir_Kind_Last_Value_Attribute => 2168, - Iir_Kind_Driving_Attribute => 2172, - Iir_Kind_Driving_Value_Attribute => 2176, - Iir_Kind_Behavior_Attribute => 2176, - Iir_Kind_Structure_Attribute => 2176, - Iir_Kind_Simple_Name_Attribute => 2183, - Iir_Kind_Instance_Name_Attribute => 2188, - Iir_Kind_Path_Name_Attribute => 2193, - Iir_Kind_Left_Array_Attribute => 2200, - Iir_Kind_Right_Array_Attribute => 2207, - Iir_Kind_High_Array_Attribute => 2214, - Iir_Kind_Low_Array_Attribute => 2221, - Iir_Kind_Length_Array_Attribute => 2228, - Iir_Kind_Ascending_Array_Attribute => 2235, - Iir_Kind_Range_Array_Attribute => 2242, - Iir_Kind_Reverse_Range_Array_Attribute => 2249, - Iir_Kind_Attribute_Name => 2258 + Iir_Kind_Zoh_Attribute => 2098, + Iir_Kind_Ltf_Attribute => 2106, + Iir_Kind_Ztf_Attribute => 2116, + Iir_Kind_Dot_Attribute => 2123, + Iir_Kind_Integ_Attribute => 2130, + Iir_Kind_Above_Attribute => 2138, + Iir_Kind_Delayed_Attribute => 2147, + Iir_Kind_Stable_Attribute => 2156, + Iir_Kind_Quiet_Attribute => 2165, + Iir_Kind_Transaction_Attribute => 2174, + Iir_Kind_Event_Attribute => 2178, + Iir_Kind_Active_Attribute => 2182, + Iir_Kind_Last_Event_Attribute => 2186, + Iir_Kind_Last_Active_Attribute => 2190, + Iir_Kind_Last_Value_Attribute => 2194, + Iir_Kind_Driving_Attribute => 2198, + Iir_Kind_Driving_Value_Attribute => 2202, + Iir_Kind_Behavior_Attribute => 2202, + Iir_Kind_Structure_Attribute => 2202, + Iir_Kind_Simple_Name_Attribute => 2209, + Iir_Kind_Instance_Name_Attribute => 2214, + Iir_Kind_Path_Name_Attribute => 2219, + Iir_Kind_Left_Array_Attribute => 2226, + Iir_Kind_Right_Array_Attribute => 2233, + Iir_Kind_High_Array_Attribute => 2240, + Iir_Kind_Low_Array_Attribute => 2247, + Iir_Kind_Length_Array_Attribute => 2254, + Iir_Kind_Ascending_Array_Attribute => 2261, + Iir_Kind_Range_Array_Attribute => 2268, + Iir_Kind_Reverse_Range_Array_Attribute => 2275, + Iir_Kind_Attribute_Name => 2284 ); function Get_Fields_First (K : Iir_Kind) return Fields_Index is @@ -6089,6 +6137,10 @@ package body Vhdl.Nodes_Meta is return Get_Parameter (N); when Field_Parameter_2 => return Get_Parameter_2 (N); + when Field_Parameter_3 => + return Get_Parameter_3 (N); + when Field_Parameter_4 => + return Get_Parameter_4 (N); when Field_Attr_Chain => return Get_Attr_Chain (N); when Field_Signal_Attribute_Declaration => @@ -6533,6 +6585,10 @@ package body Vhdl.Nodes_Meta is Set_Parameter (N, V); when Field_Parameter_2 => Set_Parameter_2 (N, V); + when Field_Parameter_3 => + Set_Parameter_3 (N, V); + when Field_Parameter_4 => + Set_Parameter_4 (N, V); when Field_Attr_Chain => Set_Attr_Chain (N, V); when Field_Signal_Attribute_Declaration => @@ -8351,6 +8407,9 @@ package body Vhdl.Nodes_Meta is | Iir_Kind_Signal_Slew_Attribute | Iir_Kind_Quantity_Slew_Attribute | Iir_Kind_Ramp_Attribute + | Iir_Kind_Zoh_Attribute + | Iir_Kind_Ltf_Attribute + | Iir_Kind_Ztf_Attribute | Iir_Kind_Dot_Attribute | Iir_Kind_Integ_Attribute | Iir_Kind_Above_Attribute @@ -8558,6 +8617,9 @@ package body Vhdl.Nodes_Meta is | Iir_Kind_Signal_Slew_Attribute | Iir_Kind_Quantity_Slew_Attribute | Iir_Kind_Ramp_Attribute + | Iir_Kind_Zoh_Attribute + | Iir_Kind_Ltf_Attribute + | Iir_Kind_Ztf_Attribute | Iir_Kind_Dot_Attribute | Iir_Kind_Integ_Attribute | Iir_Kind_Above_Attribute @@ -10751,6 +10813,9 @@ package body Vhdl.Nodes_Meta is | Iir_Kind_Signal_Slew_Attribute | Iir_Kind_Quantity_Slew_Attribute | Iir_Kind_Ramp_Attribute + | Iir_Kind_Zoh_Attribute + | Iir_Kind_Ltf_Attribute + | Iir_Kind_Ztf_Attribute | Iir_Kind_Dot_Attribute | Iir_Kind_Integ_Attribute | Iir_Kind_Above_Attribute @@ -10990,6 +11055,9 @@ package body Vhdl.Nodes_Meta is | Iir_Kind_Signal_Slew_Attribute | Iir_Kind_Quantity_Slew_Attribute | Iir_Kind_Ramp_Attribute + | Iir_Kind_Zoh_Attribute + | Iir_Kind_Ltf_Attribute + | Iir_Kind_Ztf_Attribute | Iir_Kind_Dot_Attribute | Iir_Kind_Integ_Attribute | Iir_Kind_Above_Attribute @@ -11057,6 +11125,9 @@ package body Vhdl.Nodes_Meta is | Iir_Kind_Signal_Slew_Attribute | Iir_Kind_Quantity_Slew_Attribute | Iir_Kind_Ramp_Attribute + | Iir_Kind_Zoh_Attribute + | Iir_Kind_Ltf_Attribute + | Iir_Kind_Ztf_Attribute | Iir_Kind_Dot_Attribute | Iir_Kind_Integ_Attribute | Iir_Kind_Above_Attribute @@ -11181,6 +11252,9 @@ package body Vhdl.Nodes_Meta is | Iir_Kind_Signal_Slew_Attribute | Iir_Kind_Quantity_Slew_Attribute | Iir_Kind_Ramp_Attribute + | Iir_Kind_Zoh_Attribute + | Iir_Kind_Ltf_Attribute + | Iir_Kind_Ztf_Attribute | Iir_Kind_Above_Attribute | Iir_Kind_Delayed_Attribute | Iir_Kind_Stable_Attribute @@ -11205,19 +11279,35 @@ package body Vhdl.Nodes_Meta is case K is when Iir_Kind_Signal_Slew_Attribute | Iir_Kind_Quantity_Slew_Attribute - | Iir_Kind_Ramp_Attribute => + | Iir_Kind_Ramp_Attribute + | Iir_Kind_Zoh_Attribute + | Iir_Kind_Ltf_Attribute + | Iir_Kind_Ztf_Attribute => return True; when others => return False; end case; end Has_Parameter_2; + function Has_Parameter_3 (K : Iir_Kind) return Boolean is + begin + return K = Iir_Kind_Ztf_Attribute; + end Has_Parameter_3; + + function Has_Parameter_4 (K : Iir_Kind) return Boolean is + begin + return K = Iir_Kind_Ztf_Attribute; + end Has_Parameter_4; + function Has_Attr_Chain (K : Iir_Kind) return Boolean is begin case K is when Iir_Kind_Signal_Slew_Attribute | Iir_Kind_Quantity_Slew_Attribute | Iir_Kind_Ramp_Attribute + | Iir_Kind_Zoh_Attribute + | Iir_Kind_Ltf_Attribute + | Iir_Kind_Ztf_Attribute | Iir_Kind_Dot_Attribute | Iir_Kind_Integ_Attribute | Iir_Kind_Above_Attribute diff --git a/src/vhdl/vhdl-nodes_meta.ads b/src/vhdl/vhdl-nodes_meta.ads index a3a9c66c6..7da2ac823 100644 --- a/src/vhdl/vhdl-nodes_meta.ads +++ b/src/vhdl/vhdl-nodes_meta.ads @@ -347,6 +347,8 @@ package Vhdl.Nodes_Meta is Field_Index_Subtype, Field_Parameter, Field_Parameter_2, + Field_Parameter_3, + Field_Parameter_4, Field_Attr_Chain, Field_Signal_Attribute_Declaration, Field_Actual_Type, @@ -909,6 +911,8 @@ package Vhdl.Nodes_Meta is function Has_Index_Subtype (K : Iir_Kind) return Boolean; function Has_Parameter (K : Iir_Kind) return Boolean; function Has_Parameter_2 (K : Iir_Kind) return Boolean; + function Has_Parameter_3 (K : Iir_Kind) return Boolean; + function Has_Parameter_4 (K : Iir_Kind) return Boolean; function Has_Attr_Chain (K : Iir_Kind) return Boolean; function Has_Signal_Attribute_Declaration (K : Iir_Kind) return Boolean; function Has_Actual_Type (K : Iir_Kind) return Boolean; diff --git a/src/vhdl/vhdl-prints.adb b/src/vhdl/vhdl-prints.adb index af230fe83..5b466857b 100644 --- a/src/vhdl/vhdl-prints.adb +++ b/src/vhdl/vhdl-prints.adb @@ -3479,14 +3479,7 @@ package body Vhdl.Prints is Disp_Ident (Ctxt, Name); Has_Params := False; for I in 1 .. Num loop - case I is - when 1 => - Param := Get_Parameter (Expr); - when 2 => - Param := Get_Parameter_2 (Expr); - when others => - raise Internal_Error; - end case; + Param := Get_Attribute_Parameter (Expr, I); exit when Param = Null_Iir; if not Has_Params then Disp_Token (Ctxt, Tok_Left_Paren); @@ -4643,6 +4636,12 @@ package body Vhdl.Prints is Disp_Name_Attribute (Ctxt, Expr, Name_Dot); when Iir_Kind_Integ_Attribute => Disp_Name_Attribute (Ctxt, Expr, Name_Integ); + when Iir_Kind_Zoh_Attribute => + Disp_Parametered_Attribute (Ctxt, Name_Zoh, Expr, 2); + when Iir_Kind_Ltf_Attribute => + Disp_Parametered_Attribute (Ctxt, Name_Ltf, Expr, 2); + when Iir_Kind_Ztf_Attribute => + Disp_Parametered_Attribute (Ctxt, Name_Ztf, Expr, 4); when Iir_Kind_Signal_Slew_Attribute | Iir_Kind_Quantity_Slew_Attribute => diff --git a/src/vhdl/vhdl-sem_expr.adb b/src/vhdl/vhdl-sem_expr.adb index 8a3ea8d15..fc7e59a7c 100644 --- a/src/vhdl/vhdl-sem_expr.adb +++ b/src/vhdl/vhdl-sem_expr.adb @@ -4371,6 +4371,9 @@ package body Vhdl.Sem_Expr is | Iir_Kinds_Signal_Attribute | Iir_Kinds_Signal_Value_Attribute | Iir_Kind_Above_Attribute + | Iir_Kind_Zoh_Attribute + | Iir_Kind_Ltf_Attribute + | Iir_Kind_Ztf_Attribute | Iir_Kind_Dot_Attribute | Iir_Kind_Integ_Attribute | Iir_Kind_Ramp_Attribute => diff --git a/src/vhdl/vhdl-sem_names.adb b/src/vhdl/vhdl-sem_names.adb index 10636bcb3..2830e6e77 100644 --- a/src/vhdl/vhdl-sem_names.adb +++ b/src/vhdl/vhdl-sem_names.adb @@ -1241,6 +1241,39 @@ package body Vhdl.Sem_Names is end if; end Finish_Sem_Signal_Attribute; + procedure Sem_Quantity_Attribute_Parameters + (Attr : Iir; Params : Iir_Array; Params_Type : Iir_Array; Min : Positive) + is + Param : Iir; + begin + pragma Assert (Params'First = 1); + pragma Assert (Params_Type'First = 1); + pragma Assert (Params_Type'Last = Params'Last); + for I in Params'Range loop + Param := Params (I); + if Param = Null_Iir then + if I <= Min then + Error_Msg_Sem + (+Attr, "not enough parameters for the attribute"); + end if; + return; + end if; + if Params_Type (I) = Null_Iir then + Error_Msg_Sem (+Attr, "too many parameters for the attribute"); + return; + end if; + + Param := Sem_Expression (Param, Params_Type (I)); + if Param /= Null_Iir then + if Get_Expr_Staticness (Param) < Globally then + Error_Msg_Sem + (+Param, "parameter must be a static expression"); + end if; + Set_Attribute_Parameter (Attr, I, Param); + end if; + end loop; + end Sem_Quantity_Attribute_Parameters; + procedure Finish_Sem_Quantity_Attribute (Attr_Name : Iir; Attr : Iir; Params : Iir_Array) is @@ -1268,7 +1301,7 @@ package body Vhdl.Sem_Names is when Iir_Kind_Ramp_Attribute | Iir_Kind_Signal_Slew_Attribute | Iir_Kind_Quantity_Slew_Attribute => - pragma Assert (Params'First = 1 and Params'Last = 2); + pragma Assert (Params'First = 1 and Params'Last = 4); -- AMS-LRM17 16.2.6 -- S'RAMP [(TRISE [, TFALL])] -- Parameters: @@ -1298,25 +1331,54 @@ package body Vhdl.Sem_Names is -- evaluates to a negative value. If omitted, it defaults -- to the negative of MAX_RISING_SLOPE. The value REAL'LOW -- is interpreted as a negative infinite slope. - for I in 1 .. 2 loop - Param := Params (I); - exit when Param = Null_Iir; - -- FIXME: type. - Param := Sem_Expression (Param, Real_Type_Definition); - if Param /= Null_Iir then - if Get_Expr_Staticness (Param) < Globally then - Error_Msg_Sem - (+Param, - "parameters of 'ramp must be static expressions"); - end if; - case I is - when 1 => - Set_Parameter (Attr, Param); - when 2 => - Set_Parameter_2 (Attr, Param); - end case; - end if; - end loop; + Sem_Quantity_Attribute_Parameters + (Attr, Params, (1 => Real_Type_Definition, + 2 => Real_Type_Definition, + 3 | 4 => Null_Iir), 1); + when Iir_Kind_Zoh_Attribute => + -- AMS-LRM17 16.2.6 + -- Q'LTF(T [, INITIAL_DELAY) + -- Parameters: + -- T: A static expression of type REAL that evaluates to a + -- positive value. This is the sampling period. + -- INITIAL_DELAY: A static expression of type REAL that + -- evaluates to a non-negative value. The first sampling will + -- occur after INITIAL_DELAY seconds. If omitted, it defaults + -- to 0.0. + Sem_Quantity_Attribute_Parameters + (Attr, Params, (1 => Real_Type_Definition, + 2 => Real_Type_Definition, + 3 | 4 => Null_Iir), 1); + when Iir_Kind_Ltf_Attribute => + -- AMS-LRM17 16.2.6 + -- Q'LTF(NUM, DEN) + -- Parameters: + -- NUM: a static expression of type REAL_VECTOR that contains + -- the numerator coefficients. + -- DEN: a static expression of type REAL_VECTOR that contains + -- the denominator coefficients. + Sem_Quantity_Attribute_Parameters + (Attr, Params, (1 => Real_Vector_Type_Definition, + 2 => Real_Vector_Type_Definition, + 3 | 4 => Null_Iir), 2); + when Iir_Kind_Ztf_Attribute => + -- AMS-LRM17 16.2.6 + -- Q'ZTF(NUM, DEN, T, [, INITIAL_DELAY]) + -- Parameters: + -- NUM: A static expression of type REAL_VECTOR with the + -- numerator coefficients. + -- DEN: A static expression of type REAL_VECTOR with the + -- denominator coefficients. + -- T: A static expression of type REAL that evaluates to a + -- positive value, which is the sampling period. + -- INITIAL_DELAY: A static expression of type REAL that + -- evaluates to a non-negative value, which is the time of the + -- first sampling. If omitted, it defaults to 0.0 + Sem_Quantity_Attribute_Parameters + (Attr, Params, (1 => Real_Vector_Type_Definition, + 2 => Real_Vector_Type_Definition, + 3 => Real_Type_Definition, + 4 => Real_Type_Definition), 3); when others => Error_Kind ("finish_sem_quantity_attribute", Attr); end case; @@ -1852,7 +1914,10 @@ package body Vhdl.Sem_Names is when Iir_Kind_Above_Attribute | Iir_Kind_Ramp_Attribute | Iir_Kind_Quantity_Slew_Attribute - | Iir_Kind_Signal_Slew_Attribute => + | Iir_Kind_Signal_Slew_Attribute + | Iir_Kind_Zoh_Attribute + | Iir_Kind_Ltf_Attribute + | Iir_Kind_Ztf_Attribute => if Get_Parameter (Res) = Null_Iir then -- Not finished. Need to emit an error message. Finish_Sem_Quantity_Attribute (Name, Res, (1 => Null_Iir)); @@ -2939,9 +3004,12 @@ package body Vhdl.Sem_Names is when Iir_Kind_Ramp_Attribute | Iir_Kind_Quantity_Slew_Attribute - | Iir_Kind_Signal_Slew_Attribute => + | Iir_Kind_Signal_Slew_Attribute + | Iir_Kind_Zoh_Attribute + | Iir_Kind_Ltf_Attribute + | Iir_Kind_Ztf_Attribute => declare - Params : Iir_Array (1 .. 2); + Params : Iir_Array (1 .. 4); begin -- Try to extract 2 actuals from the name association list. -- Emit a message in case of error. @@ -3962,6 +4030,7 @@ package body Vhdl.Sem_Names is Name_Prefix : constant Iir := Get_Prefix (Attr); Prefix: Iir; Res : Iir; + Res_Type : Iir; begin Prefix := Get_Named_Entity (Name_Prefix); Prefix := Finish_Sem_Name_1 (Name_Prefix, Prefix); @@ -3970,16 +4039,21 @@ package body Vhdl.Sem_Names is (+Attr, "prefix of %i attribute must denote a quantity", +Attr); end if; + Res_Type := Get_Type (Prefix); case Get_Identifier (Attr) is when Name_Above => Res := Create_Iir (Iir_Kind_Above_Attribute); - Set_Type (Res, Boolean_Type_Definition); + Res_Type := Boolean_Type_Definition; when Name_Dot => Res := Create_Iir (Iir_Kind_Dot_Attribute); - Set_Type (Res, Get_Type (Prefix)); when Name_Integ => Res := Create_Iir (Iir_Kind_Integ_Attribute); - Set_Type (Res, Get_Type (Prefix)); + when Name_Zoh => + Res := Create_Iir (Iir_Kind_Zoh_Attribute); + when Name_Ltf => + Res := Create_Iir (Iir_Kind_Ltf_Attribute); + when Name_Ztf => + Res := Create_Iir (Iir_Kind_Ztf_Attribute); when others => -- Not yet implemented attribute, or really an internal error. raise Internal_Error; @@ -3987,6 +4061,7 @@ package body Vhdl.Sem_Names is Location_Copy (Res, Attr); Set_Prefix (Res, Prefix); + Set_Type (Res, Res_Type); -- AMS-LRM17 16.2.6 Predefined analog an mixed-signal attributes -- Prefix: Any quantity denoted by the static name Q. @@ -4210,7 +4285,10 @@ package body Vhdl.Sem_Names is when Name_Above | Name_Dot - | Name_Integ => + | Name_Integ + | Name_Zoh + | Name_Ltf + | Name_Ztf => if Flags.AMS_Vhdl then Res := Sem_Quantity_Attribute (Attr); else @@ -4600,6 +4678,9 @@ package body Vhdl.Sem_Names is | Iir_Kind_Dot_Attribute | Iir_Kind_Integ_Attribute | Iir_Kind_Ramp_Attribute + | Iir_Kind_Zoh_Attribute + | Iir_Kind_Ltf_Attribute + | Iir_Kind_Ztf_Attribute | Iir_Kind_Signal_Slew_Attribute | Iir_Kind_Quantity_Slew_Attribute => -- Never static diff --git a/src/vhdl/vhdl-utils.adb b/src/vhdl/vhdl-utils.adb index 5a22d3e7a..d11b17a2b 100644 --- a/src/vhdl/vhdl-utils.adb +++ b/src/vhdl/vhdl-utils.adb @@ -1693,6 +1693,36 @@ package body Vhdl.Utils is return K = K1 or K = K2; end Kind_In; + procedure Set_Attribute_Parameter + (Attr : Iir; N : Parameter_Index; Param : Iir) is + begin + case N is + when 1 => + Set_Parameter (Attr, Param); + when 2 => + Set_Parameter_2 (Attr, Param); + when 3 => + Set_Parameter_3 (Attr, Param); + when 4 => + Set_Parameter_4 (Attr, Param); + end case; + end Set_Attribute_Parameter; + + function Get_Attribute_Parameter + (Attr : Iir; N : Parameter_Index) return Iir is + begin + case N is + when 1 => + return Get_Parameter (Attr); + when 2 => + return Get_Parameter_2 (Attr); + when 3 => + return Get_Parameter_3 (Attr); + when 4 => + return Get_Parameter_4 (Attr); + end case; + end Get_Attribute_Parameter; + function Get_HDL_Node (N : PSL_Node) return Iir is begin return Iir (PSL.Nodes.Get_HDL_Node (N)); diff --git a/src/vhdl/vhdl-utils.ads b/src/vhdl/vhdl-utils.ads index c24b3226f..4ca9d83e3 100644 --- a/src/vhdl/vhdl-utils.ads +++ b/src/vhdl/vhdl-utils.ads @@ -383,6 +383,14 @@ package Vhdl.Utils is function Kind_In (N : Iir; K1, K2 : Iir_Kind) return Boolean; pragma Inline (Kind_In); + subtype Parameter_Index is Natural range 1 .. 4; + + -- Get/Set attribute parameter by index (for AMS attributes). + procedure Set_Attribute_Parameter + (Attr : Iir; N : Parameter_Index; Param : Iir); + function Get_Attribute_Parameter + (Attr : Iir; N : Parameter_Index) return Iir; + -- IIR wrapper around Get_HDL_Node/Set_HDL_Node. function Get_HDL_Node (N : PSL_Node) return Iir; procedure Set_HDL_Node (N : PSL_Node; Expr : Iir); |