Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. `timescale 1ns / 1ps
  2. //////////////////////////////////////////////////////////////////////////////////
  3. // Company:
  4. // Engineer:
  5. //
  6. // Create Date: 13.11.2019 14:08:22
  7. // Design Name:
  8. // Module Name: vga_out
  9. // Project Name:
  10. // Target Devices:
  11. // Tool Versions:
  12. // Description:
  13. //
  14. // Dependencies:
  15. //
  16. // Revision:
  17. // Revision 0.01 - File Created
  18. // Additional Comments:
  19. //
  20. //////////////////////////////////////////////////////////////////////////////////
  21.  
  22.  
  23. module vga_out(
  24. input clk, reset,
  25. output [3:0] pix_r,
  26. output [3:0] pix_g,
  27. output [3:0] pix_b,
  28. output hsync,
  29. output vsync
  30. );
  31.  
  32. reg [10:0] hcount = 11'd300;
  33. reg [9:0] vcount = 10'd50;
  34.  
  35. //outputs
  36. assign hsync = (hcount < 152 ) ? 1'b0:1'b1;
  37. assign vsync = (vcount < 3 ) ? 1'b1:1'b0;
  38.  
  39.  
  40. //colours
  41. assign pix_r = (hcount < 1824 && hcount > 383 && vcount < 931 && vcount > 30) ? 4'hF:4'h0;
  42. assign pix_g = (hcount < 1824 && hcount > 383 && vcount < 931 && vcount > 30) ? 4'hF:4'h0;
  43. assign pix_b = (hcount < 1824 && hcount > 383 && vcount < 931 && vcount > 30) ? 4'hF:4'h0;
  44.  
  45. //assign pix_r = 4'hF;
  46. //assign pix_g = 4'hF;
  47. //assign pix_b = 4'hF;
  48.  
  49.  
  50. always @(posedge clk)
  51. begin
  52. if (reset) begin
  53. hcount <= 0;
  54. vcount <= 0;
  55. end
  56. if(hcount == 1903) begin
  57. hcount <= 0;
  58. vcount <= vcount +1;
  59. end
  60. else
  61. hcount <= hcount +1;
  62. if(vcount == 931)
  63. vcount <= 0;
  64. end
  65.  
  66.  
  67.  
  68. endmodule
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79. `timescale 1ns / 1ps
  80. //////////////////////////////////////////////////////////////////////////////////
  81. // Company:
  82. // Engineer:
  83. //
  84. // Create Date: 13.11.2019 15:47:44
  85. // Design Name:
  86. // Module Name: vga_tb
  87. // Project Name:
  88. // Target Devices:
  89. // Tool Versions:
  90. // Description:
  91. //
  92. // Dependencies:
  93. //
  94. // Revision:
  95. // Revision 0.01 - File Created
  96. // Additional Comments:
  97. //
  98.  
  99. module vga_tb();
  100. reg clk = 0;
  101. wire hsync, vsync;
  102. wire [3:0] pix_r;
  103. wire [3:0] pix_g;
  104. wire [3:0] pix_b;
  105. reg [10:0] hcount;
  106. reg [9:0] vcount;
  107.  
  108. vga_out uut (.pix_r(pix_r), .pix_g(pix_g), .pix_b(pix_b), .hsync(hsync), .vsync(vsync)/*, .hcount(hcount), .vcount(vcount)*/);
  109.  
  110.  
  111. always #5 clk = ~clk;
  112. initial begin
  113. /*
  114. $display("hcount: %d", hcount);
  115. $display("vcount: %d", vcount);
  116.  
  117. #5 assign pix_r = 4'hF;
  118. #5 assign pix_g = 4'hF;
  119. #5 assign pix_b = 4'hF;
  120. */
  121. //$finish;
  122. end
  123.  
  124.  
  125.  
  126. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement