From: Sam Moore Date: Wed, 9 Apr 2014 15:41:58 +0000 (+0800) Subject: An interface for a FPU compiled from VHDL X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=commitdiff_plain;h=1bab8e093f47967dc28a5a10030972407d7d0675;hp=1bab8e093f47967dc28a5a10030972407d7d0675 An interface for a FPU compiled from VHDL I have tested with the FPU from https://github.com/jop-devel/jop The way this works is really awful... 1. Make (or steal from jop) a VHDL FPU 2. Make (or steal from jop) a testbench that uses stdio to read operands and ops - The jop one reads from a generated file, but it is trivial to change to "STD_INPUT" and remove all the assertion tests. 3. Compile testbench into an executable with ghdl 4. Call VFPU::Start which does the following: - Create a socketpair(2) - fork(2) and in the child dup(2) stdin/stdout to the socketpair - Redirect stderr to /dev/null because the testbench generates 10^3 warning messages - in the child, exec(3) the testbench FPU 5. Call VFPU::Exec passing the desired operands and opcodes - The operands and opcodes are written as hex strings over the socketpair - The child executing the FPU program does its thing - The result is read back as a hex string 6. When finished, call VFPU::Halt to kill(2) the FPU I tried to get ghdl and gcc/g++ to make a static library to call ghdl_main instead of exec'ing things. But that didn't work. The fork and socketpair would have still been required for that approach anyway. TODO: - Make the interface (not the FPU) deal with arbitrary size registers - Wrap a Real type around it so we can #define REAL_SIMULATED_FPU I haven't put any of the VHDL in the git repo for obvious reasons. If I actually start messing with it, it will probably get a seperate repo. This may end up being a complete waste of time? Although potentially being able to run an arbitrary FPU albeit in a horrible manner does seem cool. ---