查看: 6772|回复: 4

FPGA驱动VGA

  [复制链接]
  • TA的每日心情
    开心
    2014-5-14 13:12
  • 签到天数: 180 天

    连续签到: 1 天

    [LV.7]常住居民III

    发表于 2013-1-20 16:47:50 | 显示全部楼层 |阅读模式
    分享到:

    A recent chat on All Programmable Planet about the most unusual FPGA-based applications anyone has run across, or been involved with, resulted in some interesting discussions. These conversations were not focused only on the tasks for which FPGAs have been employed (switched-mode power supply controllers replacing analog components, for example), but also some applications for which a lot of people new to FPGA development appear to have an interest.

    One recurring topic was the use of FPGA in image processing. Thanks to their nature, FPGAs are well suited to the intense levels of signal processing required by many imaging systems. Of course, one of the most rewarding aspects of image processing is seeing the resultant image on a display, and a very common form of display uses the VGA (video graphics array) standard.

    The first VGA display was introduced with the IBM PS/2 line of computers in 1987. One thing most people associate with this form of display is the 15-pin D-subminiature VGA connector you tend to find on the back of a tower computer or the side of your notebook computer.



    A 15-pin D-subminiature VGA connector.


    The original VGA standard supported a resolution of only 640x480 (which means 640 pixels in the horizontal plane and 480 lines in the vertical plane). Over the years, however, the standard has evolved to support a wide variety of resolutions, all the way up to widescreen resolutions as high as 1920x1080.

    The act of driving a VGA is surprisingly simple, being based on the use of two counters as follows:


    • Pixel counter: Counts at the required clock frequency (40MHz in this example) the number of pixels in a line, this is used to generate the horizontal timing.
    • Line counter: Also known as the Frame Counter, this repeats at the refresh rate of the desired VESA specification for 60Hz, 75Hz, 85Hz, and so on. This also identifies when the counter is within a valid region for outputting display data. The line counter is incremented each time the pixel counter reaches its terminal count.

    These counters are used to generate two synchronization (sync) markers -- the "V_Sync" (vertical sync) and "H_Sync" (horizontal sync) signals. In conjunction with the RGB (red, green, and blue) analog signals , "V_Sync" and "H_Sync" form the basic signals required to display video on a monitor.

    Actually, this may be a good time to take a step back to remind ourselves as to the origin of terms like "V_Sync" and "H_Sync." The main thing to remember is that, at the time the original VGA standard was introduced, the predominant form of computer display was based on the cathode ray tube (CRT), in which an electron beam is used to "write" on a phosphorescent screen.



    Cross-section of cathode ray tube (CRT).


    There are several ways in which an electron beam can be manipulated to create images on a CRT screen, but by far the most common technique is the raster scan. Using this approach, the electron beam commences in the upper-left corner of the screen and is guided across the screen to the right. The path the beam follows as it crosses the screen is referred to as a line. When the beam reaches the right-hand side of the screen it undergoes a process known ashorizontal flyback, in which its intensity is reduced and it is caused to "fly back" across the screen. While the beam is flying back it is also pulled a little way down the screen as shown in the following illustration:



    Path of the electron beam when using the raster scan technique.


    The beam is now used to form a second line, then a third, and so on until it reaches the bottom of the screen. The number of lines affects the resolution of the resulting picture (that is, the amount of detail that can be displayed). When the beam reaches the bottom right-hand corner of the screen it undergoes vertical flyback, in which its intensity is reduced, it "flies back" up the screen to return to its original position in the upper left-hand corner, and the whole process starts again.

    The "V_Sync" and "H_Sync" signals are used to synchronize all of these activities. Thus, returning to our pixel and line counters, the values on these counters can be decoded so as to generate the required waveforms on the "V_Sync" and "H_Sync" outputs from an FPGA (that is, on the FPGA's pins that are being used to drive the display's "V_Sync" and "H_Sync" signals). Meanwhile, generating the RGB signals will require the FPGA to drive three digital-to-analog convertors (DACs), one for each signal. As the design engineer, you must ensure that the latency through the DACs is accounted for to ensure that their outputs are correctly aligned with respect to the "V_Sync" and "H_Sync" signals.

    The line and pixel counters both have portions of their count sequences when no data is being output to the display. In the case of an 800x600 resolution display refreshing at 60Hz, for example, the vertical (line) counter will actually count 628 lines while the horizontal (pixel) counter will count 1,056 pixels.

    Why should this be so? Well, returning to our raster scan, it takes a certain amount of time for the electron beam to undergo its horizontal and vertical flyback activities. One way to think about these times is that we have an actual display area that we see, and that this actual display area "lives" in a larger (virtual) display space that contains a border zone that we don't see:



    Actual display area surrounded by virtual display zone.


    Of course, in the case of today's flat-screen, liquid crystal displays (LCDs) and similar technologies, we don't actually need to worry about things like horizontal and vertical flyback times. At least, we wouldn’t have to worry if it were not for the fact that we don't actually know what type of screen our FPGA is driving. Thus, anything driving a VGA output generates the timing signals required to drive CRT display, and other forms of display simply make allowances for any of the historical peculiarities associated with these VGA signals.

    But we digress… Each of our counters has a collection of associated timing parameters. Vertical timings are referenced in terms of lines, while horizontal timings are referenced in terms of pixels. The following values are those associated with a display resolution of 800x600:





    Using this approach, it is very easy to generate a simple VGA interface and see the results of our image processing algorithms on a monitor. Below you can see some of the simulation results I obtained from my VHDL representations of these counters:



    Simulation results for horizontal backporch.




    Simulation results for horizontal frontporch.




    Simulation results for horizontal sync.

    vga.zip

    1.59 KB, 下载次数: 17

    HDL code

    回复

    使用道具 举报

  • TA的每日心情
    奋斗
    2016-6-12 21:59
  • 签到天数: 647 天

    连续签到: 1 天

    [LV.9]以坛为家II

    发表于 2013-1-20 20:35:49 | 显示全部楼层
    我想的话,在360极速浏览器里打开就是中文了的            
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    2014-5-14 13:12
  • 签到天数: 180 天

    连续签到: 1 天

    [LV.7]常住居民III

    发表于 2013-1-21 08:00:28 | 显示全部楼层
    wyzamazon 发表于 2013-1-20 19:40
    楼主给翻译成中文呗

    这种程度的英文不难吧?有必要翻译吗?
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    奋斗
    2014-8-12 15:14
  • 签到天数: 35 天

    连续签到: 1 天

    [LV.5]常住居民I

    发表于 2013-2-15 11:54:04 来自手机 | 显示全部楼层
    用翻译软件翻译个大概再捋顺一下应该知道个八九不离十,
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    2013-5-28 09:18
  • 签到天数: 6 天

    连续签到: 1 天

    [LV.2]偶尔看看I

    发表于 2013-5-18 10:42:33 | 显示全部楼层
    谢谢楼主分享!
    好资料!
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /3 下一条



    手机版|小黑屋|与非网

    GMT+8, 2024-5-14 09:51 , Processed in 0.139794 second(s), 23 queries , MemCache On.

    ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.