原创 VGA动态显示数字

2011-5-8 16:54 3335 7 10 分类: FPGA/CPLD

//VGA displayed
//mode 800*600 72Hz
//date 2011-05-04 am
module vga_dis(
               //input pins
               clk ,     
               rst_n,   
               //output pins
               hsync,vsync,
               vga_r,vga_g,vga_b
               );
 input clk;    //50MHz
 input rst_n;  //低电平复位
output hsync;  //行同步信号
output vsync;
//颜色信号线RGB
output vga_r;
output vga_g;
output vga_b;
//----------------------------------------------------------------------
reg [10:0] x_cnt; //行坐标
reg [9:0] y_cnt;  //列坐标
//-----------------------------------------------------------------
wire [10:0]xpos;  //有效显示行坐标
wire [9:0]ypos;  //有效显示列坐标
//------------------------------------------------------------------
reg hsync_r,vsync_r;           //同步信号
wire valid;                    //有效显示区标志
reg [2:0]vga_rgb;              //显示像素颜色
reg [5:0]char1_bit;             //取模的位数
//-------------------------------------------------------------------
//定义存放数据的寄存器
reg [15:0]char_line0[9:0];
reg [15:0]char_line1[9:0];
reg [15:0]char_line2[9:0];
reg [15:0]char_line3[9:0];
reg [15:0]char_line4[9:0];
reg [15:0]char_line5[9:0];
reg [15:0]char_line6[9:0];
reg [15:0]char_line7[9:0];
reg [15:0]char_line8[9:0];
reg [15:0]char_line9[9:0];
reg [15:0]char_line10[9:0];
reg [15:0]char_line11[9:0];
reg [15:0]char_line12[9:0];
reg [15:0]char_line13[9:0];
reg [15:0]char_line14[9:0];
reg [15:0]char_line15[9:0];
reg [15:0]char_line16[9:0];
reg [15:0]char_line17[9:0];
reg [15:0]char_line18[9:0];
reg [15:0]char_line19[9:0];
reg [15:0]char_line20[9:0];
reg [15:0]char_line21[9:0];
reg [15:0]char_line22[9:0];
reg [15:0]char_line23[9:0];
reg [15:0]char_line24[9:0];
reg [15:0]char_line25[9:0];
reg [15:0]char_line26[9:0];
reg [15:0]char_line27[9:0];
reg [15:0]char_line28[9:0];
reg [15:0]char_line29[9:0];
reg [15:0]char_line30[9:0];
reg [15:0]char_line31[9:0];
//-------------------------------------------------------------------------------------
//定义扫描显示的数据,wire型
wire [47:0]line0;                //第1行
wire [47:0]line1;                //第2行
wire [47:0]line2;                //第3行
wire [47:0]line3;                //第4行
wire [47:0]line4;                //第5行
wire [47:0]line5;                //第6行
wire [47:0]line6;                //第7行
wire [47:0]line7;                //第8行
wire [47:0]line8;                //第9行
wire [47:0]line9;                //第10行
wire [47:0]line10;               //第11行
wire [47:0]line11;               //第12行
wire [47:0]line12;               //第13行
wire [47:0]line13;               //第14行
wire [47:0]line14;               //第15行
wire [47:0]line15;               //第16行
wire [47:0]line16;               //第17行
wire [47:0]line17;               //第18行
wire [47:0]line18;               //第19行
wire [47:0]line19;               //第20行
wire [47:0]line20;               //第21行
wire [47:0]line21;               //第22行
wire [47:0]line22;               //第23行
wire [47:0]line23;               //第24行
wire [47:0]line24;               //第25行
wire [47:0]line25;               //第26行
wire [47:0]line26;               //第27行
wire [47:0]line27;               //第28行
wire [47:0]line28;               //第29行
wire [47:0]line29;               //第30行
wire [47:0]line30;               //第31行
wire [47:0]line31;               //第32行
//---------------------------------------------------------------------------------------
wire [25:0]cnt;      
reg [25:0]cnt_r;             //计数,产生一秒的时间
reg [3:0]ge_r,shi_r,bai_r;   //计数时间,三位数,个十百
wire [3:0]ge,shi,bai;
//---------------------------------------------------------------------------------------
//将0123456789的取模数据存入到寄存器中,16*32
//每个字符将其最上面的数据存到line0中,然后依次往下推
//将数字x的取模数据存到地址为x的寄存器中,例如0的数据就存到地址为0的存储单元中
always
begin
          char_line0[0] <= 16'h0000;    //0的字模
          char_line1[0] <= 16'h0000;
          char_line2[0] <= 16'h0000;
          char_line3[0] <= 16'h0000;
          char_line4[0] <= 16'h0000;
          char_line5[0] <= 16'h0000;
          char_line6[0] <= 16'h03f0;
          char_line7[0] <= 16'h0738;
          char_line8[0] <= 16'h0e1c;
          char_line9[0] <= 16'h1c0e;
          char_line10[0] <= 16'h1c0e;
          char_line11[0] <= 16'h1c06;
          char_line12[0] <= 16'h3807;
          char_line13[0] <= 16'h3807;
          char_line14[0] <= 16'h3807;
          char_line15[0] <= 16'h3807;
          char_line16[0] <= 16'h3807;
          char_line17[0] <= 16'h3807;
          char_line18[0] <= 16'h3807;
          char_line19[0] <= 16'h3807;
          char_line20[0] <= 16'h3807;
          char_line21[0] <= 16'h1c06;
          char_line22[0] <= 16'h1c0e;
          char_line23[0] <= 16'h1c0e;
          char_line24[0] <= 16'h0e1c;
          char_line25[0] <= 16'h0738;
          char_line26[0] <= 16'h03f0;
          char_line27[0] <= 16'h0000;
          char_line28[0] <= 16'h0000;
          char_line29[0] <= 16'h0000;
          char_line30[0] <= 16'h0000; 
          char_line31[0] <= 16'h0000;
         
          char_line0[1] <= 16'h0000;    //1的字模
          char_line1[1] <= 16'h0000;
          char_line2[1] <= 16'h0000;
          char_line3[1] <= 16'h0000;
          char_line4[1] <= 16'h0000;
          char_line5[1] <= 16'h0000;
          char_line6[1] <= 16'h00c0;
          char_line7[1] <= 16'h01c0;
          char_line8[1] <= 16'h1fc0;
          char_line9[1] <= 16'h01c0;
          char_line10[1] <= 16'h01c0;
          char_line11[1] <= 16'h01c0;
          char_line12[1] <= 16'h01c0;
          char_line13[1] <= 16'h01c0;
          char_line14[1] <= 16'h01c0;
          char_line15[1] <= 16'h01c0;
          char_line16[1] <= 16'h01c0;
          char_line17[1] <= 16'h01c0;
          char_line18[1] <= 16'h01c0;
          char_line19[1] <= 16'h01c0;
          char_line20[1] <= 16'h01c0;
          char_line21[1] <= 16'h01c0;
          char_line22[1] <= 16'h01c0;
          char_line23[1] <= 16'h01c0;
          char_line24[1] <= 16'h01c0;
          char_line25[1] <= 16'h03e0;
          char_line26[1] <= 16'h1ffc;
          char_line27[1] <= 16'h0000;
          char_line28[1] <= 16'h0000;
          char_line29[1] <= 16'h0000;
          char_line30[1] <= 16'h0000; 
          char_line31[1] <= 16'h0000;

          char_line0[2] <= 16'h0000;    //2的字模
          char_line1[2] <= 16'h0000;
          char_line2[2] <= 16'h0000;
          char_line3[2] <= 16'h0000;
          char_line4[2] <= 16'h0000;
          char_line5[2] <= 16'h0000;
          char_line6[2] <= 16'h07f0;
          char_line7[2] <= 16'h0c3c;
          char_line8[2] <= 16'h181c;
          char_line9[2] <= 16'h300e;
          char_line10[2] <= 16'h300e;
          char_line11[2] <= 16'h380e;
          char_line12[2] <= 16'h380e;
          char_line13[2] <= 16'h000e;
          char_line14[2] <= 16'h001c;
          char_line15[2] <= 16'h0018;
          char_line16[2] <= 16'h0030;
          char_line17[2] <= 16'h0060;
          char_line18[2] <= 16'h00c0;
          char_line19[2] <= 16'h0180;
          char_line20[2] <= 16'h0300;
          char_line21[2] <= 16'h0606;
          char_line22[2] <= 16'h0c06;
          char_line23[2] <= 16'h1806;
          char_line24[2] <= 16'h300e;
          char_line25[2] <= 16'h3ffc;
          char_line26[2] <= 16'h3ffc;
          char_line27[2] <= 16'h0000;
          char_line28[2] <= 16'h0000;
          char_line29[2] <= 16'h0000;
          char_line30[2] <= 16'h0000; 
          char_line31[2] <= 16'h0000;

          char_line0[3] <= 16'h0000;    //3的字模
          char_line1[3] <= 16'h0000;
          char_line2[3] <= 16'h0000;
          char_line3[3] <= 16'h0000;
          char_line4[3] <= 16'h0000;
          char_line5[3] <= 16'h0000;
          char_line6[3] <= 16'h07e0;
          char_line7[3] <= 16'h1c78;
          char_line8[3] <= 16'h3838;
          char_line9[3] <= 16'h381c;
          char_line10[3] <= 16'h381c;
          char_line11[3] <= 16'h381c;
          char_line12[3] <= 16'h001c;
          char_line13[3] <= 16'h0038;
          char_line14[3] <= 16'h0070;
          char_line15[3] <= 16'h03e0;
          char_line16[3] <= 16'h0078;
          char_line17[3] <= 16'h001c;
          char_line18[3] <= 16'h000c;
          char_line19[3] <= 16'h000e;
          char_line20[3] <= 16'h000e;
          char_line21[3] <= 16'h380e;
          char_line22[3] <= 16'h380e;
          char_line23[3] <= 16'h380c;
          char_line24[3] <= 16'h381c;
          char_line25[3] <= 16'h1c38;
          char_line26[3] <= 16'h07e0;
          char_line27[3] <= 16'h0000;
          char_line28[3] <= 16'h0000;
          char_line29[3] <= 16'h0000;
          char_line30[3] <= 16'h0000; 
          char_line31[3] <= 16'h0000;

          char_line0[4] <= 16'h0000;    //4的字模
          char_line1[4] <= 16'h0000;
          char_line2[4] <= 16'h0000;
          char_line3[4] <= 16'h0000;
          char_line4[4] <= 16'h0000;
          char_line5[4] <= 16'h0000;
          char_line6[4] <= 16'h0038;
          char_line7[4] <= 16'h0078;
          char_line8[4] <= 16'h0078;
          char_line9[4] <= 16'h00f8;
          char_line10[4] <= 16'h01f8;
          char_line11[4] <= 16'h01f8;
          char_line12[4] <= 16'h0378;
          char_line13[4] <= 16'h0778;
          char_line14[4] <= 16'h0678;
          char_line15[4] <= 16'h0c78;
          char_line16[4] <= 16'h0c78;
          char_line17[4] <= 16'h1878;
          char_line18[4] <= 16'h3078;
          char_line19[4] <= 16'h3078;
          char_line20[4] <= 16'h7eff;
          char_line21[4] <= 16'h0078;
          char_line22[4] <= 16'h0078;
          char_line23[4] <= 16'h0078;
          char_line24[4] <= 16'h0078;
          char_line25[4] <= 16'h0078;
          char_line26[4] <= 16'h0078;
          char_line27[4] <= 16'h03ff;
          char_line28[4] <= 16'h0000;
          char_line29[4] <= 16'h0000;
          char_line30[4] <= 16'h0000; 
          char_line31[4] <= 16'h0000;

          char_line0[5] <= 16'h0000;    //5的字模
          char_line1[5] <= 16'h0000;
          char_line2[5] <= 16'h0000;
          char_line3[5] <= 16'h0000;
          char_line4[5] <= 16'h0000;
          char_line5[5] <= 16'h0000;
          char_line6[5] <= 16'h0ffe;
          char_line7[5] <= 16'h0ffe;
          char_line8[5] <= 16'h0c00;
          char_line9[5] <= 16'h0c00;
          char_line10[5] <= 16'h0c00;
          char_line11[5] <= 16'h1800;
          char_line12[5] <= 16'h1800;
          char_line13[5] <= 16'h1bf0;
          char_line14[5] <= 16'h1e38;
          char_line15[5] <= 16'h1c1c;
          char_line16[5] <= 16'h180c;
          char_line17[5] <= 16'h000e;
          char_line18[5] <= 16'h000e;
          char_line19[5] <= 16'h000e;
          char_line20[5] <= 16'h000e;
          char_line21[5] <= 16'h380e;
          char_line22[5] <= 16'h380e;
          char_line23[5] <= 16'h301c;
          char_line24[5] <= 16'h301c;
          char_line25[5] <= 16'h1838;
          char_line26[5] <= 16'h0fe0;
          char_line27[5] <= 16'h0000;
          char_line28[5] <= 16'h0000;
          char_line29[5] <= 16'h0000;
          char_line30[5] <= 16'h0000; 
          char_line31[5] <= 16'h0000;

          char_line0[6] <= 16'h0000;    //6的字模
          char_line1[6] <= 16'h0000;
          char_line2[6] <= 16'h0000;
          char_line3[6] <= 16'h0000;
          char_line4[6] <= 16'h0000;
          char_line5[6] <= 16'h0000;
          char_line6[6] <= 16'h01f8;
          char_line7[6] <= 16'h038c;
          char_line8[6] <= 16'h060e;
          char_line9[6] <= 16'h0c0e;
          char_line10[6] <= 16'h1c00;
          char_line11[6] <= 16'h1c00;
          char_line12[6] <= 16'h1800;
          char_line13[6] <= 16'h3800;
          char_line14[6] <= 16'h39f8;
          char_line15[6] <= 16'h3f1c;
          char_line16[6] <= 16'h3e0e;
          char_line17[6] <= 16'h3c07;
          char_line18[6] <= 16'h3807;
          char_line19[6] <= 16'h3807;
          char_line20[6] <= 16'h3807;
          char_line21[6] <= 16'h3807;
          char_line22[6] <= 16'h1c07;
          char_line23[6] <= 16'h1c06;
          char_line24[6] <= 16'h0e0e;
          char_line25[6] <= 16'h071c;
          char_line26[6] <= 16'h03f0;
          char_line27[6] <= 16'h0000;
          char_line28[6] <= 16'h0000;
          char_line29[6] <= 16'h0000;
          char_line30[6] <= 16'h0000; 
          char_line31[6] <= 16'h0000;

          char_line0[7] <= 16'h0000;    //7的字模
          char_line1[7] <= 16'h0000;
          char_line2[7] <= 16'h0000;
          char_line3[7] <= 16'h0000;
          char_line4[7] <= 16'h0000;
          char_line5[7] <= 16'h0000;
          char_line6[7] <= 16'h1ffe;
          char_line7[7] <= 16'h1ffe;
          char_line8[7] <= 16'h3c0c;
          char_line9[7] <= 16'h3818;
          char_line10[7] <= 16'h3018;
          char_line11[7] <= 16'h3030;
          char_line12[7] <= 16'h0030;
          char_line13[7] <= 16'h0060;
          char_line14[7] <= 16'h0060;
          char_line15[7] <= 16'h00c0;
          char_line16[7] <= 16'h00c0;
          char_line17[7] <= 16'h00c0;
          char_line18[7] <= 16'h0180;
          char_line19[7] <= 16'h0180;
          char_line20[7] <= 16'h0180;
          char_line21[7] <= 16'h0380;
          char_line22[7] <= 16'h0380;
          char_line23[7] <= 16'h0380;
          char_line24[7] <= 16'h0380;
          char_line25[7] <= 16'h0380;
          char_line26[7] <= 16'h0380;
          char_line27[7] <= 16'h0000;
          char_line28[7] <= 16'h0000;
          char_line29[7] <= 16'h0000;
          char_line30[7] <= 16'h0000; 
          char_line31[7] <= 16'h0000;

          char_line0[8] <= 16'h0000;    //8的字模
          char_line1[8] <= 16'h0000;
          char_line2[8] <= 16'h0000;
          char_line3[8] <= 16'h0000;
          char_line4[8] <= 16'h0000;
          char_line5[8] <= 16'h0000;
          char_line6[8] <= 16'h03f0;
          char_line7[8] <= 16'h07f0;
          char_line8[8] <= 16'h1c1c;
          char_line9[8] <= 16'h380e;
          char_line10[8] <= 16'h380e;
          char_line11[8] <= 16'h380e;
          char_line12[8] <= 16'h3c0e;
          char_line13[8] <= 16'h1e1c;
          char_line14[8] <= 16'h0f18;
          char_line15[8] <= 16'h07f0;
          char_line16[8] <= 16'h0ff0;
          char_line17[8] <= 16'h1c78;
          char_line18[8] <= 16'h383c;
          char_line19[8] <= 16'h701e;
          char_line20[8] <= 16'h700e;
          char_line21[8] <= 16'h700e;
          char_line22[8] <= 16'h700e;
          char_line23[8] <= 16'h700e;
          char_line24[8] <= 16'h381c;
          char_line25[8] <= 16'h1c38;
          char_line26[8] <= 16'h07e0;
          char_line27[8] <= 16'h0000;
          char_line28[8] <= 16'h0000;
          char_line29[8] <= 16'h0000;
          char_line30[8] <= 16'h0000; 
          char_line31[8] <= 16'h0000;

          char_line0[9] <= 16'h0000;    //9的字模
          char_line1[9] <= 16'h0000;
          char_line2[9] <= 16'h0000;
          char_line3[9] <= 16'h0000;
          char_line4[9] <= 16'h0000;
          char_line5[9] <= 16'h0000;
          char_line6[9] <= 16'h07e0;
          char_line7[9] <= 16'h1c30;
          char_line8[9] <= 16'h3818;
          char_line9[9] <= 16'h381c;
          char_line10[9] <= 16'h700c;
          char_line11[9] <= 16'h700e;
          char_line12[9] <= 16'h700e;
          char_line13[9] <= 16'h700e;
          char_line14[9] <= 16'h700e;
          char_line15[9] <= 16'h701e;
          char_line16[9] <= 16'h383e;
          char_line17[9] <= 16'h1c7e;
          char_line18[9] <= 16'h0fce;
          char_line19[9] <= 16'h000e;
          char_line20[9] <= 16'h001c;
          char_line21[9] <= 16'h001c;
          char_line22[9] <= 16'h001c;
          char_line23[9] <= 16'h3838;
          char_line24[9] <= 16'h3870;
          char_line25[9] <= 16'h38e0;
          char_line26[9] <= 16'h0fc0;
          char_line27[9] <= 16'h0000;
          char_line28[9] <= 16'h0000;
          char_line29[9] <= 16'h0000;
          char_line30[9] <= 16'h0000; 
          char_line31[9] <= 16'h0000;
