Advertisement
Guest User

Untitled

a guest
Feb 27th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Time in horizontal lines
  2.     parameter HorTimeWidth = 10'd128;
  3.     parameter HorFrontPorch = 10'd40;
  4.     parameter HorBackPorch = 10'd88;
  5.     parameter HorTimeToDisplay = 10'd800;
  6.     parameter HorTotalTime = 12'd1056;
  7.     parameter HorSyncStart = 10'd840;
  8.      
  9. //Time in Vertincal lines
  10.     parameter VerTimeWidth = 10'd4;
  11.     parameter VerFrontPorch = 10'd1;      
  12.     parameter VerBackPorch = 10'd23;
  13.     parameter VerTimeToDisplay = 10'd600;
  14.     parameter VerTotalTime = 10'd628;
  15.     parameter VerSyncStart = 10'd601;
  16.    
  17.     parameter initial_borders = 10'b0;
  18.    
  19. //Horizontal counter
  20. always @(posedge pclk or posedge rst)
  21.     if (rst)
  22.         hcount <= initial_borders;
  23.     else
  24.         begin
  25.             if (hcount == HorTotalTime)
  26.                 hcount <= initial_borders;
  27.             else
  28.                 hcount <= hcount + 1;
  29.         end
  30.  
  31. //Vertical counter
  32. always @(posedge pclk or posedge rst)
  33.     if (rst)
  34.         vcount <= initial_borders;
  35.     else begin
  36.         if (hcount == HorTotalTime)
  37.             begin
  38.                 if (vcount == VerTotalTime)
  39.                     vcount <= initial_borders;
  40.                 else
  41.                     vcount <= vcount +1;
  42.             end
  43.     end
  44.  
  45. always @(posedge pclk or posedge rst)
  46.     if (rst)
  47.         begin
  48.             hsync <= initial_borders;
  49.             vsync <= initial_borders;
  50.             vblnk <= initial_borders;
  51.             hblnk <= initial_borders;
  52.         end
  53.        
  54.     else begin
  55.         if (hcount >= HorSyncStart && hcount < HorTotalTime) begin
  56.             hsync <= 1;
  57.                 if (vcount >= VerTimeToDisplay && vcount < VerTotalTime)
  58.                     vblnk <= 1;
  59.                 else
  60.                     vblnk <= 0;
  61.                    
  62.                 if (vcount >= VerSyncStart && vcount < VerTotalTime)
  63.                     vsync <= 1;
  64.                 else
  65.                     vsync <= 0;
  66.         end
  67.         else
  68.             vsync <=0;
  69.                 if (hcount >= HorTimeToDisplay && hcount < HorTotalTime)
  70.                     hblnk <= 1;
  71.                 else
  72.                     hblnk <= 0;
  73.     end
  74. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement