diff options
Diffstat (limited to 'src/vhdl/ieee-std_logic_1164.adb')
-rw-r--r-- | src/vhdl/ieee-std_logic_1164.adb | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/src/vhdl/ieee-std_logic_1164.adb b/src/vhdl/ieee-std_logic_1164.adb index b0c355b..8780bf9 100644 --- a/src/vhdl/ieee-std_logic_1164.adb +++ b/src/vhdl/ieee-std_logic_1164.adb @@ -36,6 +36,101 @@ package body Ieee.Std_Logic_1164 is return Res; end Skip_Implicit; + function Is_Scalar_Parameter (Inter : Iir) return Boolean is + begin + return Get_Base_Type (Get_Type (Inter)) = Std_Ulogic_Type; + end Is_Scalar_Parameter; + + function Is_Vector_Parameter (Inter : Iir) return Boolean + is + Base_Type : constant Iir := Get_Base_Type (Get_Type (Inter)); + begin + return Base_Type = Std_Ulogic_Vector_Type + or Base_Type = Std_Logic_Vector_Type; + end Is_Vector_Parameter; + + -- Return True iff the profile of FUNC is: (l, r : std_ulogic) + function Is_Scalar_Scalar_Function (Func : Iir) return Boolean + is + Inter : constant Iir := Get_Interface_Declaration_Chain (Func); + Inter2 : Iir; + begin + if Get_Implicit_Definition (Func) /= Iir_Predefined_None then + return False; + end if; + if Inter = Null_Iir or else not Is_Scalar_Parameter (Inter) then + return False; + end if; + Inter2 := Get_Chain (Inter); + if Inter2 = Null_Iir or else not Is_Scalar_Parameter (Inter2) then + return False; + end if; + if Get_Chain (Inter2) /= Null_Iir then + return False; + end if; + + return True; + end Is_Scalar_Scalar_Function; + + -- Return True iff the profile of FUNC is: (l : std_ulogic) + function Is_Scalar_Function (Func : Iir) return Boolean + is + Inter : constant Iir := Get_Interface_Declaration_Chain (Func); + begin + if Get_Implicit_Definition (Func) /= Iir_Predefined_None then + return False; + end if; + if Inter = Null_Iir or else not Is_Scalar_Parameter (Inter) then + return False; + end if; + if Get_Chain (Inter) /= Null_Iir then + return False; + end if; + + return True; + end Is_Scalar_Function; + + -- Return True iff the profile of FUNC is: (l, r : std_[u]logic_vector) + function Is_Vector_Vector_Function (Func : Iir) return Boolean + is + Inter : constant Iir := Get_Interface_Declaration_Chain (Func); + Inter2 : Iir; + begin + if Get_Implicit_Definition (Func) /= Iir_Predefined_None then + return False; + end if; + if Inter = Null_Iir or else not Is_Vector_Parameter (Inter) then + return False; + end if; + Inter2 := Get_Chain (Inter); + if Inter2 = Null_Iir or else not Is_Vector_Parameter (Inter2) then + return False; + end if; + if Get_Chain (Inter2) /= Null_Iir then + return False; + end if; + + return True; + end Is_Vector_Vector_Function; + + -- Return True iff the profile of FUNC is: (l : std_[u]logic_vector) + function Is_Vector_Function (Func : Iir) return Boolean + is + Inter : constant Iir := Get_Interface_Declaration_Chain (Func); + begin + if Get_Implicit_Definition (Func) /= Iir_Predefined_None then + return False; + end if; + if Inter = Null_Iir or else not Is_Vector_Parameter (Inter) then + return False; + end if; + if Get_Chain (Inter) /= Null_Iir then + return False; + end if; + + return True; + end Is_Vector_Function; + procedure Extract_Declarations (Pkg : Iir_Package_Declaration) is Error : exception; @@ -137,6 +232,60 @@ package body Ieee.Std_Logic_1164 is Rising_Edge := Decl; elsif Get_Identifier (Decl) = Name_Falling_Edge then Falling_Edge := Decl; + elsif Is_Scalar_Scalar_Function (Decl) then + declare + Predefined : Iir_Predefined_Functions; + begin + case Get_Identifier (Decl) is + when Name_And => + Predefined := Iir_Predefined_Ieee_1164_Scalar_And; + when Name_Nand => + Predefined := Iir_Predefined_Ieee_1164_Scalar_Nand; + when Name_Or => + Predefined := Iir_Predefined_Ieee_1164_Scalar_Or; + when Name_Nor => + Predefined := Iir_Predefined_Ieee_1164_Scalar_Nor; + when Name_Xor => + Predefined := Iir_Predefined_Ieee_1164_Scalar_Xor; + when Name_Xnor => + Predefined := Iir_Predefined_Ieee_1164_Scalar_Xnor; + when others => + Predefined := Iir_Predefined_None; + end case; + Set_Implicit_Definition (Decl, Predefined); + end; + elsif Is_Scalar_Function (Decl) + and then Get_Identifier (Decl) = Name_Not + then + Set_Implicit_Definition + (Decl, Iir_Predefined_Ieee_1164_Scalar_Not); + elsif Is_Vector_Vector_Function (Decl) then + declare + Predefined : Iir_Predefined_Functions; + begin + case Get_Identifier (Decl) is + when Name_And => + Predefined := Iir_Predefined_Ieee_1164_Vector_And; + when Name_Nand => + Predefined := Iir_Predefined_Ieee_1164_Vector_Nand; + when Name_Or => + Predefined := Iir_Predefined_Ieee_1164_Vector_Or; + when Name_Nor => + Predefined := Iir_Predefined_Ieee_1164_Vector_Nor; + when Name_Xor => + Predefined := Iir_Predefined_Ieee_1164_Vector_Xor; + when Name_Xnor => + Predefined := Iir_Predefined_Ieee_1164_Vector_Xnor; + when others => + Predefined := Iir_Predefined_None; + end case; + Set_Implicit_Definition (Decl, Predefined); + end; + elsif Is_Vector_Function (Decl) + and then Get_Identifier (Decl) = Name_Not + then + Set_Implicit_Definition + (Decl, Iir_Predefined_Ieee_1164_Vector_Not); end if; end if; end loop; |