end
//对时钟信号进行分频处理,并得到同步信号
always @ (posedge clk or negedge rst_n)
begin
 if(!rst_n)
   x_cnt<=0;
 else if(x_cnt==1039)   //分频
   x_cnt<=0;
 else
   x_cnt<=x_cnt+1'b1;
end

always @ (posedge clk or negedge rst_n)
begin
  if(!rst_n)
    y_cnt<=0;
  else if(y_cnt==665)   //分频
    y_cnt<=0;
  else if(x_cnt==1039)
    y_cnt<=y_cnt+1'b1;
end

always @ (posedge clk or negedge rst_n)
begin
  if(!rst_n)
    hsync_r<=1;
  else if(x_cnt==0) 
    hsync_r<=0;
  else if(x_cnt==120)      //行同步信号的产生
    hsync_r<=1;
end
 
always @ (posedge clk or negedge rst_n)
begin
  if(!rst_n)
    vsync_r<=1;
  else if(y_cnt==0)
    vsync_r<=0;
  else if(y_cnt==6)        //场同步信号的产生
    vsync_r<=1;
end
 
assign hsync=hsync_r;     //用组合逻辑连接寄存器,避免产生多余的寄存器
assign vsync=vsync_r; 
//-------------------------------------------------------------------------------------
// 有效显示区标志
assign valid = (x_cnt>=187) && (x_cnt<987) && (y_cnt>=31) && (y_cnt<631);
//有效显示区坐标
assign xpos = x_cnt - 11'd187;
assign ypos = y_cnt - 10'd31;
//以上就是将vga显示的时序及显示有效坐标都写好了,下面给出各个坐标上要显示的像素的颜色
//-------------------------------------------------------------------------------------
//分频产生一秒的计时
always @ (posedge clk or negedge rst_n)
begin
  if(!rst_n)
    cnt_r<=0;
  else if(cnt_r==49_999_999)
    cnt_r<=0;
  else
    cnt_r<=cnt_r+1'b1;
 end
 assign cnt=cnt_r;

