<!DOCTYPE html> <html>
<head> <meta charset="utf-8">
<script async src="https://www.googletagmanager.com/gtag/js?id=G-NG21EXTML9"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date());
gtag('config', 'G-NG21EXTML9'); </script> <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no"> <title>VGA Controller Example</title> <meta name="keywords" content="FPGA, FPGA Prototyping, FPGA Tool, Voice Coding, procedural programming, FPGA Easy, VHDL, FPGA for beginners"> <meta name="description" content="A practical FPGA design tool that combines procedural programming using native VHDL with command-based programming"> <link rel="icon" type="image/png" sizes="16x16" href="../assets/img/logo/favicon-16x16.png"> <link rel="icon" type="image/png" sizes="32x32" href="../assets/img/logo/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="192x192" href="../assets/img/logo/android-chrome-192x192.png"> <link rel="icon" type="image/png" sizes="512x512" href="../assets/img/logo/android-chrome-512x512.png"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css"> <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.12.0/css/all.css"> <link rel="stylesheet" href="https://unpkg.com/@bootstrapstudio/bootstrap-better-nav/dist/bootstrap-better-nav.min.css"> <link rel="stylesheet" href="../assets/css/doxy-override.css"> <link rel="stylesheet" href="../assets/css/Footer-Basic.css"> <link rel="stylesheet" href="../assets/css/Login-Form-Clean.css"> <link rel="stylesheet" href="../assets/css/banner.css"> <link rel="stylesheet" href="../assets/css/examples.css"> <link rel="stylesheet" href="../assets/css/speakhdl-styles.css"> </head>
<body class="body-fixed"> <header class="justify-content-center banner-header theme-outline" dx-block="block">
VGA Controller Example
</header>
-
Design A 640x480 VGA controller to display red and green vertical stripes on a monitor.
-
Understand different ways to designate a signal to be an I/O signal that is bound for FPGA pins vs a local signal that is to be used internally.
Show Hotkey Command Sequence
Top Level Design Structure
Configuring FPGA logic to act as a simple VGA controller is straight forward. All that is needed is two general purpose counters to be used for controlling the horizontal and vertical sync signal timing. Because the VGA controller outputs analog video to the display while the FPGA has a a digital output, resistors on the development board are used convert 4 digital output pins from the FPGA to a single analog video signal for each of the 3 RGB pins on the VGA connector. To display vertical stripes on the screen from the FPGA, we alternate between driving all 4 bits of the red signal to logic 1 while the green signal is driven to logic 0, then drive all 4 bits of the green signal to logic 1 while driving the red to logic 0. Because the blue color is not utilized, all 4 bits of the blue signal are always driven to logic 0.
The design also shows three ways one can specify a signal to be treated as an I/O pin with SpeakHDL. The first way is by creating a
local signal then using the '
pin' command to assign location constraints to the signal. That method is used to assign the
red and
green signals as outputs. Another method of assigning output signals is by using the
output or
input command before declaring the signal then immediately specifying the pin locations. This method is utilized for declaring the
h_sync, and
v_sync signals to be outputs. Both of these commands are used to make an entry into the
IO_CONFIG.cfg file. The third way to designate an IO signal as is by editing the pinout information directly in the config file. This method was done when assigning the clk_pin and reset_pin locations.
In order to synthesize the design, SpeakHDL requires a
clk_pin location to be mapped to a clock oscillator on the development board and
reset_pin location which can be mapped to any input pin location (button or switch, ect). Before any clock and reset location have been specified, SpeakHDL sets the default pin locations to be '<>' and prints these locations as VHDL comments next to the
port interface of each application module.
When either the clock or reset pin locations are not specified, SpeakHDL will generate at least one
error when the 'ok' command is given.
Details for the errors and warnings can be viewed in the
ok.log file. After pin location information for the clock and reset pin are given, SpeakHDL will show an
ok status.
Select a local directory location for output files *
clear .vhd file and rename application module 'vga_controller'
-
restart
-
rename vga_controller.vhd
configure default value for 'else' statement
-
time us
-
cc
-
count 32.0
-
h_enable;
-
0 when counter0 < 5.76
-
0 when counter0 > 31.36
-
h_sync;
-
0 when counter0 < 5.12us
-
time ms
-
cc1
-
count 16.672
-
v_enable;
-
0 when counter1 < 0.992
-
0 when counter1 > 16.352
-
v_sync;
-
0 when counter1 < 0.064
setup video enable control signal
-
video_on;
-
1 when h_enable = 1
-
and v_enable = 1
-
else 0
configure output red and green signals
-
red3:
-
pin = A3, B4, C5, A4
-
0 when video_on = 0
-
1 when counter1 bit 6 = 1
-
else 0
-
green3:
-
pin = C6, A5, B6, A6
-
0 when video_on = 0
-
1 when counter1 bit 6 = 0
-
else 0
drive the blue signal to logic 0 because the color is not in use
-
blue3:
-
output blue = B7,C7,D7,D8
-
0
declare sync and v_sync as output signals
-
output h_sync = B11
-
output v_sync = B12
-
ok
Pin locations must be changed for user specific development board
Writing to a local directory is supported with Chrome and Microsoft Edge browsers
Open the
IO_CONFIG.cfg file in the editor and update the following parameters to match the user specific the development board. Then return to the .vhd file and give the 'ok' command.
-
[global]
-
clk_pin = E3
-
reset_pin = U9
-
sys_clk_freq = 100E6
-
reset_polarity = '1'
-
...
</section>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script> <script src="../assets/js/bss_custom_js.js"></script> <script src="https://unpkg.com/@bootstrapstudio/bootstrap-better-nav/dist/bootstrap-better-nav.min.js"></script> </body>
</html>