home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / vhdl / 609 < prev    next >
Encoding:
Text File  |  1992-12-22  |  3.8 KB  |  154 lines

  1. Newsgroups: comp.lang.vhdl
  2. Path: sparky!uunet!clsi!kevin
  3. From: kevin@clsi.COM (Kevin Cameron)
  4. Subject: Re: wire primitives in VHDL
  5. Message-ID: <1992Dec23.013559.10564@clsi.COM>
  6. Originator: kevin@dubhe
  7. Sender: usenet@clsi.COM
  8. Reply-To: kevin@clsi.com
  9. Organization: CAD Language Systems Inc.
  10. References:  <1992Dec22.014551.24293@ole.cdac.com>
  11. Date: Wed, 23 Dec 92 01:35:59 GMT
  12. Lines: 140
  13.  
  14.  
  15. In article <1992Dec22.014551.24293@ole.cdac.com>, george@ole.cdac.com (George Lippincott) writes:
  16. > I am trying to figure out a way in VHDL to merge two bidirectional
  17. > signals into one signal.  This is something that most of the major
  18. > logic simulators let you do but which as far as I can tell is
  19. > impossible in VHDL. 
  20. > This situation comes up when an entity is implemented in such a way 
  21. > that two bidirectional ports connect to the same signal.  What I
  22. > would like to do is have some way to "short" these two signals together.
  23. > Ideally the resolution function would see all of the drivers for
  24. > both signals and calculate a value for both nets.
  25. > This can be done in Verilog like this:
  26. >         module wire(w,w)
  27. >         inout w;
  28. >         endmodule;
  29. > I haven't been able to figure out a way to do the same thing in VHDL.
  30. > If I use the code:
  31. >         a <= b;
  32. >         b <= a;
  33. > Then a driver is added to both signals and the value gets stuck at 'U'
  34. > due to the nature of the resolution function in the IEEE 1167 package.
  35. > Does anyone have any idea on how to work around this?
  36.  
  37. I ran off the following VHDL for joining two "std_logic" resolved signals (hope
  38. you find it some help - N.B. 'U' is sometimes mapped to 'Z' and intermediate
  39. values appear in some deltas):
  40.  
  41. -- begin
  42.  
  43. library ieee;
  44.  
  45. use ieee.std_logic_1164.all;
  46.  
  47. architecture a of wire is
  48. begin
  49.  
  50.     process
  51.         variable res: std_ulogic_vector(1 to 2);
  52.     variable drv: std_logic;
  53.     begin
  54.  
  55.          w2 <= 'Z';
  56.         w1 <= 'Z';
  57.     
  58.     wait for 0nS;
  59.  
  60.     if w1 = 'U' then
  61.         drv    := w2;
  62.         elsif w2 = 'U' then
  63.         drv    := w1;
  64.     else
  65.         res(1) := w1;
  66.         res(2) := w2;
  67.             drv    := resolved(res);
  68.     end if;
  69.     
  70.     if w1 = drv and w2 /= drv then
  71.         w2 <= drv;
  72.     end if;
  73.     
  74.         if w2 = drv and w1 /= drv then
  75.         w1 <= drv;
  76.     end if;
  77.     
  78.     wait until w1 /= w2;
  79.  
  80. end process;
  81.     
  82. end;
  83.  
  84. entity test_wire is
  85. end;
  86.  
  87. library ieee;
  88.  
  89. use ieee.std_logic_1164.all;
  90.  
  91. architecture a of test_wire is
  92.     signal a,b: std_logic;
  93.     component wire port (w1,w2: inout std_logic);
  94.     end component;
  95. begin
  96.  
  97.     w1: wire port map (a,b);
  98.     
  99.     a <=    '1' after 1ns, 
  100.                  'L' after 2ns, 
  101.               'Z' after 3ns,
  102.                        'H' after 14ns,
  103.                           'Z' after 15ns;
  104.     
  105.     b <= 'Z',              'H' after 4ns, 
  106.                                'Z' after 7ns,
  107.                        'U' after 12ns,
  108.                        'H' after 14ns,
  109.                           'Z' after 15ns;
  110.     
  111. end;
  112.  
  113. -- end
  114.  
  115. which gives:
  116.  
  117.       Time(fs) + Cycle     a    b 
  118. ----------------------  ---- ---- 
  119.                   0+ 0:  'U'  'U' 
  120.                   0+ 1: *'U' *'Z' 
  121.                   0+ 2: *'U'  'Z' 
  122.             1000000+ 0: *'1'  'Z' 
  123.             1000000+ 1: *'1' *'Z' 
  124.             1000000+ 2:  '1' *'1' 
  125.             2000000+ 0: *'L'  '1' 
  126.             2000000+ 1: *'L' *'Z' 
  127.             2000000+ 2:  'L' *'L' 
  128.             3000000+ 0: *'Z'  'L' 
  129.             3000000+ 1: *'Z' *'Z' 
  130.             4000000+ 0:  'Z' *'H' 
  131.             4000000+ 1: *'Z' *'H' 
  132.             4000000+ 2: *'H'  'H' 
  133.             7000000+ 0:  'H' *'Z' 
  134.             7000000+ 1: *'Z' *'Z' 
  135.            12000000+ 0:  'Z' *'U' 
  136.            12000000+ 1: *'Z' *'U' 
  137.            12000000+ 2:  'Z' *'U' 
  138.            14000000+ 0: *'H' *'H' 
  139.            15000000+ 0: *'Z' *'Z' 
  140.  
  141. Kev.
  142. -- 
  143. Kevin Cameron          CLSI, Suite 100, 5457 Twin Knolls Rd., MD 21045, USA
  144. kevin@clsi.com         Tel: (USA) (410) 992 5700 (- 5709) x224
  145. uunet!clsi.com!kevin   Fax:       (410) 992 3536
  146. -----------------------------------------------------------------------------
  147.