Subversion Repositories pentevo

Rev

Rev 425 | Blame | Compare with Previous | 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.                 waits <= 7'd0;
  30.         end
  31. `endif
  32.  
  33.  
  34.         wire wait_off_n;
  35.         assign wait_off_n = (~wait_end) & rst_n;
  36.  
  37.         // RS-flipflops
  38.         //
  39.         always @(posedge wait_start_gluclock, negedge wait_off_n)
  40.         if( !wait_off_n )
  41.                 waits[0] <= 1'b0;
  42.         else if( wait_start_gluclock )
  43.                 waits[0] <= 1'b1;
  44.         //
  45.         always @(posedge wait_start_comport, negedge wait_off_n)
  46.         if( !wait_off_n )
  47.                 waits[1] <= 1'b0;
  48.         else if( wait_start_comport )
  49.                 waits[1] <= 1'b1;
  50.  
  51.  
  52.         always @(posedge wait_end) // just dummy for future extensions
  53.         begin
  54.                 waits[6:2] <= 5'd0;
  55.         end
  56.  
  57.  
  58.  
  59.         assign spiint_n = ~|waits;
  60. `ifndef SIMULATE
  61.         assign wait_n = spiint_n ? 1'bZ : 1'b0;
  62. `else
  63.         assign wait_n = 1'bZ;
  64. `endif
  65.  
  66. endmodule
  67.  
  68.