Version française
Home     About     Download     Resources     Contact us    

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

Browse thread
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 <florent.ouchet@i...>
Subject: Re: [Caml-list] interfacing Ocaml with Mathematica

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 *)
#load "nums.cma";;
#load "Resources.cmo";;
#load "OCamlUtils.cmo";;
#load "DesignTypes.cmo";;
#load "DesignStandardTypes.cmo";;
#load "DesignUtils.cmo";;
#load "DesignAttributes.cmo";;
#load "DesignLogic.cmo";;
#load "DesignSolver.cmo";;
#load "DesignEval.cmo";;

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,  
let formula = FormulaAssociativeOperator  

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


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