//计数器计数时间
always @ (posedge clk or negedge rst_n)
begin
 if(!rst_n)
  begin
    bai_r<=0;
    shi_r<=0;
    ge_r<=0;
  end
 else if(cnt==49_999_999)
  begin
    if(ge_r==9)
      begin
       ge_r<=0;
       shi_r<=shi_r+1'b1;
       if(shi_r==9)
        begin
          shi_r<=0;
          bai_r<=bai_r+1'b1;
          if(bai_r==9)
            bai_r<=0;
        end
      end
    else
      ge_r<=ge_r+1'b1;
  end
end

assign ge=ge_r;
assign shi=shi_r;
assign bai=bai_r;
//-------------------------------------------------------------------------------------------
//采用查询的办法,来选择显示的字模
assign line0 = {char_line0[bai],char_line0[shi],char_line0[ge]};
assign line1 = {char_line1[bai],char_line1[shi],char_line1[ge]};
assign line2 = {char_line2[bai],char_line2[shi],char_line2[ge]};
assign line3 = {char_line3[bai],char_line3[shi],char_line3[ge]};
assign line4 = {char_line4[bai],char_line4[shi],char_line4[ge]};
assign line5 = {char_line5[bai],char_line5[shi],char_line5[ge]};
assign line6 = {char_line6[bai],char_line6[shi],char_line6[ge]};
assign line7 = {char_line7[bai],char_line7[shi],char_line7[ge]};
assign line8 = {char_line8[bai],char_line8[shi],char_line8[ge]};
assign line9 = {char_line9[bai],char_line9[shi],char_line9[ge]};
assign line10= {char_line10[bai],char_line10[shi],char_line10[ge]};
assign line11= {char_line11[bai],char_line11[shi],char_line11[ge]};
assign line12= {char_line12[bai],char_line12[shi],char_line12[ge]};
assign line13= {char_line13[bai],char_line13[shi],char_line13[ge]};
assign line14= {char_line14[bai],char_line14[shi],char_line14[ge]};
assign line15= {char_line15[bai],char_line15[shi],char_line15[ge]};
assign line16= {char_line16[bai],char_line16[shi],char_line16[ge]};
assign line17= {char_line17[bai],char_line17[shi],char_line17[ge]};
assign line18= {char_line18[bai],char_line18[shi],char_line18[ge]};
assign line19= {char_line19[bai],char_line19[shi],char_line19[ge]};
assign line20= {char_line20[bai],char_line20[shi],char_line20[ge]};
assign line21= {char_line21[bai],char_line21[shi],char_line21[ge]};
assign line22= {char_line22[bai],char_line22[shi],char_line22[ge]};
assign line23= {char_line23[bai],char_line23[shi],char_line23[ge]};
assign line24= {char_line24[bai],char_line24[shi],char_line24[ge]};
assign line25= {char_line25[bai],char_line25[shi],char_line25[ge]};
assign line26= {char_line26[bai],char_line26[shi],char_line26[ge]};
assign line27= {char_line27[bai],char_line27[shi],char_line27[ge]};
assign line28= {char_line28[bai],char_line28[shi],char_line28[ge]};
assign line29= {char_line29[bai],char_line29[shi],char_line29[ge]};
assign line30= {char_line30[bai],char_line30[shi],char_line30[ge]};
assign line31= {char_line31[bai],char_line31[shi],char_line31[ge]};
//-------------------------------------------------------------------------------------------
//显示位的计算,从高位到低位
always @ (posedge clk or negedge rst_n)
begin
  if(!rst_n)
    char1_bit<=6'h3f;
  else if(xpos==380)
    char1_bit<=47;
  else if(xpos>=380&&xpos<428)
    char1_bit<=char1_bit-1'b1;
