基于DE2的VGA显示

好消息,DE2又出新的IP了,支持Quartus II 9.0、9.1、10.0和10.1

大家可以Altera的官方网站下载,也可以和我联系,传给你一份QQ:287687752

下面是IP里面的一个实例,在<Quartus II安装目录>\University_Program\IP_Core_Demos\DE2\DE2_Video_SOPC_Builder_Demos中的DE2_VGA_Both_Buffers文件中

工程环境:Quartus II 10.1sp1 + NIOS II 10.1sp1 + DE2

打开上述文件的工程,我们直接进入SOPC Builder配置如下:

2011022020412613.jpg

顶层工程文件更简单:

module DE2_VGA_Both_Buffers (
 // Inputs
 CLOCK_50,
 KEY,

 // Bidirectionals
 //  Memory (SRAM)
 SRAM_DQ,
 
 // Outputs
 //  Memory (SRAM)
 SRAM_ADDR,

 SRAM_CE_N,
 SRAM_WE_N,
 SRAM_OE_N,
 SRAM_UB_N,
 SRAM_LB_N,
 
 //  VGA
 VGA_CLK,
 VGA_HS,
 VGA_VS,
 VGA_BLANK,
 VGA_SYNC,
 VGA_R,
 VGA_G,
 VGA_B
);

/*****************************************************************************
 *                           Parameter Declarations                          *
 *****************************************************************************/


/*****************************************************************************
 *                             Port Declarations                             *
 *****************************************************************************/
// Inputs
input    CLOCK_50;
input  [3:0] KEY;

// Bidirectionals
//  Memory (SRAM)
inout  [15:0] SRAM_DQ;

// Outputs
//  Memory (SRAM)
output  [17:0] SRAM_ADDR;

output    SRAM_CE_N;
output    SRAM_WE_N;
output    SRAM_OE_N;
output    SRAM_UB_N;
output    SRAM_LB_N;

//  VGA
output    VGA_CLK;
output    VGA_HS;
output    VGA_VS;
output    VGA_BLANK;
output    VGA_SYNC;
output  [ 9: 0] VGA_R;
output  [ 9: 0] VGA_G;
output  [ 9: 0] VGA_B;

/*****************************************************************************
 *                 Internal Wires and Registers Declarations                 *
 *****************************************************************************/
// Internal Wires

// Internal Registers

// State Machine Registers

/*****************************************************************************
 *                         Finite State Machine(s)                           *
 *****************************************************************************/


/*****************************************************************************
 *                             Sequential Logic                              *
 *****************************************************************************/


/*****************************************************************************
 *                            Combinational Logic                            *
 *****************************************************************************/


/*****************************************************************************
 *                              Internal Modules                             *
 *****************************************************************************/

Video_System Char_Buffer_System (
 // 1) global signals:
 .clk_0         (CLOCK_50),
 .reset_n        (KEY[0]),
 .sys_clk        (),
 .vga_clk        (),

 // the_Pixel_Buffer
 .SRAM_DQ_to_and_from_the_Pixel_Buffer (SRAM_DQ),
 .SRAM_ADDR_from_the_Pixel_Buffer  (SRAM_ADDR),
 .SRAM_LB_N_from_the_Pixel_Buffer  (SRAM_LB_N),
 .SRAM_UB_N_from_the_Pixel_Buffer  (SRAM_UB_N),
 .SRAM_CE_N_from_the_Pixel_Buffer  (SRAM_CE_N),
 .SRAM_OE_N_from_the_Pixel_Buffer  (SRAM_OE_N),
 .SRAM_WE_N_from_the_Pixel_Buffer  (SRAM_WE_N),

 // the_vga_controller
 .VGA_CLK_from_the_VGA_Controller  (VGA_CLK),
 .VGA_HS_from_the_VGA_Controller   (VGA_HS),
 .VGA_VS_from_the_VGA_Controller   (VGA_VS),
 .VGA_BLANK_from_the_VGA_Controller  (VGA_BLANK),
 .VGA_SYNC_from_the_VGA_Controller  (VGA_SYNC),
 .VGA_R_from_the_VGA_Controller   (VGA_R),
 .VGA_G_from_the_VGA_Controller   (VGA_G),
 .VGA_B_from_the_VGA_Controller   (VGA_B)
);

