目录

求助原题

我的方案

状态转移图

我的设计

等待你的方案?


求助原题

先给出原题:(蓝色字体,即是链接本身)

We want to add parity checking to the serial receiver. Parity checking adds one extra bit after each data byte. We will use odd parity, where the number of 1s in the 9 bits received must be odd. For example, 101001011 satisfies odd parity (there are 5 1s), but 001001011 does not.

Change your FSM and datapath to perform odd parity checking. Assert the done signal only if a byte is correctly received and its parity check passes. Like the serial receiver FSM, this FSM needs to identify the start bit, wait for all 9 (data and parity) bits, then verify that the stop bit was correct. If the stop bit does not appear when expected, the FSM must wait until it finds a stop bit before attempting to receive the next byte.

You are provided with the following module that can be used to calculate the parity of the input stream (It's a TFF with reset). The intended use is that it should be given the input bit stream, and reset at appropriate times so it counts the number of 1 bits in each byte.

module parity (input clk,input reset,input in,output odd);always @(posedge clk)if (reset) odd <= 0;else if (in) odd <= ~odd;endmodule

Note that the serial protocol sends the least significant bit first, and the parity bit after the 8 data bits.

我的方案

如何用状态机设计这个电路呢?

求助路过的同行尝试做下这个题?

如果能Success,希望能告知一下,感谢。

我已经把不带奇偶校验的设计给出,如下:

https://blog.csdn.net/Reborn_Lee/article/details/103438860

https://blog.csdn.net/Reborn_Lee/article/details/103439297

最后给出我的不成功的方案:

状态转移图

我的设计

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, B9 = 9, STOP = 10, D0 = 11, D1 = 12, D2 = 13;reg [3:0] state, next_state;wire odd;wire en;reg [7:0] out_byte_mid;always@(*) begincase(state)START: beginif(~in) 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 = B9;endB9: beginnext_state = STOP;endSTOP: beginif(in&&odd) next_state = D0;else if(in&&(~odd)) next_state = D2;else next_state = D1;endD0: beginif(in == 1) next_state = START;else next_state = B1;endD1: beginif(in == 0) next_state = D1;else next_state = START;endD2: beginif(in) next_state = D2; else next_state = B1;enddefault: beginnext_state = START;endendcaseendalways@(posedge clk) beginif(reset) state <= START;else state <= next_state;endalways@(*) 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;endB9: begin;endSTOP: begin;endD0: begin;endD1: begin;endD2: begin;enddefault: begin;endendcaseendassign done = (state == D0) ? 1 : 0;assign en = (state == B1)||(state == B2)||(state == B3)||(state == B4) ||(state == B5)||(state == B6)||(state == B7)||(state == B8)||(state == B9) ? 1: 0;assign out_byte = done ? out_byte_mid : 8'b0;// New: Add parity checking.parity inst_parity(.clk(clk),.reset(reset),.in(in&en),//.en(en),.odd(odd));endmodule

等待你的方案?

20200107更新,下面是群里的一位老哥的答案,十分感谢,还没来得及看,先放这里,以免忘记。

module top_module(input clk,input in,input reset,    // Synchronous resetoutput [7:0] out_byte,output done
); reg odd;reg[4:0] state,nstate;parameter start=0,d0=1,d1=2,d2=3,d3=4,d4=5,d5=6,d6=7,d7=8,stop=9,done1=10,done2=11,w=13,p=12; always@(*)begincase(state)start:begin if(in==0)nstate=d0;else nstate=start;endd0:begin nstate=d1;out_byte[0]=in;endd1:begin nstate=d2;out_byte[1]=in;endd2:begin nstate=d3;out_byte[2]=in;endd3:begin nstate=d4;out_byte[3]=in;endd4:begin nstate=d5;out_byte[4]=in;endd5:begin nstate=d6;out_byte[5]=in;endd6:begin nstate=d7;out_byte[6]=in;endd7:begin nstate=p;out_byte[7]=in;endp: begin nstate=stop; odd=^out_byte[7:0]^in; endstop: begin if(in==1) nstate=done1;else nstate=w; enddone1:begin if(in==1) nstate=start;else nstate=d0; endw:begin if(in==1) nstate=start;else nstate=w; endendcaseendalways@(posedge clk)beginif(reset==1)state<=start;elsestate<=nstate;endassign done=(state==done1&&odd)?1:0;
endmodule

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

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

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

  2. 串口通信 / 奇校验、偶校验、0 校验和 1 校验

    --------------------------------------------- -- 时间:2019-01-28 -- 创建人:Ruo_Xiao -- 邮箱:xclsoftware@163 ...

  3. Verilog[奇校验电路]

    奇校验电路原理 奇校验: 以此为例,输入信号为Symbol,包含7为信息码元和1位校验位. 发送端通过对校验位赋值,使输入信号中1数目为奇数. 在传输过程中信号可能会受到干扰导致码元翻转,为了判定是否 ...

  4. CN_奇偶校验_奇校验码和偶校验码的概念和实例

    文章目录 奇偶校验码 奇校验: 使用(验证)方法 偶校验: 验证方法 小结 奇偶校验码结构 exercise:补全给定二进制串的奇偶校验码 奇偶校验码 奇偶校验码就是在信息码后面加一位校验码,分奇校验 ...

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

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

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

  7. verilog简单奇校验

    介绍 ·奇偶校验:根据被传输的一组二进制代码的数位中"1"的个数是奇数或偶数来进行校验.采用奇数的称为奇校验,反之,称为偶校验.采用何种校验是事先规定好的.通常专门设置一个奇偶校验 ...

  8. 【汇编】奇校验程序:输入一个字符,编写一个程序判断这个字符中1的个数,如果是偶数个1,则校验位(字符最高位)为1,如果是奇数个1,则校验位为0。并显示加入校验位前后该字符的二进制代码。

    奇校验程序:输入一个字符,编写一个程序判断这个字符中1的个数,如果是偶数个1,则校验位(字符最高位)为1,如果是奇数个1,则校验位为0.并显示加入校验位前后该字符的二进制代码. 编译结果:字符'0'A ...

  9. 数据传输中的 奇校验、偶校验

    1.在数字设备中,数据的传输是大量的,且传输的数据都是由若干位二进制代码 0 和 1 组合而成的.系统内部或外部干扰等原因,可能是数据信息在传输过程中产生错误,例如在发送端,待发送的数据是 8 位,有 ...

最新文章

  1. 10搜索文件内容搜不出_百度搜索广告太多?内容太杂?可能你们缺少这10个神器网站...
  2. sql server where 条件 区分大小写查询
  3. KeyMob推出移动广告平台,服务开发者与广告主
  4. IntelliJ IDEA启动Tomcat后,却无法访问Tomcat主页
  5. UnisGuard防篡改产品了解
  6. maya python 开根号_maya python
  7. java类快速构造_程序员有什么办法能快速梳理java知识点?有这八张图就够了
  8. 字符菱形(信息学奥赛一本通-T1028)
  9. 第二阶段团队冲刺(五)
  10. OpenCV精进之路(零):core组件——绘制点、直线、几何图形
  11. Android 音频系统:从 AudioTrack 到 AudioFlinger(全)
  12. 使用CALayer设置图像边框
  13. 常见设计规范与 Sketch 源文件下载集合
  14. 计算 KL距离 (相对熵)
  15. UDS常用诊断服务介绍
  16. 获取百度云盘真实下载链接(告别云盘客户端,全速下载)
  17. [BZOJ 3561] DZY Loves Math VI
  18. Spring Boot(一)之入门篇
  19. 【基于ECharts 数据可视化展示相关配置表全】
  20. 设计模式---单例模式Singleton

热门文章

  1. AndroidManifest.xml文件剖析
  2. 从tomcat 迁移到 WebSphere 经验总结
  3. python答辩结束语_2018-08-17 结束答辩
  4. html5自适应团购,基于HTML5的O2O团购平台的设计与实现
  5. php 整形 字符串排序,php-通过特定的字符串值进行排序
  6. 除了工作怎么交朋友_《隐秘的角落》该如何看待孩子在学校交朋友?
  7. idea缩写快捷键_idea快捷键大全
  8. 2021年春季学期-信号与系统-第十次作业参考答案
  9. python数据库模块_十二、Python高级功能之Mysql数据库模块
  10. 关于计算机组装的作文,电脑小白组装电脑,能写出这样的配置,在下佩服!