diff options
-rw-r--r-- | python/libghdl/thin/std_names.py | 6 | ||||
-rw-r--r-- | python/libghdl/thin/vhdl/nodes.py | 73 | ||||
-rw-r--r-- | python/libghdl/thin/vhdl/nodes_meta.py | 148 | ||||
-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 |
17 files changed, 484 insertions, 172 deletions
diff --git a/python/libghdl/thin/std_names.py b/python/libghdl/thin/std_names.py index 3dca3b712..0b98b88b3 100644 --- a/python/libghdl/thin/std_names.py +++ b/python/libghdl/thin/std_names.py @@ -382,9 +382,9 @@ class Name: Dot = 604 Integ = 605 Above = 606 - ZOH = 607 - LTF = 608 - ZTF = 609 + Zoh = 607 + Ltf = 608 + Ztf = 609 Ramp = 610 Slew = 611 Last_AMS_Attribute = 611 diff --git a/python/libghdl/thin/vhdl/nodes.py b/python/libghdl/thin/vhdl/nodes.py index c03729f69..720676b33 100644 --- a/python/libghdl/thin/vhdl/nodes.py +++ b/python/libghdl/thin/vhdl/nodes.py @@ -287,34 +287,37 @@ class Iir_Kind: Signal_Slew_Attribute = 272 Quantity_Slew_Attribute = 273 Ramp_Attribute = 274 - Dot_Attribute = 275 - Integ_Attribute = 276 - Above_Attribute = 277 - Delayed_Attribute = 278 - Stable_Attribute = 279 - Quiet_Attribute = 280 - Transaction_Attribute = 281 - Event_Attribute = 282 - Active_Attribute = 283 - Last_Event_Attribute = 284 - Last_Active_Attribute = 285 - Last_Value_Attribute = 286 - Driving_Attribute = 287 - Driving_Value_Attribute = 288 - Behavior_Attribute = 289 - Structure_Attribute = 290 - Simple_Name_Attribute = 291 - Instance_Name_Attribute = 292 - Path_Name_Attribute = 293 - Left_Array_Attribute = 294 - Right_Array_Attribute = 295 - High_Array_Attribute = 296 - Low_Array_Attribute = 297 - Length_Array_Attribute = 298 - Ascending_Array_Attribute = 299 - Range_Array_Attribute = 300 - Reverse_Range_Array_Attribute = 301 - Attribute_Name = 302 + Zoh_Attribute = 275 + Ltf_Attribute = 276 + Ztf_Attribute = 277 + Dot_Attribute = 278 + Integ_Attribute = 279 + Above_Attribute = 280 + Delayed_Attribute = 281 + Stable_Attribute = 282 + Quiet_Attribute = 283 + Transaction_Attribute = 284 + Event_Attribute = 285 + Active_Attribute = 286 + Last_Event_Attribute = 287 + Last_Active_Attribute = 288 + Last_Value_Attribute = 289 + Driving_Attribute = 290 + Driving_Value_Attribute = 291 + Behavior_Attribute = 292 + Structure_Attribute = 293 + Simple_Name_Attribute = 294 + Instance_Name_Attribute = 295 + Path_Name_Attribute = 296 + Left_Array_Attribute = 297 + Right_Array_Attribute = 298 + High_Array_Attribute = 299 + Low_Array_Attribute = 300 + Length_Array_Attribute = 301 + Ascending_Array_Attribute = 302 + Range_Array_Attribute = 303 + Reverse_Range_Array_Attribute = 304 + Attribute_Name = 305 class Iir_Kinds: @@ -593,6 +596,9 @@ class Iir_Kinds: 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, @@ -840,6 +846,9 @@ class Iir_Kinds: 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, @@ -2469,6 +2478,14 @@ Get_Parameter_2 = libghdl.vhdl__nodes__get_parameter_2 Set_Parameter_2 = libghdl.vhdl__nodes__set_parameter_2 +Get_Parameter_3 = libghdl.vhdl__nodes__get_parameter_3 + +Set_Parameter_3 = libghdl.vhdl__nodes__set_parameter_3 + +Get_Parameter_4 = libghdl.vhdl__nodes__get_parameter_4 + +Set_Parameter_4 = libghdl.vhdl__nodes__set_parameter_4 + Get_Attr_Chain = libghdl.vhdl__nodes__get_attr_chain Set_Attr_Chain = libghdl.vhdl__nodes__set_attr_chain diff --git a/python/libghdl/thin/vhdl/nodes_meta.py b/python/libghdl/thin/vhdl/nodes_meta.py index aff2f14d0..05ea7754e 100644 --- a/python/libghdl/thin/vhdl/nodes_meta.py +++ b/python/libghdl/thin/vhdl/nodes_meta.py @@ -347,76 +347,78 @@ class fields: Index_Subtype = 283 Parameter = 284 Parameter_2 = 285 - Attr_Chain = 286 - Signal_Attribute_Declaration = 287 - Actual_Type = 288 - Actual_Type_Definition = 289 - Association_Chain = 290 - Individual_Association_Chain = 291 - Subprogram_Association_Chain = 292 - Aggregate_Info = 293 - Sub_Aggregate_Info = 294 - Aggr_Dynamic_Flag = 295 - Aggr_Min_Length = 296 - Aggr_Low_Limit = 297 - Aggr_High_Limit = 298 - Aggr_Others_Flag = 299 - Aggr_Named_Flag = 300 - Aggregate_Expand_Flag = 301 - Association_Choices_Chain = 302 - Case_Statement_Alternative_Chain = 303 - Choice_Staticness = 304 - Procedure_Call = 305 - Implementation = 306 - Parameter_Association_Chain = 307 - Method_Object = 308 - Subtype_Type_Mark = 309 - Subnature_Nature_Mark = 310 - Type_Conversion_Subtype = 311 - Type_Mark = 312 - File_Type_Mark = 313 - Return_Type_Mark = 314 - Has_Disconnect_Flag = 315 - Has_Active_Flag = 316 - Is_Within_Flag = 317 - Type_Marks_List = 318 - Implicit_Alias_Flag = 319 - Alias_Signature = 320 - Attribute_Signature = 321 - Overload_List = 322 - Simple_Name_Identifier = 323 - Simple_Name_Subtype = 324 - Protected_Type_Body = 325 - Protected_Type_Declaration = 326 - Use_Flag = 327 - End_Has_Reserved_Id = 328 - End_Has_Identifier = 329 - End_Has_Postponed = 330 - Has_Label = 331 - Has_Begin = 332 - Has_End = 333 - Has_Is = 334 - Has_Pure = 335 - Has_Body = 336 - Has_Parameter = 337 - Has_Component = 338 - Has_Identifier_List = 339 - Has_Mode = 340 - Has_Class = 341 - Has_Delay_Mechanism = 342 - Suspend_Flag = 343 - Is_Ref = 344 - Is_Forward_Ref = 345 - Psl_Property = 346 - Psl_Sequence = 347 - Psl_Declaration = 348 - Psl_Expression = 349 - Psl_Boolean = 350 - PSL_Clock = 351 - PSL_NFA = 352 - PSL_Nbr_States = 353 - PSL_Clock_Sensitivity = 354 - PSL_EOS_Flag = 355 + Parameter_3 = 286 + Parameter_4 = 287 + Attr_Chain = 288 + Signal_Attribute_Declaration = 289 + Actual_Type = 290 + Actual_Type_Definition = 291 + Association_Chain = 292 + Individual_Association_Chain = 293 + Subprogram_Association_Chain = 294 + Aggregate_Info = 295 + Sub_Aggregate_Info = 296 + Aggr_Dynamic_Flag = 297 + Aggr_Min_Length = 298 + Aggr_Low_Limit = 299 + Aggr_High_Limit = 300 + Aggr_Others_Flag = 301 + Aggr_Named_Flag = 302 + Aggregate_Expand_Flag = 303 + Association_Choices_Chain = 304 + Case_Statement_Alternative_Chain = 305 + Choice_Staticness = 306 + Procedure_Call = 307 + Implementation = 308 + Parameter_Association_Chain = 309 + Method_Object = 310 + Subtype_Type_Mark = 311 + Subnature_Nature_Mark = 312 + Type_Conversion_Subtype = 313 + Type_Mark = 314 + File_Type_Mark = 315 + Return_Type_Mark = 316 + Has_Disconnect_Flag = 317 + Has_Active_Flag = 318 + Is_Within_Flag = 319 + Type_Marks_List = 320 + Implicit_Alias_Flag = 321 + Alias_Signature = 322 + Attribute_Signature = 323 + Overload_List = 324 + Simple_Name_Identifier = 325 + Simple_Name_Subtype = 326 + Protected_Type_Body = 327 + Protected_Type_Declaration = 328 + Use_Flag = 329 + End_Has_Reserved_Id = 330 + End_Has_Identifier = 331 + End_Has_Postponed = 332 + Has_Label = 333 + Has_Begin = 334 + Has_End = 335 + Has_Is = 336 + Has_Pure = 337 + Has_Body = 338 + Has_Parameter = 339 + Has_Component = 340 + Has_Identifier_List = 341 + Has_Mode = 342 + Has_Class = 343 + Has_Delay_Mechanism = 344 + Suspend_Flag = 345 + Is_Ref = 346 + Is_Forward_Ref = 347 + Psl_Property = 348 + Psl_Sequence = 349 + Psl_Declaration = 350 + Psl_Expression = 351 + Psl_Boolean = 352 + PSL_Clock = 353 + PSL_NFA = 354 + PSL_Nbr_States = 355 + PSL_Clock_Sensitivity = 356 + PSL_EOS_Flag = 357 Get_Boolean = libghdl.vhdl__nodes_meta__get_boolean @@ -1340,6 +1342,12 @@ Has_Parameter =\ Has_Parameter_2 =\ libghdl.vhdl__nodes_meta__has_parameter_2 +Has_Parameter_3 =\ + libghdl.vhdl__nodes_meta__has_parameter_3 + +Has_Parameter_4 =\ + libghdl.vhdl__nodes_meta__has_parameter_4 + Has_Attr_Chain =\ libghdl.vhdl__nodes_meta__has_attr_chain 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); |