diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-12-30 16:46:22 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-12-30 16:46:22 +0100 |
commit | 6340fddff21567b10dd774d5459536d37c6239dc (patch) | |
tree | 36706a03719471083be6934bb2e432cb4a386128 /src | |
parent | e9dfd170410bc6fc534f845976e08082fe217fc5 (diff) | |
download | ghdl-6340fddff21567b10dd774d5459536d37c6239dc.tar.gz ghdl-6340fddff21567b10dd774d5459536d37c6239dc.tar.bz2 ghdl-6340fddff21567b10dd774d5459536d37c6239dc.zip |
ams-vhdl: add frequency function, minor fixes.
Diffstat (limited to 'src')
-rw-r--r-- | src/vhdl/translate/trans-chap7.adb | 3 | ||||
-rw-r--r-- | src/vhdl/vhdl-evaluation.adb | 1 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes.ads | 1 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_stmts.adb | 2 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_types.adb | 6 | ||||
-rw-r--r-- | src/vhdl/vhdl-std_package.adb | 19 |
6 files changed, 26 insertions, 6 deletions
diff --git a/src/vhdl/translate/trans-chap7.adb b/src/vhdl/translate/trans-chap7.adb index 58d63ce90..cf94655e3 100644 --- a/src/vhdl/translate/trans-chap7.adb +++ b/src/vhdl/translate/trans-chap7.adb @@ -6249,7 +6249,8 @@ package body Trans.Chap7 is null; when Iir_Predefined_Now_Function - | Iir_Predefined_Real_Now_Function => + | Iir_Predefined_Real_Now_Function + | Iir_Predefined_Frequency_Function => null; -- when others => diff --git a/src/vhdl/vhdl-evaluation.adb b/src/vhdl/vhdl-evaluation.adb index 50e279a8f..5a4f2dde0 100644 --- a/src/vhdl/vhdl-evaluation.adb +++ b/src/vhdl/vhdl-evaluation.adb @@ -1726,6 +1726,7 @@ package body Vhdl.Evaluation is | Iir_Predefined_TF_Array_Not | Iir_Predefined_Now_Function | Iir_Predefined_Real_Now_Function + | Iir_Predefined_Frequency_Function | Iir_Predefined_Deallocate | Iir_Predefined_Write | Iir_Predefined_Read diff --git a/src/vhdl/vhdl-nodes.ads b/src/vhdl/vhdl-nodes.ads index 9a6e671e1..c59c1c046 100644 --- a/src/vhdl/vhdl-nodes.ads +++ b/src/vhdl/vhdl-nodes.ads @@ -5362,6 +5362,7 @@ package Vhdl.Nodes is -- Misc impure functions. Iir_Predefined_Now_Function, Iir_Predefined_Real_Now_Function, + Iir_Predefined_Frequency_Function, -- A not predefined and not known function. User function. Iir_Predefined_None, diff --git a/src/vhdl/vhdl-sem_stmts.adb b/src/vhdl/vhdl-sem_stmts.adb index 98e01ccb3..43b41d16a 100644 --- a/src/vhdl/vhdl-sem_stmts.adb +++ b/src/vhdl/vhdl-sem_stmts.adb @@ -412,7 +412,7 @@ package body Vhdl.Sem_Stmts is when Iir_Kind_Free_Quantity_Declaration | Iir_Kinds_Branch_Quantity_Declaration | Iir_Kind_Dot_Attribute => - if (Get_Kind (Get_Parent (Stmt)) + if (Get_Kind (Get_Current_Concurrent_Statement) /= Iir_Kind_Simultaneous_Procedural_Statement) then Error_Msg_Sem (+Stmt, "%n cannot be assigned", +Target_Prefix); diff --git a/src/vhdl/vhdl-sem_types.adb b/src/vhdl/vhdl-sem_types.adb index c02e682a8..3a0705d50 100644 --- a/src/vhdl/vhdl-sem_types.adb +++ b/src/vhdl/vhdl-sem_types.adb @@ -2400,11 +2400,13 @@ package body Vhdl.Sem_Types is -- Analyze NAME as a nature name. Return NAME or an error node. function Sem_Nature_Mark (Name : Iir) return Iir is - Nature_Mark : Iir; + Nature_Mark : constant Iir := Sem_Denoting_Name (Name); Res : Iir; begin - Nature_Mark := Sem_Denoting_Name (Name); Res := Get_Named_Entity (Nature_Mark); + if Is_Error (Res) then + return Name; + end if; Res := Get_Nature (Res); case Get_Kind (Res) is when Iir_Kind_Scalar_Nature_Definition diff --git a/src/vhdl/vhdl-std_package.adb b/src/vhdl/vhdl-std_package.adb index d080327ff..7f6273dfe 100644 --- a/src/vhdl/vhdl-std_package.adb +++ b/src/vhdl/vhdl-std_package.adb @@ -1051,9 +1051,9 @@ package body Vhdl.Std_Package is Add_Decl (Function_Now); end; - -- AMS-LRM17 16.3 - -- impure function NOW return REAL; if AMS_Vhdl then + -- AMS-LRM17 16.3 + -- impure function NOW return REAL; declare Function_Now : Iir_Function_Declaration; begin @@ -1066,6 +1066,21 @@ package body Vhdl.Std_Package is Vhdl.Sem_Utils.Compute_Subprogram_Hash (Function_Now); Add_Decl (Function_Now); end; + + -- AMS-LRM17 16.3 + -- impure function FREQUENCY return REAL; + declare + Function_Freq : Iir_Function_Declaration; + begin + Function_Freq := Create_Std_Decl (Iir_Kind_Function_Declaration); + Set_Std_Identifier (Function_Freq, Std_Names.Name_Frequency); + Set_Return_Type (Function_Freq, Real_Subtype_Definition); + Set_Pure_Flag (Function_Freq, False); + Set_Implicit_Definition + (Function_Freq, Iir_Predefined_Frequency_Function); + Vhdl.Sem_Utils.Compute_Subprogram_Hash (Function_Freq); + Add_Decl (Function_Freq); + end; end if; -- natural subtype |