fpga之显示字符串
//必须在有效区域下显示颜色才有颜色
显示字符可以在设定一个有效区域内显示
另加两个wire 求出新的x,y
module vga_fpga(
clk,rst_n,
vga_b,vga_g,vga_r,rom_data,rom_addr,
VGA_HS,VGA_VS,
VGA_BLANK_N,VGA_SYNC_N,VGA_CLK
);
input clk,rst_n;
output [4:0] rom_addr;
output [127:0]rom_data;
output [7:0] vga_b;
output [7:0] vga_g;
output [7:0] vga_r;
output VGA_BLANK_N ;
output VGA_HS;
output VGA_SYNC_N;
output VGA_VS;
output VGA_CLK;
/*********************************/
//扫描x,y;
reg [10:0] count_x;//计数列
reg [10:0] count_y;//计数行
always @(posedge clk or negedge rst_n)
if(!rst_n)
count_x <= 1'd0;
else if(count_x == 11'd1056)
count_x <= 1'd0;
else
count_x <= count_x + 1'b1;
always @(posedge clk or negedge rst_n)
if(!rst_n)
count_y <= 1'd0;
else if(count_y == 11'd625)
count_y <= 1'd0;
else if(count_x == 11'd1056)
count_y <= count_y +1'd1;
else
count_y <= count_y;
/************************************/
//行列同步
assign VGA_VS = (count_y <= 11'd3) ? 1'b0 : 1'b1;
assign VGA_HS = (count_x <= 11'd80)? 1'b0 : 1'b1;
assign VGA_SYNC_N = (count_y <= 11'd3) ? 1'b0 : 1'b1;
assign VGA_BLANK_N = (count_x <= 11'd80)? 1'b0 : 1'b1;
/**************************************/
//是否行列有效
reg isready;
always @(posedge clk or negedge rst_n)
if(!rst_n)
isready <= 1'b0;
else if((count_x > 11'd240 && count_x < 11'd1040)&&(count_y > 11'd24 && count_y < 11'd624))
isready <= 1'b1;
else
isready <= 1'b0;
/************************************/
//x,y坐标
wire [10:0]loca_x;
wire [10:0]loca_y;
assign loca_x = isready ? count_x-11'd240 : 11'd0;
assign loca_y = isready ? count_y-11'd24 : 11'd0;
/*****************************************/
//显示 从第一百行 第一百列开始
//在小矩形框内显示
reg isvalid;
always @(posedge clk or negedge rst_n)
if(!rst_n)
isvalid <= 1'b0;
else if((loca_x > 7'd99 && loca_x < 8'd228)&&(loca_y > 7'd99 && loca_y < 8'd132))
isvalid <= 1'b1;
else isvalid <= 1'b0;
wire [7:0] valid_x;
wire [7:0] valid_y;
assign valid_x = isvalid ? loca_x - 8'd100 :1'd0;
assign valid_y = isvalid ? loca_y - 8'd100 :1'd0;
/*****************************************/
reg [5:0] l;//行
always @(posedge clk or negedge rst_n)
if(!rst_n)
l <= 1'd0;
else if(isready && (valid_y < 7'd32))
l <= valid_y;
// else
// l <= 1'd0;
reg [7:0] h;
always @(posedge clk or negedge rst_n)
if(!rst_n)
h <= 1'd0;
else if(isready && (valid_x < 8'd128))
h <= valid_x;
//else
// h <= 1'd0;
//显示颜色
reg [23:0] vga_s;
always @(posedge clk or negedge rst_n)
if(!rst_n)
vga_s <= 24'd0;
else if( rom_data[7'd127 - h] && isvalid)
vga_s <= 24'hfffafa; //baise
else if(!rom_data[7'd127 - h] && isvalid)
vga_s <= 24'h008b00; //绿
else
vga_s <= 24'hffec8b;//huang
/**********************************************/
vga_rom (
.address (rom_addr ),
.clock ( clk ),
.q ( rom_data )
);
assign rom_addr = l;
assign VGA_CLK = clk;
assign vga_b = isready ? vga_s[7:0] :8'd0;
assign vga_g = isready ? vga_s[15:8] :8'd0;
assign vga_r = isready ? vga_s[23:16]:8'd0;
endmodule
fpga之显示字符串的更多相关文章
- 强化学习实战 | 自定义gym环境之显示字符串
如果想用强化学习去实现扫雷.2048这种带有数字提示信息的游戏,自然是希望自定义 gym 环境时能把字符显示出来.上网查了很久,没有找到gym自带的图形工具Viewer可以显示字符串的信息,反而是通过 ...
- x8086汇编在显存中显示字符串
题目:在屏幕中间显示绿色,绿底红色,白底蓝色的字符串‘welcome to masm!’ 80X25彩色字符模式显示缓冲区的结构: 在内存地址结构中,B8000H~BFFFFH共32KB的空间,为80 ...
- fpga vga 显示
VGA(Video Graphics Array)是IBM在1987年随PS/2机一起推出的一种视频传输标准,具有分辨率高.显示速率快.颜色丰富等优点,在彩色显示器领域得到了广泛的应用.不支持热插拔, ...
- 嵌入式中 动态阿拉伯语字符串 转换 LCD显示字符串【感谢建国雄心】
本文参考CSDBN:建国雄心 的博客,这里找不到该帖子,放一个类似的仅供参考https://blog.csdn.net/qiaojiongzeng6321/article/details/748572 ...
- 让QtCreator在调试时显示字符串 Qt调试助手 QtDebuggingHelper qtc-debugging-helper
When starting gdb with application message “Debugging Helper Missing” is displayed [Solved] http://q ...
- 应中DOS中断显示字符串(摘自《汇编语言》王爽)
data segment s1 db 'Good,better,best,$' s2 db 'Never let it rest,$' s3 db 'Till good is better,$' s4 ...
- php 每隔30s在页面显示字符串
例子 // 30秒执行一次 ignore_user_abort(); //即使Client断开(如关掉浏览器),PHP脚本也可以继续执行. set_time_limit(); // 执行时间为无限制, ...
- 编程:在屏幕中间分别显示绿色、绿底红色、白底蓝色的字符串 'welcome to masm!'
body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...
- C# 字符串多行显示、文本换行
以textbox为例 ①:先设置textbox的属性Multiline为true ②:组织好显示字符串:FistLine(第一行要显示的字符).SecondLine(第二行要显示的字符)....... ...
随机推荐
- Java基础之集合:概览
Java Basic->Collections->Overview 先抛一个问题,用一个类似树形的结构,介绍下 Java 的集合类数据结构:有哪些,从简单到复杂,有怎么样的继承关系. 下面 ...
- windows 8以上找回开始菜单
步骤如下: 右击任务栏,选择工具栏——新建工具 在工具栏---新建工具栏的输入框中输入,”C:\ProgramData\Microsoft\Windows\Start Menu\Programs,然后 ...
- 使用typeof方法反射属性和方法
Type type = typeof(System.Int32);//获得int类型的Type对象 foreach (MethodInfo method in type.GetMethods())// ...
- ubuntu下无法打开windows下ntfs文件系统的解决方法
例如:/dev/sda5无法加载,使用如下命令 sudo ntfsfix /dev/sda5 如果命令没有安装,先安装(sudo apt-get install ntfsprogs).
- 记录在IIS中安装部署Orchard遇到的问题
本机环境:Windows 8.1 + IIS8.5 + VS2013+SQLServer2012 首先是从官网直接下载Orchard.Web 1.7.2版的安装包,在本机IIS上部署,按官方文档一步步 ...
- C#中鼠标划过按钮时候的提示信息
ToolTip p = new ToolTip(); p.ShowAlways = true; p.SetToolTip(this.Buton1, &quo ...
- SpringMVC入门笔记一
SpringMVC优势 性能比struts2好 简单 便捷 易学 和Spring无缝集成(使用spring ioc aop) 约定优于配置 能够简单进行Junit测试 ...
- 一,IL访问静态属性和字段
一,IL访问静态属性和字段 IL介绍 通用中间语言(Common Intermediate Language,简称CIL,发音为"sill"或"kill")是一 ...
- .NET程序集1
谈谈.NET程序集(一) 谈谈.NET程序集(一) The Assembly in .NET by 唐小崇 http://www.cnblogs.com/tangchong 在.NET出现之前, Wi ...
- Android: Type Method 'NewStringUTF' could not be resolved
编译一个最简单的Android NDK 例子(android-ndk-r8/samples/hello-jni)出现了错误信息:Type Method 'NewStringUTF' could n ...