You are on page 1of 16

OSen Logic

1 G Eth TCP/UDP 硬件协议栈

Rev 1.0
2016/2/13

Contact QQ:1517642772 Email:chat1@126.com


OSen Logic

特性

 完全硬件实现,延迟低。
 简单的 FIFO 接口。
 包括了 MAC 层。
 可配置的 IP 地址和端口号。
 支持巨型帧。
 支持服务器模式。

Contact QQ:1517642772 Email:chat1@126.com


OSen Logic

结构

mac_config
eth_fsm
Simple MAC
Rx Path
88E1111

Tx Path

Data Source Parameter Config

User Module

Contact QQ:1517642772 Email:chat1@126.com


OSen Logic

操作流程

 第一步: 修改 “tcpip_hw_defines.sv”.

1.如果 phy 接口是 RGMII, 去掉注释:“//`define RGMII_IF”, otherwise, the core use GMII.

2. 如果使用户模块在 FPGA 外, 去掉注释”//`define DATA_GEN_OUTSIDE”。否则, 使用内部的


data_gen 模块。

 第二步: 修改 “typedefs.pkg.sv”
在 “parameter PKG_SIZE = 2048;”, 如果值大于 1450, 你必须在 PC 端打开巨型帧。
1. 打开设备管理器。
2. 右击所用网卡,选择属性。

Contact QQ:1517642772 Email:chat1@126.com


OSen Logic

3. 在 高 级 标 签 页 里 的 巨 型 数 据 包 , 修 改 值 为 需 要 的 值 。

如果巨型帧是关闭的, 把代码里的 2048 改为 1450 以下。


 第三步,编译工程

把特定 FPGA 的 ip 核文件加如工程然后编译。


ip 核文件是 sync_fifo.v,

 第四步,运行时的操作

接口如下:
input [7:0] wr_data,
input wr_clk,
input wr_en,
output wr_full,

output [7:0] rd_data,

Contact QQ:1517642772 Email:chat1@126.com


OSen Logic

input rd_clk,
input rd_en,
output rd_empty,

input [31:0] local_ipaddr, //FPGA ip address


input [31:0] remote_ipaddr, //PC ip address
input [15:0] local_port, //FPGA port number

这个 IP 核的用户接口是相当简单的。
这个 IP 核可以看作 2 个 fifo,写 fifo 用于发送数据,读 fifo 用于接收数据。
另外 3 个端口用于配置 ip 地址和端口。

Contact QQ:1517642772 Email:chat1@126.com


OSen Logic

PC 端 TCP 示例程序
1. 把 IP 核的接口配置成如下

.local_ipaddr({8'd192, 8'd168, 8'd2, 8'd97}),


.remote_ipaddr({8'd192, 8'd168, 8'd2, 8'd3}),
.local_port({16'd6677}),

2. 设置 PC 的 ip 为上面的 remote_ipaddr.
3. 可以 ping 上面的 local_ipaddr.
4. 打开 net_clinet.exe.
5. 点击 start 开始捕获一次数据。

6. 可以用鼠标左右键缩放。
如果放大到一定程度,可以看到捕获的数据。

Contact QQ:1517642772 Email:chat1@126.com


OSen Logic

7. 如果要测试连续发数据的网速,修改 net_client 工程里的 client.c,把 bytes_rcved_num +=


result;改为 bytes_rcved_num += 0,编译后点 start,可以在任务管理器查看网速。但是
net_client 不会显示数据。

Contact QQ:1517642772 Email:chat1@126.com


OSen Logic

1G Eth TCP/UDP hardware stack

This IP Core has 2 versions, UDP version is open source IP Core, and TCP version is not open
source.

Contact QQ:1517642772 Email:chat1@126.com


OSen Logic

Rev 1.0
2016/2/13

Features

 Hardware implement stack, Low Latency.


 Simple FIFO interface.
 MAC layer included.
 Configurable IP Address, Port Number.
 Support Huge Packet, max user data size(tcp or udp data size) is 2048.
 TCP proxy supports server mode.

Contact QQ:1517642772 Email:chat1@126.com


OSen Logic

Core architecture

mac_config
eth_fsm
Simple MAC
Rx Path
88E1111

Tx Path

Data Source Parameter Config

User Module

Operation

 Step1: Modify “tcpip_hw_defines.sv”.

Contact QQ:1517642772 Email:chat1@126.com


OSen Logic

1.If the phy interface is RGMII, uncomment “//`define RGMII_IF”, otherwise, the core use GMII.

2.If user module and the data_gen module is not on the same FPGA, uncomment”//`define
DATA_GEN_OUTSIDE”, otherwise, the core use data_gen module inside.

 Step2: Modify “typedefs.pkg.sv”


At “parameter PKG_SIZE = 2048;”, if value is greater than 1450, you need to turn on huge
packet on PC.
4. Open device manager.
5. Open properties of the net adaptor.

6. At advanced tab,find huge data packet,change the value to desired value.

Contact QQ:1517642772 Email:chat1@126.com


OSen Logic

If huge packet is not enabled, change 2048 to less than 1450.


 Step3: Compile the project.

Add the FPGA vendor specific IP cores to the project and compile.
The ip core file is sync_fifo.v.

 Step4.Run time operation.

The interface are as the follows.


input [7:0] wr_data,
input wr_clk,
input wr_en,
output wr_full,

output [7:0] rd_data,


input rd_clk,
input rd_en,
output rd_empty,

Contact QQ:1517642772 Email:chat1@126.com


OSen Logic

input [31:0] local_ipaddr, //FPGA ip address


input [31:0] remote_ipaddr, //PC ip address
input [15:0] local_port, //FPGA port number

The interface between the core and user module are quite simple.
The core can be treated as two fifos, write fifo for tx data and rx fifo for rx data.
The other three ports configure the operating parameters.

Contact QQ:1517642772 Email:chat1@126.com


OSen Logic

PC Side TCP Example


1.open client.exe

2.click start to capture 16M data

3. you can zoom in or out use left/right button of mouse.


If you zoom in enough, you can see captured data.

Contact QQ:1517642772 Email:chat1@126.com


OSen Logic

Contact QQ:1517642772 Email:chat1@126.com

You might also like