home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / verilog / 504 < prev    next >
Encoding:
Internet Message Format  |  1993-01-21  |  2.1 KB

  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: Verilog code for Inverted, Open collector, Output Enable Bus
  5. Keywords: Inverted, Open collector, Output Enable Bus
  6. Message-ID: <8369@tekig7.PEN.TEK.COM>
  7. Date: 21 Jan 93 20:53:48 GMT
  8. References: <C17p8K.7nA@iphase.com>
  9. Sender: news@tekig7.PEN.TEK.COM
  10. Organization: Tektronix, Inc., Beaverton,  OR.
  11. Lines: 63
  12.  
  13. In article <C17p8K.7nA@iphase.com> phan@iphase.com (Tai Phan) writes:
  14. >If anyone knows a simple way to describe in Verilog an Open collector, 
  15. >Inverted, with Output enable bus, please help.  The parameters are as follow:
  16. >
  17. >// Verilog code
  18. >
  19. >input [31:0] inp;               // Input bus
  20. >input oen_;                     // Output enable
  21. >output [31:0] outp_;            // Output bus
  22. >
  23. >// When oen_ is 1, outp_ should be 32'hzzzzzzzz
  24. >// when oen_ is 0, outp_ is 0 if inp is 1, and z if inp is 0 (OC inverted)
  25. >// For single bit, I have the code that works:
  26. >
  27. >wire [31:0] outp_;
  28. >assign outp_[31] = (~oen_ && inp[31]) ? 'b0 : 'bz;
  29. >assign outp_[30] = (~oen_ && inp[30]) ? 'b0 : 'bz;
  30. >.......
  31. >and so on
  32. >
  33. >Thanks,
  34. >
  35. >Tai Phan
  36. >--------
  37. >Interphase Corp.
  38. >(214) 919 9000
  39. >phan@iphase.com
  40.  
  41. Is this what you are looking for? (this example can be run)
  42.  
  43. `timescale 1ns/100ps
  44. module oc_bus( outp_, inp, oen_);
  45.   // Verilog code
  46.   input [31:0] inp;               // Input bus
  47.   input oen_;                     // Output enable
  48.   output [31:0] outp_;            // Output bus
  49.  
  50.   triand (strong1, highz0) [31:0] outp_ = (~oen_ ? ~inp : 32'bz);
  51.  
  52. endmodule
  53.  
  54. module oc_bus_test;
  55.   reg  [31:0] inbus;
  56.   reg         busen_;
  57.   wire [31:0] outbus;
  58.  
  59.   oc_bus b1( outbus, inbus, busen_);
  60.  
  61.   initial
  62.   $monitor("inbus = %h | busen_ = %h | outbus = %h \n",
  63.       inbus, busen_, outbus,
  64.       "                               (binary)= %b \n", 
  65.       outbus);
  66.  
  67.   initial begin
  68.     #000 inbus = 32'hffff0000; busen_ = 1'b1;
  69.     #100 inbus = 32'h0000ffff; busen_ = 1'b0;
  70.     #100 inbus = 32'h00ff5500; busen_ = 1'b0;
  71.     #100 $finish;
  72.   end
  73. endmodule
  74.  
  75. Regards - Cliff Cummings - cliffc@tekeda.pen.tek.com
  76.