Question: The program I have below creates a straight line across the screen, and slowly goes up and down. I need to convert this program to

The program I have below creates a straight line across the screen, and slowly goes up and down. I need to convert this program to instead be two boxes within each other on the left and an arrow on the right, and they both need to move up and down. The description for the project is below. The FPGA I am using is called the DE0-CV and the altera monitor program is the software we use to compile.

ftp://ftp.altera.com/up/pub/Altera_Material/15.0/Computer_Systems/DE0-CV/DE0-CV_Computer.pdf (This is a link to the manual of my FPGA)

The program I have below creates a straight line across the screen,

#include "nios2_ctrl_reg_macros.h" #include

/* This program implements a basic animation by drawing a HORIZONTAL line that moves up * and down the screen. The speed of movement is controlled by the VGA vertical sync * timing. * For DE0-CV: YELLOW 0xFF00, RED 0xFA00, GREEN 0x1CE0, BLUE 0x001F */ /* global variables */

volatile int pixel_buffer_start = 0x08000000;// VGA pixel buffer int resolution_x = 320; // VGA screen size 320 for DE0-CV int resolution_y = 240; // VGA screen size 240 for DE0-CV

void clear_screen(void); void draw_hline(int, int, int, int, int); void draw_box(int, int, int, int, int); void plot_pixel(int, int, short int);

int main(void)

{ int x_0, y, x_1, y_dir, color;

clear_screen ( ); // Normally make the VGA screen BLACK. // BLUE for highlighting erasure here. x_0 = 10; // Change for DE0-CV x_1 = 200; // Change for DE0-CV y = 120; // Change for DE0-CV y_dir = 1;

color = 0xF800; // 224 decimal = RED draw_hline (x_0, y, x_1, y, color);

while (1) { // Hold the line in current position int count = 0; while (count

if ((y = (resolution_y-1))) y_dir = -y_dir; // Draw new line color = 0xF800; // RED for DE0-CV 0xF800 draw_hline (x_0, y, x_1, y, color); } }

/* Function to blank the VGA screen */ void clear_screen( ) { int clearColor = 0x001F; /* Normally make the VGA screen BLACK. BLUE for highlighting erasure here. for DE0-CV substitute 0x001F */ int y, x; int pixel_ptr;

for (y = 0; y

/* This function draws a line between points (x0, y0) * and (x1, y1). One ROW at a time. The function assumes that the coordinates are valid * */ void draw_box(int x0, int y0, int x1, int y1, int color) { int y; int x; for(y=y0;y { for(x=x0;x { plot_pixel(x,y,color); } } }

/* Draw Horizontal Line */ void draw_hline(int x0, int y0, int x1, int y1, int color) { int y=y0; int x; for(x=x0;x { plot_pixel(x,y,color); } }

void plot_pixel(int x, int y, short int pixel_color) { //*(volatile char *)(pixel_buffer_start + (y

-------------------------------------

This is the

nios2_ctrl_reg_macros.h

#ifndef __NIOS2_CTRL_REG_MACROS__ #define __NIOS2_CTRL_REG_MACROS__ /*****************************************************************************/ /* Macros for accessing the control registers. */ /*****************************************************************************/ #define NIOS2_READ_STATUS(dest) \ do { dest = __builtin_rdctl(0); } while (0) #define NIOS2_WRITE_STATUS(src) \ do { __builtin_wrctl(0, src); } while (0) #define NIOS2_READ_ESTATUS(dest) \ do { dest = __builtin_rdctl(1); } while (0) #define NIOS2_READ_BSTATUS(dest) \ do { dest = __builtin_rdctl(2); } while (0) #define NIOS2_READ_IENABLE(dest) \ do { dest = __builtin_rdctl(3); } while (0) #define NIOS2_WRITE_IENABLE(src) \ do { __builtin_wrctl(3, src); } while (0) #define NIOS2_READ_IPENDING(dest) \ do { dest = __builtin_rdctl(4); } while (0) #define NIOS2_READ_CPUID(dest) \ do { dest = __builtin_rdctl(5); } while (0) #endif 

YOUR ASSIGNMENT IS TO: B.3 write a c program using Altera Monitor Program that displays two rectangles and an arrow pointing up on a monitor using VGA as illustrated in Figure 1. The objects must move from their initial location (somewhere in the middle of the screen to the top of the monitor, then down to the bottom of the monitor. Each move is to be displayed for second. The objects will move non-stop from top to bottom and vice v Students are encouraged to be creative ersa. in completing this lab. Use soft the color for the background. Light blue Light red Light green Figure 1. Two rectangles and an arrow

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!