首页 > 其他分享 >Serial receiver

Serial receiver

时间:2024-04-15 20:45:25浏览次数:18  
标签:begin end next state receiver Serial parameter bit

In many (older) serial communications protocols, each data byte is sent along with a start bit and a stop bit, to help the receiver delimit bytes from the stream of bits. One common scheme is to use one start bit (0), 8 data bits, and 1 stop bit (1). The line is also at logic 1 when nothing is being transmitted (idle).

Design a finite state machine that will identify when bytes have been correctly received when given a stream of bits. It needs to identify the start bit, wait for all 8 data 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.

在许多(较旧的)串行通信协议中,每个数据字节都与起始位和停止位一起发送,以帮助接收方从位流中分隔字节。一种常见的方案是使用 1 个起始位 (0)、8 个数据位和 1 个停止位 (1)。当没有传输任何内容(空闲)时,该线路也处于逻辑 1 处。

设计一个有限状态机,当给定一个位流时,它将识别何时正确接收字节。它需要识别起始位,等待所有 8 个数据位,然后验证停止位是否正确。如果停止位未按预期出现,则 FSM 必须等到找到停止位后再尝试接收下一个字节。
题目网站

module top_module(
    input clk,
    input in,
    input reset,    // Synchronous reset
    output done
); 
    parameter [3:0] START = 4'd0;
    parameter [3:0] ONE = 4'd1;
    parameter [3:0] TWO = 4'd2;
    parameter [3:0] THREE = 4'd3;
    parameter [3:0] FOUR = 4'd4;
    parameter [3:0] FIVE = 4'd5;
    parameter [3:0] SIX = 4'd6;
    parameter [3:0] SEVEN = 4'd7;
    parameter [3:0] EIGHT = 4'd8;
    parameter [3:0] STOP = 4'd9;
    parameter [3:0] IDLE = 4'd10;
    parameter [3:0] WAIT = 4'd11;
    
    reg [3:0] state,next_state;
    
    always @(*)begin
        case(state)
            START:begin
                next_state = ONE;
            end
            ONE:begin
                next_state = TWO;
            end
            TWO:begin
                next_state = THREE;
            end
            THREE:begin
                next_state = FOUR;
            end
            FOUR:begin
                next_state = FIVE;
            end
            FIVE:begin
                next_state = SIX;
            end
            SIX:begin
                next_state = SEVEN;
            end
            SEVEN:begin
                next_state = EIGHT;
            end
            EIGHT:begin
                if(in)begin
                    next_state = STOP;
                end
                else begin
                    next_state = WAIT;
                end
            end
            STOP:begin
                if(in)begin
                    next_state = IDLE;
                end
                else begin
                    next_state = START;
                end
            end
            WAIT:begin
                if(in)begin
                    next_state = IDLE;
                end
                else begin
                    next_state = WAIT;
                end
            end
            IDLE:begin
                if(~in)begin
                    next_state = START;
                end
                else begin
                    next_state = IDLE;
                end
            end
        endcase
    end
    
    always @(posedge clk)begin
        if(reset)begin
            state <= IDLE;
        end
        else begin
            state <= next_state;
        end
    end
    
    assign done = (state == STOP);

endmodule

标签:begin,end,next,state,receiver,Serial,parameter,bit
From: https://www.cnblogs.com/jzzg/p/18136865

相关文章

  • Serial receiver and datapath
    Seealso:SerialreceiverNowthatyouhaveafinitestatemachinethatcanidentifywhenbytesarecorrectlyreceivedinaserialbitstream,addadatapaththatwilloutputthecorrectly-receiveddatabyte.out_byteneedstobevalidwhendoneis1,and......
  • Django ModelSerializer 中如何实现自定义验证
    随着Web开发的日益复杂化,对数据验证的需求也日益增加。DjangoRESTframework提供了一套强大的、灵活的验证系统,帮助开发者轻松处理各种复杂情况。本文将重点探讨DjangoModelSerializer中如何实现自定义验证。1.简介DjangoModelSerializer不仅简化了序列化过程,还内建了......
  • Cannot deserialize the current JSON array (e.g. [1,2,3]) into type ‘model’ bec
    错误:CannotdeserializethecurrentJSONarray(e.g.[1,2,3])intotype‘model’becausethetyperequiresaJSONobject(e.g.{“name”:“value”})todeserializecorrectly.TofixthiserroreitherchangetheJSONtoaJSONobject 原因:json或xml字符串中......
  • RT路由器 serial 口ppp multilink 绑定接口配置
    配置MutlilinkPPP捆绑,编号为1interfacemultilink1                   ipadd192.168.100.1255.255.255.0   pppmultilink                                ......
  • C#JsonConvert.DeserializeObject反序列化与JsonConvert.SerializeObject序列化
    原文链接:https://blog.csdn.net/qq_45451847/article/details/120434797JSONJSON序列化是将对象转换为JSON格式的字符串,而JSON反序列化是将JSON格式的字符串转换为对象。对于JSON大家都了解,JSON是一种轻量级的文本数据交换格式而非编程语言,既然是数据交换格式,那就需要不断的进......
  • Ajax 发送json格式数据以及发送文件(FormData)和自带的序列化组件: serializers
    前后端传输数据的编码格式(contentType)get请求数据就是直接放在url?后面的url?usernmae=junjie&password=123...可以向后端发送post请求的方式form请求ajax请求前后端传输数据的编码格式urlencodedformdatajson研究form表单:默认的数据编码格式是(urlencod......
  • 4.摄像头组件-Serializer( Max96717)
    MAX96717概述:     CSI-2toGMSL2Serializer   Max96717PinConfiguration1.D0/1/2/3_P/N,CKP/CKN: MIPI输入接口2.SIOP/N: 差分输出3.PWDNB: 断电输入(低电平有效),具有1MΩ下拉电阻至地。                    将P......
  • SRIO(Serial RapidIO)PCS层 64B/67B编码介绍(二)
     64b/67b传输码字    PCS使用的64b/67b传输码将64位数据块和/或控制信息编码为67位码字,用于传输,并在接收时反转过程。码字有两种类型:“数据”码字和“控制”码字。数据码字编码64位的数据。控制码字编码64位的控制信息或数据和控制信息的某种组合。码字格式  ......
  • ESP32上传失败,ESP32: No serial data received,Failed uploading: uploading error: ex
    ESP32:Noserialdatareceived解决方案给ESP32烧录的时候,报错Afatalerroroccurred:FailedtoconnecttoESP32:Noserialdatareceived.Fortroubleshootingstepsvisit:https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.htmlFa......
  • Serializable是什么,为什么要实现Serializable接口?
    什么是Serializable接口什么是序列化?为什么要序列化对象什么情况下需要序列化?为什么要定义serialversionUID变量序列化的使用关于serialVersionUID定义实体类的时候会先定义一个BaseDomain类用来实现Serializable接口什么是Serializable接口一个对象序列化的接口,一个类......