daily pastebin goal
88%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 43 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1.  
  2. //zaddom2
  3. module fpga2018a (CLOCK_27, VGA_HS, VGA_VS, VGA_R, VGA_B, VGA_G);
  4. output reg VGA_HS;
  5. output reg VGA_VS;
  6. output reg [9:0] VGA_R;
  7. output reg [9:0] VGA_G;
  8. output reg [9:0] VGA_B;
  9. input [1:0] CLOCK_27;
  10.  
  11. parameter FRONT_PORCH_A = 16;
  12. parameter SYNC_PULSE_B = 96;
  13. parameter BACK_PORCH_C = 48;
  14. parameter ACTIVE_VIDEO_D = 640;
  15.  
  16. parameter V_FRONT_PORCH_A = 10;
  17. parameter V_SYNC_PULSE_B = 2;
  18. parameter V_BACK_PORCH_C = 33;
  19. parameter V_ACTIVE_VIDEO_D = 480;
  20.  
  21. wire VGA_CLK;
  22. a u0 (
  23.         .clk_res_reset (0), // clk_res.reset
  24.         .clk_out_clk   (VGA_CLK),   // clk_out.clk
  25.         .clk_in_clk    (CLOCK_27)     //  clk_in.clk
  26. );
  27.  
  28. reg [9:0] HS_count;
  29. //HS signal generator
  30. always @(posedge VGA_CLK)
  31. begin
  32.  if (HS_count < FRONT_PORCH_A + SYNC_PULSE_B + BACK_PORCH_C + ACTIVE_VIDEO_D)
  33.  HS_count <= HS_count + 1;
  34.  else
  35.  HS_count <= 0;
  36.  
  37.  if (HS_count < SYNC_PULSE_B)
  38.  VGA_HS <= 0;
  39.  else
  40.  VGA_HS <= 1;
  41. end
  42.  
  43. reg [9:0] VS_count;
  44. //HS signal generator
  45. always @(posedge VGA_CLK)
  46. begin
  47.  if (HS_count==0)
  48.  begin
  49.  if (VS_count < V_FRONT_PORCH_A + V_SYNC_PULSE_B + V_BACK_PORCH_C + V_ACTIVE_VIDEO_D)
  50.  VS_count <= VS_count +1;
  51.  else
  52.  VS_count <= 0;
  53.  
  54.  if (VS_count < V_SYNC_PULSE_B)
  55.  VGA_VS <= 0;
  56.  else
  57.  VGA_VS <=1;
  58.  end
  59. end
  60.  
  61.  wire IS_VGA_DISPLAY;
  62.  assign IS_VGA_DISPLAY = ((HS_count >= BACK_PORCH_C + SYNC_PULSE_B && HS_count <= BACK_PORCH_C + SYNC_PULSE_B +
  63.  ACTIVE_VIDEO_D && VS_count >= V_BACK_PORCH_C + V_SYNC_PULSE_B && VS_count <= V_BACK_PORCH_C + V_SYNC_PULSE_B + V_ACTIVE_VIDEO_D));
  64.  
  65.  wire [9:0] pos_x, pos_y;
  66.  assign pos_x = HS_count - (BACK_PORCH_C + SYNC_PULSE_B);
  67.  assign pos_y = VS_count - (V_BACK_PORCH_C + V_SYNC_PULSE_B);
  68.  
  69.  always
  70.  begin
  71.     if (IS_VGA_DISPLAY)
  72.         begin
  73.             if ( (pos_y >= (240/215)*pos_x) && pos_y <= 240 && pos_x >=0 && pos_x <= 240)
  74.                 begin
  75.                     VGA_R = 0;
  76.                     VGA_G = 7;
  77.                     VGA_B = 1;
  78.                 end
  79.             else if ( pos_y > 240 && (pos_y <= ((-1)*((240/215)*pos_x)+480)) && pos_x >=0 && pos_x <= 240 )
  80.                 begin
  81.                     VGA_R = 0;
  82.                     VGA_G = 7;
  83.                     VGA_B = 1;
  84.                 end
  85.             else if (pos_x >= 0 && pos_x <= 640 && pos_y >= 0 && pos_y < 160)
  86.                 begin
  87.                     VGA_R = 220;
  88.                     VGA_G = 16;
  89.                     VGA_B = 52;
  90.                 end
  91.             else if (pos_x >= 0 && pos_x <= 640 && pos_y >= 160 && pos_y < 320)
  92.                 begin
  93.                     VGA_R = 255;
  94.                     VGA_G = 255;
  95.                     VGA_B = 255;
  96.                 end
  97.             else if (pos_x >= 0 && pos_x <= 640 && pos_y >= 320 && pos_y <= 480)
  98.                 begin
  99.                     VGA_R = 0;
  100.                     VGA_G = 0;
  101.                     VGA_B = 0;
  102.                 end
  103.             else
  104.             begin
  105.                 VGA_B = 0;
  106.                 VGA_G = 0;
  107.                 VGA_R = 0;
  108.             end
  109.            
  110.         end
  111.  end
  112.      
  113. endmodule
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top