zepter@isnix.informatik.rwth-aachen.de (Peter Zepter) (02/28/91)
Interfacing C-Programs to VHDL Simulations with Intermetrics 2.1b/3.0 For simulation purposes we want to send data to and read data from a VHDL simulation by a C program repeatedly. The UNIX interprocess communication facilities allow this by running two processes. One is the C program representing the system level and the other the VHDL simulation representing the ASIC used in the system. On the C side of the communication we use pipes or named pipes and write to or read from them using the system calls read(2V) and write(2V). The file descriptors can be marked for blocking I/O with fcntl(2V). If the number of bytes provided at the write end of each pipe equals the number of bytes read at the other end and the sequence of corresponding read and write calls in both processes is correct, this ensures communication without deadlock. In VHDL (or at least Intermetrics' VHDL implementation) we can only rely on the standard package TEXTIO. The language reference manual does not provide any information how the readline and writeline functions should be implemented and the Intermetrics Technical Support refuses to explain any details to users which have only a university licence. We found out by experimenting with the VHDL simulator, that it only reads the input data in blocks of the pipe buffer size (i.e. 4096 bytes at our system). A number of bytes less than that is only read when EOF occurs. Reading and writing only starts if more than 4096 bytes are present. It is not clear whether the I/O is blocking or non-blocking. The endfile function seems to return TRUE if there is no input in the pipe to be read, although the UNIX convention says EOF occurs only if the writing process has closed the file descriptor for writing or does no longer exist. In our experimental configuration with a C and a VHDL process communicating by two pipes it depends on the number of operations performed in the C program between two read and write operations or, whether deadlock occurs or not. If we redirect the standard output of the C-program to a file instead of the screen, the behaviour of the communication changes, too. Does any reader of this news group know any details about Intermetrics implementation of the opertions in 'TEXTIO'? Has anybody implemented some IPC to and from VHDL? Are there other VHDL simulators providing better support to IPC (e.g. by allowing procedures and subroutines written in C)? Peter Zepter, Klaus ten Hagen, Ralf Oberheim ERT - Aachen University of Technology |phone: +49/241/807887 Templergraben 55 |fax: +49/241/807631 D-5100 Aachen, Germany |internet: zepter@ert.rwth-aachen.de -- Peter Zepter ERT - Aachen University of Technology phone: +49/241/807887 Templergraben 55 fax: +49/241/807631 D-5100 Aachen, Germany internet: zepter@ert.rwth-aachen.de