您当前的位置: 首页 > 

FPGA硅农

暂无认证

  • 3浏览

    0关注

    282博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

基于移位寄存器的序列检测器实现

FPGA硅农 发布时间:2022-02-24 01:00:00 ,浏览量:3

在基于System verilog的序列检测器一文中,我们通过状态机进行了实现,今天,博主介绍另外一种序列检测的实现方式:移位寄存器。 我们仍然以10010这个序列为例,主要的设计思想如下: 1.设置一个5位的移位寄存器,以及一个计数器; 2.每个时钟周期,该移位寄存器进行一次左移,并将最新的bit输入最低位,计数器自增1; 3.每个周期,都将移位寄存器的值和10010进行比较,若相同,且计数器的值大于等于4(这么做主要为了避免10010010被检测出两次),则说明检测到该序列,此时计数器的值归零。

RTL实现
`timescale 1ns / 1ps
//
// Company: 
// Engineer: 
// 
// Create Date: 2022/02/23 19:53:01
// Design Name: 
// Module Name: top
// Project Name: 
// Target Devices: 
// Tool Versions: 
// Description: 
// 
// Dependencies: 
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 
//


module top(
input logic clk,
input logic rst,
input logic bit_in,
input logic valid,          //标志当前bit有效
output logic detected
    );

logic [4:0] shift_reg;
logic [31:0] count;
//shift_reg
always_ff@(posedge clk,posedge rst)
if(rst)
    shift_reg[4:0]            
关注
打赏
1658642721
查看更多评论
0.0983s