您好,欢迎访问三七文档
顶层结构:数据模块和IP核模块:寄存器配置和数据产生模块:a、b结构:macmac_datain[31:0]mac_endmac_startmac_wrclk_50M/ff_rx_clkmac_reg_addr[7:0]mac_reg_wr_data[31:0]clk50M/ff_tx_clknersetclk_125M/tx_clkphy_rx_clkphy_rx_data[7:0]phy_rx_data_validphy_rx_errphy_ff_tx_data[7:0]phy_tx_enphy_tx_errrandomaclk1_25Mresetpacked_generator_fifofifo_datain[7:0]fifo_wrenfifo_wclkfifoa_rdclk_50Mnresetdata_a[31:0]rdusedw[9:0]packed_generator_compareageadffclk_50Mfifoa_flagrandombclk_31_25Mresetpacked_generator_fifofifo_datain[7:0]fifo_wrenfifo_wclkfifob_rdclk_50Mnresetdata_b[31:0]rdusedw[9:0]packed_generator_compareagebdffclk_50Mfifob_flagclk50Mpllclk_125Mclk_31_25Mclk1_25rstnresetphy_resetaphy_resetbbutton_resetset_regmac_reg_wrenmac_reg_wr_data[31:0]mac_reg_addr[7:0]afifoa_rddata_a[31:0]fifoa_flagbclk_31_25Mfifob_rdclk_50Mnresetdata_b[31:0]fifob_flagmac_wrclk_50Mresetmac_datain[31:0]mac_wrmac_startmac_endfifoa_rdfifob_rdclk1_25Mclk_50Mnresetphy_resetaphy_resetbnresetclk50M350350data_modulemac_reg_wrenff_tx_data[31:0]ff_tx_wrenff_tx_sopff_tx_eopip_receiveclk50Mphy_rx_clkphy_rx_data_validphy_rx_errphy_rx_data[7:0]phy_tx_enphy_tx_errphy_ff_tx_data[7:0]phy_resetbphy_resetaclk_125M_outbutton_resetrandom模块是数据投保协议模块并产生[7:0]的递增数据,经过fifo将数据以[31:0]输出,然后rdusedw[9:0]与350进行比较,比较大小,如果大的话输出fifo_flag=1。表示后面可以添加以太帧。寄存器wr模块状态机:s1状态表:constructthemacframeheaderandfirst2bytesofudppayload,totallengthis42+2=44bytesheadcnt条件状态注解1first4byteofmacheadermac_dataout=32'h01005e09;wr_num=wr_num+10'd1;mac_wr=1;mac_start=1;headcnt=headcnt+9'd1;first4byteofmacheader2channel_sel==0mac_dataout=32'h09091234channel_sel==1mac_dataout=32'h090a1234;wr_num=wr_num+10'd1;mac_start=0;headcnt=headcnt+9'd1;3mac_dataout=32'h56789abc;wr_num=wr_num+10'd1;headcnt=headcnt+9'd1;4last2byteofmacheaderandfirst2byteofipheadermac_dataout=32'h08004500;wr_num=wr_num+10'd1;headcnt=headcnt+9'd1;5channel_sel==0mac_dataout=32'h0596b3ba;channel_sel==1mac_dataout=32'h059633fd;wr_num=wr_num+10'd1;headcnt=headcnt+9'd1;6mac_dataout=32'h00000111;wr_num=wr_num+10'd1;headcnt=headcnt+9'd1;7channel_sel==0mac_dataout=32'hae7cc0a8;channel_sel==1mac_dataout=32'h2e3ac0a8;wr_num=wr_num+10'd1;headcnt=headcnt+9'd1;8channel_sel==0mac_dataout=32'ha865e009;firstchannel:sourceip=192.168.168.101channel_sel==1mac_dataout=32'ha864e009;wr_num=wr_num+10'd1;headcnt=headcnt+9'd1;secondchannel:sourceip=192.168.168.1009last2byteofipheaderandfirst2byteofudpheaderchannel_sel==0mac_dataout=32'h0909d431;fifoa_rd=1;firstchannel:destip=224.9.9.9channel_sel==1mac_dataout=32'h090ad431;wr_num=wr_num+10'd1;headcnt=headcnt+9'd1;fifob_rd=1;secondchannel:destip=224.9.9.1010mac_dataout=32'h17710582;wr_num=wr_num+10'd1;headcnt=headcnt+9'd1;11last2byteofudpheaderandfirst2byteofudppayloadchannel_sel==0temp_data=fifoa_datain;channel_sel==1temp_data=fifob_datain;mac_dataout=32'h00000000;wr_num=wr_num+10'd1;headcnt=1;state=2'b11;noudpchecksum,first2byteofudppayloadis0x0000rstrst_headcnt=1;datacnt=1fifoa_rd=0;fifoa_rd=0;mac_dataout=0;temp_data=0;mac_wr=0;mac_start=0;mac_end=0;wr_num=0;flag=0;channel_sel=0;s0flag=~flag?flag=1flag=0s1fifoa_flag==1_channel_sel=0;fifob_flag==1__channel_sel=1;s2headcnt=1____channel_sel=1s2状态表:constructtherestpartofudppayload,totallengthis350*4=1400bytesdatacnt条件状态注解348*datacnt=datacnt+9'd1;channel_sel==0temp_data=fifoa_datain;fifoa_rd=0;channel_sel==1temp_data=fifob_datain;mac_dataout={temp_data[7:0],temp_data[15:8],temp_data[23:16],temp_data[31:24]};wr_num=wr_num+10'd1;fifob_rd=0;350datacnt=datacnt+9'd1;temp_data=32'd0;mac_dataout={temp_data[7:0],temp_data[15:8],temp_data[23:16],temp_data[31:24]};wr_num=wr_num+10'd1;mac_end=1;351datacnt=1;temp_data=32'd0;mac_dataout=32'd0;mac_end=0;mac_wr=0;state=2'b00;wr_num=0;elsedatacntdatacnt=datacnt+9'd1;channel_sel=0temp_data=fifoa_datain;channel_sel=1temp_data=fifob_datain;mac_dataout={temp_data[7:0],temp_data[15:8],temp_data[23:16],temp_data[31:24]};wr_num=wr_num+10'd1;状态描述:S0:将flag信号做一个反转,并定义flag=0&&fifoa_flag==1时channel_sel=0;flag=1&&fifob_flag==1时channel_sel=1;S1:6+6+2+20+8+1400字节;具体分为a,b;在这里针对a进行描述。b888e3e5efb5123456789abc080045000596b3ba00000111d6e5c0a8a865c0a80001d4311771058200000000+data_in;1、b888e3e5efb5自己电脑本机mac地址;2、123456789abc板子上mac地址(自己进行配置);3、0800凡是携带IP包的帧的类型域都是0x0800;4、45000IP首部/版本5、0596IP头+数据长度20+8+1402=1430;6、b3ba16位标示,每传1位16位标示加1;7、0000FLAGS/offset位;8、01通过最多路由级数TTL;9、11UDP协议10、d6e5checksum数据计算方法:取IP数据报报头部分(20B),数据如下:45000596b3ba00000111d6e5c0a8a865c0a80001(1)将校验和字段置为0:将d6e5置为0000,即变成:45000596b3ba000001110000c0a8a865c0a80001(2)反码求和4500+0596/021c+b3ba+0000+0111+0000+c0a8+a865+c0a8+0001=32917将将进位(3)加到低16位(2917)上:0003+2917=291a;(3)取反码将291a取反得:checksum=d6e50010100100011010=291a1101011011100101=d6e5;11、c0a8a865源IP地址,板子上自定义的IP地址;12、c0a80001目的IP地址,pc机上使用的协议4静态地址;13、d431源端口号1771目的端口号(不用更改)14、0582UDP头+数据长度8+1402=14100x582;15、0000检验校验checksum是否正确计算方法:(1)对首部中每个16bit进行二进制反码求和;(2)将(1)中得到的和再取反码,看是否为0.接收到的IP数据报首部:45000596b3ba00000111d6e5c0a8a865c0a80001下面来验证下:(1)反码求和4500+0030+804c+4000+8006+b52e+d343+117b+cb51+153d=3fffc4500+0596+b3ba+0000+0111+d6e5+c0a8+a865+c0a8+0001=3fffc0003+fffc=ffff;(2)取
本文标题:程序说明文档
链接地址:https://www.777doc.com/doc-2150956 .html