interfacing a PC based program with a FPGA

Hi, I'm looking to integrate a FPGA based program into a PC based application. I understand i need to write a serial interfacing code on the FPGA side and an API on the PC side,considering i intend to use a RS 232 serial interface bet'n the PC and the FPGA board. I need help regarding the PC side API programming.I'll be using a 'C' program and would like to call the FPGA based functions. Can anyone suggest how i go about this?any references?

TIA. Srinivas

Reply to
Srinivas
Loading thread data ...

As I understand you need help writing a program in C to communicate with the serial port?! Then you'd better ask this question on a newsgroup related to the software programming not a FPGA or Verilog news group! Also you will need to provide some more information; at least the OS under which you are going to run your program.

Regards Arash

Reply to
Arash Salarian

You may want to find a good terminal emulator program rather than trying to write your own. The last time I write code for a serial port (under windows) it was a real PITA. But then you may be using a decent OS. But under any OS, you will be talking to the driver, not the serial port.

If you have to write a program, try searching on the web for source code for a terminal emulator or similar project. There are lots of open source projects out there.

--

Rick "rickman" Collins

rick.collins@XYarius.com
Ignore the reply address. To email me use the above address with the XY
removed.

Arius - A Signal Processing Solutions Company
Specializing in DSP and FPGA design      URL http://www.arius.com
4 King Ave                               301-682-7772 Voice
Frederick, MD 21701-3110                 301-682-7666 FAX
Reply to
rickman

It would depend on your operating system. If it is Windows, then there are a couple helpful documents in Microsoft's MDSN site. Search for "Serial Communications C" or something like that. It will probably take

2 to 3 pages of code to setup the serial channel.
Reply to
Prasanth Kumar

Coding serial communication for DOS is simple since you can control the port registers directly, however it's not easy task in windows unless you familiar with C/C++, win32 API, MFC...if you own a VSC++ develope studio, there's some good examples, check for the project TTY

Reply to
thangkho

Is serial interface a must? There are relatively cheap development boards available with either Ethernet or USB interface. Might be easier to start with and lot more bandwidth, too! Depends of course on your requirements, hobby project?

Just my $0.02, HTH

J.S.

Reply to
John Smith

Depends on what OS you are running on the PC. If Linux look for ioperm (just google), if windows look for inpout32.dll. There are probably a lot of other choices, but these worked for me. The downside is that a Linux program using ioperm has to be run as root or setuid root, which of couse is a security risc. /NS

Reply to
Nils Strandberg

Goto LCC for Windows web page:

formatting link

In Free download section you can find the Windows API Documentation. I havn't check if this document have the API descriptions for serial port but I guess it should be in it. Even if it doesn't it is still a good reference for Windows programming. Note: Not suitable for .NET environment.

Joe

Reply to
Joe

... ...

Hello,

is serial communication a must? If not you could use the PC parallel port (parport macro and associated software) and transfer data at 500KBytes/sec, no special semiconductors needed. Free sources available. see:

formatting link

formatting link

formatting link

with best regards,

Peter Seng

############################# SENG digitale Systeme GmbH Im Bruckwasen 35 D 73037 Goeppingen Germany tel +7161-75245 fax +7161-72965 eMail snipped-for-privacy@seng.de net

formatting link

Reply to
Peter Seng

perhaps this few lines of C can get you started (if you're using Windows):

DCB dcb; HANDLE hCom; DWORD dwError; BOOL fSuccess;

// // open serial line // hCom = CreateFile(argv[argc-1], GENERIC_READ | GENERIC_WRITE, 0, /* comm devices must be opened w/exclusive-access */ NULL, /* no security attrs */ OPEN_EXISTING, /* comm devices must use OPEN_EXISTING */ 0, /* not overlapped I/O */ NULL /* hTemplate must be NULL for comm devices */ );

if (hCom == INVALID_HANDLE_VALUE) { dwError = GetLastError(); printf("error\n"); exit(-1); }

fSuccess = GetCommState(hCom, &dcb);

if (!fSuccess) { printf("error\n"); exit(-1); }

// // set properties // dcb.BaudRate = 115200; dcb.ByteSize = 8; dcb.Parity = NOPARITY; dcb.StopBits = ONESTOPBIT;

/* use RTS/CTS handshake */ dcb.fOutxCtsFlow = TRUE; dcb.fRtsControl = RTS_CONTROL_ENABLE;

dcb.fOutxDsrFlow = FALSE; dcb.fDtrControl = DTR_CONTROL_DISABLE; dcb.fDsrSensitivity = FALSE;

fSuccess = SetCommState(hCom, &dcb);

if (!fSuccess) { printf("error in SetCommState\n"); exit(-1); }

// write a single byte WriteFile(hCom, &data, 1, &cnt, NULL); // read a single byte ReadFile(hCom, &c, 1, &cnt, NULL);

Martin

---------------------------------------------- JOP - a Java Processor core for FPGAs:

formatting link

Reply to
Martin Schoeberl

Thanks to all. i'm using a win2000 system. but guess the same serial port code should work for all Win based systems. Martin,i've actualy written similar code after posting here last. Thanks for your code(your's much neater :) ) i figured serial communication to be the easiet of all PC-FPGA communication ,I could implement hence the choice.I intend to "graduate" to others in due course of time.

rgds. srinivas.

Reply to
Srinivas

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.