Communication between FPGA and PC with ethernet

Hello

I have to make an connection to a FPGA-borad.

formatting link

This board only supports ethernet communication with the mac-layer. Now I have to build an app that can send data(in my case images) to the board.

My question is now how can i send data using the mac-layer only from a c++ programm.

I do not think that we are using(or is possible to use) a router/switch between the pc and the board, we will use an pachted-ethernet-cable.

thanks

Reply to
Roggey
Loading thread data ...

I am not certain I entirely understand what you are asking, but it sounds like you have bits and pieces of various concepts and I think you need to research the components of your system a bit more.

You will need to start, by examing the protocol (language) that the device you need to communicate with undestands. Once you have a clear understanding of it, which in this case sounds like the MAC layer in a typical ethernet protocol, you can begin to look at what you will need to connect to it.

I suspect you are looking for a form of magic bullet, such as conenct through a router and you will all of a sudden have needed commands at your figertips. Unfortunately, it probably doesn't exist.

As far as accessing this with a C++ program, being C++ isn't enough. It will depend on what platform you are using, what tools and libraries you have available, what "level" you are writing you code for (driver, application, etc).

Reply to
Noway2

"Roggey" writes: |> I have to make an connection to a FPGA-borad. |> |>

formatting link
|> |> This board only supports ethernet communication with the mac-layer. Now |> I have to build an app that can send data(in my case images) to the |> board. |> |> My question is now how can i send data using the mac-layer only from a |> c++ programm.

How to sent UDP packets or establish a TCP connection from C++ depends entirely on your operating system. Under Unix/Linux, you may want to start on the "man 2 socket" manual page and related tutorials. On MacOS, it's probably the same.

On the FPGA side:

If you have a way to upload a microcontroller into the FPGA, or it has already a built-in processor, and you have a C compiler for it, you can install either a bare-boned TCP/IP stack such as

formatting link

which also supports ARP and DHCP, or even a full embedded operating system such as Linux or Windows CE. Thats the most flexible and luxurious approach.

If you want to avoid using a processor, then you can probably forget about using TCP. But decoding UDP packets in hardware may still be very feasible.

If your Ethernet it is a point-to-point link, you may want to try sending out UDP packets to IP broadcast addresses. This should be translated into MAC broadcasts and therefore bypasss the entire address-resolution protocol (ARP) mechanism in which your FPGA will not participate. On the decoding end, you will have to hope that the IP packets arrive unfragmented and with constant-length headers (i.e., no options), which is normally the case for UDP packets shorter than ~1.5 kB.

Of course all this is a real hack and may fail as soon as anything else gets connected to the same network. But as long as you do not expect Ethernet to run will all the features with which it is used normally, it can be used almost as easily as any other type of serial port.

Markus

--
Markus Kuhn, Computer Laboratory, University of Cambridge
http://www.cl.cam.ac.uk/~mgk25/ || CB3 0FD, Great Britain
Reply to
Markus Kuhn

Roggey schrieb:

That is a good question. I know what you are looking for.

Normally people use the IP stack and every OS has its own implementation of that.

I would be interested in that too, how to send data over the Ethernet. At least the people who implemented the IP stack had to know how to do it :)

Guenter

Reply to
GHEDWHCVEAIS

I think what you are looking for is a DLL which allows raw ethernet frames to be sent - I'm sure it must be possible, but may need to talk to the card at a low level and may be card-specific. It would also need to fight of Windows' own attempts to use it.

This looks promising :

formatting link

Reply to
Mike Harrison

Actually all the source is out there but alas not in a very accessible form. One can go to the linux source and grab the driver for the specific network card in question and also use the linux ethernet driver at the bottom of the ip stack (eth_drv.c I think).

Reply to
m

Check out this link for some ideas:

formatting link

Reply to
hansp

formatting link
this cost very much like 200/400$ depending on the type.

Reply to
Roggey

I found a solution i think it will work. I will test it int the next week.

I will use an opsource program

