看图写代码

阅读<<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 >>的更多相关文章

  1. 瞧一瞧,看一看呐,用MVC+EF快速弄出一个CRUD,一行代码都不用写,真的一行代码都不用写!!!!

    瞧一瞧,看一看呐用MVC+EF快速弄出一个CRUD,一行代码都不用写,真的一行代码都不用写!!!! 现在要写的呢就是,用MVC和EF弄出一个CRUD四个页面和一个列表页面的一个快速DEMO,当然是在不 ...

  2. mpvue微信小程序怎么写轮播图,和官方微信代码的差别

    目前用mpvue很多第三方的ui库是引入不了的,因为它不支持含有dom操作. 那我们要做轮播图的话一个是手写另外一个就是用小程序的swiper组件了: 官方代码: <swiper indicat ...

  3. 原生Js写轮播图代码

    html css js 在知道jQuery如何实现轮播效果的基础上,用js写代码 如图:标记这里的地方 理解一下 用到的知识: 1.HTML DOM 的appendChild() 和 removeCh ...

  4. 用最简单的代码写出banner图轮播效果

    以下视频是由[赵一鸣随笔]博客提供的“用最简单的代码写出banner图轮播效果”. 查看全屏高清视频,请点击链接:http://www.zymseo.com/58.html

  5. 如何写出优雅的CSS代码 ?(转)

    对于同样的项目或者是一个网页,尽管最终每个前端开发工程师都可以实现相同的效果,但是他们所写的代码一定是不同的.有的优雅,看起来清晰易懂,代码具有可拓展性,这样的代码有利于团队合作和后期的维护:而有的混 ...

  6. 如何写出优雅的css代码 ?

    如何写出优雅的css代码 ? 对于同样的项目或者是一个网页,尽管最终每个前端开发工程师都可以实现相同的效果,但是他们所写的代码一定是不同的.有的优雅,看起来清晰易懂,代码具有可拓展性,这样的代码有利于 ...

  7. 从div盒子模型谈如何写可维护的css代码(转)

    市面上我们常常会看到各种各样的设计模式书籍,Java设计模式.C#设计模式.Ruby设计模式等等.在众多的语言设计模式中我唯独找不到关于CSS设计模式的资料,即使在网上找到类似内容,细细一看之下才发觉 ...

  8. Nodejs开源项目里怎么样写测试、CI和代码测试覆盖率

    测试 目前主流的就bdd和tdd,自己查一下差异 推荐 mocha和tape 另外Jasmine也挺有名,angularjs用它,不过挺麻烦的,还有一个选择是qunit,最初是为jquery测试写的, ...

  9. UML类图应该怎么看?

    学无止境,精益求精 十年河东,十年河西,莫欺少年穷 学历代表你的过去,能力代表你的现在,学习代表你的将来 我每次写博基本都是这样开头,除了激励自己,每句话也都挺有道理! 呵呵,今天是阴历2017年我工 ...

随机推荐

  1. HDU 6106 17多校6 Classes(容斥简单题)

    Problem Description The school set up three elective courses, assuming that these courses are A, B, ...

  2. 【Python】多线程-2

    1.    进程和线程的区别: (1) 一个进程可以有多个线程,一个进程中的多个线程共享该进程的所有资源,多线程切换比多进程切换快,因为不用上下文切换,Python中并发建议用多进程 (2) 进程是资 ...

  3. XML Schema——笔记整理

    什么是 XML Schema? 定义可出现在文档中的元素 定义可出现在文档中的属性 定义哪个元素是子元素 定义子元素的次序 定义子元素的数目 定义元素是否为空,或者是否可包含文本 定义元素和属性的数据 ...

  4. [转]一文读懂《梁宁·产品思维30讲》最精华内容(含全套PPT)

    http://chuansong.me/n/2294260949029 8 年前,我的主业是产品经理,产品思维改变了我认识世界的方式,让我明白司空见惯的设计,也有其底层逻辑. 几年后我接触培训.运营自 ...

  5. php防止sql注入的方法(转)

    [一.在服务器端配置] 安全,PHP代码编写是一方面,PHP的配置更是非常关键. 我们php手手工安装的,php的默认配置文件在 /usr/local/apache2/conf/php.ini,我们最 ...

  6. c语言求最大公约数和最小公倍数(转)

    最大公约数与最小公倍数的求解是很多初学C的人所面临的一道问题.当然这道问题并不难解答,也有很多人已经写过相关的博客,我在此书写此篇博客,一是为了让自己能够夯实基础,另外就是希望能够帮到和我一样的初学者 ...

  7. PHP设计模式之观察者模式(转)

    开篇还是从名字说起,“观察者模式”的观察者三个字信息量很大.玩过很多网络游戏的童鞋们应该知道,即便是斗地主,除了玩家,还有一个角色叫“观察者".在我们今天他谈论的模式设计中,观察者也是如此. ...

  8. 打印GBK、GB2312字符集全字符

    根据编码表填充数据就可以了~~~~(>_<)~~~~~\(≧▽≦)/~啦啦啦 #include <stdio.h> #include <stdlib.h> #inc ...

  9. [LeetCode&Python] Problem 122. Best Time to Buy and Sell Stock II

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  10. xdoj-1010(区间问题)

    题目链接 1 扫描一遍不行扫描两遍呗 2 O(n)时间确定cd[i]  [max( a[k]-_min) _min是k+1~n的最小值.i<=k<=n] #include <cstd ...