The width of the line is 4 pixels, starts form pixel 32 to
pixel
35.
Use the Basys 3 board, a VGA cable, a monitor, gvim, and
Vivado
for the task.
As you can find
from the example code in the 'VGA' lecture tutorial,
the VGA controller module has three conditions in parallel which means
the three main 'if statements' will be implemented in parallel. First, according
to the 640x480 VGA standard, the 25 MHz pixel scanning
rate will go through all 800 x 525 pixel time. Therefore, the following
code snippet should stay:
Then during the
visible range, it should enable the display:
The 'enable'
flag is set so that when 'enable == 1', color codes
are assigned to the red, green, and blue ports. Otherwise, 4'h0 is
assigned to all three color channels, effectively doing nothing or
setting the color to black outside of the visible area (so it doesn't
matter). When the scanner is within the 640x480 range, 'enable' becomes
1, and the color of each pixel is determined by its position. In this
case, a solid green bar appears on the left side, with a customizable
width and a fixed length of 480. The remaining area is filled with a
universal white color, which can be managed in the 'else' condition.
2.
Draw an
additional red bar on the monitor (25 points)
The red bar has
the following
boundaries: X: 600 - 605; Y: 200 - 250
Similar to Task
1, you can display another bar with a different color on the right
side. To achieve this, simply add another parallel 'if statement' to
the code from Task 1. The red bar is a rectangular object defined by
four edges. You can specify its position by setting four lines in the
coordinate system.
3.
Move
the red bar to the right (horizontally) by 1 pixel for every 0.5
second. (25
points) To move the red
bar slowly, you can update its pixel positions every 0.5 seconds. By
shifting all the red bar’s pixels to the right simultaneously at each
interval, it creates the effect of the entire red bar moving to the
right in 0.5-second increments.
The object moves
horizontally therefore by moving the object, I just need to update the
left and right boundary each 0.5 seconds. All other scanning mechnism
could remain unchanged.
Demo video:
4.
Bounce
it back and forth between the green line and the X location of 600. The
speed is 0.01s/pixel. (25 points) The keypoint for
this task is to figure out which direction the red bar was
moving to. When it is moving between locations 35 and 600, if the
previous
pixel value is smaller, then the red bar is moving to the right, in
that case, every pixel's location of the red bar should increment by 1.
Otherwise, it should decrease by 1.
The object
starts from the left. There should be an 'if statement' to start the
movement.
I set the
reference point at the left side of the red bar so I used 'red_left'.