From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c7ea1cb7a2beb2ee X-Google-Attributes: gid103376,public From: Charles Hixson Subject: Re: Disallowing Pre-Defined Operations Date: 2000/03/17 Message-ID: <38D2ACA9.84FBD9F6@earthlink.net>#1/1 X-Deja-AN: 598931861 Content-Transfer-Encoding: 7bit References: <8a9eeg$qtv$1@newpoisson.nosc.mil> <8ababr$c3u$1@wanadoo.fr><8afhed$f9v$1@newpoisson.nosc.mil> <8aoifb$49f$1@newpoisson.nosc.mil> <38D001D7.4D6E4284@averstar.com> <38D013EF.1F431E34@cadence.com> <38D15537.B06CA311@earthlink.net> <38D2A073.A30FF041@cadence.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 953330867 198.94.156.19 (Fri, 17 Mar 2000 14:07:47 PST) Organization: EarthLink Inc. -- http://www.EarthLink.net MIME-Version: 1.0 NNTP-Posting-Date: Fri, 17 Mar 2000 14:07:47 PST Newsgroups: comp.lang.ada Date: 2000-03-17T00:00:00+00:00 List-Id: Paul Graham wrote: > Charles Hixson wrote: > > > > Re: Units: > > mks? cgs? or English System? (And is a gallon an Imperial Gallon or a US > > gallon?) Are angles measures in degrees, radians, or mils? (etc.) > > VHDL has a syntax for defining units for a given physical type. For > instance: > > type distance is range integer'left to integer'right > units angstrom; > nm = 10 angstrom; > mm = 1000_000 nm; > inch = 25 mm; > end units; > > Internally a value of a physical type is represented in terms of its > base unit, in this case angstroms. This representation is obtained from > the 'pos attribute. To convert from one unit to another (e.g., for > display purposes) you can do: > > variable d : distance; -- vhdl declaration syntax > variable d_inches : integer; > variable d_mm : integer; > > d_inches := distance'pos(d) / distance'pos(1 inch); > d_mm := distance'pos(d) / distance'pos(1 mm); > > It's also possible to combine different units of the same type: > > d := 3 mm + 4 inch + 2 angstrom; > > Paul That would have saved at least one space probe. (By that here I mean the automatic conversion of units.)