endmodule

看看RTL视图:

2011022020440967.jpg

把编译好的配置文件下载DE2中,进入NIOS II

看看里面的给的C代码:

#include"system.h"

/* function prototypes */
void VGA_text (int, int, char *);
void VGA_box (int, int, int, int, short);

/********************************************************************************
 * This program demonstrates use of the character and pixel buffers
 *
 * It performs the following:
 *  1. Draws a blue box on the VGA display, and places a text string inside
 *     the box. Also, moves the word ALTERA around the display, "bouncing" off
 *     the blue box and screen edges
********************************************************************************/
int main(void)
{
 /* Declare volatile pointer to pixel DMA controller (volatile means that IO load
    and store instructions will be used to access these pointer locations,
    instead of regular memory loads and stores) */
   volatile int * Pixel_DMA_controller = (int *) PIXEL_BUFFER_DMA_BASE; // DMA controller base address

 int delay = 0; // synchronize with the screen drawing

 /* these variables are used for a blue box and a "bouncing" ALTERA on the VGA screen */
 int ALT_x1; int ALT_x2; int ALT_y;
 int ALT_inc_x; int ALT_inc_y;
 int blue_x1; int blue_y1; int blue_x2; int blue_y2;
 int screen_x; int screen_y; int char_buffer_x; int char_buffer_y;
 short color;

 /* create messages to be displayed on the VGA display */
 char text_top_VGA[20] = "Altera DE2\0";
 char text_bottom_VGA[20] = "Video Buffers\0";
 char text_ALTERA[10] = "ALTERA\0";
 char text_erase[10] = "      \0";

 /* the following variables give the size of the pixel buffer */
 screen_x = 319; screen_y = 239;
 color = 0x1863;  // a dark grey color
 VGA_box (0, 0, screen_x, screen_y, color); // fill the screen with grey
 // draw a medium-blue box around the above text, based on the character buffer coordinates
 blue_x1 = 28; blue_x2 = 52; blue_y1 = 26; blue_y2 = 34;
 // character coords * 4 since characters are 4 x 4 pixel buffer coords (8 x 8 VGA coords)
 color = 0x187F;  // a medium blue color
 VGA_box (blue_x1 * 4, blue_y1 * 4, blue_x2 * 4, blue_y2 * 4, color);
 /* output text message in the middle of the VGA monitor */
 VGA_text (blue_x1 + 5, blue_y1 + 3, text_top_VGA);
 VGA_text (blue_x1 + 5, blue_y1 + 4, text_bottom_VGA);

 char_buffer_x = 79; char_buffer_y = 59;
 ALT_x1 = 0; ALT_x2 = 5/* ALTERA = 6 chars */; ALT_y = 0; ALT_inc_x = 1; ALT_inc_y = 1;
 VGA_text (ALT_x1, ALT_y, text_ALTERA);

 *(Pixel_DMA_controller) = 0; // dummy write to start buffer swap process
 while (1)
 {
  if ( (*(Pixel_DMA_controller+3) & 1) == 0) // wait for Status register bit S == 0
  {
   /* If the screen has been drawn completely then we can draw a new image. This
    * section of the code will only be entered each time the screen is redrawn */
   delay = delay + 1;

   if (delay == 2)
   {
    delay = 0;
    /* The delay is inserted to slow down the animation */

    /* move the ALTERA text around on the VGA screen */
    VGA_text (ALT_x1, ALT_y, text_erase);  // erase
    ALT_x1 += ALT_inc_x;
    ALT_x2 += ALT_inc_x;
    ALT_y += ALT_inc_y;

    if ( (ALT_y == char_buffer_y) || (ALT_y == 0) )
     ALT_inc_y = -(ALT_inc_y);
    if ( (ALT_x2 == char_buffer_x) || (ALT_x1 == 0) )
     ALT_inc_x = -(ALT_inc_x);

    if ( (ALT_y >= blue_y1 - 1) && (ALT_y <= blue_y2 + 1) )
    {
     if ( ((ALT_x1 >= blue_x1 - 1) && (ALT_x1 <= blue_x2 + 1)) ||
      ((ALT_x2 >= blue_x1 - 1) && (ALT_x2 <= blue_x2 + 1)) )
     {
      if ( (ALT_y == (blue_y1 - 1)) || (ALT_y == (blue_y2 + 1)) )
       ALT_inc_y = -(ALT_inc_y);
      else
       ALT_inc_x = -(ALT_inc_x);
     }
    }
    VGA_text (ALT_x1, ALT_y, text_ALTERA);
   }
   /* Execute a swap buffer command. This will allow us to check if the screen has
    * been redrawn before generating a new animation frame. */
   *(Pixel_DMA_controller) = 0;
  }
 }
}

