Subversion Repositories pentevo

Rev

Blame | Last modification | View Log | Download | RSS feed | ?url?

  1. // (c) NedoPC 2010
  2. //
  3. // wait generator for Z80
  4.  
  5. `include "../include/tune.v"
  6.  
  7.  
  8. module zwait(
  9.  
  10.         input  wire rst_n,
  11.  
  12.         input  wire wait_start_gluclock,
  13.         input  wire wait_start_comport,
  14.  
  15.         input  wire wait_end,
  16.  
  17.  
  18.         output reg  [6:0] waits,
  19.  
  20.         output wire wait_n,
  21.         output wire spiint_n
  22. );
  23.  
  24.  
  25. `ifdef SIMULATE
  26.         initial
  27.         begin
  28.                 force waits = 7'd0;
  29.         end
  30. `endif
  31.  
  32.  
  33.         wire wait_off_n;
  34.         assign wait_off_n = (~wait_end) & rst_n;
  35.  
  36.         // RS-flipflops
  37.         //
  38.         always @(posedge wait_start_gluclock, negedge wait_off_n)
  39.         if( !wait_off_n )
  40.                 waits[0] <= 1'b0;
  41.         else if( wait_start_gluclock )
  42.                 waits[0] <= 1'b1;
  43.         //
  44.         always @(posedge wait_start_comport, negedge wait_off_n)
  45.         if( !wait_off_n )
  46.                 waits[1] <= 1'b0;
  47.         else if( wait_start_comport )
  48.                 waits[1] <= 1'b1;
  49.  
  50.  
  51.         always @(posedge wait_end) // just dummy for future extensions
  52.         begin
  53.                 waits[6:2] <= 5'd0;
  54.         end
  55.  
  56.  
  57.  
  58.         assign spiint_n = ~|waits;
  59.         assign wait_n = spiint_n ? 1'bZ : 1'b0;
  60.  
  61. endmodule
  62.  
  63.