VHDL Issue Number: 2031 Language_Version: VHDL-2002 Classification: Language Modeling Enhancement or Deficiency Summary: "mod" function needed for TIME Relevant_LRM_Sections: 7.2.4 Multiplying Operators Proposed_Resolution: Add predefined functions "mod" and/or "rem" for physical types. Related_Issues: Key_Words_and_Phrases: Authors_Name: Chuck Swart Authors_Phone_Number: 503.685.0846 Authors_Fax_Number: 503.685.0921 Authors_Email_Address: cswart@model.com Authors_Affiliation: Model Technology Authors_Address1: 8005 SW Boeckman Road Authors_Address2: Wilsonville, OR 97070 Authors_Address3: Current Status: VASG-Approved Superseded By: ------------------------ Date Submitted: 24 September 2003 Date Analyzed: 12 August 2004 Author of Analysis: Deepak Pant Revision Number: 05 Date Last Revised: 15 November 2005 Description of Problem ---------------------- For designs involving cyclic behavior, a "mod" or "rem" function for type time would be very useful. Such a function cannot be easily written in VHDL because representations of type time are usually larger than those of type INTEGER so the conversion from TIME to INTEGER causes loss of data. However, it should not be particularly difficult to support these functions within a VHDL implementation. Proposed Resolution ------------------- Add predefined functions "mod" and/or "rem" for physical types. VASG-ISAC Analysis & Rationale ------------------------------ This is a useful request. Multiplying operators already exist for physical types and hence supporting mod & rem as builtin operators for physical types should be possible. VASG-ISAC Recommendation for IEEE Std 1076-2002 ----------------------------------------------- No change. VASG-ISAC Recommendation for Future Revisions --------------------------------------------- Section 7.2.6 of the 2002 LRM will need to be updated: a) The statement "the operators mod and rem are predefined for any integer type" should be changed to "the operators mod and rem are predefined for any integer type and any physical type". b) The following two rows should be added to the second table in this section: Operator|Operation |Left operand |Right operand| Result type | | | type | type | | ------------------------------------------------------------- mod | Modulus |Any physical | Same type | Same type | | | type | | | ------------------------------------------------------------- rem | Remainder|Any physical | Same type | Same type | | | type | | | ------------------------------------------------------------- c) The following text should be added after the definition of the division operation for physical types: For two operands A and B, where A is an object of physical type Tp and has a value P1 and B is an object of the same type with value P2, the predefined remainder and the modulus operations are defined as: 1. The remainder operation (A rem B) is defined as: Tp'Val(Tp'Pos(P1) rem Tp'Pos(P2) ) This operation should satisfy the following relation: A = Tp'Val((A/B)*Tp'Pos(P2)) + (A rem B) 2. The modulus operation (A mod B) is defined as: Tp'Val(Tp'Pos(P1) mod Tp'Pos(P2)) This operation must satisfy the following relation for some integer value N: A = B * N + (A mod B) c) The following examples should be added to the list of examples at the end of the section: 5 ns rem 3 ns = 2 ns 5 ns mod 3 ns = 2 ns 5 ns mod 3 ps = 2 ps (-5 ns) rem 3 ns = -2 ns (-5 ns) mod 3 ns = 1 ns -------------END OF IR----------------