home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / verilog / 482 < prev    next >
Encoding:
Text File  |  1992-12-21  |  2.3 KB  |  70 lines

  1. Path: sparky!uunet!news.tek.com!tekig7!tekeda!cliffc
  2. From: cliffc@tekeda.PEN.TEK.COM (Clifford E Cummings)
  3. Newsgroups: comp.lang.verilog
  4. Subject: Re: execution of always blocks
  5. Message-ID: <8021@tekig7.PEN.TEK.COM>
  6. Date: 18 Dec 92 23:57:08 GMT
  7. References: <13665@optilink.COM> <1992Dec18.174451.11544@newsgate.sps.mot.com> <1992Dec18.200153.25828@twisto.eng.hou.compaq.com>
  8. Sender: news@tekig7.PEN.TEK.COM
  9. Organization: Tektronix, Inc., Beaverton,  OR.
  10. Lines: 58
  11.  
  12. In article <1992Dec18.200153.25828@twisto.eng.hou.compaq.com> ehlers@tiktok.eng.hou.compaq.com (Steve Ehlers) writes:
  13. >In article <1992Dec18.174451.11544@newsgate.sps.mot.com> rajesh@chdasic.sps.mot.com writes:
  14. >>manley@optilink.COM (Terry Manley) writes:
  15. >>
  16. >>> always @(posedge Clk) c = b;
  17. >>> always @(posedge Clk) b = a;
  18. >>
  19. >>If you have to use two always blocks, you could put
  20. >>a #0 delay before the procedural assignment that you want
  21. >>done last. That will make VerilogXL schedule that event
  22. >>for processing at the end of that timestamp.
  23. >
  24. >Which is fine if you only care about which ONE is last.  If you have 
  25. >three (or more) registers, you'll still have problems.  Using the
  26. >non-blocking assignment operator ( <= ) will give you the behavior you want:
  27. >
  28. > always @(posedge Clk) c <= b;
  29. > always @(posedge Clk) b <= a;
  30.  
  31. Intra-assignment timing provides another alternative
  32. (The following example can be run as is).
  33.  
  34. /* Example of "intra-assignment" timing control across */
  35. /* procedural blocks. Placing timing control on the    */
  36. /* right-hand side (RHS) of the "=" causes temporary   */
  37. /* storage of the RHS variable, and schedules future   */
  38. /* assignment using the stored RHS value.              */
  39. /*                                                     */
  40. /* Cliff Cummings - 12/18/92                           */
  41.  
  42. `timescale 1ns /100ps
  43. module Qintra;
  44.   reg [3:0] a, b;
  45.   reg clk;
  46.  
  47.   // Wait 1 time unit to allow initial assignment of "b"
  48.   always #1 a = @(posedge clk) b;
  49.  
  50.   // Wait 1 time unit to allow initial assignment of "a"
  51.   always #1 b = @(posedge clk) a;
  52.  
  53.   initial begin
  54.       clk = 0;
  55.       forever #10 clk = ~clk;
  56.     end
  57.  
  58.   initial begin
  59.       $timeformat(-9, 2, "ns", 10);
  60.       #1 $monitor($time, ": a = %h,  b = %h", a, b);
  61.     end
  62.  
  63.   initial begin
  64.       a=4'h5; b=4'ha;
  65.       #100 $stop;
  66.       #100 $finish;
  67.     end
  68.       
  69. endmodule
  70.