资源简介
FPGA硬件逻辑资源实现UDP协议通信的开源代码,用FPGA实现千兆以太网的数据协议打包部分,可直接移植到xilinx的FPGA芯片上使用,VHDL纯语言编写。
代码片段和文件信息
package com.pjf;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;
public class UDPCxn {
private DatagramSocket skt;
private InetAddress dstIP;
public UDPCxn(long dstIPadr) throws SocketException UnknownHostException {
skt = new DatagramSocket();
byte[] target = new byte[4];
target[0] = (byte) ((dstIPadr >> 24) & 0xff);
target[1] = (byte) ((dstIPadr >> 16) & 0xff);
target[2] = (byte) ((dstIPadr >> 8) & 0xff);
target[3] = (byte) (dstIPadr & 0xff);
dstIP = InetAddress.getByAddress(target);
}
public UDPCxn(String dstIPadr) throws SocketException UnknownHostException {
skt = new DatagramSocket();
String[] parts = dstIPadr.split(“[.]“);
if (parts.length != 4) {
throw new UnknownHostException(“ip addr must have 4 parts“);
}
byte[] target = new byte[4];
for (int i = 0; i<4; i++) {
target[i] = (byte) Integer.parseInt(parts[i]);
}
dstIP = InetAddress.getByAddress(target);
}
public void send(byte[] data int port) throws IOException {
DatagramPacket pkt = new DatagramPacket(data data.length dstIP port);
System.out.println(“Sending packet“);
skt.send(pkt);
}
public void fixSend(String str int port boolean print) throws IOException {
String s1 = str.replace(‘~‘‘\001‘);
byte[] data = s1.getBytes();
DatagramPacket pkt = new DatagramPacket(data data.length dstIP port);
if (print) {
System.out.println(“Sending packet: “ + str + “ on port “ + port);
}
skt.send(pkt);
}
public byte[] rcv() throws IOException {
byte[] buf = new byte[1024];
DatagramPacket pkt = new DatagramPacket(buf buf.length);
// System.out.println(“waiting to receive ...“);
skt.receive(pkt);
int len = pkt.getLength();
byte[] rd = pkt.getData();
byte[] data = new byte[len];
for (int i=0; i data[i] = rd[i];
}
return data;
}
public void close() {
skt.close();
}
}
相关资源
- FPGA基于NIOS II的电子钟设计
- 基于UDP在广域网和局域网都能通信类
- FPGA数字信号处理九Vivado FFT IP核实现
- xilinx FPGA开发实用教程第2版配套光盘
- xilinx ise 9.x fpga cpld设计指南(高清晰
- DAC8532_SPI_双通道verilog控制
- FPGA verilog例程+详细的注释
- 基于Quartus Prime Std 18.0的FPGA基础开发流
- Xilinx FPGA伴你玩转USB3.0与LVDS
- 基于NIOS内核的FPGA电路系统设计.pdf
- VerilogHDL那些事儿-整合篇.pdf
- 基于FPGA的多路高速串口设计与实现
- FPGA实用代码 VHDL
- FPGA开发板Verilog例程基础+进阶
- VerilogHDL数字设计与综合第二版带书签
- 基于 CPLD_FPGA 的数字通信系统建模与设
-
fpgapla
yer_9983842.zip - FPGA综合系统设计五频谱分析系统
- 基于FPGA的二维FFT实现
- 国外经典FPGA-Prototyping-By-Verilog-Exampl
- 六位抢答器VHDL
- 数字系统的VHDL设计江国强 编
- FPGA经典设计100例
- 友晶 DE1-SoC中文教材+DS-5 AE版使用说明
- FPGA驱动OLED动态显示Verilog代码
- xiliix_FPGA数字信号处理设计教程
- sublime text3 verilog&VHDL;语言专版
- VHDL转换VERILOG工具
- Z00224 FPGA 快速系统原型设计权威指南
- 基于fpga的vhdl课程设计_函数信号发生
评论
共有 条评论