目录

序言

原题复现

我的设计


序言

上篇博文:

HDLBits 系列(30)Serial Receiver

写了串行接收器如何接收8位串行数据,正确接收8位串行数据后给一个接收完毕标志信号,这篇博文来继续进一步输出正确接收的串行数据,在done有效时刻输出并行的8bit数据。

特别容易实现,对上篇博客的代码进行略微添加即可。需要注意的是这种uart协议先发送的bit位为低bit位。

原题复现

先给出原题,在给出设计:

Now that you have a finite state machine that can identify when bytes are correctly received in a serial bitstream, add a datapath that will output the correctly-received data byte. out_byte needs to be valid when done is 1, and is don't-care otherwise.

Note that the serial protocol sends the least significant bit first.

我的设计

设计如下:

module top_module(input clk,input in,input reset,    // Synchronous resetoutput [7:0] out_byte,output done
); //// Use FSM from Fsm_seriallocalparam START = 0, B1 = 1, B2 = 2, B3 = 3, B4 = 4, B5 = 5, B6 = 6, B7 = 7, B8 = 8, STOP = 9, DONE0 = 10, DONE1 = 11;reg [3:0] state, next_state;always@(*) begincase(state)START: beginif(in == 0) next_state = B1;else next_state = START;endB1: beginnext_state = B2;endB2: beginnext_state = B3;endB3: beginnext_state = B4;endB4: beginnext_state = B5;endB5: beginnext_state = B6;endB6: beginnext_state = B7;endB7: beginnext_state = B8;endB8: beginnext_state = STOP;endSTOP: beginif(in == 0) next_state = DONE1;else next_state = DONE0;endDONE0: beginif(in == 1) next_state = START;else next_state = B1;endDONE1: beginif(in == 0) next_state = DONE1;else next_state = START;enddefault: beginnext_state = START;endendcaseendalways@(posedge clk) beginif(reset) state <= START;else state <= next_state;endassign done = (state == DONE0) ? 1 : 0;// New: Datapath to latch input bits.reg [7:0] out_byte_mid;always@(*) begincase(state)START: begin;endB1: beginout_byte_mid[0] = in;endB2: beginout_byte_mid[1] = in;endB3: beginout_byte_mid[2] = in;endB4: beginout_byte_mid[3] = in;endB5: beginout_byte_mid[4] = in;endB6: beginout_byte_mid[5] = in;endB7: beginout_byte_mid[6] = in;endB8: beginout_byte_mid[7] = in;endSTOP: begin;endDONE0: begin;endDONE1: begin;enddefault: begin;endendcaseendassign out_byte = (done == 1)? out_byte_mid:'bz;endmodule

测试成功。

HDLBits 系列(31)Serial Receiver and Datapath相关推荐

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

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

  2. HDLBits 系列(8)——Sequential Logic(Finite State Machines(一))

    目录 3.2 Sequential Logic 3.2.5 Finite State Machines 1. Simple FSM 1 (asynchronous reset) 2. Simple F ...

  3. HDLBits 系列(30)Serial Receiver

    目录 序言 原题复现 翻译 状态转移图 我的设计 设计解释 序言 所谓的串行接收器(Serial Receiver),类似,或者根本就是Uart的协议的一种形式,Uart的接收器部分,如何实现呢? 原 ...

  4. 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 ...

  5. HDLBits 系列(39)求解带有奇校验的串口接收数据的简化电路设计

    目录 求助原题 我的方案 状态转移图 我的设计 等待你的方案? 求助原题 先给出原题:(蓝色字体,即是链接本身) We want to add parity checking to the seria ...

  6. SAP PM入门系列31 - IW40 Display Orders (Multilevel)

    SAP PM入门系列31 - IW40 Display Orders (Multilevel) SAP PM模块里,事务代码IW40是另外一个用户查询维护订单(工单)数据的报表.不过它以多层方式显示维 ...

  7. HDLBits 系列(34)Serial two's complememter(Mealy and Moore FSM)

    目录 Mealy 状态机 原题复现 我的设计 Moore 状态机 原题复现 状态转移图 我的设计 Mealy 状态机 原题复现 原题复现: The following diagram is a Mea ...

  8. HDLBits 系列(40)如何写 TestBench 文件?

    目录 序言 变量定义 时钟设计 设计输入 模块例化 实战演练 序言 由于入门的测试文件很简单,所以一直以来也都是直接给出测试文件,直到今天才想着去总结一个测试文件的写法.这篇博客将根据HDLBits的 ...

  9. HDLBits 系列(1)从HDLBits中获取灵感,整顿自己,稳步前行

    目录 前言 对HDLBits的夸赞 最后想说的话 前言 坚持一件事情很难系列,有些事情看似简单,但是坚持做下去确实会有所收获,举个不恰当的例子,总搞一些自己觉得难的东西,会让自己的博客断更,困难的东西 ...

最新文章

  1. mysql 检查哪些项目_mysql根据内容查询在哪个表.go
  2. 经典C语言程序100例之一零零
  3. VC 对话框 DIALOG
  4. ux和ui_从UI切换到UX设计
  5. .Net Core分布式部署中的DataProtection密钥安全性
  6. ajax接受的格式,关于ajax接受json格式的数据
  7. 回溯算法n皇后问题_使用回溯算法的N Queen问题和解决方案
  8. css 浮动效果 0302
  9. kickstart 为 rhel5 创建 ext4 分区
  10. iOS 自带地图定位失败原因 Code=0和Code=1区别
  11. Java 多线程详解(二)------如何创建进程和线程
  12. Android UI--自定义ListView(实现下拉刷新+加载更多)
  13. ISO14229-1道路车辆-统一诊断服务(UDS)-1
  14. 使用docker搭建couchbase集群
  15. python round用法_Python round 函数
  16. 计算机网络安全存在哪些潜在威胁,【计算机安全论文】威胁计算机安全论文(共4016字)...
  17. Difference between Vienna DL LLS and UL LLS
  18. 双系统(win10+ubuntu)引导页消失
  19. Adobe XMP SDK项目应用(续2)
  20. 毕业半年,买了一台MacBook Pro

热门文章

  1. checkio的日子(3)
  2. 转:ASP.NET程序中常用小技巧
  3. 淮北师范大学计算机学院在哪个校区,2021年淮北师范大学信息学院有几个校区,大一新生在哪个校区...
  4. js小数运算出现多为小数问题_JS操作小数运算,结果莫名其妙出现多位小数问题...
  5. eplan和西门子plc的对接_玩转西门子全集成自动化之TIA Selection Tool
  6. python如何并发上千个get_用greenlet实现Python中的并发
  7. mysql主从复制原理详解_MySQL主从复制没使用过?三大步骤让你从原理、业务上理解透彻...
  8. 教师要与时俱进,不要自以为正确
  9. 第十七届全国大学智能车竞赛赛区划分
  10. 参加第十六届全国大学生智能车竞赛广东省报名队伍