Advertisement
AnatolySharapov

vga.svh

Oct 4th, 2021 (edited)
738
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. `ifndef _vga_svh_
  2. `define _vga_svh_
  3.  
  4. // `define RGB
  5. `ifndef RGB
  6.     `define WHITE
  7. `endif
  8.  
  9. // `define VGA640X480
  10. `define VGA1280X1024
  11.  
  12.     `ifdef VGA640X480
  13.    
  14.         // VGA Signal 640 x 480 @ 60 Hz Industry standard timing
  15.         // http://tinyvga.com/vga-timing/640x480@60Hz
  16.    
  17.         // General timing
  18.         // Screen refresh rate  60 Hz
  19.         // Vertical refresh     31.46875 kHz
  20.         // Pixel freq.          25.175 MHz
  21.  
  22.         // Horizontal timing (line)
  23.         // Polarity of horizontal sync pulse is negative.
  24.         // Scanline part Pixels Time [µs]
  25.         // Visible area  640    25.422045680238
  26.         `define VISIBLE_LINE_PXLS 640
  27.        
  28.         // Front porch   16     0.63555114200596
  29.         `define HORIZ_FRONT_PORCH_PXLS 16
  30.         // Sync pulse start = 640 + 16 = 656          
  31.  
  32.         // Sync pulse    96     3.8133068520357
  33.         `define HORIZ_SYNC_PULSE_PXLS 96
  34.         // Sync pulse end = 640 + 16 + 96 = 752        
  35.        
  36.         // Back porch    48     1.9066534260179
  37.         // Whole line    800    31.777557100298
  38.         `define WHOLE_LINE_PXLS 800  
  39.  
  40.         // Vertical timing (frame)
  41.         // Polarity of vertical sync pulse is negative.
  42.         // Frame part    Lines  Time [ms]
  43.         // Visible area  480    15.253227408143
  44.         `define VISIBLE_FRAME_PXLS 480
  45.        
  46.         // Front porch   10     0.31777557100298
  47.         `define VERT_FRONT_PORCH_PXLS 10
  48.         // Sync pulse start = 480 + 10 = 490        
  49.        
  50.         // Sync pulse    2      0.063555114200596
  51.         `define VERT_SYNC_PULSE_PXLS 2        
  52.        
  53.         // Back porch    33     1.0486593843098
  54.         // Sync pulse end = 480 + 10 + 2 = 492        
  55.        
  56.         // Whole frame   525    16.683217477656        
  57.         `define VERT_FRAME_PXLS 525  
  58.  
  59.         // counters dim to hold max of `WHOLE_LINE_PXLS and `VERT_FRAME_PXLS
  60.         `define CNT_WDT 10
  61.        
  62.     `elsif VGA1280X1024
  63.    
  64.         // VESA Signal 1280 x 1024 @ 60 Hz timing
  65.         // http://tinyvga.com/vga-timing/1280x1024@60Hz    
  66.  
  67.         // General timing
  68.         // Screen refresh rate  60 Hz
  69.         // Vertical refresh     63.981042654028 kHz
  70.         // Pixel freq.          108.0 MHz  
  71.    
  72.         // Horizontal timing (line)
  73.         // Polarity of horizontal sync pulse is positive.
  74.         // Scanline part Pixels Time [µs]
  75.         // Visible area  1280   11.851851851852
  76.         `define VISIBLE_LINE_PXLS 1280
  77.        
  78.         // Front porch   48     0.44444444444444
  79.         `define HORIZ_FRONT_PORCH_PXLS 48
  80.  
  81.         // Sync pulse    112        1.037037037037
  82.         `define HORIZ_SYNC_PULSE_PXLS 112
  83.        
  84.         // Back porch    248        2.2962962962963
  85.         // Whole line    1688   15.62962962963
  86.         `define WHOLE_LINE_PXLS 1688  
  87.  
  88.         // Vertical timing (frame)
  89.         // Polarity of vertical sync pulse is positive.
  90.         // Frame part    Lines  Time [ms]
  91.         // Visible area  1024   16.004740740741
  92.         `define VISIBLE_FRAME_PXLS 1024
  93.        
  94.         // Front porch   1      0.01562962962963
  95.         `define VERT_FRONT_PORCH_PXLS 1
  96.        
  97.         // Sync pulse    3      0.046888888888889
  98.         `define VERT_SYNC_PULSE_PXLS 3        
  99.        
  100.         // Back porch    38     0.59392592592593
  101.        
  102.         // Whole frame   1066   16.661185185185        
  103.         `define VERT_FRAME_PXLS 1066
  104.  
  105.         `define CNT_WDT 11        
  106.    
  107.  
  108.     `else // defaulf - for test purposes
  109.    
  110.         `define VISIBLE_LINE_PXLS       100
  111.         `define HORIZ_FRONT_PORCH_PXLS  2
  112.         `define HORIZ_SYNC_PULSE_PXLS   4
  113.         `define WHOLE_LINE_PXLS         150  
  114.         `define VISIBLE_FRAME_PXLS      50
  115.         `define VERT_FRONT_PORCH_PXLS   3
  116.         `define VERT_SYNC_PULSE_PXLS    2        
  117.         `define VERT_FRAME_PXLS         70      
  118.        
  119.     `endif    
  120.    
  121.     // Sync pulse start = Visible area + Front porch
  122.     `define HORIZ_SYNC_PRE_PXLS (`VISIBLE_LINE_PXLS + `HORIZ_FRONT_PORCH_PXLS)        
  123.    
  124.     // Sync pulse end   = Visible area + Front porch + Sync pulse
  125.     `define HORIZ_SYNC_POST_PXLS (`VISIBLE_LINE_PXLS + `HORIZ_FRONT_PORCH_PXLS + `HORIZ_SYNC_PULSE_PXLS)    
  126.    
  127.     // Sync pulse start = Visible area + Front porch
  128.     `define VERT_SYNC_PRE_PXLS (`VISIBLE_FRAME_PXLS + `VERT_FRONT_PORCH_PXLS)        
  129.    
  130.     // Sync pulse end   = Visible area + Front porch + Sync pulse
  131.     `define VERT_SYNC_POST_PXLS (`VISIBLE_FRAME_PXLS + `VERT_FRONT_PORCH_PXLS + `VERT_SYNC_PULSE_PXLS)    
  132.    
  133.     `define CNT_RNG [`CNT_WDT-1:0]
  134.    
  135.     `define FIRST_HORIZ_BORDER_PXLS  (`VISIBLE_FRAME_PXLS / 3)
  136.     `define SECOND_HORIZ_BORDER_PXLS (`VISIBLE_FRAME_PXLS - `VISIBLE_FRAME_PXLS / 3)    
  137.            
  138. `endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement