您的位置:首页 > 文旅 > 旅游 > 自己怎么制作小程序商城_室内设计师资格证报考条件_网页推广怎么做_网络推广产品要给多少钱

自己怎么制作小程序商城_室内设计师资格证报考条件_网页推广怎么做_网络推广产品要给多少钱

2025/2/23 6:47:14 来源:https://blog.csdn.net/qq_36666115/article/details/143196026  浏览:    关键词:自己怎么制作小程序商城_室内设计师资格证报考条件_网页推广怎么做_网络推广产品要给多少钱
自己怎么制作小程序商城_室内设计师资格证报考条件_网页推广怎么做_网络推广产品要给多少钱

编码

`timescale 1ns / 1ps
//
// Company: 
// Engineer: 
// 
// Create Date: 2024/08/28 17:35:32
// Design Name: 
// Module Name: CRC_24
// Project Name: 
// Target Devices: 
// Tool Versions: 
// Description: 
// 
// Dependencies: 
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 
//module CRC_24(
clk,
rst,din,
din_p,
din_clk_p,dout,
dout_p,
dout_clk_p,
crc24
);input clk                     ;//in [1] 系统时钟
input rst                     ;//in [1] 系统复位,高有效input din                     ;//in [1] CRC待译码数据
input din_p                   ;//in [1] CRC待译码数据帧头
input din_clk_p               ;output dout                   ; 
output dout_p                 ; 
output dout_clk_p             ;
output [23:0] crc24           ;
parameter CODE_TYPE  =16'd24  ; 
parameter CODE_LENGTH=16'd1128; reg [15:0] cnts;
always @ (posedge clk or posedge rst)
beginif(rst)begincnts<=16'hffff;endelse if(din_p)begincnts<=16'd0;endelse if(cnts <= CODE_LENGTH)//864begincnts<=cnts+1'b1;endelsebegincnts<=cnts;end
endreg din_delay;
always @ (posedge clk or posedge rst)
beginif(rst)begindin_delay<=1'b0;endelse begindin_delay<=din;end
endreg [23:0] shift_regs;
always @ (posedge clk or posedge rst)
beginif(rst)beginshift_regs<=24'd0;endelse if(din_p)beginshift_regs<=24'd0;endelse if(cnts <= CODE_LENGTH-1-CODE_TYPE )//bianma -16,译码时全部移位beginshift_regs[0] <=shift_regs[15]^din_delay;shift_regs[1] <=shift_regs[0];shift_regs[2] <=shift_regs[1];shift_regs[3] <=shift_regs[2];shift_regs[4] <=shift_regs[3];shift_regs[5] <=shift_regs[4]^shift_regs[15]^din_delay;shift_regs[6] <=shift_regs[5];shift_regs[7] <=shift_regs[6];//shift_regs[8] <=shift_regs[7];shift_regs[9] <=shift_regs[8];shift_regs[10]<=shift_regs[9];shift_regs[11]<=shift_regs[10];shift_regs[12]<=shift_regs[11]^shift_regs[15]^din_delay;shift_regs[13]<=shift_regs[12];shift_regs[14]<=shift_regs[13];shift_regs[15]<=shift_regs[14];shift_regs[16]<=shift_regs[15];shift_regs[17]<=shift_regs[16];shift_regs[18]<=shift_regs[17];shift_regs[19]<=shift_regs[18];shift_regs[20]<=shift_regs[19];shift_regs[21]<=shift_regs[20];shift_regs[22]<=shift_regs[21];shift_regs[23]<=shift_regs[22];endelsebeginshift_regs<=shift_regs;	end
endassign crc24 = shift_regs;reg din_p_delay;
always @ (posedge clk or posedge rst)
beginif(rst)begindin_p_delay<=1'b0;endelsebegindin_p_delay<=din_p;end
endreg dout_p;
always @ (posedge clk or posedge rst)
beginif(rst)begindout_p<=1'b0;endelsebegindout_p<=din_p_delay;end
endreg dout;
always @ (posedge clk or posedge rst)
beginif(rst)begindout<=1'b0;endelse if(cnts<=CODE_LENGTH-CODE_TYPE-1)begindout<=din_delay;endelse if(cnts<=CODE_LENGTH-1)begindout<=shift_regs[CODE_LENGTH-1-cnts];//正常情况下,译码出来的CRC校验为0,按最终check_reg的指示来表示endelsebegindout<=din_delay;//elseend
endreg dout_clk_p;
always @ (posedge clk or posedge rst)
beginif(rst)begindout_clk_p<=1'b0;endelse if(cnts<=CODE_LENGTH-1)//CRC 32   0~311begindout_clk_p<=1'b1;endelsebegindout_clk_p<=1'b0;end
endendmodule

解码

`timescale 1ns / 1ps
//
// Company: 
// Engineer: 
// 
// Create Date: 2024/08/28 19:37:42
// Design Name: 
// Module Name: CRC_24_Decode
// Project Name: 
// Target Devices: 
// Tool Versions: 
// Description: 
// 
// Dependencies: 
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 
//module CRC_24_Decode(
clk,
rst,din,
din_p,
din_clk_p,dout,
dout_p,
dout_clk_p,
dout_last,check
);input clk                     ;//in [1] 系统时钟
input rst                     ;//in [1] 系统复位,高有效input din                     ;//in [1] CRC待译码数据
input din_p                   ;//in [1] CRC待译码数据帧头
input din_clk_p               ;output dout                   ; 
output dout_p                 ; 
output dout_clk_p             ;
output dout_last              ;output check                  ;parameter CODE_TYPE  =16'd24  ; 
parameter CODE_LENGTH=16'd1128; reg [15:0] cnts;
always @ (posedge clk or posedge rst)
beginif(rst)begincnts<=16'hffff;endelse if(din_p)begincnts<=16'd0;endelse if(cnts <= CODE_LENGTH)//864begincnts<=cnts+1'b1;endelsebegincnts<=cnts;end
endreg din_delay;
always @ (posedge clk or posedge rst)
beginif(rst)begindin_delay<=1'b0;endelse begindin_delay<=din;end
endreg din_p_delay;
always @ (posedge clk or posedge rst)
beginif(rst)begindin_p_delay<=1'b0;endelsebegindin_p_delay<=din_p;end
endreg [23:0] recv_regs;
always @ (posedge clk or posedge rst)
beginif(rst)beginrecv_regs <= 24'd0;endelse if(din_clk_p)beginrecv_regs <= {recv_regs[22:0],din};endelsebeginrecv_regs <= recv_regs;end
endreg [23:0] shift_regs;
always @ (posedge clk or posedge rst)
beginif(rst)beginshift_regs<=24'd0;endelse if(din_p)beginshift_regs<=24'd0;endelse if(cnts <= CODE_LENGTH-1-CODE_TYPE )//bianma -16,译码时全部移位beginshift_regs[0] <=shift_regs[15]^din_delay;shift_regs[1] <=shift_regs[0];shift_regs[2] <=shift_regs[1];shift_regs[3] <=shift_regs[2];shift_regs[4] <=shift_regs[3];shift_regs[5] <=shift_regs[4]^shift_regs[15]^din_delay;shift_regs[6] <=shift_regs[5];shift_regs[7] <=shift_regs[6];//shift_regs[8] <=shift_regs[7];shift_regs[9] <=shift_regs[8];shift_regs[10]<=shift_regs[9];shift_regs[11]<=shift_regs[10];shift_regs[12]<=shift_regs[11]^shift_regs[15]^din_delay;shift_regs[13]<=shift_regs[12];shift_regs[14]<=shift_regs[13];shift_regs[15]<=shift_regs[14];shift_regs[16]<=shift_regs[15];shift_regs[17]<=shift_regs[16];shift_regs[18]<=shift_regs[17];shift_regs[19]<=shift_regs[18];shift_regs[20]<=shift_regs[19];shift_regs[21]<=shift_regs[20];shift_regs[22]<=shift_regs[21];shift_regs[23]<=shift_regs[22];endelsebeginshift_regs<=shift_regs;	end
endreg dout_p;
always @ (posedge clk or posedge rst)
beginif(rst)begindout_p<=1'b0;endelsebegindout_p<=din_p_delay;end
endreg dout;
always @ (posedge clk or posedge rst)
beginif(rst)begindout<=1'b0;endelse if(cnts<=CODE_LENGTH-1)begindout<=din_delay;endelsebegindout<=din_delay;//elseend
endreg dout_clk_p;
always @ (posedge clk or posedge rst)
beginif(rst)begindout_clk_p<=1'b0;end//	else if(cnts<=CODE_LENGTH-1-CODE_TYPE)//CRC 32   0~311else if(cnts<=CODE_LENGTH-1)//CRC 32   0~311begindout_clk_p<=1'b1;endelsebegindout_clk_p<=1'b0;end
endreg dout_last;
always @ (posedge clk or posedge rst)
beginif(rst)begindout_last<=1'b0;end//	else if(cnts<=CODE_LENGTH-1-CODE_TYPE)//CRC 32   0~311else if(cnts==CODE_LENGTH-1)//CRC 32   0~311begindout_last<=1'b1;endelsebegindout_last<=1'b0;end
endreg check;
always @ (posedge clk or posedge rst)
beginif(rst)begincheck <= 1'b0;endelse if(recv_regs == shift_regs)begincheck <= 1'b1;endelsebegincheck <= 1'b0;end
endendmodule

