首页 > 其他分享 >Serial receiver and datapath

Serial receiver and datapath

时间:2024-04-15 20:44:52浏览次数:22  
标签:begin end datapath next state receiver Serial parameter par

See also: Serial receiver

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 reset
    output [7:0] out_byte,
    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;
    
    reg [7:0]	par_in;
    
    always @(*)begin
        case(state)
            START:begin
                next_state = ONE;
                par_in[0] = in;
            end
            ONE:begin
                next_state = TWO;
                par_in[1] = in;
            end
            TWO:begin
                next_state = THREE;
                par_in[2] = in;
            end
            THREE:begin
                next_state = FOUR;
                par_in[3] = in;
            end
            FOUR:begin
                next_state = FIVE;
                par_in[4] = in;
            end
            FIVE:begin
                next_state = SIX;
                par_in[5] = in;
            end
            SIX:begin
                next_state = SEVEN;
                par_in[6] = in;
            end
            SEVEN:begin
                next_state = EIGHT;
                par_in[7] = in;
            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);
    assign out_byte = (state == STOP) ? par_in : 8'd0;

endmodule

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

相关文章

  • PS/2 packet parser and datapath
    Seealso:PS/2packetparser.Nowthatyouhaveastatemachinethatwillidentifythree-bytemessagesinaPS/2bytestream,addadatapaththatwillalsooutputthe24-bit(3byte)messagewheneverapacketisreceived(out_bytes[23:16]isthefirstby......
  • 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接口一个对象序列化的接口,一个类......