Subversion Repositories pentevo

Rev

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

  1. // just an example with frequencies. not to be used!
  2.  
  3. // Copyright 2007 Altera Corporation. All rights reserved.
  4. // Altera products are protected under numerous U.S. and foreign patents,
  5. // maskwork rights, copyrights and other intellectual property laws.
  6. //
  7. // This reference design file, and your use thereof, is subject to and governed
  8. // by the terms and conditions of the applicable Altera Reference Design
  9. // License Agreement (either as signed by you or found at www.altera.com).  By
  10. // using this reference design file, you indicate your acceptance of such terms
  11. // and conditions between you and Altera Corporation.  In the event that you do
  12. // not agree with such terms and conditions, you may not use the reference
  13. // design file and please promptly destroy any copies you have made.
  14. //
  15. // This reference design file is being provided on an "as-is" basis and as an
  16. // accommodation and therefore all warranties, representations or guarantees of
  17. // any kind (whether express, implied or statutory) including, without
  18. // limitation, warranties of merchantability, non-infringement, or fitness for
  19. // a particular purpose, are specifically disclaimed.  By making this reference
  20. // design file available, Altera expressly does not recommend, suggest or
  21. // require that this reference design file be used in combination with any
  22. // other product not provided by Altera.
  23. /////////////////////////////////////////////////////////////////////////////
  24.  
  25. // baeckler - 02-15-2007
  26.  
  27. module  vga_driver      (
  28.                 r,g,b,
  29.                 current_x,current_y,request,
  30.                 vga_r,vga_g,vga_b,vga_hs,vga_vs,vga_blank,vga_clock,
  31.                 clk27,rst27);
  32.  
  33. input [9:0]     r,g,b;
  34. output [9:0] current_x;
  35. output [9:0] current_y;
  36. output request;
  37.  
  38. output [9:0] vga_r, vga_g, vga_b;
  39. output vga_hs, vga_vs, vga_blank, vga_clock;
  40.  
  41. input clk27, rst27;
  42.  
  43. ////////////////////////////////////////////////////////////
  44.  
  45. //      Horizontal      Timing
  46. parameter       H_FRONT =       16; // 600ns
  47. parameter       H_SYNC  =       96; // 3.5us
  48. parameter       H_BACK  =       48; // 1.8us
  49. parameter       H_ACT   =       640;//
  50. parameter       H_BLANK =       H_FRONT+H_SYNC+H_BACK;
  51. parameter       H_TOTAL =       H_FRONT+H_SYNC+H_BACK+H_ACT;
  52.  
  53. //      Vertical Timing
  54. parameter       V_FRONT =       11;
  55. parameter       V_SYNC  =       2;
  56. parameter       V_BACK  =       31;
  57. parameter       V_ACT   =       480;
  58. parameter       V_BLANK =       V_FRONT+V_SYNC+V_BACK;
  59. parameter       V_TOTAL =       V_FRONT+V_SYNC+V_BACK+V_ACT;
  60.  
  61. ////////////////////////////////////////////////////////////
  62.  
  63. reg [9:0] h_cntr, v_cntr, current_x, current_y;
  64. reg h_active, v_active, vga_hs, vga_vs;
  65.  
  66. assign  vga_blank = h_active & v_active;
  67. assign  vga_clock = ~clk27;
  68. assign  vga_r = r;
  69. assign  vga_g = g;
  70. assign  vga_b = b;
  71. assign  request = ((h_cntr>=H_BLANK && h_cntr<H_TOTAL)  &&
  72.                                                  (v_cntr>=V_BLANK && v_cntr<V_TOTAL));
  73.  
  74. always @(posedge clk27) begin
  75.         if(rst27) begin
  76.                 h_cntr <= 0;
  77.                 v_cntr <= 0;
  78.                 vga_hs <= 1'b1;
  79.                 vga_vs <= 1'b1;
  80.                 current_x <= 0;
  81.                 current_y <= 0;
  82.                 h_active <= 1'b0;
  83.                 v_active <= 1'b0;
  84.         end
  85.         else begin
  86.                 if(h_cntr != H_TOTAL) begin
  87.                         h_cntr <= h_cntr + 1'b1;
  88.                         if (h_active) current_x <= current_x + 1'b1;
  89.                         if (h_cntr == H_BLANK-1) h_active <= 1'b1;
  90.                 end
  91.                 else begin
  92.                         h_cntr  <= 0;
  93.                         h_active <= 1'b0;
  94.                         current_x <= 0;
  95.                 end
  96.  
  97.                 if(h_cntr == H_FRONT-1) begin
  98.                         vga_hs <= 1'b0;
  99.                 end
  100.  
  101.                 if (h_cntr == H_FRONT+H_SYNC-1) begin
  102.                         vga_hs <= 1'b1;
  103.  
  104.                         if(v_cntr != V_TOTAL) begin
  105.                                 v_cntr <= v_cntr + 1'b1;
  106.                                 if (v_active) current_y <= current_y + 1'b1;
  107.                                 if (v_cntr == V_BLANK-1) v_active <= 1'b1;
  108.                         end
  109.                         else begin
  110.                                 v_cntr <= 0;
  111.                                 current_y <= 0;
  112.                                 v_active <= 1'b0;
  113.                         end
  114.                         if(v_cntr == V_FRONT-1) vga_vs <= 1'b0;
  115.                         if(v_cntr == V_FRONT+V_SYNC-1) vga_vs <= 1'b1;
  116.                 end
  117.         end
  118. end
  119.  
  120. endmodule