目录

原题复现

审题

状态转移图

我的设计


原题复现

原题复现:

Synchronous HDLC framing involves decoding a continuous bit stream of data to look for bit patterns that indicate the beginning and end of frames (packets). Seeing exactly 6 consecutive 1s (i.e., 01111110) is a "flag" that indicate frame boundaries. To avoid the data stream from accidentally containing "flags", the sender inserts a zero after every 5 consecutive 1s which the receiver must detect and discard. We also need to signal an error if there are 7 or more consecutive 1s.

Create a finite state machine to recognize these three sequences:

  • 0111110: Signal a bit needs to be discarded (disc).
  • 01111110: Flag the beginning/end of a frame (flag).
  • 01111111...: Error (7 or more 1s) (err).

When the FSM is reset, it should be in a state that behaves as though the previous input were 0.

Here are some example sequences that illustrate the desired operation.

审题

根据题目来看,这是一个序列识别的一个问题,如果识别到序列有连续5个1(即1111_10),则disc有效;

如果有连续6个1(即1111_110),则flag有效;

如果有连续7个1或者更多的1,则err有效。

状态转移图

就是这样一个问题,我们根据上述波形图来画出状态转移图:

我的设计

根据状态转移图,很容易得到设计:

module top_module(input clk,input reset,    // Synchronous resetinput in,output disc,output flag,output err);localparam S0 = 0, S1 = 1, S2 = 2, S3 = 3, S4 = 4, S5 = 5, S6 = 6, DISC = 7, FLAG = 8, ERR = 9;reg [3:0] state, next_state;always@(*) begincase(state)S0: beginif(in) next_state = S1;else next_state = S0;endS1: beginif(in) next_state = S2;else next_state = S0;endS2: beginif(in) next_state = S3;else next_state = S0;endS3: beginif(in) next_state = S4;else next_state = S0;endS4: beginif(in) next_state = S5;else next_state = S0;endS5: beginif(in) next_state = S6;else next_state = DISC;endS6: beginif(in) next_state = ERR;else next_state = FLAG;endDISC: beginif(in) next_state = S1;else next_state = S0;endFLAG: beginif(in) next_state = S1;else next_state = S0;endERR: beginif(in) next_state = ERR;else next_state = S0;enddefault: beginnext_state = S0;endendcaseendalways@(posedge clk)beginif(reset) state <= S0;else state <= next_state;endassign disc = (state == DISC)?1:0;assign flag = (state == FLAG)?1:0;assign err = (state == ERR)?1:0;endmodule

测试成功!

这是序列检测的一个典型做法,校招可没少做这种题目,只是好像都还要比这个简单。

HDLBits 系列(32)Sequence recognition(序列检测)相关推荐

  1. HDLBits 系列(0)专题目录

    本篇博文是近来总结HDLBits系列的目录,点击蓝色字体即可进入查看具体内容. HDLBits 系列(1)从HDLBits中获取灵感,整顿自己,稳步前行 HDLBits 系列(2)如何避免生成锁存器? ...

  2. HDLBits 系列(29)PS/2 mouse protocol(PS/2 packet parser and datapath)

    目录 序言 原题传送 题目解释 我的设计 序言 上篇博客: HDLBits 系列(28)PS/2 mouse protocol(PS/2 packet parser) 只对PS/2 mouse pro ...

  3. anchor free 目标检测_《目标检测》系列之二:目标检测中的Anchor机制回顾

    前段时间,YOLOv4&v5大火,很多人忽视了yolov5在anchor上的一些细节变化,因此,本文从Faster RCNN着手,逐步分析SSD.YOLOv4&v5的anchor机制. ...

  4. 状态机fsm_Verilog专题(三十二)101 Sequence Recognition Mealy FSM(101序列识别状态机)...

    HDLBits网址:https://hdlbits.01xz.net/wiki/Main_Page 题目 实现一个Mealy型有限状态机,该机可以识别输入信号x上的序列" 101" ...

  5. 三段式状态机_FPGA笔试题——序列检测(FSM状态机)

    FSM有限状态机,是FPGA和数字IC相关岗位必须要掌握的知识点,在笔试和面试中都非常常见. (1)了解状态机:什么是摩尔型状态机,什么是米利型状态机,两者的区别是什么?一段式.二段式.三段式状态机的 ...

  6. 神经网络学习小记录50——Pytorch 利用efficientnet系列模型搭建yolov3目标检测平台

    神经网络学习小记录50--Pytorch 利用efficientnet系列模型搭建yolov3目标检测平台 学习前言 什么是EfficientNet模型 源码下载 EfficientNet模型的实现思 ...

  7. 神经网络学习小记录26——Keras 利用efficientnet系列模型搭建yolov3目标检测平台

    神经网络学习小记录26--Keras 利用efficientnet系列模型搭建efficientnet-yolov3目标检测平台 学习前言 什么是EfficientNet模型 源码下载 Efficie ...

  8. SAP PM入门系列32 - S_ALR_87013432 Display Confirmations

    SAP PM入门系列32 - S_ALR_87013432 Display Confirmations S_ALR_87013432 这个报表事务代码,用于查询维修工单(维护订单)的确认数据. 执行事 ...

  9. HDLBits 系列(31)Serial Receiver and Datapath

    目录 序言 原题复现 我的设计 序言 上篇博文: HDLBits 系列(30)Serial Receiver 写了串行接收器如何接收8位串行数据,正确接收8位串行数据后给一个接收完毕标志信号,这篇博文 ...

最新文章

  1. 通过命令行在Python中测试以太坊RPC客户端
  2. win10安装问题小结
  3. jQuery easyUI--下拉菜单的制作
  4. grpc入门到精通_Spring Cloud 从入门到精通(一)Nacos 服务中心初探
  5. SVN: bdb: BDB1538 Program version 5.3 doesn't match environment version 4.7
  6. 从人与世界的关系上来看,人其实分为两部分
  7. 组网胖模式_胖AP和瘦AP的区别,组网优缺点分析
  8. OwnCloud 搭建
  9. paip.html 及css调试工具---debugbar
  10. cad卸载_CAD绘图效率太低?1GCAD逆天插件送给你,用了再也不卸载
  11. html 文件 转换成mp4视频,[swf转视频]一个带有Play播放按钮的swf文件怎么转换成mp4视频...
  12. PHP实现留言板功能
  13. 计算机根号函数,excel公式中开根号是哪一个函数啊(excel开根号的公式)
  14. MySQL-Order by用法
  15. 计算机信息科学学科分类,-学科分类与代码.doc
  16. Docker 入门,万字详解!
  17. ES6基础语法(let、const、解构赋值、模板字符串、简化对象、箭头函数、扩展运算符)(一)
  18. Innovus/Encounter Floorplan命令合集(二)
  19. 一首励志的歌曲《我相信》
  20. java图片高保真缩放

热门文章

  1. php数据采集类,一个数据采集类
  2. svn中项目管理中ec_笔记本电脑中的隐形管家:EC
  3. 顶级Java多线程面试题及回答
  4. 编写微指令 计算机组成,计算机组成原理微指令实验报告
  5. 项目服务器有15个能说明什么,15.1 我的面试经历 by smyhvae - 前端入门进阶
  6. c语言sprt的程序怎么用,sqrt函数在c语言中怎么用?
  7. java 找不到符号变量_java编程找不到符号
  8. mysql和oracle表的互导_oracle到mysql的导数据方式(适用于任意数据源之间的互导)...
  9. flask 检测post是否为空_用Flask和Vue制作一个单页应用(五)
  10. gis快速接地开关_一种基于扫描电镜和能谱仪的GIS放电异物来源分析方法