/****************************************************************************************
 * Subroutine to send a string of text to the VGA monitor
****************************************************************************************/
void VGA_text(int x, int y, char * text_ptr)
{
 int offset;
   volatile char * character_buffer = (char *) CHAR_BUFFER_WITH_DMA_AVALON_CHAR_BUFFER_SLAVE_BASE; // VGA character buffer

 /* assume that the text string fits on one line */
 offset = (y << 7) + x;
 while ( *(text_ptr) )
 {
  *(character_buffer + offset) = *(text_ptr); // write to the character buffer
  ++text_ptr;
  ++offset;
 }
}

/****************************************************************************************
 * Draw a filled rectangle on the VGA monitor
****************************************************************************************/
void VGA_box(int x1, int y1, int x2, int y2, short pixel_color)
{
 int offset, row, col;
   volatile short * pixel_buffer = (short *) PIXEL_BUFFER_BASE; // VGA pixel buffer

 /* assume that the box coordinates are valid */
 for (row = y1; row <= y2; row++)
 {
  col = x1;
  while (col <= x2)
  {
   offset = (row << 9) + col;
   *(pixel_buffer + offset) = pixel_color; // compute halfword address, set pixel
   ++col;
  }
 }
}

接上显示器,我们就可以看到跳动的文字ALTERA了,还有蓝色的BOX,呵呵!

posted on 2011-02-20 20:48  Neddy11 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/Neddy/archive/2011/02/20/1959218.html

基于SSM框架的智能家政保洁预约系统,是一个旨在提高家政保洁服务预约效率和管理水平的平台。该系统通过集成现代信息技术,为家政公司、家政服务人员和消费者提供了一个便捷的在线预约和管理系统。 系统的主要功能包括: 1. **用户管理**:允许消费者注册、登录,并管理他们的个人资料和预约历史。 2. **家政人员管理**:家政服务人员可以注册并更新自己的个人信息、服务类别和服务时间。 3. **服务预约**:消费者可以浏览不同的家政服务选项,选择合适的服务人员,并在线预约服务。 4. **订单管理**:系统支持订单的创建、跟踪和管理,包括订单的确认、完成和评价。 5. **评价系统**:消费者可以在家政服务完成后对服务进行评价,帮助提高服务质量和透明度。 6. **后台管理**:管理员可以管理用户、家政人员信息、服务类别、预约订单以及处理用户反馈。 系统采用Java语言开发,使用MySQL数据库进行数据存储,通过B/S架构实现用户与服务的在线交互。系统设计考虑了不同用户角色的需求,包括管理员、家政服务人员和普通用户,每个角色都有相应的权限和功能。此外,系统还采用了软件组件化、精化体系结构、分离逻辑和数据等方法,以便于未来的系统升级和维护。 智能家政保洁预约系统通过提供一个集中的平台,不仅方便了消费者的预约和管理,也为家政服务人员提供了一个展示和推广自己服务的机会。同时,系统的后台管理功能为家政公司提供了强大的数据支持和决策辅助,有助于提高服务质量和管理效率。该系统的设计与实现,标志着家政保洁服务向现代化和网络化的转型,为管理决策和控制提供保障,是行业发展中的重要里程碑。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值