home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / verilog / 417 < prev    next >
Encoding:
Text File  |  1992-11-12  |  3.6 KB  |  100 lines

  1. Newsgroups: comp.lang.verilog
  2. Path: sparky!uunet!wupost!cs.uiuc.edu!m.cs.uiuc.edu!swine.cs.uiuc.edu!hughes
  3. From: hughes@swine.cs.uiuc.edu (Eric Hughes)
  4. Subject: Re: Avoiding inertial delay in delay lines
  5. Message-ID: <1992Nov12.142615.10697@m.cs.uiuc.edu>
  6. Sender: news@m.cs.uiuc.edu (News Database (admin-Mike Schwager))
  7. Organization: University of Illinois, Dept. of Comp. Sci., Urbana, IL
  8. References: <1992Nov12.053306.12799@afterlife.ncsc.mil>
  9. Date: Thu, 12 Nov 1992 14:26:15 GMT
  10. Lines: 88
  11.  
  12. smb@afterlife.ncsc.mil (Steve M. Burinsky) writes:
  13.  
  14. >I need to simulate delay lines in order to model a bus interface.  The
  15. >solution seems obvious --  use a net delay.  However, the signal I need
  16. >to delay has pulse widths (w) which are shorter than the delay time (d);
  17. >that is w < d.  The problem is that inertial delay causes the short pulse
  18. >to disappear within the delay.
  19.  
  20. >So, how should this be implemented?  I have two options, neither of which
  21. >I like:
  22. >1.  Implement the delay line as a string of (for example) 10 buffers, each
  23. >with 10% of the total required delay.  This has drawbacks, as it requires
  24. >that the user know the number of internal sub-delay units in order to
  25. >guarantee acurate delay generation.  Also, (given that 10 buffers are used)
  26. >10w > d is required.
  27. >2.  Implement a PLI routine which calls (for example) tf_strdelputp, which
  28. >allows me to specify transport (versus inertial) delay.
  29.  
  30. >Is there anyway I can choose transport delay using a standard language
  31. >construct?  Is there another (easy, portable, general) way of implementing
  32. >delay lines I'm missing?
  33.  
  34. >Thanks,
  35. >Steve Burinsky
  36. >smb@afterlife.ncsc.mil
  37.  
  38. >-- 
  39.  
  40. >Steve M. Burinsky
  41. >smb@afterlife.ncsc.mil
  42.  
  43. I bumped into this problem a long time ago.  I found that the most flexible
  44. way to solve the problem was to write a module for the delay line.  The model
  45. is truly event-driven, which keeps it from slowing down the simulation too
  46. much.  I've included it below.
  47.  
  48. Good luck,  Eric Hughes
  49. 451 Loomis Lab   1110 W. Green St.   Urbana, IL  61801  USA
  50. hughes@cs.uiuc.edu
  51.  
  52. ------------------------------------------------
  53. module trans_delay(In, Out);
  54.  
  55. parameter qlen = 60;               /* number of transitions to be queued */
  56. parameter delay_time = 960;        /* delay time of pipe */
  57.  
  58. input   In;                        /* input signal */
  59. output  Out;                       /* output signal */
  60. reg     Out;
  61.  
  62. reg     [32:1] times [1:qlen];     /* queue of transition times */
  63. reg     [1:qlen] values;           /* queue of transition values */
  64. integer read_addr;                 /* addresses to read */
  65. integer write_addr;                /*  and write */
  66. reg     q_full;                    /* remember if queue is full */
  67. reg     q_empty;                   /* remember if queue is empty */
  68.  
  69. initial begin
  70.     read_addr = 1;
  71.     write_addr = 1;
  72.     q_full = 0;
  73.     q_empty = 1;
  74.     @(negedge q_empty);
  75.     while (1) begin                /* drive the output */
  76.         #(times[read_addr] - $stime);
  77.         Out = values[read_addr];
  78.         q_full = 0;
  79.         read_addr = read_addr % qlen + 1;
  80.         if (read_addr == write_addr) begin
  81.             q_empty = 1;           /* queue is empty */
  82.             @(negedge q_empty);    /* wait for insertion */
  83.         end /* if */
  84.     end /* while */
  85. end /* initial */
  86.  
  87. always @(In) begin
  88.     if(q_full) $display("Transport queue is full -- make it bigger");
  89.     else begin
  90.         times[write_addr] = $stime + delay_time;
  91.         values[write_addr] = In;
  92.         write_addr = write_addr % qlen + 1;
  93.         if (read_addr == write_addr) q_full = 1;
  94.         q_empty = 0;
  95.     end /* else */
  96. end /* always */
  97.  
  98. endmodule
  99.  
  100.