Newer
Older
Erwan Jahier
committed
(* Time-stamp: <modified the 08/04/2013 (at 13:25) by Erwan Jahier> *)
(** Synchronous Object Component *)
(* Just a string because :
- it's more ocamldebug-friendly
- Name clashing issues ougth to have been fixed before
*)
type ident = string
type var_type =
| Bool | Int | Real
| Extern of ident
| Enum of (ident * ident list)
| Struct of ident * (ident * var_type) list
| Array of (var_type * int)
| Alpha of int
type var = ident * var_type
ident *
var_type list * (* I/O type list *)
Erwan Jahier
committed
(int * int * int) option (* to deal with slices (unused FTTB) *)
Erwan Jahier
committed
type instance = ident * key
(* Variable denotation *)
type var_expr =
| Var of var
| Const of var (* useful? *)
| Field of var_expr * ident * var_type
| Index of var_expr * int * var_type
let (var_type_of_var_expr : var_expr -> var_type) =
function
| Var(_,vt)
| Const(_,vt)
type atomic_operation =
| Assign (* Wire *)
| Method of instance * ident (* node step call ; the ident is the step name *)
| Procedure of key (* memoryless method made explicit (a good idea?) *)
(* Guarded Atomic Operation *)
type gao =
| Case of ident (* enum var *) * (ident (* enum value *) * gao list) list
| Call of var_expr list * atomic_operation * var_expr list
(* outputs * op * inputs *)
type step_impl =
| Predef
| Gaol of var list * gao list (* local vars + body *)
| Iterator of string * key * int (* iterator, iterated soc key, size *)
Erwan Jahier
committed
| Boolred of int * int * int
| Condact of key * var_expr list (* condact-ed node, default constants *)
(* XXX c'est laid ces histoires d'index. y'a qu'a recopier les
variables nécessaires et puis c'est marre !!! *)
idx_ins : int list; (* input index in the profile *)
idx_outs : int list; (* output index in the profile *)
impl : step_impl;
(* impl : (var list * gao list) option; (* local vars + body ; None for predef op *) *)
}
type precedence = ident * ident list
(* Partial order over step members. Maps a step method name with
the list of step methods that should be called _before_.
nb : steps in step are already ordered ; this partial order
can be useful to find another (better) total order w.r.t. test
opening.
*)
Erwan Jahier
committed
type t = {
(* les memoires de l'objet sont calculées par l'interpreteur (ou l'objet C) *)
key : key;
profile : var list * var list;
instances : instance list;
(* init : step_method option; *)
step : step_method list; (* the order in the list is a valid w.r.t.
the partial order defined in precedences *)
precedences : precedence list; (* partial order over step methods *)
have_mem : (var_type * var_expr option) option;
(* Do this soc have a memory (pre, fby) + its type + default value *)
Erwan Jahier
committed
(* SocKeyMap ? *)
module SocMap = Map.Make(
struct
type t = key
let compare = compare
end
)
Erwan Jahier
committed
Erwan Jahier
committed
let cpt = ref 0
let (make: key -> instance) =
fun sk ->
let (id,_,_) = sk in
let instance = Printf.sprintf "%s%03d" id !cpt in
incr cpt;
instance,sk