测试的Test

`timescale 1ns / 1ps
//
// Company: 
// Engineer: 
// 
// Create Date: 2024/08/28 19:23:39
// Design Name: 
// Module Name: tb_crc24
// Project Name: 
// Target Devices: 
// Tool Versions: 
// Description: 
// 
// Dependencies: 
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 
//module tb_crc24();reg ad9361_l_clk,rst;   initial beginad9361_l_clk=0;forever #4.545 ad9361_l_clk=~ad9361_l_clk;
end
initial beginrst=1;#9.09 rst=0;
endreg [31:0] cnts;
always @ (posedge ad9361_l_clk or posedge rst)
beginif(rst)begincnts<=32'hffff_ff00;endelse if(cnts ==32'd110000)//100msbegincnts<=32'd0;endelsebegincnts<=cnts + 1'b1;end
endreg [7:0] din;
reg din_p;
reg din_clk_p;
always @ (posedge ad9361_l_clk or posedge rst)
beginif(rst)begindin_clk_p<=1'b0;endelse if((cnts>=32'd1)&&(cnts<=32'd232))begindin_clk_p<=1'b1;endelsebegindin_clk_p<=1'b0;end
endalways @ (posedge ad9361_l_clk or posedge rst)
beginif(rst)begindin<=8'd0; endelsebegincase(cnts)32'd1:begin din<=8'd1;  enddefault:begin din<=din + 8'd18; endendcaseend
endalways @ (posedge ad9361_l_clk or posedge rst)
beginif(rst)begindin_p<=1'b0; endelsebegincase(cnts)32'd1:begin din_p<=1'b1;  enddefault:begin din_p<=1'b0; endendcaseend
endwire dout,dout_p,dout_clk_p;
wire [23:0] crc24;
CRC_24 CRC(.clk        (ad9361_l_clk),.rst        (rst),.din        (din[0]),.din_p      (din_p),.din_clk_p  (din_clk_p),.dout       (dout),.dout_p     (dout_p),.dout_clk_p (dout_clk_p),.crc24      (crc24)
);wire dout_d,dout_p_d,dout_clk_p_d,check,dout_last;
CRC_24_Decode CRC_24_Decode(.clk        (ad9361_l_clk),.rst        (rst),.din        (dout),.din_p      (dout_p),.din_clk_p  (dout_clk_p),.dout       (dout_d),.dout_p     (dout_p_d),.dout_clk_p (dout_clk_p_d),.dout_last  (dout_last),.check      (check)
);endmodule

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com