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(第二行要显示的字符)....... ...
随机推荐
- [置顶] Ants(Northeastern Europe 2007)
Ants Time Limit: 5 ...
- SQLSERVER误删Windows登录用户
SQLSERVER误删除了Windows登录用户验证方式使用Windows身份验证的解决方法 SQLSERVER误删Windows登录用户验证方式使用Windows身份验证的解决方法 今天看到这篇 ...
- 一致性hash和虚拟节点
consistent hashing 算法的原理 consistent hashing 是一种 hash 算法,简单的说,在移除 / 添加一个 cache 时,它能够尽可能小的改变已存在key 映射关 ...
- c#一个简单的实例告诉你,多继承还可以这么来
我想多继承,要怎么搞???我想你一定会说“接口”,那么你有没有遇到这样的问题,你需要在一个类中继承另外2个类的所有方法,你要怎么做呢???难道要Coyp实现代码?No,往下看... 定义一个空接口比如 ...
- codeigniter(ci)在nginx下返回404的处理方法即codeigniter在nginx下配置方法
codeigniter(ci)在nginx下返回404的处理方法即codeigniter在nginx下配置方法 进入nginx的配置文件 加上一句(本来就有这句,只需要修改一下就行了) locatio ...
- 文本框文字垂直居中 CSS
<html> <head> <style type="text/css"> #text { height:20px; vertical-alig ...
- Jquery EasyUI中treegrid
Jquery EasyUI中treegrid的中右键菜单和一般按钮同时绑定事件时的怪异事件 InChatter系统开源聊天模块前奏曲 最近在研究WCF,又因为工作中的项目需要,要为现有的系统增加一 ...
- MS数据库优化查询最常见的几种方法
1.没有索引或者没有用到索引(这是查询慢最常见的问题,是程序设计的缺陷) 2.I/O吞吐量小,形成了瓶颈效应. 3.没有创建计算列导致查询不优化. 4.内存不足 5.网络速度慢 6.查询出的数据量过大 ...
- OpenXml操作Word的一些操作总结.
OpenXml操作Word的一些操作总结. OpenXml相对于用MS提供的COM组件来生成WORD,有如下优势: 1.相对于MS 的COM组件,因为版本带来的不兼容问题,及各种会生成WORD半途会崩 ...
- MessageBox, MessageBoxBurttons, MessageBoxIcon 详细解析
[函数]:<整型> MessageBox(<字符串 Text, <字符串> Title, <整型> MessageBoxBurttons,MessageBox ...