formatting link
This program manage all the stuff like open the networkadapter and stuff like that.

here is some code i found:

#include #include #include

int main(int argc, char **argv) { pcap_t *fp; char errbuf[PCAP_ERRBUF_SIZE]; u_char packet[100]; int i;

/* Check the validity of the command line */ if (argc != 2) { printf("usage: %s interface", argv[0]); return 1; }

/* Open the adapter */ if ((fp = pcap_open_live(argv[1], // name of the device 65536, // portion of the packet to capture. It doesn't matter in this case 1, // promiscuous mode (nonzero means promiscuous) 1000, // read timeout errbuf // error buffer )) == NULL) { fprintf(stderr,"\nUnable to open the adapter. %s is not supported by WinPcap\n", argv[1]); return 2; }

/* Supposing to be on ethernet, set mac destination to 1:1:1:1:1:1 */ packet[0]=1; packet[1]=1; packet[2]=1; packet[3]=1; packet[4]=1; packet[5]=1;

/* set mac source to 2:2:2:2:2:2 */ packet[6]=2; packet[7]=2; packet[8]=2; packet[9]=2; packet[10]=2; packet[11]=2;

/* Fill the rest of the packet */ for(i=12;i

Reply to
Roggey

Get help from your local software/network/sysadmin geeks.

If I was doing that, I'd send UDP packets, and throw away (skip over) the IP and UDP headers on the receiving side.

It's probably simplest if you can get a second ethernet card on your PC. You will probably have to setup routing and/or ARP by hand.

--
The suespammers.org mail server is located in California.  So are all my
other mailboxes.  Please do not send unsolicited bulk e-mail or unsolicited
commercial e-mail to my suespammers.org address or any of my other addresses.
These are my opinions, not necessarily my employer's.  I hate spam.
Reply to
Hal Murray

hello i am doing a project called "10 BASE T ETHERNET INTERFACE USING FPGA" i am using a xilinx's spartan2 XC2S50 chip and using VHDL.now i wanted to ask if any of u have any information on the codes of VHDL that i'll be needing and related stuff. if u happen to have any thing at all kindly send them to me. another question. ethernet traffic is digital. now a logic "zero" must be a band of voltage and similarly a logic "one". now i wanted to ask if i am using a 10/100 Mbps ethernet card or lan card as they are called what will be my voltages level. ie the RJ 45 female of my lan card will send

a logic "0" at which voltage/voltage band and on what voltage/voltage band will be logic"1". its important to find these as i am connecting FPGA to lan card and hoping that signals fm lan card does not blow up the damn chip. your early positive reply will save me lots of time.hope u will be able to able to spare some time. thanku all

Reply to
aayush

not if you're looking at the cat3 wire.

Not really. For 10bt, a {high,low} is one and {low,high} is zero. Read about Manchaster coding. For 100btx it is quite a bit more complicated.

You always need a network chip (at least a PHY or PHY+MAC) which you connect to the RJ45 to talk to the wire. You shouldn't connect the FPGA to the RJ45 directly. If you connect FPGA to the LAN card you don't need to know anything about what goes on the wire as it completely isolates it from you and gives you well-behaved bits.

Reply to
mk

Yes, I've built the transmitter twice (in both altera and xilinx) parts and it more or less worked. In one case I had to send it through a switch before an embedded ethernet board could understand it. Haven't tried the receiver. Getting it to do anything usefull is a bit different though. BTW you probably need to be local amin on a win XP box to receive UDP packets...

There are really a bunch of options:

- A serial to ethernet converter module, which may handle a TCP/IP protocol for you (LANCHIP, etc)

- An ethernet chip or card intended for PC-ISA - lots of embeded guys have used these (avoid PCI though)

- using an ethernet "PHY" chip to interface to the cable (with transformer of course) and then implementing the "MAC" function along with all the protocol stuff in the FPGA

- implementing everything in the FPGA except for the transforer (yes, some people cheat with capacitor coupling). This is what the FPGA4FUN project does.

Reply to
cs_posting

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.