FPGA中常用写法
来源:互联网 发布:centos jdk1.7 安装 编辑:程序博客网 时间:2024/04/30 08:27
(1)rs232中判断数据起始位
always @(posedge clk)
begin
if(cnt_start==300) %300是通过FPGA在线测试查看rx持续为高的大概时间确定的
process_en <= 1'b1;
else if(rx)
cnt_start <= cnt_start + 1;
else
cnt_start <= 0;
end
//
always @(posedge clk)
if(process_en)
begin
case(TS)
0:begin
if(cnt_wait==8)begin cnt_wait<=0;TS<=TS+1;end //cnt_wait持续8个时钟,防止抖动
else if(~rx) cnt_wait<=cnt_wait+1;
else cnt_wait<=0;
end
180: TS <= 0;
default:TS <= TS + 1;
endcase
end
else
begin
TS <= 0;
cnt_wait <= 0;
end
//
always @(posedge clk)
case(TS)
21: rx_buff[0] <= rx;
41: rx_buff[1] <= rx;
61: rx_buff[2] <= rx;
81: rx_buff[3] <= rx;
101:rx_buff[4] <= rx;
121:rx_buff[5] <= rx;
141:rx_buff[6] <= rx;
161:rx_buff[7] <= rx;
162:DV <= 1'b1;
163:DV <= 1'b0;
endcase
(2)查找数据头
可以将串行的数据转换乘并行,然后与固定头数据进行比较,做出正确的判断
//-------寻找信息头-------//
parameter [47:0] head_data = 48'h24_47_50_47_53_56;//$GPRMC
parameter [15:0] end_data = 16'h0D_0A;
reg [47:0] head_data_temp = 48'd0;
reg [15:0] end_data_temp = 16'd0;
always @ (posedge Clk_192K)
begin
if(data_en)
begin
head_data_temp <= {head_data_temp[39:0],dataout};
end_data_temp <= {end_data_temp[7:0],dataout};
end
end
reg flag = 0;
always @ (posedge Clk_192K)
begin
if(head_data_temp == head_data)
flag <= 1;
else if(end_data_temp == end_data)
flag <= 0;
end
- FPGA中常用写法
- FPGA协议的写法
- FPGA时序约束中常用公式推导
- 竞赛中常用的C++写法
- 程序中常用路径的写法
- java bean 中equal的常用写法
- JavaScript中常用的函数以及基础写法汇总
- android中常用的匿名内部类的写法
- android中app升级的两种常用写法
- Android中常用的两种动画写法
- React.js中常用的ES6写法总结
- Shell中for循环的几个常用写法
- Spring 框架中切入点 pointcut 表达式的常用写法
- Shell中for循环的几个常用写法
- FPGA常用复位处理比较
- fpga 中 clock skew
- FPGA中SRL16资源
- FPGA中LUT设计
- L1-013. 计算阶乘和
- 检查线程是否关闭
- UMG拖放控制
- 第五封信 / 友子,我真的很想你 啊!彩虹
- Python文件读写
- FPGA中常用写法
- shiro整合springmvc
- React componentWillUnmount 替换 this.IsMounted()
- python socket,socketserver
- C#序列化
- when can we meet POJ-2028
- css隐藏滚动条,兼容ie和chrome
- 剑指offer题23
- ubuntu系统下codeblocks安装