使用的是MZ702N,例程ch33部分,没有使用接收部分,仅通过udp_ip_protocol_stack上传常数数据00ff,网络调试助手没有收数,求协议栈的正确调用方法...。
prj仅顶层文件修改,如下:
udp_ip_protocol_stack udp_ip_protocol_stack
(
.LOCAL_PORT_NUM (16'hf000),
.LOCAL_IP_ADDRESS (32'hc0a80a01),
.LOCAL_MAC_ADDRESS (48'h000a35000102),
.ICMP_EN (1'b1),
.ARP_REPLY_EN (1'b1),
.ARP_REQUEST_EN (1'b1),
.ARP_TIMEOUT_VALUE (30'd20_000_000),
.ARP_RETRY_NUM (4'd2),
.core_clk (clk_15_625),
.reset (core_reset),
.udp_tx_ready (udp_tx_ready),
.app_tx_ack (app_tx_ack),
.app_tx_request (app_tx_data_request), //app_tx_data_request
.app_tx_data_valid (app_tx_data_valid),
.app_tx_data (64'h00ff),
.app_tx_data_keep (app_tx_data_keep),
.app_tx_data_last (app_tx_data_last),
.app_tx_data_length (udp_data_length),
.app_tx_dst_port (16'hf001),
.ip_tx_dst_address (32'hc0a80a02),
.app_rx_data_valid (),
.app_rx_data (),
.app_rx_data_keep (),
.app_rx_data_last (),
.app_rx_data_length (),
.app_rx_port_num (),
.udp_rx_error (),
.mac_tx_data_valid (mac_tx_valid),
.mac_tx_data (mac_tx_data),
.mac_tx_keep (mac_tx_keep),
.mac_tx_ready (mac_tx_ready),
.mac_tx_last (mac_tx_last),
.mac_tx_user (mac_tx_user),
.mac_rx_data_valid (1'b0),
.mac_rx_data (64'd0),
.mac_rx_keep (1'b0),
.mac_rx_last (1'b0),
.mac_rx_user (1'b0),
.ip_rx_error (),
.dst_ip_unreachable (dst_ip_unreachable)
);
进程部分以下屏蔽掉部分无效信号如下:
/*
always @(posedge clk_15_625)
begin
if(core_reset)
udp_error_flag <= 1'b0;
else if(udp_rx_error)
udp_error_flag <= 1'b1;
else
udp_error_flag <= udp_error_flag;
end
udp_packet_fifo udp_packet_fifo
(
.rst(core_reset), // input rst
.wr_clk(clk_15_625), // input wr_clk
.rd_clk(clk_15_625), // input rd_clk
.din(app_rx_data), // input [63 : 0] din
.wr_en(app_rx_data_valid), // input wr_en
.rd_en(app_tx_data_read), // input rd_en
.dout(app_tx_data), // output [63 : 0] dout
.full(), // output full
.empty(), // output empty
.rd_data_count(udp_packet_fifo_data_cnt) // output [8 : 0] rd_data_count
);
always@(posedge clk_15_625 or posedge core_reset)
begin
if(core_reset)
udp_data_length <= 16'd0;
else begin
if(app_rx_data_valid)
udp_data_length <= app_rx_data_length;
else
udp_data_length <= udp_data_length;
end
end
*/
always@(posedge clk_15_625 or posedge core_reset)
begin
if(core_reset) begin
udp_data_length<=16'd30;
app_tx_data_request <= 1'b0;
// app_tx_data_read <= 1'b0;
app_tx_data_last <= 1'b0;
app_tx_data_keep <= 8'hff;
app_tx_data_valid <= 1'b0;
fifo_read_data_cnt <= 12'd0;
STATE <= WAIT_UDP_DATA;
end
else begin
udp_data_length<=16'd30;
case(STATE)
WAIT_UDP_DATA:
begin
//if((udp_packet_fifo_data_cnt >= 12'd1500) && udp_tx_ready) begin
if( udp_tx_ready) begin
app_tx_data_request <= 1'b1;
STATE <= WAIT_ACK;
end
// else begin
// app_tx_data_request <= 1'b0;
// STATE <= WAIT_UDP_DATA;
// end
end
WAIT_ACK:
begin
if(app_tx_ack) begin
app_tx_data_request <= 1'b0;
// app_tx_data_read <= 1'b1;
app_tx_data_valid <= 1'b1;
if(udp_data_length <= 8) begin
app_tx_data_last <= 1'b1;
app_tx_data_keep <= (8'hff >> (8 - udp_data_length));
STATE <= DELAY;
end
else begin
fifo_read_data_cnt <= fifo_read_data_cnt + 8;
STATE <= SEND_UDP_DATA;
end
end
else if(dst_ip_unreachable) begin
app_tx_data_request <= 1'b0;
app_tx_data_valid <= 1'b0;
STATE <= WAIT_UDP_DATA;
end
else begin
app_tx_data_request <= 1'b1;
// app_tx_data_read <= 1'b0;
app_tx_data_valid <= 1'b0;
STATE <= WAIT_ACK;
end
end
SEND_UDP_DATA:
begin
app_tx_data_valid <= 1'b1;
fifo_read_data_cnt <= fifo_read_data_cnt + 8;
// app_tx_data_read <= 1'b1;
if((fifo_read_data_cnt + 8) >= udp_data_length) begin
app_tx_data_last <= 1'b1;
app_tx_data_keep <= (8'hff >> (fifo_read_data_cnt + 8 - udp_data_length ));
STATE <= DELAY;
end
else begin
STATE <= SEND_UDP_DATA;
end
end
DELAY:
begin
// app_tx_data_read <= 1'b0;
app_tx_data_valid <= 1'b0;
app_tx_data_last <= 1'b0;
app_tx_data_keep <= 8'hff;
fifo_read_data_cnt <= 12'd0;
// if(app_rx_data_valid)
// STATE <= WAIT_UDP_DATA;
// else
STATE <= DELAY;
end
default: STATE <= WAIT_UDP_DATA;
endcase
end
end
|
|