home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / vhdl / 622 < prev    next >
Encoding:
Text File  |  1993-01-04  |  1.6 KB  |  50 lines

  1. Newsgroups: comp.lang.vhdl
  2. Path: sparky!uunet!clsi!kevin
  3. From: kevin@clsi.COM (Kevin Cameron)
  4. Subject: Re: data types, vhdl
  5. Message-ID: <1993Jan4.201803.11646@clsi.COM>
  6. Originator: kevin@dubhe
  7. Sender: usenet@clsi.COM
  8. Reply-To: kevin@clsi.com
  9. Organization: CAD Language Systems Inc.
  10. Date: Mon, 4 Jan 93 20:18:03 GMT
  11. Lines: 37
  12.  
  13.  
  14. In article <C08p03.Htv@ucunix.san.uc.edu> you write:
  15. > Hi folks,
  16. > Is there any options in the vhdl language that lets me declare types
  17. > equivalent to the "union" in C. The brute force method that I can think of
  18. > is to declare a record with all the possible choices in the original union
  19. > as a strictly present field; and have integer tags to access the types: 
  20. >     e.g.    -- pseudo vhdl code;
  21. >     type union is record
  22. >         -- the tag to determine what field to use;
  23. >         access_type : integer;
  24. >         -- this is where the union starts
  25. >         -- list is declared earlier as an access type to a list;
  26. >         u1 : real;
  27. >         u2 : integer;
  28. >         u3 : list
  29. >         end record;
  30. > Is there any alternative to this lengthy  way of designing a data structure.
  31. > thanks for any replies and comments.
  32.  
  33. Use one field of a type large enough to store each member of the union, and use
  34. type conversion functions depending on the tag value. This is ineffecient in speed
  35. but more efficient in storage (particularly for signals) - some type conversions
  36. will be difficult too.
  37.  
  38. Kev.
  39. -- 
  40. Kevin Cameron          CLSI, Suite 100, 5457 Twin Knolls Rd., MD 21045, USA
  41. kevin@clsi.com         Tel: (USA) (410) 992 5700 (- 5709) x224
  42. uunet!clsi.com!kevin   Fax:       (410) 992 3536
  43. -----------------------------------------------------------------------------
  44.