diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-05-01 17:43:19 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-05-02 04:10:02 +0200 |
commit | 9224975c3893f69c8e5a5758d0762909a90f25a6 (patch) | |
tree | 92145dc03d30064e8aece547c4d3110cd4e6a338 | |
parent | 33861bcc4a3bdd3253a5f7f8532823deb16c7287 (diff) | |
download | ghdl-9224975c3893f69c8e5a5758d0762909a90f25a6.tar.gz ghdl-9224975c3893f69c8e5a5758d0762909a90f25a6.tar.bz2 ghdl-9224975c3893f69c8e5a5758d0762909a90f25a6.zip |
std_package: add units to physical literals of time units.
Fix #808
-rw-r--r-- | src/vhdl/std_package.adb | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/vhdl/std_package.adb b/src/vhdl/std_package.adb index 8bc6b0011..a04fafd4c 100644 --- a/src/vhdl/std_package.adb +++ b/src/vhdl/std_package.adb @@ -793,9 +793,8 @@ package body Std_Package is Last_Unit : Iir_Unit_Declaration; use Iir_Chains.Unit_Chain_Handling; - function Create_Std_Phys_Lit (Value : Iir_Int64; - Unit : Iir_Simple_Name) - return Iir_Physical_Int_Literal + function Create_Std_Phys_Lit_Wo_Unit (Value : Iir_Int64; Unit : Iir) + return Iir_Physical_Int_Literal is Lit: Iir_Physical_Int_Literal; begin @@ -806,6 +805,19 @@ package body Std_Package is Set_Type (Lit, Time_Type_Definition); Set_Expr_Staticness (Lit, Time_Staticness); return Lit; + end Create_Std_Phys_Lit_Wo_Unit; + + function Create_Std_Phys_Lit (Value : Iir_Int64; Unit : Iir) + return Iir_Physical_Int_Literal + is + Lit: Iir_Physical_Int_Literal; + Unit_Name : Iir; + begin + Lit := Create_Std_Phys_Lit_Wo_Unit (Value, Unit); + Unit_Name := Create_Std_Iir (Iir_Kind_Simple_Name); + Set_Identifier (Unit_Name, Get_Identifier (Unit)); + Set_Unit_Name (Lit, Unit_Name); + return Lit; end Create_Std_Phys_Lit; procedure Create_Unit (Unit : out Iir_Unit_Declaration; @@ -881,10 +893,10 @@ package body Std_Package is Time_Subtype_Definition := Create_Std_Iir (Iir_Kind_Physical_Subtype_Definition); Constraint := Create_Std_Range_Expr - (Create_Std_Phys_Lit (Low_Bound (Flags.Flag_Time_64), - Time_Fs_Unit), - Create_Std_Phys_Lit (High_Bound (Flags.Flag_Time_64), - Time_Fs_Unit), + (Create_Std_Phys_Lit_Wo_Unit (Low_Bound (Flags.Flag_Time_64), + Time_Fs_Unit), + Create_Std_Phys_Lit_Wo_Unit (High_Bound (Flags.Flag_Time_64), + Time_Fs_Unit), Time_Type_Definition); Set_Range_Constraint (Time_Subtype_Definition, Constraint); Set_Base_Type (Time_Subtype_Definition, Time_Type_Definition); |