home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / verilog / 436 < prev    next >
Encoding:
Internet Message Format  |  1992-11-19  |  1.8 KB

  1. Path: sparky!uunet!think.com!unixland!wellspring!elliot
  2. From: elliot@Wellspring.COM (Elliot H. Mednick)
  3. Newsgroups: comp.lang.verilog
  4. Subject: Memory Addressing in verilog
  5. Distribution: world
  6. Message-ID: <722187863snx@Wellspring.COM>
  7. References: <1992Nov18.181933.10242@bcrka451.bnr.ca>
  8. Date: Thu, 19 Nov 92 15:44:23 GMT
  9. Organization: Wellspring Solutions, Sutton, MA.
  10. Reply-To: elliot@Wellspring.COM
  11. Lines: 31
  12.  
  13. In article <1992Nov18.181933.10242@bcrka451.bnr.ca> swood@bnr.ca writes:
  14.  > My question is: does verilog do any bounds checking on index values to register
  15.  >                 arrays or do I have to implement such checks myself?
  16.  
  17. You have to implement the checks yourself.  Note that in RTL coding, you
  18. don't want to do checking unless the hardware you are designing is going to
  19. do range-checking.  In behavioral-level coding, you can do whatever you want.
  20.  
  21. One technique that you ca use is to have a seperate "integrity-check"
  22. module that continually tests things like index ranges and detects
  23. other illegal conditions.  This module would be a 2nd top-level module
  24. (that is, niether of the top-level module instantiate each other) and
  25. reference variables within the simulation model by hierarchical names
  26. so it would be non-intrusive.  This way, you can have an RTL model,
  27. perhaps for synthesis, but with the range checking not part of the
  28. actual RTL model.  For example:
  29.  
  30.  
  31. module integrity;
  32.  
  33. // monitor 'index'
  34. always @(my_module.index)
  35.   if (my_module.index < 0 || my_module.index > `MAX_INDEX)
  36.      $display ("Index out-of-bounds detected at time %t!", $time);
  37. ...
  38. endmodule
  39.  
  40. --
  41. Elliot H. Mednick                                        P.O. Box 150
  42. Wellspring Solutions                                     Sutton, MA. 01590
  43. elliot@Wellspring.com                                    +1 508 865 7271
  44.