您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 销售管理 > W5300-FPGA控制代码-做TCPS
`timescale1ns/1ps//////////////////////////////////////////////////////////////////////////////////moduleW5300_Ctrl(rst_n,//EP2C5T144clk50MHz,INT,//W5300LINKLED,RESET,CS,WR,RD,ADDR,DATA,CE,//IS61LV6416OE,WE,UB,LB,A,IO,D_OUTPUT1,D_OUTPUT2);//`includeDefine.v//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~inputrst_n;//EP2C5T144inputclk50MHz;inputINT;//W5300inputLINKLED;outputRESET;outputCS;outputWR;outputRD;output[9:0]ADDR;inout[15:0]DATA;outputD_OUTPUT1;outputD_OUTPUT2;outputCE;//IS61LV6416outputOE;outputWE;outputUB;outputLB;output[15:0]A;inout[15:0]IO;//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~wireclk50MHz;regRESET;//W5300regCS;regWR;regRD;reg[9:0]ADDR;reg[15:0]Dout/*synthesispreserve=1*/;regD_OUTPUT1;regD_OUTPUT2;//IS61LV6416regCE;regOE/*synthesispreserve=1*/;regWE;regUB;regLB;reg[15:0]A;reg[15:0]IO_in/*synthesispreserve=1*/;//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~regW5300_WR_Select;//selectregSend_En;//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~reg[7:0]DLY;reg[19:0]DLY1;reg[31:0]DLY2;//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~reg[7:0]Next_State/*synthesispreserve=1*/;//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//************************************************//Ô´MACµØÖ·¼Ä´æÆ÷485300313033reg[15:0]SHAR0,SHAR2,SHAR4;initialbeginSHAR0=16'h4853;SHAR2=16'h0031;SHAR4=16'h3033;end//Íø¹ØµØÖ·192.168.0.1reg[15:0]GAR[1:2];initialbeginGAR[1]=16'hC0A8;GAR[2]=16'h0001;end//×ÓÍøÑÚÂë255.255.255.0reg[15:0]SUBR[1:2];initialbeginSUBR[1]=16'hFFFF;SUBR[2]=16'hFF00;end//Ô´IPµØÖ·¼Ä´æÆ÷192.168.0.20reg[15:0]SIPR[1:2];initialbeginSIPR[1]=16'hC0A8;SIPR[2]=16'h0014;end//ÖжÏIRreg[15:0]IR/*synthesispreserve=1*/;reg[3:0]IR_State/*synthesispreserve=1*/;reg[7:0]S0_SR_state;//--------------------------------reg[15:0]S0_MR;//SOCKET0ģʽ¼Ä´æÆ÷reg[15:0]S0_CR;//SOCKET0ÃüÁî¼Ä´æÆ÷reg[15:0]S0_IR/*synthesispreserve=1*/;//SOCKET0ÖжϼĴæÆ÷reg[15:0]S0_SSR;//SOCKET0״̬¼Ä´æÆ÷reg[15:0]S0_RX_RSR2;reg[15:0]S0_RX_FIFOR;reg[15:0]S0_DHAR;//Ä¿µÄMACµÚ1£¬2λreg[15:0]rx_size;reg[15:0]tx_size;reg[15:0]rx_size_i;reg[15:0]tx_size_i;reg[15:0]j;reg[15:0]S0_PORTR[0:0];//SOCKET0µÄ¶Ë¿ÚºÅ¶Ë¿ÚºÅ5000initialbeginS0_PORTR[0]=16'h1388;endreg[15:0]S0_MSSR[0:0];//SOCKET0×î´ó·ÖƬ³¤¶ÈinitialbeginS0_MSSR[0]=16'h05b4;end//Ä¿µÄIPµØÖ·¼Ä´æÆ÷192.168.0.30//reg[15:0]S0_DIPR[1:2];//initialbegin//S0_DIPR[1]=16'hC0A8;//S0_DIPR[2]=16'h001E;endregS0_SENDOK/*synthesispreserve=1*/;//·¢Ëͳɹ¦regS0_RECV;regOUTtime;///////////////////////////////////////////////////////////////////////////////////////assignDATA=(W5300_WR_Select||Send_En)?Dout:16'hz;assignIO=(WE)?16'hz:IO_in;always@(posedgeclk50MHz)beginif(!rst_n)beginRESET=1'b0;CS=1'b1;WR=1'b1;RD=1'b1;ADDR=10'h0;Dout=16'h0;D_OUTPUT1=1'b1;D_OUTPUT2=1'b1;DLY=8'd0;DLY2=32'd0;DLY1=20'd0;Send_En=1'b0;W5300_WR_Select=1'b1;Next_State=8'd0;CE=1'b1;//IS61LV6416OE=1'b1;WE=1'b1;UB=1'b1;LB=1'b1;A=16'd0;IO_in=16'd0;S0_SENDOK=1'b0;S0_RX_RSR2=1'b0;endelsebegincase(Next_State)//***************³õʼ»¯***********************8'd0:beginRESET=1'b1;CS=1'b1;WR=1'b1;RD=1'b1;ADDR=10'h0;Dout=16'h0;D_OUTPUT1=1'b1;D_OUTPUT2=1'b1;DLY=8'd0;DLY2=32'd0;DLY1=20'd0;W5300_WR_Select=1'b1;CE=1'b1;//IS61LV6416OE=1'b1;WE=1'b1;UB=1'b1;LB=1'b1;A=16'd0;IO_in=16'd0;Send_En=1'b0;Next_State=8'd0;RESET=1'b0;S0_SENDOK=1'b1;//·¢Ëͳɹ¦³õʼΪ1Next_State=8'd1;S0_RX_RSR2=1'b0;end//************Ó²¼þ¸´Î»W5300***************8'd1:beginif(DLY1==20'd50000)begin//ÑÓʱ1ms2usÒÔÉÏRESET=1'b1;CS=1'b1;WR=1'b1;RD=1'b1;ADDR=10'h0;Dout=16'h0;DLY1=20'd0;DLY2=32'd0;Next_State=8'd2;endelsebeginRESET=1'b0;//ÀµÍCS=1'b1;WR=1'b1;RD=1'b1;ADDR=10'h0;Dout=16'h0;DLY2=32'd0;D_OUTPUT1=1'b1;D_OUTPUT2=1'b1;DLY1=DLY1+1'b1;Next_State=8'd1;endend8'd2:beginif(DLY2==32'd100000000)begin//»Ö¸´ºóÒ»Ö±µÈ´ý2s//10msÒÔÉÏRESET=1'b1;CS=1'b1;WR=1'b1;RD=1'b1;ADDR=10'h0;Dout=16'h0;DLY1=20'd0;DLY2=32'd0;Next_State=8'd3;endelsebeginRESET=1'b1;CS=1'b1;WR=1'b1;RD=1'b1;ADDR=10'h0;Dout=16'h0;DLY1=20'd0;DLY2=DLY2+1'b1;Next_State=8'd2;endend//*************************W5300ÅäÖÃ**************************//--------------MACµØÖ·£¬Íø¹Ø£¬×ÓÍøÑÚÂ룬ԴIPµØÖ·--------------//************************************************************//--------------Ô´MACµØÖ·¼Ä´æÆ÷485300313033---------------8'd3:beginCS=1'b0;//ʼÄÜWR=1'b0;RD=1'b1;ADDR=10'h8;//¸øµØÖ·Dout=16'h0;DLY=8'd0;Next_State=8'd4;end8'd4:beginif(DLY==8'd2)beginCS=1'b1;WR=1'b1;RD=1'b1;ADDR=10'h0;//µØÖ·Çå0Dout=Dout;DLY=8'd0;Next_State=8'd5;endelsebeginCS=CS;WR=WR;RD=RD;ADDR=ADDR;Dout=SHAR0;//SHAR04853DLY=DLY+1'b1;Next_State=8'd4;endend8'd5:begin//CS=1'b1;WR=1'b1;RD=1'b1;ADDR=10'h0;Dout=16'h0;DLY=8'd0;Next_State=8'd6;end8'd6:beginCS=1'b0;WR=1'b0;RD=1'b1;ADDR=10'h00a;//¸øµØÖ·Dout=16'h0;DLY=8'd0;Next_State=8'd7;end8'd7:beginif(DLY==8'd2)beginCS=1'b1;WR=1'b1;RD=1'b1;ADDR=10'h0;Dout=Dout;DLY=8'd0;Next_State=8'd8;endelsebeginCS=CS;WR=WR;RD=RD;ADDR=ADDR;Dout=SHAR2;DLY=
本文标题:W5300-FPGA控制代码-做TCPS
链接地址:https://www.777doc.com/doc-3032505 .html