看图写代码---看图写代码 阅读<<Audio/Video Connectivity Solutions for Virtex-II Pro and Virtex-4 FPGAs >>
看图写代码
阅读<<Audio/Video Connectivity Solutions for Virtex-II Pro and Virtex-4 FPGAs >>
1.SDI Block Diagram and SD-SDI Section Chapters
2.XYZ Word Format for the 4:4:4:4 TRS Symbol
端口定义:
module trs_detect (
// inputs
clk, // clock input
ce, // clock enable
rst, // async reset input
vid_in, // video input // outputs
vid_out, // delayed and clipped video output
rx_trs, // asserted during first word of TRS symbol
rx_eav, // asserted during first word of an EAV symbol
rx_sav, // asserted during first word of an SAV symbol
rx_f, // field bit from last received TRS symbol
rx_v, // vertical blanking interval bit from last TRS symbol
rx_h, // horizontal blanking interval bit from last TRS symbol
rx_xyz, // asserted during TRS XYZ word
rx_xyz_err, // XYZ error flag for non-4444 standards
rx_xyz_err_4444,// XYZ error flag for 4444 standards
rx_anc, // asserted during first word of ADF
rx_edh // asserted during first word of ADF if it is an EDH packet
);
以下代码的作用是对输入数据(vid_in)进行解码:
1.寄存器锁存vid_in数据:
//
// in_reg
//
// The input register loads the value on the vid_in port.
//
always @ (posedge clk or posedge rst)
if (rst)
in_reg <= ;
else if (ce) //时钟使能
in_reg <= vid_in; //接收数据
2.检测是否有输入的数据全为1即3FF,或者全为0即000:
all_ones_in 和 all_zeros_in采用的是组合逻辑
//
// all ones and all zeros detectors
//
// This logic determines if the input video word is all ones or all zeros. To
// provide compatibility with 8-bit video equipment, the LS two bits are
// ignored.
//
assign all_ones_in = &in_reg[:]; //检测输入的图像数据是否全为0或者1
assign all_zeros_in = ~|in_reg[:];
3.将接收到的视频数据,和生成的all_ones_in , all_zeros_in信号存入寄存器 pipe1
//
// pipe1
//
// The pipe1 register holds the inut video and the outputs of the all zeros
// and all ones detectors.
//
always @ (posedge clk or posedge rst) //锁存接收到的数据
if (rst)
begin
pipe1_vid <= ;
pipe1_ones <= 'b0;
pipe1_zeros <= 'b0;
end
else if (ce)
begin
pipe1_vid <= in_reg;
pipe1_ones <= all_ones_in;
pipe1_zeros <= all_zeros_in;
end
4.将pipe1里面的数据存入pipe2寄存器,这就相当于把pipe1延时一个时钟周期:
//
// pipe2_reg
//
// The pipe2 register delays the contents of the pipe1 register for one more
// clock cycle.
//
always @ (posedge clk or posedge rst) //将pipe1延时一个时钟周期
if (rst)
begin
pipe2_vid <= ;
pipe2_ones <= 'b0;
pipe2_zeros <= 'b0;
end
else if (ce)
begin
pipe2_vid <= pipe1_vid;
pipe2_ones <= pipe1_ones;
pipe2_zeros <= pipe1_zeros;
end
5.现在我们可以认为,pipe2寄存器里面传入的是最先传入的第一个视频数据,pipe1里面传入的是紧跟着的第二个视频数据,all_zeros_in显示的是当前传入的视频数据的状态。此段代码的功能是对三个连续的视频数据进行检测,是否有3ff,000,000 和 000,000,3ff这样连续的三个数据。
//
// TRS & ANC detector
//
// The trs signal when the sequence 3ff, 000, 000 is stored in the pipe2, pipe1,
// and in_reg registers, respectively. The anc signal is asserted when these
// same registers hold the sequence 000, 3ff, 3ff.
//
assign trs = all_zeros_in & pipe1_zeros & pipe2_ones; //原来如此,3ff,000,000检测
assign anc = all_ones_in & pipe1_ones & pipe2_zeros; //000,3ff,3ff 检测
assign eav = trs & vid_in[]; //当检测到了trs之后,下一个视频数据就是xyz的信息,其中的第6位为H H =1
assign sav = trs & ~vid_in[]; // H = 0
当检测到3ff,000,000 时,trs变为高电平,当检测到000,000,3ff时,anc变为高电平,当检测到TRS时候,我们再解码EAV 和 SAV。
参考BT.656的标准:
我们可以知道,SAV 和 EAV 是由TRS symbol 中的第6位H的值来确定的,因此有了:eav 和 sav 信号的逻辑产生。
6.产生 f, v, h信号
//
// f, v, and h flag generation
//
assign f = trs ? vid_in[] : out_reg_f;
assign v = trs ? vid_in[] : out_reg_v;
assign h = trs ? vid_in[] : out_reg_h;
当检测到trs信号时,f,v,h的信号分别是当前传入视频数据的第8,7,6位,当没有检测到trs信号时,返回的是输出寄存器里面的值,即上一次检测到trs的时候,f,v,h的状态
7.关于XYZ信号的检测
首先:trs将值传递给out_reg_trs需要一个时钟周期。
//
// output reg
//
// The output register holds the the output video data and various flags.
//
always @ (posedge clk or posedge rst)
if (rst)
begin
out_reg_vid <= ;
out_reg_trs <= 'b0;
out_reg_eav <= 'b0;
out_reg_sav <= 'b0;
out_reg_anc <= 'b0;
out_reg_edh <= 'b0;
out_reg_xyz <= 'b0;
out_reg_xyz_err <= 'b0;
out_reg_xyz_err_4444 <= 'b0;
out_reg_f <= ;
out_reg_v <= ;
out_reg_h <= ;
end
else if (ce)
begin
out_reg_vid <= pipe2_vid;
out_reg_trs <= trs;
out_reg_eav <= eav;
out_reg_sav <= sav;
out_reg_anc <= anc;
out_reg_edh <= anc & edh_in;
out_reg_xyz <= xyz;
out_reg_xyz_err <= xyz_err;
out_reg_xyz_err_4444 <= xyz_err_4444;
out_reg_f <= f;
out_reg_v <= v;
out_reg_h <= h;
end
然后:out_reg_trs传入trs_delay[0]信号需要一个时钟周期
//
// trs_delay register
//
// Used to assert the xyz signal when pipe2 contains the XYZ word of a TRS
// symbol.
always @ (posedge clk or posedge rst)
if (rst)
trs_delay <= 'b00;
else if (ce)
trs_delay <= {trs_delay[], out_reg_trs};
将out_reg_trs的值传递到trs_delay[1]又需要一个时钟周期
经过三个时钟周期,XYZ的值已经存储在了pipe2寄存器上面,因此才有了如下代码:对xyz中的数据进行校验。
//
// XYZ and XYZ error logic
//
// The xyz signal is asserted when the pipe2 register holds the XYZ word of a
// TRS symbol. The xyz_err signal is asserted if an error is detected in the
// format of the XYZ word stored in pipe2. This signal is not valid for the
// 4444 component digital video formats. The xyz_err_4444 signal is asserted
// for XYZ word format errors.
//
assign xyz = trs_delay[]; assign xyz_err =
xyz &
((pipe2_vid[] ^ pipe2_vid[] ^ pipe2_vid[]) | // P3 = V ^ H
(pipe2_vid[] ^ pipe2_vid[] ^ pipe2_vid[]) | // P2 = F ^ H
(pipe2_vid[] ^ pipe2_vid[] ^ pipe2_vid[]) | // P1 = F ^ V
(pipe2_vid[] ^ pipe2_vid[] ^ pipe2_vid[] ^ pipe2_vid[]) | // P0 = F ^ V ^ H
~pipe2_vid[]); assign xyz_err_4444 =
xyz &
((pipe2_vid[] ^ pipe2_vid[] ^ pipe2_vid[] ^ pipe2_vid[]) | // P4 = F ^ V ^ H
(pipe2_vid[] ^ pipe2_vid[] ^ pipe2_vid[] ^ pipe2_vid[]) | // P3 = F ^ V ^ S
(pipe2_vid[] ^ pipe2_vid[] ^ pipe2_vid[] ^ pipe2_vid[]) | // P2 = V ^ H ^ S
(pipe2_vid[] ^ pipe2_vid[] ^ pipe2_vid[] ^ pipe2_vid[]) | // P1 = F ^ H ^ S
~pipe2_vid[]);
看图写代码---看图写代码 阅读<<Audio/Video Connectivity Solutions for Virtex-II Pro and Virtex-4 FPGAs >>的更多相关文章
- 瞧一瞧,看一看呐,用MVC+EF快速弄出一个CRUD,一行代码都不用写,真的一行代码都不用写!!!!
瞧一瞧,看一看呐用MVC+EF快速弄出一个CRUD,一行代码都不用写,真的一行代码都不用写!!!! 现在要写的呢就是,用MVC和EF弄出一个CRUD四个页面和一个列表页面的一个快速DEMO,当然是在不 ...
- mpvue微信小程序怎么写轮播图,和官方微信代码的差别
目前用mpvue很多第三方的ui库是引入不了的,因为它不支持含有dom操作. 那我们要做轮播图的话一个是手写另外一个就是用小程序的swiper组件了: 官方代码: <swiper indicat ...
- 原生Js写轮播图代码
html css js 在知道jQuery如何实现轮播效果的基础上,用js写代码 如图:标记这里的地方 理解一下 用到的知识: 1.HTML DOM 的appendChild() 和 removeCh ...
- 用最简单的代码写出banner图轮播效果
以下视频是由[赵一鸣随笔]博客提供的“用最简单的代码写出banner图轮播效果”. 查看全屏高清视频,请点击链接:http://www.zymseo.com/58.html
- 如何写出优雅的CSS代码 ?(转)
对于同样的项目或者是一个网页,尽管最终每个前端开发工程师都可以实现相同的效果,但是他们所写的代码一定是不同的.有的优雅,看起来清晰易懂,代码具有可拓展性,这样的代码有利于团队合作和后期的维护:而有的混 ...
- 如何写出优雅的css代码 ?
如何写出优雅的css代码 ? 对于同样的项目或者是一个网页,尽管最终每个前端开发工程师都可以实现相同的效果,但是他们所写的代码一定是不同的.有的优雅,看起来清晰易懂,代码具有可拓展性,这样的代码有利于 ...
- 从div盒子模型谈如何写可维护的css代码(转)
市面上我们常常会看到各种各样的设计模式书籍,Java设计模式.C#设计模式.Ruby设计模式等等.在众多的语言设计模式中我唯独找不到关于CSS设计模式的资料,即使在网上找到类似内容,细细一看之下才发觉 ...
- Nodejs开源项目里怎么样写测试、CI和代码测试覆盖率
测试 目前主流的就bdd和tdd,自己查一下差异 推荐 mocha和tape 另外Jasmine也挺有名,angularjs用它,不过挺麻烦的,还有一个选择是qunit,最初是为jquery测试写的, ...
- UML类图应该怎么看?
学无止境,精益求精 十年河东,十年河西,莫欺少年穷 学历代表你的过去,能力代表你的现在,学习代表你的将来 我每次写博基本都是这样开头,除了激励自己,每句话也都挺有道理! 呵呵,今天是阴历2017年我工 ...
随机推荐
- Python 多个装饰器装饰同一个函数
def wrapper1(fn): def inner(*args, **kwargs): print("1111111") ret = fn(*args, **kwargs) p ...
- phpcms 新建模块安装
1.安装配置---小问题: 估计就我这么傻 T-T ,改成自己的目录名. 2.模块的目录: 模块存放在modules文件夹里,打开这个文件夹,里面的一个文件夹代表一个模块. 3.建立模块以及其基本目 ...
- java杨辉三角和空心菱形(二维数组篇)
一.杨辉三角 import java.util.Scanner; //导入包 public class Test7 { public static void main(String[]args){ S ...
- A记录和CNAME记录的区别
1.什么是域名解析? 域名解析就是国际域名或者国内域名以及中文域名等域名申请后做的到IP地址的转换过程.IP地址是网路上标识您站点的数字地址,为了简单好记,采用域名来代替ip地址标识站点地址.域名的解 ...
- 20165228 2017-2018-2 《Java程序设计》第5周学习总结
20165228 2017-2018-2 <Java程序设计>第5周学习总结 教材学习内容总结 内部类和匿名类 通过throw关键字抛出异常对象,终止方法的继续执行 使用try-catch ...
- fatal: unable to access 'https://xxxxx': SSL connect error
/********************************************************************** * fatal: unable to access 'h ...
- WEBBASE篇: 第二篇, HTML知识2
HTML知识2 <!doctype html> <html lang="en"> <head> <meta charset="U ...
- go:基于时间轮定时器方案
/* * http://blog.csdn.net/yueguanghaidao/article/details/46290539 * 修改内容:为定时器增加类型和参数属性,修改回调函数类型 */ p ...
- TP thinkphp 权限管理 权限认证 功能
(如有打扰,请忽略)阿里云ECS大羊群,2U4G低至1.4折,限实名新用户,需要的点吧https://promotion.aliyun.com/ntms/act/vm/aliyun-group/tea ...
- Java基础一(开发环境、注释、关键字、标识符、数据)
1.Java开发环境搭建2.HelloWorld案例3.注释.关键字.标识符4.数据(数据类型.常量) ###01java语言概述 * A: java语言概述 * a: Java是sun公司开发的一门 ...