This site is updated infrequently. For up-to-date information, please visit the new OCaml website at ocaml.org.

interfacing Ocaml with Mathematica
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
 Date: 2010-09-07 (09:02) From: Florent Ouchet Subject: Re: [Caml-list] interfacing Ocaml with Mathematica
```Hello,

You might be interested in the evaluation core of VSyml [1], which is
not Mathematica-based.

The module DesignEval rewrites and evaluates function trees whose
types are defined in the module DesignTypes. However, this project
aims at symbolically simulate VHDL code, (by mixing immediate values
and variables - denoted at symbols - in expression trees) and
therefore it might be a little bit oversized for your needs. The
boolean rewrite rules are quite efficient although the arithmetic
rewriting rules might need some rework for corner cases.

Here is an example of how to invoke the evaluator:

(* make all && cd build/byte && ocaml *)

open DesignStandardTypes;; (* for boolean type definition *)
open DesignTypes;; (* for formula types *)
open DesignEval;; (* for evaluator definitions *)

let a_symbol = FormulaSymbol {symboltype=vhdl_boolean_type;symbolname="a"};;
let b_symbol = FormulaSymbol {symboltype=vhdl_boolean_type;symbolname="b"};;

let or_formula = FormulaAssociativeOperator (OperatorAssociativeOr,
[a_symbol;b_symbol]);;
let formula = FormulaAssociativeOperator
(OperatorAssociativeAnd,[a_symbol;or_formula]);;

designeval_formula formula default_struct_context default_eval_context;;
--> returns a_symbol

The syntax is /a little bit/ verbose, but that's required to evaluate
complex VHDL expression. It supports associative and/unary
and/or/nand/nor/xor/xnor/unary -/-/+/*/// and many others...

Best Regards,

- Florent Ouchet

[1] http://users-tima.imag.fr/vds/ouchet/vsyml.html

--
Florent Ouchet
PhD Student, CIS/VDS Groups
TIMA Laboratory, Grenoble, France

```