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(第二行要显示的字符)....... ...
随机推荐
- 定制你自己的jQuery
如何定制你自己的jQuery jQuery随着版本的不断升级代码量也随之增加,从1.0.0的不到两千行到现在的1.10.2已经突破1万行. 新的API不断增加,但有些在项目中并没有用到.jQuery团 ...
- 把《C语言接口与实现》读薄之第一章:引言
1.1文学程序 文学程序(literate program):接口及其实现的代码与对其进行解释的正文交织在一起.文学程序由英文正文和带标签的程序代码块组成.例如, 〈compute x * y〉≡ s ...
- js模版引擎handlebars.js实用教程
js模版引擎handlebars.js实用教程 阅读本文需要了解基本的Handlebars.js概念,本文并不是Handlebars.js基础教程,而是注重于实际应用,为读者阐述使用过程中可能会遇到的 ...
- 一致性hash和虚拟节点
consistent hashing 算法的原理 consistent hashing 是一种 hash 算法,简单的说,在移除 / 添加一个 cache 时,它能够尽可能小的改变已存在key 映射关 ...
- C# 多线程学习总结
C# 多线程学习总结 C#多线程学习(一) 多线程的相关概念 什么是进程? 当一个程序开始运行时,它就是一个进程,进程包括运行中的程序和程序所使用到的内存和系统资源.而一个进程又是由多个线程所组成的. ...
- 《cracking the coding intreview》——链表
前言 最近准备暑假回家回家修整一下,所以时间大部分用来完成项目上的工作,同时为了9月份的校招,晚上的时间我还在学习<cracking the coding intreview>,第二章链表 ...
- 随便讲讲XSS攻击
作为一个前端工程师,XSS漏洞不应该只是安全部门的工作.在项目上马的时候就应该对可能涉及的安全问题有所预防才是有一个好前端.- - 什么是XSS •跨站脚本攻击(Cross-site script ...
- C#HTTP代理的实现之注册表实现
HTTP代理的实现形式,可以通过修改注册表项,然后启动浏览器来实现,也可以通过SOCKET通信,构造HTTP头实现.下面是关于注册表实现的方式. 注册表实现,只需要修改几个关键的注册表项就可以了. 第 ...
- [每日一题] OCP1z0-047 :2013-07-26 alter table set unused之后各种情况处理
有疑问可以去itpub讨论:http://www.itpub.net/thread-1804872-1-1.html 对于alter table setunused的用法,查官方文档: alter_t ...
- oracle中backup模式
在数据库打开的情况下备份(归档模式),把表空间或者数据库置于backup 模式下, 如: SQL> alter database begin backup; Database altered ...