home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / verilog / 331 < prev    next >
Encoding:
Text File  |  1992-09-01  |  2.1 KB  |  69 lines

  1. Newsgroups: comp.lang.verilog
  2. Path: sparky!uunet!Cadence.COM!acae037!eversole
  3. From: eversole@acae037.cadence.com (Richard Eversole; x6239)
  4. Subject: Re: readmem
  5. Message-ID: <1992Aug31.133512.22582@Cadence.COM>
  6. Sender: usenet@Cadence.COM (Usenet News)
  7. Nntp-Posting-Host: acae037
  8. Reply-To: eversole@acae037.cadence.com (Richard Eversole; x6239)
  9. Organization: Cadence Design Systems, Inc.
  10. References: <4006@rbiffm.informatik.uni-frankfurt.de> <ovs5imk@fido.asd.sgi.com>
  11. Date: Mon, 31 Aug 1992 13:35:12 GMT
  12. Lines: 55
  13.  
  14. In article <ovs5imk@fido.asd.sgi.com>, williams@agomoda.asd.sgi.com (Eric Williams) writes:
  15. |> In <4006@rbiffm.informatik.uni-frankfurt.de> justin@rbiffm.informatik.uni-frankfurt.de (Justin Strohschneider) writes:
  16. |> 
  17. |> >For the simulation of a computer architecture it is necessary for me to
  18. |> >define a RAM as a module and to have several incarnations of this RAM with
  19. |> >different contents.
  20. |> >The $readmem system task can be used to fill a memory array with data.
  21. |> >The problem I have is to realize different filenames in the $readmem task.
  22. |> >I would be very glad if anybody could give me some information concerning
  23. |> >this problem.
  24. |> 
  25. |> Two ways you could do this.  The first method simply does the readmemh from
  26. |> the module that instantiates the memories.  It sounds like you're trying to
  27. |> put the readmem in the module that contains the memory.  In this case try
  28. |> method 2 which passes this filename into the module as an input.
  29. |> 
  30. |> -Eric Williams
  31.  
  32.  
  33. Another alternative (and prefered over second option shown by Eric is
  34. to use the parameter construct. There are two ways to use this:
  35. override with defparam and module parameter value assignment.
  36. Both are shown in the following simple example. Note I only use
  37. a $display but it could be $readmemh or whatever.
  38.  
  39.  
  40. module test;
  41.  
  42. wire A;
  43.  
  44. memmod #("FILEA") U1(A); // Parameter Value Assignment
  45.  
  46. defparam U2.FOO = "BAR";
  47. memmod U2(A);
  48.  
  49. endmodule
  50.  
  51. module memmod(A);
  52. input A;
  53.  
  54. parameter FOO = "";
  55.  
  56. initial
  57.  $display("%s",FOO);
  58. endmodule
  59.  
  60.  
  61. -- 
  62.   
  63.   =====================================================================
  64.  
  65.     eversole@cadence.com
  66.   
  67.     Live long and prosper !
  68.  
  69.