end
/*--------------------------------------------------------------------------------------
VGA彩色信号
RGB = 000  黑色    RGB = 100   红色
    = 001  蓝色        = 101   紫色
    = 010  绿色        = 110   黄色
    = 011  青色        = 111   白色
----------------------------------------------------------------------------------------*/
//VGA显示的坐标定位,显示为绿色,背景为白色
always @ (posedge clk)
begin
 if(!valid) vga_rgb<=0;
 else if(xpos>=381&&xpos<430)
 begin
  case(ypos)
    190 : if(line0[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    191 : if(line1[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    192 : if(line2[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    193 : if(line3[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    194 : if(line4[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    195 : if(line5[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    196 : if(line6[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    197 : if(line7[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    198 : if(line8[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    199 : if(line9[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    200 : if(line10[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    201 : if(line11[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    202 : if(line12[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    203 : if(line13[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    204 : if(line14[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    205 : if(line15[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    206 : if(line16[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    207 : if(line17[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    208 : if(line18[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    209 : if(line19[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    210 : if(line20[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    211 : if(line21[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    212 : if(line22[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    213 : if(line23[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    214 : if(line24[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    215 : if(line25[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    216 : if(line26[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    217 : if(line27[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    218 : if(line28[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    219 : if(line29[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    220 : if(line30[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
    221 : if(line31[char1_bit])
             vga_rgb<=3;
          else
             vga_rgb<=0;
   default : vga_rgb<=0;  
  endcase
 end
  else
  vga_rgb<=0;
end
//r,g,b控制液晶屏颜色显示
assign vga_r = vga_rgb[2];
assign vga_g = vga_rgb[1];
assign vga_b = vga_rgb[0]; 
 
endmodule

PARTNER CONTENT

文章评论3条评论)

登录后参与讨论

用户377235 2014-4-16 14:46

为什么输出的rgb 都是一位的 VGA这样能用吗??

用户377235 2013-12-26 19:56

楼主取字模用的是什么软件

用户1710391 2012-12-23 11:20

定义存放数据的寄存器 reg [15:0]char_line0[9:0]; 这是什么意思啊
相关推荐阅读
用户343965 2011-08-06 13:10
NIOS核操作IIC通讯协议
本程序是操作ADS1110芯片的。 在nios核加SDA和SCL两个IO口,SDA为双向的,SCL为输出的。 在IDE中输入如下代码: iic.h中的代码:   #ifndef IIC_H_#defi...
用户343965 2011-06-15 15:42
JTAG下载程序能运行,但是ASP下载,却运行不了
最近,做作品时,想把程序下载到Flash里面去,但是下了好几遍都不行。程序能下载,但是下载完成后,运行起来并不是那么回事。从网上找了一下,发现原来是是自己软件的原因。我用的是Quartus 9.1的,...
用户343965 2011-04-18 23:02
一个男人关心的东西 决定了他的层次
  无意中看到了这篇文章,觉得写得很好,就转过来了。无论是男的还是女的,都应该具备吧!                                                一、拥有自信和风...
用户343965 2011-04-15 19:54
努力做到这几点
在成功的时候要学会谦虚在失败的时候要学会坚毅在快乐的时候要学会节制在痛苦的时候要学会忍耐在愤怒的时候要学会冷静在害怕的时候要学会勇敢在焦虑的时候要学会乐观在迷惑的时候要学会分析在犹豫的时候要学会果断在...
用户343965 2011-04-15 16:53
傻孩子,你对我再好,我也不会爱上你
你可能觉得难过,不是,你应该觉得难过。 因为无论你对我怎么好,我都不领情。 我不是看不到,我只是装作看不到。 我根本不想看到。 你觉得自己很喜欢我, 甚至觉得再没有一个人可以像你那么喜欢我。你用尽全力...
EE直播间
更多
我要评论
3
7
关闭 站长推荐上一条 /3 下一条