Advertisement
Guest User

Untitled

a guest
Mar 7th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Horizontal counter
  2. always @(posedge pclk or posedge rst)
  3. if (rst)
  4.     hcount <= 0;
  5. else
  6.    begin
  7.        if (hcount == HorTotalTime - 1)
  8.         hcount <= 0;
  9.        else
  10.         hcount <= hcount + 1;
  11.        end
  12.  
  13. //Vertical counter
  14. always @(posedge pclk or posedge rst)
  15. if (rst)
  16.     hcount <= 0;
  17. else
  18.    begin
  19.     if (hcount == HorTotalTime - 1)
  20.         begin
  21.             if (vcount == VerTotalTime - 1)
  22.                 vcount <= 0;
  23.             else
  24.                 vcount <= vcount +1;
  25.         end
  26.    end
  27.  
  28. always @(posedge pclk or posedge rst)
  29.     if (rst) begin
  30.         hsync <= 0;
  31.         vsync <= 0;
  32.         hblnk <= 0;
  33.         vblnk <= 0;
  34.     end
  35.    
  36.     else begin
  37.    
  38.     if (hcount >= HorSyncStart && hcount <= (HorSyncStart + HorTimeWidth)) begin
  39.         hsync = 1;
  40.     end
  41.     else begin
  42.         hsync = 0;
  43.     end
  44.    
  45.     if (vcount >= VerSyncStart && vcount <= (VerSyncStart + VerTimeWidth)) begin
  46.         vsync = 1;
  47.     end
  48.     else begin
  49.         vsync = 0;
  50.     end
  51.    
  52.     if (hcount >= HorTimeToDisplay) begin
  53.         hblnk = 1;
  54.     end
  55.     else begin
  56.         hblnk = 0;
  57.     end
  58.    
  59.     if (vcount >= VerTimeToDisplay) begin
  60.         vblnk = 1;
  61.     end
  62.     else begin
  63.         vblnk = 0;
  64.     end
  65.    
  66.     end
  67.  
  68. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement