【FPGA学习笔记】VL26 含有无关项的序列检测
2022/7/3 23:20:37
本文主要是介绍【FPGA学习笔记】VL26 含有无关项的序列检测,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
描述
请编写一个序列检测模块,检测输入信号a是否满足011XXX110序列(长度为9位数据,前三位是011,后三位是110,中间三位不做要求),当信号满足该序列,给出指示信号match。
程序的接口信号图如下:
程序的功能时序图如下:
请使用Verilog HDL实现以上功能,并编写testbench验证模块的功能。 要求代码简洁,功能完整。
输入描述:
clk:系统时钟信号 rst_n:异步复位信号,低电平有效 a:单比特信号,待检测的数据输出描述:
match:当输入信号a满足目标序列,该信号为1,其余时刻该信号为0 答:移位寄存器
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
module sequence_detect(
input clk,
input rst_n,
input a,
output reg match
);
reg [ 8 : 0 ] a_r;
always@(posedge clk or negedge rst_n) begin
if (~rst_n)
match <= 1 'b0;
else
match <= (a_r[ 2 : 0 ] == 3 'b110) && (a_r[8:6] == 3' b011);
end
always@(posedge clk or negedge rst_n) begin
if (~rst_n)
a_r <= 9 'b0;
else
a_r <= {a_r[ 7 : 0 ], a};
end
endmodule
|
状态机
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
module sequence_detect(
input clk,
input rst_n,
input a,
output reg match
);
parameter ZERO= 0 , ONE= 1 , TWO= 2 , THREE= 3 , FOUR= 4 , FIVE= 5 , SIX= 6 , SEVEN= 7 , EIGHT= 8 , NINE= 9 ;
reg [ 3 : 0 ] state, nstate;
always@(posedge clk or negedge rst_n) begin
if (~rst_n)
state <= ZERO;
else
state <= nstate;
end
always@(*) begin
case (state)
ZERO : nstate = a? ZERO : ONE;
ONE : nstate = a? TWO : ONE;
TWO : nstate = a? THREE: ONE;
THREE : nstate = FOUR;
FOUR : nstate = FIVE;
FIVE : nstate = SIX;
SIX : nstate = a? SEVEN: ONE;
SEVEN : nstate = a? EIGHT: ONE;
EIGHT : nstate = a? ZERO: NINE;
NINE : nstate = a? TWO : ONE;
default : nstate = ZERO;
endcase
end
always@(posedge clk or negedge rst_n) begin
if (~rst_n)
match = 0 ;
else
match = state==NINE;
end
endmodule
|
这篇关于【FPGA学习笔记】VL26 含有无关项的序列检测的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-13TiDB + ES:转转业财系统亿级数据存储优化实践
- 2024-05-09“2024鸿蒙零基础快速实战-仿抖音App开发(ArkTS版)”实战课程已上线
- 2024-05-09聊聊如何通过arthas-tunnel-server来远程管理所有需要arthas监控的应用
- 2024-05-09log4j2这么配就对了
- 2024-05-09nginx修改Content-Type
- 2024-05-09Redis多数据源,看这篇就够了
- 2024-05-09Google Chrome驱动程序 124.0.6367.62(正式版本)去哪下载?
- 2024-05-09有没有大佬知道这种数据应该怎么抓取呀?
- 2024-05-09这种运行结果里的10.100000001,怎么能最快改成10.1?
- 2024-05-09企业src漏洞挖掘-有意思的命令执行