Guest User

Untitled

a guest
Sep 15th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module hvsync_generator(clk, vga_h_sync, vga_v_sync, inDisplayArea, CounterX, CounterY);
  2. input clk;
  3. output vga_h_sync, vga_v_sync;
  4. output inDisplayArea;
  5. output [9:0] CounterX;
  6. output [8:0] CounterY;
  7.  
  8. //////////////////////////////////////////////////
  9. reg [9:0] CounterX;
  10. reg [8:0] CounterY;
  11. wire CounterXmaxed = (CounterX==10'h2FF);
  12.  
  13. always @(posedge clk)
  14. if(CounterXmaxed)
  15.     CounterX <= 0;
  16. else
  17.     CounterX <= CounterX + 1;
  18.  
  19. always @(posedge clk)
  20. if(CounterXmaxed) CounterY <= CounterY + 1;
  21.  
  22. reg vga_HS, vga_VS;
  23. always @(posedge clk)
  24. begin
  25.     vga_HS <= (CounterX[9:4]==6'h2D); // change this value to move the display horizontally
  26.     vga_VS <= (CounterY==500); // change this value to move the display vertically
  27. end
  28.  
  29. reg inDisplayArea;
  30. always @(posedge clk)
  31. if(inDisplayArea==0)
  32.     inDisplayArea <= (CounterXmaxed) && (CounterY<480);
  33. else
  34.     inDisplayArea <= !(CounterX==639);
  35.    
  36. assign vga_h_sync = ~vga_HS;
  37. assign vga_v_sync = ~vga_VS;
  38.  
  39. endmodule
Add Comment
Please, Sign In to add comment