Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / tools / importer / main_lustre_importer.ml @ 4fda48d3

History | View | Annotate | Download (1.25 KB)

1 3ca452f3 ploc
(* An application that loads json provided input and produces Lustre
2
3
Usage:
4
lustrei -vhdl myvhdl.json 
5
lustrei -scade myscademodel.json 
6
  will produce a lustre file that can be compiled and analyzed
7
8
VHDL is handled in a double way: as a backend and as an import language
9
In a first step, lustrei -vhdl -print myvhdl.json shall print the VHDL model in stdout
10
11
 *)
12 55963629 Arnaud Dieumegard
(*
13 3ca452f3 ploc
open Vhdl_ast
14
open Vhdl_test
15 55963629 Arnaud Dieumegard
  *)
16
open Yojson.Safe
17 40364f53 Arnaud Dieumegard
open Vhdl_to_lustre
18 d3f0059e Arnaud Dieumegard
open Vhdl_ast_utils
19
open Vhdl_ast_map
20 40364f53 Arnaud Dieumegard
open Vhdl_ast_deriving
21 55963629 Arnaud Dieumegard
open Printf
22 40364f53 Arnaud Dieumegard
open Printers
23
open Format
24 55963629 Arnaud Dieumegard
25 3ca452f3 ploc
let _ =
26
  (* Load model with Yojson *)
27 55963629 Arnaud Dieumegard
  let vhdl_json = from_file Sys.argv.(1) in
28
29 62b6a61c Arnaud Dieumegard
  (* Create VHDL values *)
30
  let vhdl = vhdl_file_t_of_yojson vhdl_json in
31 d77323b8 Arnaud Dieumegard
32 d3f0059e Arnaud Dieumegard
  (* Simplify VHDL values *)
33 62b6a61c Arnaud Dieumegard
  match vhdl with
34
    Ok x ->
35 40364f53 Arnaud Dieumegard
      (* Parsed VHDL JSON value *)
36 4fda48d3 Arnaud Dieumegard
      (* Format.printf "Parsed VHDL: \n%s\n" (pretty_to_string (vhdl_file_t_to_yojson x)); *)
37 40364f53 Arnaud Dieumegard
      (* Fold Op vhdl_expr_t values *)
38 d3f0059e Arnaud Dieumegard
      let folded = replace_op_expr#vhdl_file_t x in
39 40364f53 Arnaud Dieumegard
      (* Translate vhdl_file_t value as lustre value *)
40
      let program = to_lustre#vhdl_file_t folded in
41 4fda48d3 Arnaud Dieumegard
      Format.printf "%s\n" (show_vhdl_file_t program);
42 40364f53 Arnaud Dieumegard
      (* Pretty print lustre value *)
43
 (*     Printers.pp_prog std_formatter program; *)
44
      
45 d77323b8 Arnaud Dieumegard
  | Error e -> Format.printf "Error: %s\n" e;